Skip to content
Snippets Groups Projects
Commit 3e8db0e4 authored by Arnaud Levy's avatar Arnaud Levy
Browse files

qualiopi wip

parent 0576ca43
No related branches found
No related tags found
No related merge requests found
Showing
with 96 additions and 247 deletions
......@@ -21,35 +21,24 @@ class Admin::Features::Education::ProgramsController < Admin::Features::Educatio
def create
@program.university = current_university
respond_to do |format|
if @program.save
format.html { redirect_to [:admin, @program], notice: "Program was successfully created." }
format.json { render :show, status: :created, location: @program }
else
format.html { render :new, status: :unprocessable_entity }
format.json { render json: @program.errors, status: :unprocessable_entity }
end
if @program.save
redirect_to [:admin, @program], notice: "Program was successfully created."
else
render :new, status: :unprocessable_entity
end
end
def update
respond_to do |format|
if @program.update(program_params)
format.html { redirect_to [:admin, @program], notice: "Program was successfully updated." }
format.json { render :show, status: :ok, location: @program }
else
format.html { render :edit, status: :unprocessable_entity }
format.json { render json: @program.errors, status: :unprocessable_entity }
end
if @program.update(program_params)
redirect_to [:admin, @program], notice: "Program was successfully updated."
else
render :edit, status: :unprocessable_entity
end
end
def destroy
@program.destroy
respond_to do |format|
format.html { redirect_to admin_features_education_programs_url, notice: "Program was successfully destroyed." }
format.json { head :no_content }
end
redirect_to admin_features_education_programs_url, notice: "Program was successfully destroyed."
end
protected
......@@ -58,11 +47,8 @@ class Admin::Features::Education::ProgramsController < Admin::Features::Educatio
super
add_breadcrumb Features::Education::Program.model_name.human(count: 2), admin_features_education_programs_path
if @program
if @program.persisted?
add_breadcrumb @program, [:admin, @program]
else
add_breadcrumb 'Créer'
end
@program.persisted? ? add_breadcrumb(@program, [:admin, @program])
: add_breadcrumb('Créer')
end
end
......
......@@ -9,58 +9,13 @@ class Admin::Features::Education::Qualiopi::CriterionsController < Admin::Featur
breadcrumb
end
def new
breadcrumb
end
def edit
breadcrumb
add_breadcrumb 'Modifier'
end
def create
respond_to do |format|
if @criterion.save
format.html { redirect_to [:admin, @criterion], notice: "Criterion was successfully created." }
format.json { render :show, status: :created, location: [:admin, @criterion] }
else
format.html { render :new, status: :unprocessable_entity }
format.json { render json: @criterion.errors, status: :unprocessable_entity }
end
end
end
def update
respond_to do |format|
if @criterion.update(criterion_params)
format.html { redirect_to [:admin, @criterion], notice: "Criterion was successfully updated." }
format.json { render :show, status: :ok, location: [:admin, @criterion] }
else
format.html { render :edit, status: :unprocessable_entity }
format.json { render json: @criterion.errors, status: :unprocessable_entity }
end
end
end
def destroy
@criterion.destroy
respond_to do |format|
format.html { redirect_to admin_qualiopi_criterions_url, notice: "Criterion was successfully destroyed." }
format.json { head :no_content }
end
end
protected
def breadcrumb
super
add_breadcrumb Features::Education::Qualiopi.model_name.human, admin_features_education_qualiopi_criterions_path
if @criterion
if @criterion.persisted?
add_breadcrumb @criterion, [:admin, @criterion]
else
add_breadcrumb 'Créer'
end
add_breadcrumb @criterion, [:admin, @criterion]
end
end
......
......@@ -6,73 +6,17 @@ class Admin::Features::Education::Qualiopi::IndicatorsController < Admin::Featur
end
def show
@programs = current_university.features_education_programs
@checks = [
:prerequisites,
:objectives,
:duration,
:pricing,
:registration,
:pedagogy,
:evaluation,
:accessibility
]
breadcrumb
end
def new
breadcrumb
end
def edit
breadcrumb
add_breadcrumb 'Modifier'
end
def create
respond_to do |format|
if @indicator.save
format.html { redirect_to [:admin, @indicator], notice: "Indicator was successfully created." }
format.json { render :show, status: :created, location: [:admin, @indicator] }
else
format.html { render :new, status: :unprocessable_entity }
format.json { render json: @indicator.errors, status: :unprocessable_entity }
end
end
end
def update
respond_to do |format|
if @indicator.update(indicator_params)
format.html { redirect_to [:admin, @indicator], notice: "Indicator was successfully updated." }
format.json { render :show, status: :ok, location: [:admin, @indicator] }
else
format.html { render :edit, status: :unprocessable_entity }
format.json { render json: [:admin, @indicator].errors, status: :unprocessable_entity }
end
end
end
def destroy
@indicator.destroy
respond_to do |format|
format.html { redirect_to admin_qualiopi_indicators_url, notice: "Indicator was successfully destroyed." }
format.json { head :no_content }
end
end
protected
def breadcrumb
super
add_breadcrumb Features::Education::Qualiopi.model_name.human(count: 2), admin_features_education_qualiopi_criterions_path
if @indicator
if @indicator.persisted?
add_breadcrumb @indicator.criterion, [:admin, @indicator.criterion]
add_breadcrumb @indicator, [:admin, @indicator]
else
add_breadcrumb 'Créer'
end
add_breadcrumb @indicator.criterion, [:admin, @indicator.criterion]
add_breadcrumb @indicator, [:admin, @indicator]
end
end
......
......@@ -20,37 +20,26 @@ class Admin::Features::Websites::SitesController < Admin::Features::Websites::Ap
def create
@site.university = current_university
respond_to do |format|
if @site.save
format.html { redirect_to [:admin, @site], notice: "Site was successfully created." }
format.json { render :show, status: :created, location: [:admin, @site] }
else
breadcrumb
format.html { render :new, status: :unprocessable_entity }
format.json { render json: @site.errors, status: :unprocessable_entity }
end
if @site.save
redirect_to [:admin, @site], notice: "Site was successfully created."
else
breadcrumb
render :new, status: :unprocessable_entity
end
end
def update
respond_to do |format|
if @site.update(site_params)
format.html { redirect_to [:admin, @site], notice: "Site was successfully updated." }
format.json { render :show, status: :ok, location: [:admin, @site] }
else
breadcrumb
format.html { render :edit, status: :unprocessable_entity }
format.json { render json: @site.errors, status: :unprocessable_entity }
end
if @site.update(site_params)
redirect_to [:admin, @site], notice: "Site was successfully updated."
else
breadcrumb
render :edit, status: :unprocessable_entity
end
end
def destroy
@site.destroy
respond_to do |format|
format.html { redirect_to admin_features_websites_sites_url, notice: "Site was successfully destroyed." }
format.json { head :no_content }
end
redirect_to admin_features_websites_sites_url, notice: "Site was successfully destroyed."
end
protected
......@@ -59,11 +48,8 @@ class Admin::Features::Websites::SitesController < Admin::Features::Websites::Ap
super
add_breadcrumb Features::Websites::Site.model_name.human(count: 2), admin_features_websites_sites_path
if @site
if @site.persisted?
add_breadcrumb @site, [:admin, @site]
else
add_breadcrumb 'Créer'
end
@site.persisted? ? add_breadcrumb(@site, [:admin, @site])
: add_breadcrumb('Créer')
end
end
......
......@@ -10,7 +10,9 @@
# updated_at :datetime not null
#
class Features::Education::Qualiopi::Criterion < ApplicationRecord
has_many :indicators
has_many :indicators, dependent: :destroy
validates :number, uniqueness: true
def to_s
"Critère #{number}"
......
......@@ -3,6 +3,7 @@
# Table name: features_education_qualiopi_indicators
#
# id :uuid not null, primary key
# glossary :text
# level_expected :text
# name :text
# non_conformity :text
......@@ -24,6 +25,8 @@
class Features::Education::Qualiopi::Indicator < ApplicationRecord
belongs_to :criterion
validates :number, uniqueness: true
def to_s
"Indicateur #{number}"
end
......
<%= simple_form_for [:admin, criterion] do |f| %>
<div class="row">
<div class="col-md-2">
<%= f.input :number %>
</div>
<div class="col-md-10">
<%= f.input :name %>
</div>
</div>
<% content_for :buttons do %>
<%= submit f %>
<% end %>
<% end %>
json.extract! qualiopi_criterion, :id, :number, :name, :description, :created_at, :updated_at
json.url qualiopi_criterion_url(qualiopi_criterion, format: :json)
<% content_for :title, @criterion %>
<%= render 'form', criterion: @criterion %>
<% content_for :title, Features::Education::Qualiopi.model_name.human %>
<div class="row">
<% @criterions.each do |criterion| %>
<div class="col-md-6">
<h2 class="mt-5"><%= link_to criterion, [:admin, criterion] %></h2>
<p><%= criterion.name %></p>
<% @criterions.each do |criterion| %>
<div class="row">
<div class="col-md-5">
<h2><%= link_to criterion, [:admin, criterion] %></h2>
<p class="lead"><%= criterion.name %></p>
</div>
<div class="offset-md-1 col-md-6">
<% criterion.indicators.each do |indicator| %>
<h3 class="h4"><%= link_to indicator, [:admin, indicator] %></h3>
<p><%= indicator.name %></p>
<% end %>
</div>
<% end %>
</div>
</div>
<hr class="my-5">
<% end %>
json.array! @qualiopi_criterions, partial: "qualiopi_criterions/qualiopi_criterion", as: :qualiopi_criterion
<% content_for :title, Features::Education::Qualiopi::Criterion.model_name.human %>
<%= render 'form', criterion: @criterion %>
json.partial! "qualiopi_criterions/qualiopi_criterion", qualiopi_criterion: @qualiopi_criterion
<%
@programs = current_university.features_education_programs
@checks = [
:prerequisites,
:objectives,
:duration,
:pricing,
:registration,
:pedagogy,
:evaluation,
:accessibility
]
%>
<table class="table mt-5">
<thead>
<tr>
<th><%= Features::Education::Program.model_name.human %></th>
<% @checks.each do |check| %>
<th><%= Features::Education::Program.human_attribute_name(check) %></th>
<% end %>
</tr>
</thead>
<tbody>
<% @programs.each do |program| %>
<tr>
<td><%= link_to program, [:admin, program] %></td>
<% @checks.each do |check| %>
<% valid = !program.send(check).blank? %>
<th>
<% if valid %>
<span class="fas fa-check text-success"></span>
<% else %>
<span class="fas fa-times text-danger"></span>
<% end %>
</th>
<% end %>
</tr>
<% end %>
</tbody>
</table>
<%= simple_form_for [:admin, indicator] do |f| %>
<%= f.association :criterion, include_blank: false %>
<div class="row">
<div class="col-md-2">
<%= f.input :number %>
</div>
<div class="col-md-5">
<%= f.input :name, input_html: { rows: 5 } %>
<%= f.input :level_expected, input_html: { rows: 5 } %>
</div>
<div class="col-md-5">
<%= f.input :proof, input_html: { rows: 5 } %>
<%= f.input :requirement, input_html: { rows: 5 } %>
<%= f.input :non_conformity, input_html: { rows: 5 } %>
</div>
</div>
<% content_for :buttons do %>
<%= submit f %>
<% end %>
<% end %>
json.extract! qualiopi_indicator, :id, :criterion_id, :number, :name, :level_expected, :proof, :requirement, :non_conformity, :created_at, :updated_at
json.url qualiopi_indicator_url(qualiopi_indicator, format: :json)
<% content_for :title, @indicator %>
<%= render 'form', indicator: @indicator %>
json.array! @qualiopi_indicators, partial: "qualiopi_indicators/qualiopi_indicator", as: :qualiopi_indicator
<% content_for :title, Features::Education::Qualiopi::Indicator.model_name.human %>
<%= render 'form', indicator: @indicator %>
......@@ -3,38 +3,20 @@
<p class="lead"><%= @indicator.name %></p>
<div class="row">
<% [:level_expected, :proof, :requirement, :non_conformity].each do |attribute| %>
<div class="col-md-3">
<h2 class="h4 mt-4"><%= Features::Education::Qualiopi::Indicator.human_attribute_name(attribute) %></h2>
<p><%= @indicator.send attribute %></p>
<% [:level_expected, :proof, :requirement, :non_conformity, :glossary].each do |attribute| %>
<%
name = Features::Education::Qualiopi::Indicator.human_attribute_name(attribute)
value = @indicator.send attribute
next if value.blank?
%>
<div class="col-md-4">
<h2 class="h4 mt-4"><%= name %></h2>
<%= simple_format value %>
</div>
<% end %>
</div>
<table class="table mt-5">
<thead>
<tr>
<th><%= Features::Education::Program.model_name.human %></th>
<% @checks.each do |check| %>
<th><%= Features::Education::Program.human_attribute_name(check) %></th>
<% end %>
</tr>
</thead>
<tbody>
<% @programs.each do |program| %>
<tr>
<td><%= link_to program, [:admin, program] %></td>
<% @checks.each do |check| %>
<% valid = !program.send(check).blank? %>
<th>
<% if valid %>
<span class="fas fa-check text-success"></span>
<% else %>
<span class="fas fa-times text-danger"></span>
<% end %>
</th>
<% end %>
</tr>
<% end %>
</tbody>
</table>
<% begin %>
<%= render "admin/features/education/qualiopi/evaluations/criterion_#{@indicator.number}" %>
<% rescue %>
<% end %>
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment