diff options
| author | Patrick Hoste <pko@odoo.com> | 2019-12-02 13:47:53 +0000 |
|---|---|---|
| committer | Thibault Delavallée <tde@odoo.com> | 2019-12-24 08:56:12 +0000 |
| commit | e42ee496f89a830c938a20389a9fc645dfbf96c8 (patch) | |
| tree | 57a456e02861f7cab1f645a2ddf905bee5934269 /addons/website_slides/controllers | |
| parent | 9b534649d5a223523895f1440a359b3ef9529dff (diff) | |
[IMP] website_slides: add comments on answers showed after answering a quiz
PURPOSE :
A quiz after a course content is a good way to check if the user gets the previous lesson.
Despite, the user/student may not understand why his answer was wrong/correct.
In this task we'll allow the teacher to add a comment next to the asnwer of a quiz.
SPECIFICATION :
The quiz creator will now be able to comment the answers to inform the frontend user why
his answer is wrong/correct. He will be able to add the comments both in backend and frontend.
Task ID : 2072566
PR : #41188
Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
Diffstat (limited to 'addons/website_slides/controllers')
| -rw-r--r-- | addons/website_slides/controllers/main.py | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/addons/website_slides/controllers/main.py b/addons/website_slides/controllers/main.py index fbebb1613be..05d4b455b06 100644 --- a/addons/website_slides/controllers/main.py +++ b/addons/website_slides/controllers/main.py @@ -133,7 +133,8 @@ class WebsiteSlides(WebsiteProfile): 'answer_ids': [{ 'id': answer.id, 'text_value': answer.text_value, - 'is_correct': answer.is_correct if slide_completed or request.website.is_publisher() else None + 'is_correct': answer.is_correct if slide_completed or request.website.is_publisher() else None, + 'comment': answer.comment if request.website.is_publisher else None } for answer in question.sudo().answer_ids], } for question in slide.question_ids] } @@ -753,7 +754,8 @@ class WebsiteSlides(WebsiteProfile): 'answer_ids': [(0, 0, { 'sequence': answer['sequence'], 'text_value': answer['text_value'], - 'is_correct': answer['is_correct'] + 'is_correct': answer['is_correct'], + 'comment': answer['comment'] }) for answer in answer_ids] }) return request.env.ref('website_slides.lesson_content_quiz_question').render({ @@ -798,7 +800,6 @@ class WebsiteSlides(WebsiteProfile): return {'error': 'slide_quiz_incomplete'} user_bad_answers = user_answers.filtered(lambda answer: not answer.is_correct) - user_good_answers = user_answers - user_bad_answers self._set_viewed_slide(slide, quiz_attempts_inc=True) quiz_info = self._get_slide_quiz_partner_info(slide, quiz_done=True) @@ -815,8 +816,12 @@ class WebsiteSlides(WebsiteProfile): 'level_up': rank_progress['previous_rank']['lower_bound'] != rank_progress['new_rank']['lower_bound'] }) return { - 'goodAnswers': user_good_answers.ids, - 'badAnswers': user_bad_answers.ids, + 'answers': { + answer.question_id.id: { + 'is_correct': answer.is_correct, + 'comment': answer.comment + } for answer in user_answers + }, 'completed': slide.user_membership_id.sudo().completed, 'channel_completion': slide.channel_id.completion, 'quizKarmaWon': quiz_info['quiz_karma_won'], |
