Skip to content

Commit

Permalink
🐛 Ne renvoie pas d'erreur si l'évènements n'a pas de score ou de scor…
Browse files Browse the repository at this point in the history
…e max
  • Loading branch information
marouria committed Oct 28, 2024
1 parent 9522c19 commit d770a73
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
2 changes: 1 addition & 1 deletion app/models/restitution/export_positionnement.rb
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ def remplis_reponses_par_code(sheet, ligne, code, evenements)
end

def pourcentage_reussite(evenements)
scores = evenements.map { |e| [e.donnees['scoreMax'], e.donnees['score']] }
scores = evenements.map { |e| [e.donnees['scoreMax'] || 0, e.donnees['score'] || 0] }
score_max, score = scores.transpose.map(&:sum)
score_max.zero? ? 0 : (score * 100 / score_max).round
end
Expand Down
9 changes: 8 additions & 1 deletion spec/models/restitution/export_positionnement_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@
score: 1,
scoreMax: 2,
metacompetence: 'renseigner_horaires' }
create :evenement_reponse,
partie: partie,
donnees: { question: 'LOdi3',
metacompetence: 'parametres' }
create :evenement_reponse,
partie: partie,
donnees: { intitule: intitule_question2,
Expand Down Expand Up @@ -80,7 +84,10 @@
question2 = worksheet.row(4)
expect(question2[0]).to be_nil
question2 = worksheet.row(5)
expect(question2[0]).to eq('LOdi4')
expect(question2[0]).to eq('LOdi3')
question2 = worksheet.row(6)
expect(question2[3]).to be_nil
expect(question2[4]).to be_nil
expect(question2[1]).to eq(intitule_question2)
expect(question2[2]).to eq('Le chat de Mme Coupin')
expect(question2[3]).to be_nil
Expand Down

0 comments on commit d770a73

Please sign in to comment.