Commit Graph
174 Commits
Author SHA1 Message Date
David Beguin 574154eb47 [FIX] survey: redirect on login page on survey start if not logged in.
Before this commit, when sharing a survey 'Login required' to a non logged in
user, the redirection was made to the home page.
The reason is: when the survey is not started yet, no user input is already
created for this survey and this user. So if no user_input has been created,
yet, that means that the user has never started the survey before and user
need first to login before continuing.

After this commit, we redirect to the loggin page.

Task ID: 2246430

closes odoo/odoo#58965

X-original-commit: a309d889ddf6e03a6701e921258cfa9338800fbb
Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
Signed-off-by: David Beguin <dbeguin@users.noreply.github.com>
2020-10-02 09:54:10 +00:00
David Beguin 1f9cd08234 [FIX] survey: ensure to retrieve the participant's answer when restarting
In order to avoid making it possible to follow the same survey multiple times
at the same time, a survey cookie is added with the survey token and answer
token.

When starting the survey, if the cookie contains a valid answer token for that
survey token, the survey session is reloaded where the participant left it.
When the user finished the survey, the cookie is deleted to allow to retake the
survey later, if possible.

Note: A participant can still open multiple tabs with the same survey, but it
will be linked to the same survey answer. So if the user tries to submit another
answer, the late answer will overwrite the previous one.

Task ID: 2345468

closes odoo/odoo#58728

X-original-commit: c97c266313aff864f8c397fb1b42f792f9650e5e
Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
2020-09-28 16:58:13 +00:00
Goffin Simon 923c1eae5e [FIX] survey: 403 Forbidden when printing survey
Steps to reproduce the bug:

- Let's consider a survey S
- Set the scoring option of S to Scoring without answers at the end
- print S

Bug:

A 403 error was raised.

opw:2307495

closes odoo/odoo#55556

X-original-commit: bb627bf8c182905adcf2bf9d9820c6e91dd44d26
Signed-off-by: Simon Goffin (sig) <sig@openerp.com>
2020-08-06 12:34:14 +00:00
David Beguin f0f7f888d3 [FIX] survey: display only answered question in survey review mode
Unanswered questions or sections are now hidden in the survey review mode.
Only the question answered by the user will be visible.
If the survey was done during a session, the users will see their own answers,
even if the theme they selected was not the most voted one (in case of
conditional questions).

To get the questions to display :
- questions that have been answered
- + the ones that should have been answered = active questions
  In session, active questions are based on most voted answers)

This commit also fixes the randomized questions handling in most voted answers,
as copied predefined questions where <NewIds> and those was not usable in
some templates.

Task ID: 2230980

X-original-commit: 8ca79727d5a93b91746c1e63d59d08550417906c
2020-07-28 08:03:34 +00:00
Yannick Tivisse 0215a52252 [IMP] survey: Extract code to allow inheritance
closes odoo/odoo#52636

Taskid: 2186462
Related: odoo/enterprise#10951
Related: odoo/upgrade#1314
Signed-off-by: Yannick Tivisse (yti) <yti@odoo.com>
2020-06-10 09:03:06 +00:00
Martin Trigaux d9287caf94 [IMP] *: convert to private methods
render, render_template, load, activity_schedule_with_view,
get_website_pages should all be private:
It should not be possible to render an aribtrary template only with
its name or id

Still need to render some qweb views from js so the method
render_template is kept public.
This explains why the website editor still need read access on
ir.ui.view as we want to allow any snippet to be rendered.
2020-05-14 13:59:10 +02:00
David Beguin 280c6bf1d6 [IMP] survey: auto submit for questions and matrix with simple choice
Purpose
=======

Speed up survey completion.

Specifications
==============

This commit apply an auto commit when user select a choice on a simple choice
question or on a matrix question with simple choice.

The auto commit happens following those conditions:
- Only on simple choice and matrix with simple choice questions
- For matrix, only when last subquestion is answered
- Only when Back mode is active
- If this is not the last question

Link
====

PR #46768
Task 2208574
2020-03-31 16:25:53 +00:00
Aurélien Warnon 176e5a5066 [IMP] survey: improve survey form navigation
This commit slightly changes the way users navigate through the survey form:
- The back button was moved to the bottom-right of the screen.
- The "Continue" button stays at the center but there is also a "next" button
  at the bottom-right of the screen (same behavior -> submits the form)
- Arrow keys (left + right) navigation is now supported

Technical note: As the survey navigation is now outside of the survey content,
that was re-rendered on every submit, we have to manually refresh the
navigation with a second template render on the controller side.

LINKS

PR #46768
Task 2208574
2020-03-31 16:25:52 +00:00
Aurélien Warnon 695294b953 [IMP] survey: apply small survey form design changes
This commit slightly improves the survey form by adding a few cosmetic changes,
notably:

- Add/reduce some margins/paddings
- Adjust colors/font-weight
- Adjust heights
- Change some icons by more fitting replacements
- Center matrix choices
- Move survey progression to bottom-right
- Remove ugly jumbotrons
- Hide survey title in page_per_question layout
- When there are 5 or less option for simple_choice or multiple_choice
  questions, display the options vertically.
- Only show the textarea for the "comment answer" if the user clicks on the
  related option.

One of the biggest design change is the introduction of a "minimized layout"
that reduces the width of some question types on bigger screen.
This gives a cleaner look to the survey form.
Impacted question types:
- Numeric
- Date
- Datetime
- Simple / Multiple choices

Technical note: As the survey progression is now outside of the survey content,
that was re-rendered on every submit, we have to manually refresh the
progression with a second template render on the controller side.

Small fix addition:
We also fix the matrix key selection feature in case the matrix had a total of
more than 25 options, which would raise an error.
Indeed, they "use key selection" condition only checked the number of rows,
and not the rows * columns (total number of options count).

LINKS

PR #46768
Task 2208574
2020-03-31 15:43:03 +00:00
Aurélien Warnon a330099b92 [IMP] survey: improve session "short link" management
PURPOSE

Improve the various sessions flow to make it easier for attendees to reach the
session and to allow better interactions between the host and his audience.

This comes with small usability improvements as well as increased
"beautifulness" by using custom layouts & animations.

SPECS

- For live session only:
  Currently, the "short link" feature is good but it still needs to be improved
  with the following points:
    - Make the default "code" shorter (4) and digit only.
    - Allow to customize the "code"
    - Check for potential collisions

Added at the same time:
- input element is focused when you land on the '/s' page.

LINKS

PR #46768
Task 2208574
2020-03-31 15:12:04 +00:00
David Beguin af9b9d56c0 [FIX] survey: fix conditional questions navigation on survey
This commit remove unecessary array around triggered_questions_by_answer values
that is used at the client side to find inactive questions.

Before this fix, when looping through every elements of
triggered_questions_by_answer, we got an array, instead of each question id
separately.

PR #48442
Task ID 2208574
2020-03-27 15:03:48 +00:00
Aurélien Warnon 8d09178b42 [FIX] survey: correctly handle "free text sections" in surveys and sessions
We now have a way to display "free text sections" during the survey flow.
(Since 5b74f54396 )

However, the behavior during survey sessions was not optimal:
- Attendees could click on "submit" and it would raise an error
- The section description was not displayed on the host screen
- The section description was never the "current question" of the session of it
  was the first item of the question_and_page_ids

This commit fixes all those points to have a nice session flow.

While the host is explaining the section description to the attendees, they get
a waiting message on their screen.

In addition, we fixed the display to avoid showing pages that lack a
description, and we reworked the '_get_pages_or_questions' method to have more
meaningful and readable cases for every layouts.

LINKS

PR #48442
Task 2208574
2020-03-27 15:03:32 +00:00
David Beguin 2d499c0236 [IMP] survey: integrate conditional questions in session mode
Purpose
=======

This commit makes the live session mode work with conditional question.
The point is to determine which question to display next. As multiple users
are 'voting' for answers of the same questions, the way to determine the
next question to display is to keep only the most voted answer.

The most voted answer will be the only one to trigger the linked conditional
question.

E.g.: considering
- following survey configuration:
    - Q1: A1, A2
    - Q2: triggered by Q1-A1
    - Q3: triggered by Q1-A2
- following user inputs:
    - U1: A1 selected
    - U2: A2 selected
    - U3: A2 selected
The next question displayed to ALL users will be Q3.

Note: If U4 had selected A1, the next question would have been Q2 as
when there is an equality, we select the first one.

Link
====

Task ID: 23509
PR #44950
2020-03-06 10:29:50 +00:00
David Beguin 0675d68afb [IMP] survey: add conditional display option on questions
Purpose
=======

This commit adds a new survey mode : conditional questions. A conditional
question is a question that will be displayed to the user only if the user
selects a specific answer from another previous question i.e. question B is
displayed if user answers 'Choice 1' at question A.

Specifications
==============

There are 2 different ways to handle conditional questions.

  * For one_page and page_per_section survey layout: conditional management is
    done mainly at frontend side. The idea is to be able to load all the
    questions of the section, hide the conditional questions and display them
    dynamically on answer check.
    E.g.: If user checks answer 'Choice 1' from question A, question B is
    displayed immediately.
    If question B is on section 2 and survey layout is set to section per page,
    question B will be displayed immediately on next page template load.
    Indeed, on each page load, server sends all the selected answers and the
    template displays the conditional question depending on the already
    elected answers;

  * For page_per_question survey layout: conditional management is done mainly
    at backend side. The idea is to find on each page the next question to
    display depending on:

    * navigation direction (next - previous)
    * already selected answers and conditional question dependance
    * survey questions sequence

	E.g.: If questions survey are Question A, B and C and question B must be
	displayed if answer 'Choice 1' from question A is selected.
	At Question A, if user select 'Choice 1' and goes next: display B
	At Question B, no matter the answer, if user goes next: display C
	At Question B, no matter the answer, if user goes prev: display A
	At Question A, if user select 'Choice 2' and goes next: display C
	At Question C, no matter the answer, if user goes next: End survey
	At Question C, if user has selected 'Choice 1' at question A and goes prev -> B
	At Question C, if user has selected 'Choice 2' at question A and goes prev -> A

In both modes answers on questions that should not have been displayed to the
user depending on the previous selected answers are cleared.
E.g. : User checks 'choice 1' from question A, then complete question B.
Then user unchecks 'choice 1' -> answer on question B is cleared.

Ignore conditional configuration :

  * during survey session, to avoid having different users answering different
    questions on the same session. That would be confusing for users to see
    questions on presenter screen that they didn't have the opportunity to
    answer;
  * if survey questions selection is random, because it will not display
    conditional questions if they are not kept by randomization. To avoid
    confusion, conditional configuration is simply ignored, not unset, so the
	user can still reactivate it without having to reconfigure everything.

Remove questions that should not have been displayed to the user (depending of
the made choices) in scoring computation and print layout.
--> Inactives questions are removed from predefined questions when user finish
the survey.
E.g.: If the user selects first path on 2, he will never see second path.
If the user answers correctly to all question of first path, he should have
100%, instead of 50%, even if questions of path 2 are mandatory and scored.

Link
====

Task ID: 23509
PR #44950
2020-03-06 10:29:50 +00:00
Aurélien Warnon de2fa26165 [IMP] survey: improve survey session frontend layouts
PURPOSE

Improve layouts and usability for the host screens when using survey sessions.
We focus on the "host" screens, as the attendee screen is based on regular
survey flows/design.

SPECS

In short: copy mentimeter "wow effect".

Main points:

- Remove the "question" container (keep only "Results/Ranking")
- Remove the tabs concept, views are displayed in full screen
- Purpose is to have a "clean view"
    - The display must be "full screen" with only relevant info
    - Enable a easy keyboard navigation with left/right keyboard arrows
      and spacebar
- Switching from results to ranking to next question is always linear
  (next/previous instead of tabs)
- Improve charts
    - Remove the pie chart : make bar charts instead for simple / multiple
      choices
    - Show the chart results "as people answer to it"
      Only if question is not scored, otherwise show when all answers are
      received / when user goes to "next"
    - For free text/date/datetime: show small bubbles with attendees answers
- Add resize, fade in/out, ... animations for "wow effect"

LINKS

PR #45111
Upgrade PR odoo/upgrade#774
Task 2191924
2020-02-27 16:40:57 +00:00
Dharmraj Jhala d628ec05ed [FIX] survey: fix incorrect behavior while retaking the test survey
Before this commit, while retaking a survey with 'Retry' button, the test
mode was not retained leading to unexpected behavior. This commit fixes the
issue by populating required parameters while retrying the survey that ensures
proper behavior for both test and non-test entries.

Task ID 2170720
Closes #43806

closes odoo/odoo#44187

X-original-commit: 65d77b7101acf63fb4316187b5fd94b050b945c3
Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
2020-01-29 11:52:13 +00:00
Aurélien Warnon 774d43c49f [REF] survey: clean useless .decode('utf-8') calls
This commit cleans some useless .decode('utf-8') calls when we return rendered
templates results in the survey controllers.

The http module is capable of handling that type of results and the calls were
not necessary / added complexity.

Task '2187328'

closes odoo/odoo#44540

Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
2020-02-04 07:37:26 +00:00
Aurélien WarnonandDavid Beguin e973bd5519 [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>
2020-01-31 14:35:48 +00:00
David Beguin 44c3a6ef8d [FIX] survey: allow question answer image for public users
As well as background, suggested answers images are not available for public
users as they don't have access rights on that model. This commit adds a route
called by survey template that render the suggested answers image in sudo mode.

closes odoo/odoo#44351

Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
2020-01-31 08:04:15 +00:00
Aurélien Warnon bfae383f9f [FIX] survey: fix survey result filters
Since recent refactoring, filter data have 'question' and 'answers' as
filter_data keys, instead of 'question_text' and 'labels'. This commit fixes
the naming in template using filter_data.

Also, comment that does not count as answer is not linked to a suggested
answer. So that filtering on those comment does nothing because we cannot
find an answer_id in that case. As it makes no real sens anyway to filter
on those kind of comment, filtering have been disabled on those comments.

Triggered by task ID 1972640 (live sessions on survey)
PR #44205
2020-01-29 14:33:53 +00:00
David Beguin aedeccbeea [IMP] survey : redesign frontend layout
In this commit, all the questions type have been redesigned to look more fancy.
(impacted question types : radio and checkboxes, text boxes (textarea and text
inputs, date and datetime inputs and matrix)

For radio and checkboxes, both design have been aligned to work the same way
(except checkboxes can still have more than one selected option).
Selection by key have been applied on those two question types if the number of
option is under 26 (to use all the alphabeat character for selection). This
selection by key is only available on page per question layout.

Tests have been adapted accordingly to the redesign (typically for choice and
matrix inputs)

* Progress Bar

This commit adds a progress bar to the survey to inform the user
where he is in the survey filling process.

There are two progress modes:
    - Number : will display the number of the current page on the total number
    of pages (or questions if layout mode is question_per_page)
    - Percentage : will display the percentage of page or question already done

So this leads to, on last page:
    - in Number mode :
    the progress bar div is 100% filled         3 / 3 pages   [===]
    - in percentage mode :
    the progress bar is aligned to percentage   66% completed [== ]

* Print Widget

A widget is added for survey print mode in order to resize all textarea to fit
their content, instead of showing a scroll bar. This can be usefull if user
wants to print the results. He will get the entire content of the 'textarea
answers' instead of only the two first lines.

* Misc

This commit also :
    - adds background image to survey.
    - redo quizz correction and add some data to illustrate non scored
    questions rendering in print template
    - review breadcrumb style

Note : readonly data option on survey form widget is not set anywhere yet but
the usage is done in prevention of the future work on presenter view for survey
session mode.

Task ID: '2150291'
PR #43237
2020-01-17 16:04:17 +00:00
David BeguinandAurélien Warnon 4a7c84e696 [REF] survey: use ajax instead of redirection for screen transitions
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>
2020-01-13 15:50:14 +00:00
David Beguin f325813c06 [REF] survey: rename skip state in in_progress
This commit renames state 'skip' into 'in_progress' as 'skip' does not really
mean anything.

Task ID: 2152223
PR #41453
2020-01-10 11:01:04 +00:00
David Beguin 26147efeab [IMP] survey: save questions on time limit reached
Purpose
=======

If the timer goes to 00:00, the form is automatically submitted but the answers
are not saved. The form should be submitted, validation should filter out
invalid answers to avoid showing validation errors on the form, and save
answers.
If the answer is not in the correct format : skip the question
If the answer is required but there is no answer : skip the question

This way, we can still compute score.

Specifications
==============

This commit removes the invalid answers from the question to save, only if the
timer is not over, to be able to compute score on not finished survey.

In order to avoid being able to submit answers when the survey is marked as
done, a check was added to return an error for that use case.

Also, to avoid frontend timer hacking, an extra buffer of 10 seconds has been
added. If the time limit is reached and the submit occurs 10 seconds after the
maximum stop time (start time + time limit), no answer can be submitted.

Task ID: 2152223
PR #41453
2020-01-10 11:01:04 +00:00
Thibault Delavallée 4b95e7e5ef [FIX] survey: correctly compute filters based on finished
Oversight of 374b57a153 .
2019-12-06 09:53:32 +00:00
Thibault Delavallée 351a4439b3 [REF] survey: clean results page and its code generating statistics
PURPOSE

As new features are about to land in survey, notably live interactions [1]
and new survey building [2] performing a pre cleaning is necessary. In this
PR we clean survey models by: removing unnecessary fields, cleaning some code
and finally renaming models.

SPECIFICATIONS

Purpose of this commit is to globally rewrite the way statistics are
pre computed and used in results page of surveys. Indeed current code is
very complex, having a lot of calls to the same methods while taking only
part of its results. It also have a mix of model and controller methods,
data is computed several times a bit differently, ...

In this commit we rewrite that part. Including

  * a simpler code flow;
  * a simpler data structure;
  * use a better naming for methods instead of "prepare_results" called
    randomly within the code and re-using part of its returned content;
  * use record sets / records instead of giving sub-elements of a record
    like question.title, label.value, ...

Data structure

  * simply give a question_and_page_ids to the template that will iterate
    on pages / questions;
  * have a graph_data, table_data dictionaries available for graph and
    table display with simple entries;
  * graph_data: holding all necessary but minimalist data for graph display
    if question allows it;
  * table_data: holding all necessary but minimalist data for table / summary
    display;
  * hold record sets of done / failed answers and answer lines;

In this commit we also simplify and clean pagination in survey graph results

  * remove page_range helper tool that can be inlined in the templates
    directly, doing a simple range;
  * fix and improve pagination code;

LINKS

[0] Related to Task ID 2061901 (survey models cleaning and preparation)
[1] Task ID 1972640 (live interactions)
[2] Task ID 2119587 (new frontend for building surveys)

PR #40765
2019-12-05 15:21:28 +00:00
Thibault Delavallée bb3d4634df [FIX] survey: lint JS files and reorganize route code
PURPOSE

As new features are about to land in survey, notably live interactions [1]
and new survey building [2] performing a pre cleaning is necessary. In this
PR we clean survey models by: removing unnecessary fields, cleaning some code
and finally renaming models.

SPECIFICATIONS

This commit lints JS files located in survey as some typos and mistakes
were recently introduced. Code related to routes is also slightly reorganized
to better understand file main sections.

LINKS

[0] Related to Task ID 2061901 (survey models cleaning and preparation)
[1] Task ID 1972640 (live interactions)
[2] Task ID 2119587 (new frontend for building surveys)

PR #40765
2019-12-05 15:21:28 +00:00
Thibault Delavallée a6e9ee91d1 [REF] survey: on survey.user_input{.line}, reorganize and clean model code
PURPOSE

As new features are about to land in survey, notably live interactions [1]
and new survey building [2] performing a pre cleaning is necessary. In this
PR we clean survey models by: removing unnecessary fields, cleaning some code
and finally renaming models.

SPECIFICATIONS

In survey.user_input.line, clean code about constraints. Purpose is to make
it easier to read and understand.

Code creating user input lines is moved from survey.user_input.line model to
survey.user_input. Indeed it is now based on a user_input record, and create
answer line related to a question, based on values coming from controllers
(and therefore frontend). It makes more sense to delegate that code to the
user_input model itself that creates its lines. Code is also rewritten to
be cleaner and easier to read.

Code computing statistics on user input records is moved from survey model
to user_input model, where it belongs. Missing translation marks are added
because translations matter.

LINKS

[0] Related to Task ID 2061901 (survey models cleaning and preparation)
[1] Task ID 1972640 (live interactions)
[2] Task ID 2119587 (new frontend for building surveys)

PR #40765
2019-12-05 15:21:28 +00:00
Thibault Delavallée 755ac5f313 [REF] survey: on survey.user_input, rename some fields to ease understanding
PURPOSE

As new features are about to land in survey, notably live interactions [1]
and new survey building [2] performing a pre cleaning is necessary. In this
PR we clean survey models by: removing unnecessary fields, cleaning some code
and finally renaming models.

SPECIFICATIONS: RENAME QUIZ_SCORE ON SURVEY.USER_INPUT

On survey.user_input, quiz_score field to scoring_percentage

``quiz_score`` field name is related to the old "quiz" behavior of surveys
that is replaced by certifications and scoring mechanisms. Let us propagate
the renaming, beginning with a ``scoring_`` prefix.

SPECIFICATIONS: RENAME QUIZZ_PASSED ON SURVEY.USER_INPUT

on survey.user_input, rename quizz_passed field to scoring_success

``quizz_passed`` field name is related to the old "quiz" behavior of surveys
that is replaced by certifications and scoring mechanisms. Let us propagate
the renaming, beginning with a ``scoring_`` prefix.

SPECIFICATIONS: RENAME TOKEN ON SURVEY.USER_INPUT

on survey.user_input, rename token field to access_token

Survey user input model holds two token field. One is used to distinguish
a pool of attempts linked to a given invite: ``invite_token``. The other
one is used to control access to a specific user input. It means that
``invite_token`` indicates a set of user inputs and each of them is accessed
through its own ``token``. To be coherent with other naming in odoo this
latter field is renamed to ``access_token``.

LINKS

[0] Related to Task ID 2061901 (survey models cleaning and preparation)
[1] Task ID 1972640 (live interactions)
[2] Task ID 2119587 (new frontend for building surveys)

PR #40765
2019-12-05 15:21:28 +00:00
Thibault Delavallée 1e66894042 [REF] survey: on survey.survey, rename some fields to ease understanding
PURPOSE

As new features are about to land in survey, notably live interactions [1]
and new survey building [2] performing a pre cleaning is necessary. In this
PR we clean survey models by: removing unnecessary fields, cleaning some code
and finally renaming models.

SPECIFICATIONS: RENAME THANKS_YOU_MESSAGE ON SURVEY.SURVEY

On survey.survey, rename thanks_you_message to description_done

In this commit we rename thanks_you_message field. Indeed for certifications
or recruitment form, "thank you" is not really the unique content you
would get in a post-survey message. We therefore rename it to description_done
to better indicate its use.

SPECIFICATIONS: RENAME CERTIFICATE ON SURVEY.SURVEY

On survey.survey, rename certificate field to certification

All certification related fields on survey model begin with certification_ .
Only the boolean one telling if a survey is a certification or not is called
certificate. In order to ease grep and ordering it is renamed to certification.

SPECIFICATIONS: RENAME PASSING_SCORE ON SURVEY.SURVEY

on survey.survey, rename passing_score field to scoring_success_min

``passing_score`` field name is not really the best name we could find.
Renaming the field using a ``scoring_`` prefix allow to know this field
is linked to the scoring mechanism.

LINKS

[0] Related to Task ID 2061901 (survey models cleaning and preparation)
[1] Task ID 1972640 (live interactions)
[2] Task ID 2119587 (new frontend for building surveys)

PR #40765
2019-12-05 15:21:28 +00:00
Thibault Delavallée 7edeb24de9 [REF] survey: globally rename survey.user_input_line model to survey.user_input.line
PURPOSE

As new features are about to land in survey, notably live interactions [1]
and new survey building [2] performing a pre cleaning is necessary. In this
PR we clean survey models by: removing unnecessary fields, cleaning some code
and finally renaming models.

SPECIFICATIONS

Main user answer model is ``survey.user_input``. It holds lines related to
answers given to specific questions. In this commit we rename this model from
``survey.user_input_line`` to ``survey.user_input.line`` to be coherent with
general odoo naming guidelines.

LINKS

[0] Related to Task ID 2061901 (survey models cleaning and preparation)
[1] Task ID 1972640 (live interactions)
[2] Task ID 2119587 (new frontend for building surveys)

PR #40765
2019-12-05 15:21:28 +00:00
Thibault Delavallée 84bb9c748d [REF] survey: remove unused or unnecessary fields to clean models
PURPOSE

As new features are about to land in survey, notably live interactions [1]
and new survey building [2] performing a pre cleaning is necessary. In this
PR we clean survey models by: removing unnecessary fields, cleaning some code
and finally renaming models.

SPECIFICATIONS: QUESTION FIELD ON SURVEY.SURVEY

On survey.survey, remove question field, unnecessary related on title.

Question model holds two fields for its title: ``title`` and ``question``.
Question is simply a related on title, making the two fields completely
redundant. It is mainly due to historical reasons, when updating models for
certifications and eLearning. In this commit we keep only title field and
remove the question related field as it adds unnecessary complexity to the
model.

SPECIFICATIONS: INPUT_TYPE FIELD ON SURVEY.USER_INPUT

On survey.user_input, remove input_type and its garbage collect.

``input_type`` field exists on user input model to tell whether answer has
been created through invite or through manual click on a survey page. It
has been added a long time ago when surveys were either open to everyone,
either closed and on invite only.

Since eLearning and certification surveys access mode on surveys has evolved.
Notably being able to distinguish invite from manual survey user input is not
necessary anymore. Indeed what is important is the way people can reach the
survey, not how they created their user input.

Invitation creates token and this can be used if people effectively want to
find invitation-related user inputs.

Since 09ea5c7d49 manual entries still in draft are garbage collected.
Reason is still unclear as it is not obvious that tons of unnecessary entries
will be created. As this seems like unnecessary optimization this commit
removes that feature along with the input_type field.

SPECIFICATIONS: REPLACE URLS FIELDS BY METHODS ON SURVEY.{SURVEY, USER_INPUT}

On survey.{survey, user_input}, remove url fields replaced by methods

In this commit we remove some remaining of URL fields that are better found
using methods. Both survey and user input holds a "start" url field that is
replaced by a method call ``get_start_url`` on both survey (generic) and
user input (token specific) models. We also introduced a ``get_print_url``
method doing the same for the printable version of survey / user input.

SPECIFICATIONS: REMOVE CATEGORY FIELD ON SURVEY.SURVEY

On survey.survey, remove unused category field.

Survey model holds a ``category`` field whose purpose is to be able to somehow
categorize surveys according to their use. However using this field is not
easy as it is hidden and is a simple selection field. Module should add their
own key. Its sole use is in ``hr_recruitment_survey`` which is a niche module.
Let us clean models and lessen model complexity.

LINKS

[0] Related to Task ID 2061901 (survey models cleaning and preparation)
[1] Task ID 1972640 (live interactions)
[2] Task ID 2119587 (new frontend for building surveys)

PR #40765
2019-12-05 15:21:28 +00:00
sri-odooandQuentin Mourier c8d09da004 [IMP] survey: allow to somehow customize certification report templates
This commit adds possibility to select a layout for certification rendering.
User can choose among 6 predefined layouts carefully designed and that should
cover all use cases, therefore removing any need of allowing customization.

It also adds possibility to preview certification directly from survey.

closes odoo/odoo#32675

Task: 1967652
Pr: #32675
Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
Co-authored-by: Stefano Rigano <sri@odoo.com>
Co-authored-by: Quentin Mourier <qmo@odoo.com>
2019-11-28 11:55:01 +00:00
Thibault Delavallée ca1c975d78 [REF] survey: split templates into main files and rename templates
PURPOSE

Purpose is to perform some cleaning in survey models: naming, ordering,
dead code [0]. As new features are about to land in survey, notably live
interactions [1] and new survey building [2] performing a pre cleaning
is necessary [3].

SPECIFICATIONS

Remove dead code :

  * split templates into 3 main files

   * survey_templates: holding main templates when taking a survey;
   * survey_templates_statistics: graph and statistics (results) of a survey;
   * survey_templates_management: templates linked to corner cases and
     error management (403, closed survey, ...) as well as tools and utility
     templates;

  * rename template ids to ease code understanding;

No functional changes should occur with this commit. It contains only
code move, not any change at all.

LINKS

[0] Related to Task ID 2144393 (surveys split / cleaning)
[1] Task ID 1972640 (live interactions)
[2] Task ID 2119587 (new frontend for building surveys)
[3] Task ID 2061901 (survey models cleaning and preparation)

PR #40623
2019-11-25 09:48:23 +00:00
David Beguin ee0b11f2ce [REF] survey : make survey result a widget
This commit cake the survey result analysis js constroller become a widget.
This also simplify style rules using CSS (was handled in JS).
This also modifies the handling of filters to use real
and correctly formated GET parameters.
Redirect url with parameters are now handled automatically
using URLSearchParams() instead of building manually the query string.

Task ID : 1930132
PR #32419
2019-11-19 12:52:22 +00:00
David Beguin 3bb4ac8dc6 [IMP-REF] survey : refactor questions naming, validation and save flow
This commit simplifies the answer_tag and question name
by removing the survey_id (uses now only question id) for the most simple cases

Factorise the save and validate survey answers to avoid duplicate code

Review posted submit data :
- process all questions by question type (instead of using form data
(key,value) that needed key parsing and was un-typed)
- regroup answers by questions and adapt all validation and save flow
- remove post data in save and validate question methods
  and uses directly the answer(s)
- remove useless input names

The tests have been adapted consequently

Task ID : 1930132
PR #32419
2019-11-19 12:52:22 +00:00
David Beguin b1e32976a6 [REF] survey : make survey form a widget
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-11-19 12:51:55 +00:00
Jeremy Kersten fef7ec7c97 [FIX] website,*: remove useless route from sitemap
preparation for cleaning of v13
task-2065018

closes odoo/odoo#39051

X-original-commit: 8a0fc6476c70a4126043de3b3efbd1096e41f968
Signed-off-by: Jérémy Kersten (jke) <jke@openerp.com>
2019-10-18 14:59:02 +00:00
alt-odoo db90ae1cd6 [FIX] survey: display results of survey with no sections
Since commit https://github.com/odoo/odoo/commit/dba478332681dd21a39c4a183c002b1cf6e046d2, a survey can have questions with no section
associated, which means 'page_ids' field will be empty.

This prevents to display the analysis results of a survey, as we are
still expecting a structure page/questions. To solve it, if a question
does not have a section associated, we use an empty page instead.

closes odoo/odoo#39087

X-original-commit: 45c2964c1cfd07cabfa6a1a1b8e796bea4c521d7
Signed-off-by: Alex Tuyls <alt-odoo@users.noreply.github.com>
2019-10-21 07:40:07 +00:00
Christophe Simonis d67b2483e5 [MERGE] forward port branch saas-12.4 up to 9ed4872ea0
closes odoo/odoo#37372

Signed-off-by: Christophe Simonis <chs@odoo.com>
2019-09-24 17:45:37 +00:00
Christophe Simonis ac4fc6e7c7 [MERGE] forward port branch saas-12.3 up to bd3e510edb
closes odoo/odoo#37314

Signed-off-by: Christophe Simonis <chs@odoo.com>
2019-09-24 09:44:56 +00:00
Florimond Husquinet (fhu) 45c6341ba4 [FIX] survey: answers not saved when using breadcrums
- Create a survey with one page per section.
- Go to the second section and select an answer.
- Go back to the first section using the breadcrums.

Before this commit:

if you go back again to the second section, you will see that your answer
wasn't saved.

After this commit:

answers are saved even when navigating with breadcrums.

closes odoo/odoo#37157

Opw: 2072948
Signed-off-by: Nicolas Lempereur (nle) <nle@odoo.com>
2019-09-20 13:44:23 +00:00
Jitendra Prajapati 240e860f24 [IMP] survey: add an overall correctness graph when finishing a certification
PURPOSE

Perform a back2basics review of survey to improve daily use, new user
onboarding and labelling.

SPECIFICATIONS

When finishing a certification survey, add an overall correctness circular
graph. Quarters are

  * correct
  * partially (if multiple corrects answers on the survey);
  * incorrect
  * unanswered

Questions without points are not displayed in this graph.

LINKS

Task 2039068
PR #36229
2019-08-29 15:37:04 +00:00
Thibault Delavallée 0636347099 [IMP] survey: reorder some code to ease understanding
PURPOSE

Perform a back2basics review of survey to improve daily use, new user
onboarding and labelling.

SPECIFICATIONS

Reorder some code to better understand module organization.

LINKS

Task 2039068
PR #36229
2019-08-29 15:36:32 +00:00
Raphael Collet b7fd679a6c [FIX] *: sudo() -> with_user() 2019-07-04 11:32:22 +00:00
Aurélien Warnon d6f07e659d [REF] survey: add a "_mark_done" method to improve answers state management
As other modules than survey (namely hr_skills) now need a hook to add specific
behavior when a survey answer is marked as 'done', we removed the '_send_certification'
method and replaced it with a '_mark_done' method.

It will make it easier to override this method as it has a more generic meaning.

closes odoo/odoo#32880

Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
2019-04-23 12:05:29 +00:00
Aurélien Warnon 2268e747c9 [FIX] survey: allow creating survey with no sections
Task#1958723

This commit fixes the survey form to allow creating, testing and sharing
surveys that don't have sections as long as they don't use the "page_per_section"
layout.

closes odoo/odoo#32159

Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
2019-04-10 15:03:10 +00:00
Hetal Dhanak 926bf780b9 [IMP] survey: hide retry button on print view
-Previously, The Retry button was visible on printable view of the
survey as well as on answers.
	-This commit fixes the issue by passing an extra parameter to
determine whether user is in printable view or simply in answer review.

Task: 1967500

closes odoo/odoo#32618

Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
2019-04-25 05:29:09 +00:00
Aurélien Warnon 44ae98d3dd [IMP] survey: add a download button at the end of certification process
Purpose
=======

When the user successfully takes a certification, he can download the certification
document using a new "Download certification" button.
(In addition to receiving an email containing the certification)

Also cleaned a bit the way certifications are downloaded.

Task-1941250
2019-03-15 20:38:58 +00:00
Aurélien Warnon f322816ae8 [ADD] website_slides_survey: add a new bridge between slide and survey
Task #1940360
Subtask of #1902304

Purpose
=======

Adds certification capabilities to the website_slides module.
Channel/courses can now include certifications as a new type of slide.

This new type of slide is available as a "Certification" button on the slide creation
frontend view (next to "Video", "Presentation", ...).
Users have to link the slide to an actual survey that has the 'certificate' field
set to true (that will populate the slide's survey_id field).

Slides of type certification are handled in frontend in a very simple way for now:
- A button "Begin certification" that redirects the user to the related survey frontend.
- A button "Download certification" when the user has succeeded the certification.
- When the survey is done, if it's linked to a slide, a button "Go back to course" allows
  the user to go back to the slide frontend.

(There is a special use case for when the website_publisher designing the survey lands on a
certification slide: he is allowed to test the survey with a survey_input created as test_entry)

Survey creation as well as limited time, limited number of attempts, ... are still completely
handled in the survey module. That means that the user will have to first create a suitable survey
that is a certification and only then create a slide of type "certification" and link
the created survey to it.

Ideally, the taking of the survey should be transparently included in the slide frontend but
it requires a full refactoring of the way surveys are submitted. This will most likely come in
a later commit.

This commit is an advanced merge of full eLearning module (see task #1902304).
2019-02-15 15:32:46 +00:00