Skip to content

Commit

Permalink
🍱 Modifie la tâche rake pour pouvoir attacher les assets de la questi…
Browse files Browse the repository at this point in the history
…on glisser déposer
  • Loading branch information
marouria authored and cprodhomme committed Nov 14, 2024
1 parent 2c7991f commit 301fb76
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions lib/tasks/questions.rake
Original file line number Diff line number Diff line change
Expand Up @@ -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'
}
Expand Down Expand Up @@ -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
Expand All @@ -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

Expand All @@ -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),
Expand Down

0 comments on commit 301fb76

Please sign in to comment.