[FIX] survey: ignore randomise questions mode in live session

As there is no session object, it is not possible to generate a randomised set
of questions that will be displayed for all the clients.

When getting the most voted answers while checking which question is the next
one to display, or if this question is the last one, predefined questions are
regenarated each time a fake user input is created (the most voted answers.)

So at the end, while checking if a question is the last one, we compare
different objects.

This is not an issue for non-randomised survey, as everything is constant.

So, until a solution is found to keep information related to a session in
particular, randomised questions mode will be ignored in live session mode.

Task ID: 2230980

X-original-commit: 7f0981c4a61429802a5fe24dd794221b1275dfe3
This commit is contained in:
David Beguin
2020-07-28 08:03:36 +00:00
committed by Thibault Delavallée
parent d271c32058
commit 0941f784ef
+2 -2
View File
@@ -72,7 +72,7 @@ class Survey(models.Model):
('all', 'All questions'),
('random', 'Randomized per section')],
string="Selection", required=True, default='all',
help="If randomized is selected, add the number of random questions next to the section.")
help="If randomized is selected, you can configure the number of random questions by section. This mode is ignored in live session.")
progression_mode = fields.Selection([
('percent', 'Percentage'),
('number', 'Number')], string='Progression Mode', default='percent',
@@ -509,7 +509,7 @@ class Survey(models.Model):
if self.questions_layout == 'page_per_section':
result = self.page_ids
elif self.questions_layout == 'page_per_question':
if self.questions_selection == 'random':
if self.questions_selection == 'random' and not self.session_state:
result = user_input.predefined_question_ids
else:
result = self.question_and_page_ids.filtered(