Skip to content

Commit

Permalink
🗃️ Créé toutes les questions du nniveau 2 de numératie en base
Browse files Browse the repository at this point in the history
  • Loading branch information
marouria committed Sep 26, 2024
1 parent c30aeda commit 6e9172f
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
24 changes: 24 additions & 0 deletions db/migrate/20240926055940_creation_questions_numeratie_niveau2.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
class CreationQuestionsNumeratieNiveau2 < ActiveRecord::Migration[7.0]
class ::Question < ApplicationRecord; end
class ::Questionnaire < ApplicationRecord; end
class ::QuestionnaireQuestion < ApplicationRecord; end

def change
numeratie = Questionnaire.find_or_create_by(nom_technique: 'numeratie_2024')
{
'QuestionClicDansImage' => ['N2Plp1', 'N2Pod1', 'N2Pod2'],
'QuestionQcm' => ['N2Plp2', 'N2Rlp1', 'N2Rlp2', 'N2Put1', 'N2Put2', 'N2Rut1', 'N2Rut2', 'N2Ptg2', 'N2Rtg1', 'N2Rtg2', 'N2Ppl1', 'N2Rpl1', 'N2Rpl2'],
'QuestionSaisie' => ['N2Ppe1', 'N2Ppe2', 'N2Rpe1', 'N2Rpe2', 'N2Psu1', 'N2Psu2', 'N2Rsu1', 'N2Rsu2', 'N2Pom1', 'N2Pom2', 'N2Rom1', 'N2Rom2', 'N2Rod1', 'N2Rod2', 'N2Ptg1', 'N2Ppl2'],
'QuestionGlisserDeposer' => ['N2Pon1', 'N2Pon2', 'N2Ron1', 'N2Ron2']
}.each do |type, nom_techniques|
nom_techniques.each do |nom_technique|
question = Question.find_or_initialize_by(nom_technique: nom_technique)
question.type = type
question.type_saisie = :numerique if type == 'QuestionSaisie'
question.libelle = nom_technique
question.save!
QuestionnaireQuestion.find_or_create_by(questionnaire_id: numeratie.id, question_id: question.id)
end
end
end
end
2 changes: 1 addition & 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_23_134418) do
ActiveRecord::Schema[7.0].define(version: 2024_09_26_055940) do
# These are extensions that must be enabled in order to support this database
enable_extension "pgcrypto"
enable_extension "plpgsql"
Expand Down

0 comments on commit 6e9172f

Please sign in to comment.