[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/odoo#74238 X-original-commit: d5355037545fb8366675b792f8cc5ed30ecca1bf Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
This commit is contained in:
committed by
Thibault Delavallée
parent
a7e3d8755a
commit
bd9be9f061
@@ -76,7 +76,7 @@ class SurveyUserInput(models.Model):
|
||||
score_percentage = (score_total / total_possible_score) * 100
|
||||
user_input.scoring_percentage = round(score_percentage, 2) if score_percentage > 0 else 0
|
||||
|
||||
@api.depends('scoring_percentage', 'survey_id.scoring_success_min')
|
||||
@api.depends('scoring_percentage', 'survey_id')
|
||||
def _compute_scoring_success(self):
|
||||
for user_input in self:
|
||||
user_input.scoring_success = user_input.scoring_percentage >= user_input.survey_id.scoring_success_min
|
||||
|
||||
@@ -115,6 +115,10 @@ class TestCertificationFlow(common.TestSurveyCommon, HttpCase):
|
||||
self.assertEqual(user_inputs.scoring_percentage, 87.5)
|
||||
self.assertTrue(user_inputs.scoring_success)
|
||||
|
||||
# Check that the certification is still successful even if scoring_success_min of certification is modified
|
||||
certification.write({'scoring_success_min': 90})
|
||||
self.assertTrue(user_inputs.scoring_success)
|
||||
|
||||
# Check answer correction is taken into account
|
||||
self.assertNotIn("I think they're great!", user_inputs.mapped('user_input_line_ids.value_text_box'))
|
||||
self.assertIn("Just kidding, I don't like it...", user_inputs.mapped('user_input_line_ids.value_text_box'))
|
||||
|
||||
Reference in New Issue
Block a user