[FIX] survey: corrects progress number for random questions

Purpose
=======

Make sure we display a correct progress number.

Specs
=====

When configuring a survey as one page per question and the random selection
of the questions, the numbers near the progress bar where not correct.
With this commit they now are.

task-2988062

closes odoo/odoo#109802

X-original-commit: 9487495e5e9a3f6ce899249f7eab6c7074c64464
Signed-off-by: Warnon Aurélien (awa) <awa@odoo.com>
This commit is contained in:
Thomas Josse (thjo)
2023-01-12 19:08:57 +01:00
committed by Aurélien Warnon
parent 389f83802e
commit 36a490f38c
2 changed files with 9 additions and 3 deletions
+3 -1
View File
@@ -360,7 +360,9 @@ class Survey(http.Controller):
'page_number': page_ids.index(survey_data['page'].id) + (1 if survey_sudo.progression_mode == 'number' else 0)
})
elif survey_sudo.questions_layout == 'page_per_question':
page_ids = survey_sudo.question_ids.ids
page_ids = (answer_sudo.predefined_question_ids.ids
if not answer_sudo.is_session_answer
else survey_sudo.question_ids.ids)
survey_progress = request.env['ir.qweb']._render('survey.survey_progression', {
'survey': survey_sudo,
'page_ids': page_ids,
+6 -2
View File
@@ -38,7 +38,12 @@
<t t-set="page_number" t-value="page_ids.index(page.id) + (1 if survey.progression_mode == 'number' else 0)"/>
</t>
<t t-else="">
<t t-set="page_ids" t-value="survey.question_ids.ids"/>
<t t-if="not answer.is_session_answer">
<t t-set="page_ids" t-value="answer.predefined_question_ids.ids"/>
</t>
<t t-else="">
<t t-set="page_ids" t-value="survey.question_ids.ids"/>
</t>
<t t-set="page_number" t-value="page_ids.index(question.id)"/>
</t>
</t>
@@ -61,7 +66,6 @@
<t t-if="answer.test_entry" t-call="survey.survey_button_form_view" />
<div class="wrap o_survey_wrap d-flex">
<div class="container o_survey_form d-flex flex-column mb-5">
<t t-call="survey.survey_fill_header" />
<t t-call="survey.survey_fill_form" />
</div>