[IMP] survey: reload the survey where the user left it
When going back, after this commit, the last displayed page is saved in order to reload the survey exactly where the user left it, instead of loading the survey at the latest question of the survey displayed to the user. Typically, if the user goes back and leave the survey on question 4, after reaching the question 7, instead of reloading the survey on question 7, the survey will be reloaded on question 4, where the user left the survey. Task-2225393 Part-of: odoo/odoo#79156
This commit is contained in:
@@ -484,16 +484,17 @@ class Survey(http.Controller):
|
||||
if answer_sudo.survey_time_limit_reached or survey_sudo.questions_layout == 'one_page':
|
||||
answer_sudo._mark_done()
|
||||
elif 'previous_page_id' in post:
|
||||
# when going back, save the last displayed to reload the survey where the user left it.
|
||||
answer_sudo.write({'last_displayed_page_id': post['previous_page_id']})
|
||||
# Go back to specific page using the breadcrumb. Lines are saved and survey continues
|
||||
return self._prepare_question_html(survey_sudo, answer_sudo, **post)
|
||||
else:
|
||||
vals = {'last_displayed_page_id': page_or_question_id}
|
||||
if not answer_sudo.is_session_answer:
|
||||
next_page = survey_sudo._get_next_page_or_question(answer_sudo, page_or_question_id)
|
||||
if not next_page:
|
||||
answer_sudo._mark_done()
|
||||
|
||||
answer_sudo.write(vals)
|
||||
answer_sudo.write({'last_displayed_page_id': page_or_question_id})
|
||||
|
||||
return self._prepare_question_html(survey_sudo, answer_sudo)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user