diff --git a/lib/tasks/questions.rake b/lib/tasks/questions.rake index cec8fc974..860a768a4 100644 --- a/lib/tasks/questions.rake +++ b/lib/tasks/questions.rake @@ -54,6 +54,9 @@ constantes = { sous_consigne_HPfb_1: 'terrasse_cafe', sous_consigne_HPfb_2: 'telephone_email' }, + NOM_TECHNIQUES_GLISSER_DEPOSER: { + hpar_1: 'journal_vide' + }, DOSSIER_ID: 'DOSSIER_ID', TYPE_QUESTION: 'TYPE_QUESTION' } @@ -82,6 +85,8 @@ namespace :questions do attache_assets(NOM_TECHNIQUES_QCM) when 'SOUS_CONSIGNE' attache_assets(NOM_TECHNIQUES_CONSIGNES) + when 'GLISSER_DEPOSER' + attache_assets(NOM_TECHNIQUES_GLISSER_DEPOSER) end end end @@ -102,6 +107,7 @@ def attache_assets(nom_techniques) recupere_fichier(question, "#{nom_illustration}.png") recupere_fichier(question, "#{question.nom_technique}.mp3", question.transcription_intitule) attach_audio_choix(question) if nom_techniques == NOM_TECHNIQUES_QCM + attach_images_reponses(question) if nom_techniques == NOM_TECHNIQUES_GLISSER_DEPOSER end end @@ -123,6 +129,12 @@ def attach_audio_choix(question) end end +def attach_images_reponses(question) + question.reponses.each do |choix| + recupere_fichier(question, "#{choix.nom_technique}.png", choix) + end +end + def attach_file_to(instance, file_content, fichier_path, nom_technique) instance.send(attachment_type(fichier_path)).attach( io: StringIO.new(file_content),