summaryrefslogtreecommitdiff
path: root/addons/survey/tests
diff options
context:
space:
mode:
authorAurélien Warnon <awa@odoo.com>2020-01-21 10:42:16 +0000
committerAurélien Warnon <awa@odoo.com>2020-01-31 14:35:48 +0000
commite973bd5519295ca737b57de6d50b021ffb5ec6c4 (patch)
tree0e14b576c2c68c2fb0af218a3e809ebe91090a18 /addons/survey/tests
parent5e6c09a1aee33a4e30b6c861998d0c4d4c5900fa (diff)
[IMP] survey: add a 'live session' mode to the survey app
PURPOSE Add a "live session" mode for survey that allows the host to interact with its audience. He controls the pace of the survey and the audience answers questions one at a time. Results for each question can be displayed by the host to adapt his speech in real time. A gamification component even allows to give points to the attendees, based on the quickness of their answer, and create ranking to keep everyone's attention. SPECIFICATIONS This whole feature is deeply integrated with survey. It adds a layer of "survey session" on top if it that gathers attendees and answers during the lifespan of the session. The attendee identity is filled in by a special question that is marked as "Save as user nickname". If the host has not configured that question or if the user doesn't answer, they are marked as "Anonymous" in the rankings. The answer score computation is also altered during the session to take the speed of the answer into account. To ease the access to the survey to attendees, we have introduced two new routes in the survey main controller: - '/s/123456' That uses the 6 first characters of the token to give quick access to the survey and allow typing the URL manually somewhat conveniently. - '/s' that renders a view that asks the attendee to enter the survey 'code', which then redirects to the previous route. This commit also fixes a few bugs: - A bugged use case with the "enter key" listener. When the survey is done, we display a "result template" that shows the user his score and allows him to retry if possible. When this template is displayed, we don't want to listen to the "enter" key that allows to submit the survey form. - We now correctly remove the timer and initialize the result widget when the user presses 'enter' on the last page / question. SURVEY SESSION FLOW HOST point of view: - On the Survey Form, the host configures: - "Reward quick answers" that gives more points to attendees if they answer quickly - Question Time Limit, on each question, that defines the time limit for that specific question, allowing to have different (or no) timer for each question. - From the Survey Form, the host can start a "live session" Only one session per survey can be running at a time. - When he starts the session, the session_state is marked as 'ready', meaning all attendees landing on the survey page will be part of the session. - The host will land on a page showing the current number of attendees as well as the link for the attendees to join that session. - The host starts the session, activating the first question of this session. We keep an active reference to the "current_question_id" and use the bus to trigger an event that will refresh the survey page for all attendees, showing them the question and allowing them to answer. - The host gets a "question management screen", from which he can: - See the current question text & suggested answers - See the current question timer - See the number of answers received for the question - Display the answers of the question (same view as the survey "results" page, but only for the question) - Display the ranking of attendees (if "competitive mode" is enabled) - The host controls the pace of the survey by moving to the next question until it's the last one of the survey, then ends the current session. When the session is closed, we mark the answers of the attendees as "done". - The host lands on a screen where he sees the survey results and the ranking of all attendees. ATTENDEE point of view: - He reaches the survey when a session and open, and gets a screen asking him to wait until the host decides to start the session. - When the sessions starts, he's automatically redirected to the first question (see above). - If the session is already started when he reaches the link, he lands on the current question (and NOT on the first one) - If the host has configured a time limit, the attendee sees the countdown while he's answering. - When the attendee answers the question, the screen tells him the answer is registered and he has to wait for the host to go to the next question, which will happen automatically. - If the timer reaches 0 and he has not submitted his answer, it's too late and he waits for the next one. - It continues like that until the end of the session. - At the end of the session, the attendee gets a screen with his global results (same as a regular scored survey). PR #43568 Task 1972640 Co-authored-by: David Beguin <dbe@odoo.com>
Diffstat (limited to 'addons/survey/tests')
-rw-r--r--addons/survey/tests/common.py5
-rw-r--r--addons/survey/tests/test_certification_flow.py3
-rw-r--r--addons/survey/tests/test_survey_flow.py3
3 files changed, 11 insertions, 0 deletions
diff --git a/addons/survey/tests/common.py b/addons/survey/tests/common.py
index 640556491f0..609a133c286 100644
--- a/addons/survey/tests/common.py
+++ b/addons/survey/tests/common.py
@@ -216,6 +216,11 @@ class TestSurveyCommon(common.SavepointCase):
def _access_page(self, survey, token):
return self.url_open('/survey/%s/%s' % (survey.access_token, token))
+ def _access_begin(self, survey, token):
+ base_url = self.env['ir.config_parameter'].sudo().get_param('web.base.url')
+ url = base_url + '/survey/begin/%s/%s' % (survey.access_token, token)
+ return self.opener.post(url=url, json={})
+
def _access_submit(self, survey, token, post_data):
base_url = self.env['ir.config_parameter'].sudo().get_param('web.base.url')
url = base_url + '/survey/submit/%s/%s' % (survey.access_token, token)
diff --git a/addons/survey/tests/test_certification_flow.py b/addons/survey/tests/test_certification_flow.py
index 3689c1cc200..e23fdffb8b0 100644
--- a/addons/survey/tests/test_certification_flow.py
+++ b/addons/survey/tests/test_certification_flow.py
@@ -115,6 +115,9 @@ class TestCertificationFlow(common.TestSurveyCommon, HttpCase):
self.assertResponse(response, 200)
csrf_token = self._find_csrf_token(response.text)
+ r = self._access_begin(certification, answer_token)
+ self.assertResponse(r, 200)
+
with patch.object(IrMailServer, 'connect'):
self._answer_question(q01, q01.suggested_answer_ids.ids[3], answer_token, csrf_token)
self._answer_question(q02, q02.suggested_answer_ids.ids[1], answer_token, csrf_token)
diff --git a/addons/survey/tests/test_survey_flow.py b/addons/survey/tests/test_survey_flow.py
index 534b3d29a59..c8d814fae69 100644
--- a/addons/survey/tests/test_survey_flow.py
+++ b/addons/survey/tests/test_survey_flow.py
@@ -85,6 +85,9 @@ class TestSurveyFlow(common.TestSurveyCommon, HttpCase):
self.assertAnswer(answers, 'new', self.env['survey.question'])
csrf_token = self._find_csrf_token(r.text)
+ r = self._access_begin(survey, answer_token)
+ self.assertResponse(r, 200)
+
# Customer submit first page answers
answer_data = {
page0_q0.id: {'value': ['Alfred Poilvache']},