Skip to content

Commit

Permalink
⚡️ Ajoute une transaction pour les questions
Browse files Browse the repository at this point in the history
  • Loading branch information
Guitguitou committed Nov 13, 2024
1 parent 16079b1 commit d44016a
Showing 1 changed file with 10 additions and 12 deletions.
22 changes: 10 additions & 12 deletions app/models/import_export/questions/import.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,22 +31,20 @@ def process_rows(data)
end
end

# rubocop:disable Metrics/AbcSize
def cree_question
@question = Question.new(type: @type) # On crée une nouvelle instance pour chaque ligne
@question.assign_attributes(libelle: @row[0], nom_technique: @row[1], description: @row[7])
attache_fichier(@question.illustration, @row[2])
@question.save!
cree_transcription(:intitule, @row[4], @row[3])
cree_transcription(:modalite_reponse, @row[6], @row[5]) unless @question.sous_consigne?
update_champs_specifiques
@question
ActiveRecord::Base.transaction do
intialise_question
cree_transcription(:intitule, @row[4], @row[3])
cree_transcription(:modalite_reponse, @row[6], @row[5]) unless @question.sous_consigne?
update_champs_specifiques
@question
end
end
# rubocop:enable Metrics/AbcSize

def intialise_question
@question.assign_attributes(libelle: @row[0],
nom_technique: @row[1], description: @row[7])
@question = Question.new(type: @type) # On crée une nouvelle instance pour chaque ligne
@question.assign_attributes(libelle: @row[0], nom_technique: @row[1],
description: @row[7])
attache_fichier(@question.illustration, @row[2])
@question.save!
end
Expand Down

0 comments on commit d44016a

Please sign in to comment.