diff --git a/addons/survey/models/survey_user.py b/addons/survey/models/survey_user.py index ee291c7b713..4bbee52d030 100644 --- a/addons/survey/models/survey_user.py +++ b/addons/survey/models/survey_user.py @@ -180,11 +180,22 @@ class SurveyUserInput(models.Model): 2. send the certification email with attached document if - The survey is a certification - It has a certification_mail_template_id set - - The user succeeded the test """ + - The user succeeded the test + Will also run challenge Cron to give the certification badge if any.""" self.write({'state': 'done'}) + Challenge = self.env['gamification.challenge'].sudo() + badge_ids = [] for user_input in self: - if user_input.survey_id.certificate and user_input.quizz_passed and user_input.survey_id.certification_mail_template_id: - user_input.survey_id.certification_mail_template_id.send_mail(user_input.id, notif_layout="mail.mail_notification_light") + if user_input.survey_id.certificate and user_input.quizz_passed: + if user_input.survey_id.certification_mail_template_id: + user_input.survey_id.certification_mail_template_id.send_mail(user_input.id, notif_layout="mail.mail_notification_light") + if user_input.survey_id.certification_give_badge: + badge_ids.append(user_input.survey_id.certification_badge_id.id) + + if badge_ids: + challenges = Challenge.search([('reward_id', 'in', badge_ids)]) + if challenges: + Challenge._cron_update(ids=challenges.ids, commit=False) @api.multi def _get_survey_url(self): diff --git a/addons/survey/views/survey_templates.xml b/addons/survey/views/survey_templates.xml index 20426c852ca..605fd56ef60 100644 --- a/addons/survey/views/survey_templates.xml +++ b/addons/survey/views/survey_templates.xml @@ -25,27 +25,35 @@

Thank you!

- -
You scored %
- -
Congratulations, you have passed the test!
+
+
+ +
You scored %
+ +
Congratulations, you have passed the test!
-
- - - Download certification - + + + +
Unfortunately, you have failed the test.
+
+ + +
+ If you wish, you can review your answers
-
- -
Unfortunately, you have failed the test.
-
- - -
- If you wish, you can review your answers +
+
+ +
You received the badge !
+