Skip to content

Commit

Permalink
👽️ Rajoute intitule et modalite de réponse à une question clic dans t…
Browse files Browse the repository at this point in the history
…exte
  • Loading branch information
marouria committed Nov 21, 2024
1 parent fc0547c commit 4faedd6
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
8 changes: 7 additions & 1 deletion app/models/question_clic_dans_texte.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ class QuestionClicDansTexte < Question
QUESTION_TYPE = 'QuestionClicDansTexte'

def as_json(_options = nil)
base_json
json = base_json
json.merge!(json_audio_fields, additional_json_fields)
end

private
Expand All @@ -19,6 +20,11 @@ def base_json
end
end

def additional_json_fields
{ 'intitule' => transcription_intitule&.ecrit,
'modalite_reponse' => transcription_modalite_reponse&.ecrit }
end

# Exemple de réponse: "bonnesReponses": ["mot1", "mot2"]
def bonnes_reponses_json
texte_sur_illustration.scan(/\[([^\]]+)\]\(#bonne-reponse\)/).flatten
Expand Down
5 changes: 3 additions & 2 deletions spec/models/question_clic_dans_texte_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,9 @@
let(:json) { question_clic_dans_texte.as_json }

it 'serialise les champs' do
expect(json.keys).to match_array(%w[id nom_technique description texte_cliquable
illustration reponse type])
expect(json.keys).to match_array(%w[id nom_technique audio_url description texte_cliquable
illustration intitule_audio reponse type intitule
modalite_reponse consigne_audio])
expect(json['type']).to eql('clic-sur-mots')
expect(json['texte_cliquable']).to eql(contenu)
expect(json['description']).to eql(question_clic_dans_texte.description)
Expand Down

0 comments on commit 4faedd6

Please sign in to comment.