Skip to content

Commit d535503

Browse files
fmdltde-banana-odoo
authored andcommitted
[FW][FIX] survey: avoid retrospective computation
- Create a survey with passing score at 80 point - Some user complete the quizz with 85 point, the quizz is "passed" - If you update the passing score at 90, the quizz completed by user are now "unpassed". This PR avoid to recompute quizz_passed. closes odoo#74116 X-original-commit: 7dde9ad Signed-off-by: Thibault Delavallee (tde) <[email protected]>
1 parent 7e9949b commit d535503

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

addons/survey/models/survey_user.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ def _compute_scoring_values(self):
7575
score_percentage = (score_total / total_possible_score) * 100
7676
user_input.scoring_percentage = round(score_percentage, 2) if score_percentage > 0 else 0
7777

78-
@api.depends('scoring_percentage', 'survey_id.scoring_success_min')
78+
@api.depends('scoring_percentage', 'survey_id')
7979
def _compute_scoring_success(self):
8080
for user_input in self:
8181
user_input.scoring_success = user_input.scoring_percentage >= user_input.survey_id.scoring_success_min

addons/survey/tests/test_certification_flow.py

+4
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,10 @@ def test_flow_certification(self):
116116
self.assertEqual(user_inputs.scoring_percentage, 87.5)
117117
self.assertTrue(user_inputs.scoring_success)
118118

119+
# Check that the certification is still successful even if scoring_success_min of certification is modified
120+
certification.write({'scoring_success_min': 90})
121+
self.assertTrue(user_inputs.scoring_success)
122+
119123
# Check answer correction is taken into account
120124
self.assertNotIn("I think they're great!", user_inputs.mapped('user_input_line_ids.value_text_box'))
121125
self.assertIn("Just kidding, I don't like it...", user_inputs.mapped('user_input_line_ids.value_text_box'))

0 commit comments

Comments
 (0)