Skip to content

Commit

Permalink
✨ Permet d'ajouter un nombre de caractère max à une question saisie d…
Browse files Browse the repository at this point in the history
…e nombre
  • Loading branch information
marouria committed Oct 14, 2024
1 parent fcc1d5e commit c9280f0
Show file tree
Hide file tree
Showing 8 changed files with 14 additions and 2 deletions.
1 change: 1 addition & 0 deletions app/admin/questions_saisie.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
:suffix_reponse, :description, :reponse_placeholder, :type_saisie,
:illustration, :supprimer_illustration,
:supprimer_audio_intitule,
:reponse_longueur_max,
:supprimer_audio_modalite_reponse,
transcriptions_attributes: %i[id categorie ecrit audio _destroy],
bonne_reponse_attributes: %i[id intitule audio type_choix _destroy nom_technique]
Expand Down
1 change: 1 addition & 0 deletions app/models/question_saisie.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ def base_json
json['sous_type'] = type_saisie
json['placeholder'] = reponse_placeholder
json['description'] = description
json['max_length'] = reponse_longueur_max
end
end

Expand Down
1 change: 1 addition & 0 deletions app/views/admin/questions_saisies/_form.html.arb
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ active_admin_form_for [:admin, resource] do |f|
locals: { f: f }

f.input :suffix_reponse
f.input :reponse_longueur_max, as: :number
f.input :reponse_placeholder
f.input :type_saisie
f.has_many :bonne_reponse, allow_destroy: false, new_record: t('.ajout_reponse'),
Expand Down
1 change: 1 addition & 0 deletions app/views/admin/questions_saisies/_show.html.arb
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ panel 'Détails de la question' do
tag_audio(consigne)
end
row :suffix_reponse
row :reponse_longueur_max
row :reponse_placeholder
row :type_saisie
row :created_at
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class AjouteReponseMaxlenghtToQuestion < ActiveRecord::Migration[7.0]
def change
add_column :questions, :reponse_longueur_max, :integer
end
end
3 changes: 2 additions & 1 deletion db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.

ActiveRecord::Schema[7.0].define(version: 2024_09_26_055940) do
ActiveRecord::Schema[7.0].define(version: 2024_10_14_084435) do
# These are extensions that must be enabled in order to support this database
enable_extension "pgcrypto"
enable_extension "plpgsql"
Expand Down Expand Up @@ -307,6 +307,7 @@
t.datetime "deleted_at"
t.integer "type_saisie", default: 0
t.string "categorie"
t.integer "reponse_longueur_max"
t.index ["deleted_at"], name: "index_questions_on_deleted_at"
t.index ["libelle"], name: "index_questions_on_libelle"
t.index ["nom_technique"], name: "index_questions_on_nom_technique", unique: true, where: "(deleted_at IS NULL)"
Expand Down
Binary file modified docs/erd.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 3 additions & 1 deletion spec/models/question_saisie_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
create(:question_saisie,
transcription_ecrit: 'Mon Intitulé',
reponse_placeholder: 'écrivez ici',
reponse_longueur_max: 5,
illustration: Rack::Test::UploadedFile.new(
Rails.root.join('spec/support/programme_tele.png')
))
Expand All @@ -31,14 +32,15 @@
it 'serialise les champs' do
expect(json.keys).to match_array(%w[id intitule audio_url nom_technique suffix_reponse
description illustration modalite_reponse type sous_type
placeholder reponse])
placeholder reponse max_length])
expect(json['type']).to eql('saisie')
expect(json['sous_type']).to eql('redaction')
expect(json['placeholder']).to eql('écrivez ici')
expect(json['intitule']).to eql('Mon Intitulé')
expect(json['reponse']['textes']).to eql(reponse.intitule)
expect(json['reponse']['bonneReponse']).to be(true)
expect(json['modalite_reponse']).to eql(modalite.ecrit)
expect(json['max_length']).to eql(question_saisie.reponse_longueur_max)
end

it "retourne l'illustration" do
Expand Down

0 comments on commit c9280f0

Please sign in to comment.