summaryrefslogtreecommitdiff
path: root/addons/survey/static/src/js/survey_timer.js
AgeCommit message (Collapse)Author
2020-04-08[FIX] survey: fix survey timer related issuesAurélien Warnon
This commit fixes timer related issues on survey flows, for both regulars surveys and survey sessions. The timer was unreliable in its completion by a whole second, which had not a big impact at the user level but could make some tests fail (randomly). Side changes from this commit: - Reduced delays in the survey session tests to speed up testing - Removed some timer flickering on survey views LINKS Task 2230526 Runbot error ID 535 closes odoo/odoo#49178 X-original-commit: 15c72aec71d42624685fb0fc9df25279c7855310 Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
2020-01-31[IMP] survey: add a 'live session' mode to the survey appAurélien Warnon
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>
2020-01-13[REF] survey: use ajax instead of redirection for screen transitionsDavid Beguin
PURPOSE To have a better UX, the transition between questions in a survey should not be done by loading another page, but by loading next questions in AJAX. This will allow to fade out / fade in the next question and improve the user experience, as well as prepare the work for the complete survey redesign. SPECIFICATIONS General ======= This commit refactors the way the questions are loaded. To go to next question(s), instead of redirecting to a new page containing the next question(s), the submit process is loading the next question(s) using ajax. The template of the question is prepared at server side and is given in html string to the client that display the next question in a smooth transition (fade in / fade out). This commit includes also the start and the end screen of the survey inside the survey form in order to perform smooth transition between start screen and first question(s) and between last question(s) and end screen. Only one master template (survey form) is now used to display every part of the survey : start + questions + end screens. The answer_done error is now handled by the _prepare_survey_data itself. If the user wants to display an already_done survey, the returned template is the end screen. This commit handles page transition for the survey results. When submitting survey, the survey result widget is initialized and attached to the survey result section. A new route has been added : /survey/begin/. If the user arrives on start screen, the state is 'New'. Once the user clicks on Start button, an rpc call is made to survey/begin that will call the survey_prepare_data to render the first question page and set the state to in_progress and the start_datetime of the answer. Validation ========== Add the validation of all types of questions directly in the frontend. This allows to reduce the latency before the survey is validated and was necessary to go along with our new fade out / fade in mechanism. The client does not need to wait the validation answer from the server to display validation error messages. The current questions are only faded out if the frontend validation has passed. The server still makes this validation before submitting answers and loading next question(s) to avoid direct rpc calls that would mess up the answers. Error messages are now displayed with a slide down transition, for a wonderful wow effect ! Timer ===== As the survey form works with ajax to display start screen, question(s) and end page, the timer has to be started only after the start screen. This commit display and start the timer only after start survey button is clicked. Breadcrumb ========== As the survey form now works in ajax to display in same page start screen, question(s) and end page screen, the breadcrumb has to be controlled not only on page loading but also manually between transition from a screen to another. To ease the breadcrumb management, breadcrumb is now a widget that will reload a js template, mainly depending of the current page id. The js form initialize or update this widget giving this new page id. On breadcrumb item click, the widget triggers a onclick caught by the form that calls the submit with the given target. This commit handles page transition for the breadcrumb. When going forward or backward (next or previous page), the breadcrumb activates, deactivates and links elements are reinitialized depending of the target page. LINKS Task ID: 2152223 PR #41453 Co-authored-by: Aurélien Warnon <awa@odoo.com>
2019-11-19[REF] survey : make survey timer a widgetDavid Beguin
This commit makes the survey timer js controller become a widget. This widget is called by the survey form widget. When the time is over, the widget triggers a time_up event instead of calling the submit. the time_up event is catched by the survey form widget that calls himself the submit, as the submit is on the form and not on the timer itself. Task ID : 1930132 PR #32419
2019-11-19[REF] survey : make survey form a widgetDavid Beguin
Purpose of this commit is - to make the survey js controller a widget, to be more 'odoo-standard'. - to lessen number of RPCs and clean old code for prefilling and validation of surveys. Clean Prefill : Prefill can be done directly in the template as the template has already all the needed values (in answer object). Clean Validation : Validation is done at server side and is independant from prefilling values. Dates: Dates are now formatted directly in the template, at rendering, using a format_date fonction pointer called in the template. Don't use widget in review mode: Remove o_survey_form class from review template as only dates were processed in the widget for review template. Breadcrumb : Remove button previous, prev=prev and go_back mechanism : The previous page is handled by the breadcrump Remove redirect url mechanism. Breadcrumb now saves the answers when going to a previous page. Move o_survey_form class to a higher div to englobe breadcrumb in the widget and ease his handling. Remove locale load as already done in session.js#load_modules This commit modifies the route type of survey submit to work in json. The js survey form controller calls now manually the route via rpc. Task ID : 1930132 PR #32419
2019-03-06[REF] survey: adapt code after jQuery updateVincent Schippefilt
Part of task 1896658 Co-authored-by: Aaron Bohy <aab@odoo.com> Co-authored-by: Christophe Matthieu <chm@odoo.com> Co-authored-by: Mathieu Duckerts-Antoine <dam@odoo.com> Co-authored-by: David Monjoie <dmo@odoo.com> Co-authored-by: Martin Geubelle <mge@odoo.com> Co-authored-by: svs-odoo <svs@odoo.com> Co-authored-by: Vincent Schippefilt <vsc@odoo.com>
2019-02-06[IMP] survey: scoring & certificationAurélien Warnon
Task #1902306 Purpose ======= This commit adds certification capabilities to the survey module. A certification is a survey with the "certification" flag set to true than can be linked to a certification email template that contains a certification document (PDF). This template can be edited by the user in the technical settings to customize the certification email/document. To be able to implement this certification concept, we also have to add scoring mechanisms to surveys. survey.questions of type 'simple_choice' and 'multiple_choice' now have scores for the suggested answers. These question scores allow to compute a global score that is used to determine whether the user has successfully passed the certification or not. As additional features, we also have: - A time limit with an interface timer that limits the test to X minutes When reached, the survey is automatically submitted and unregistered (= unsubmitted) answers are not taken into account. - A limited number of attempts for the survey/certification If reached, the user can't take the survey/certification anymore The 'survey result' layout was adapted accordingly to show the success rate of participants and the correct answers to the survey questions. Specs ======= - Create a new survey : - Add a description field for the survey - Options on a survey : - Passing score : (sum of all good answers) in % - If No scoring => No passing score, no certificate - If Scoring with answers => Passing score and can see the answers (can create certificate) - If Scoring without answers => Passing score but can't review the answers at the end (can create certificate) - for the questions, if "no scoring" selected, can 't see the option "good answer" and "score" on the questions - If the 2 others options, can see the options "good answer" and "score" on the questions - all the types of questions are available for each option. - Questions - Add the option correct answer on the multiples questions (one or more good answers) - Certifications - If scoring, force "mandatory" for "mutliple choices (1or multiple answers)" - On the dashboard => visual information that this specific survey is a certification - Time Limit : The student is informed on the home screen of the survey of the time limit. The clock start when he clicks on "start survey" - Template of the certificate : send email with attachment PDF - Front-end : - Add some margin - Replace "Back to survey" with the blue-bar from the portal - Add a timer (start when the survey starts) - Add a progress bar (number of section and number of question inside the section) - Analyse of the results : - First a global graph with the number of people who''ve participated and passed the test - Stages of a survey : - Remove the stage "Permanent" - 3 stages : - draft : not on-line but can be tested (with phantom token) - In progress : on-line - closed : not on-line - Who can test a survey : the manager and the user. Add this condition to the phantom token.