Commit Graph
186 Commits
Author SHA1 Message Date
Noe Antoine 01ffaea48b [FIX] survey: allow partial scores to answers almost correct.
BEFORE THIS COMMIT / How to reproduce :

Consider a multiple choice question with single answer.

A. 2 points
B. 1 point
C. -1 point

Here, the user can only select one answer. He picks A. He only obtains 2/3 points.
This is because the maximum score was computed as the sum of all positive scores
for the question. It does not make sense, as the student can only pick one answer.
Therefore, the formula does not allow giving partial scores (here, answer B, close
to the correct answer) while maintaining correct score percentages.

AFTER THIS COMMIT:

The sum of positive scores is still used as maximum score for multiple choice
with multiple answers, as we want the student to pick all good answers for max score.

However, for multiple choice with single answer, we use the maximum positive score
(or 0, if none) among answers, as it the maximum score one can get while selecting
a single answer.

-> example above : I pick A, I obtain 2 points out of max(2, 1, (0)) = 2
-> I obtain max score for the question. 2/2.

ps: As the sum only uses striclty positive values, the negative points are still
operational and the flow is not changed.

TESTS:

A test test_partial_scores_simple_choice is added to make sure the simple_choice
is repaired and always gives 100% of points if the best answer is picked.

Task-2533836

closes odoo/odoo#77426

X-original-commit: 2cdfb7805564943ccf857e49b41d3b597fd727bb
Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
2021-09-30 10:38:15 +00:00
Aurélien Warnon aaba76b770 [FIX] survey: correctly consider all non-answered questions as skipped
Currently, if the survey participant does not answer questions of type:
- simple_choice
- multiple_choice
- matrix

The system does not register any survey.user_input_line with the "skipped"
attribute set to True. Meaning that this question's answer will not appear in
the survey statistics as skipped (in fact it will not appear at all).

This commit makes sure we correctly save a user_input_line set as skipped=True
when not answering to those types of questions.

A unit test has been added to make sure that we consider every non-answered
question type as properly skipped within the survey statistics.

Task-2622869

X-original-commit: 87ea302044ff7ac26888000101254b1af2524046
Part-of: odoo/odoo#76606
2021-09-16 08:36:06 +00:00
Swapnesh Shah 5a6057e5fd [FIX] survey: do not always get answer_score
Calling `_get_answer_score_values` on each question creation or update is
not necessary if value is already provided.

Followup of odoo/odoo@0d32ed45ae

closes odoo/odoo#76223

X-original-commit: c6c7605cdae803aca4f441ef4e622a1b79f17019
Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
2021-09-09 12:05:00 +00:00
52fedc8e91 [IMP] survey: add average duration on survey
Average duration of each survey is added. To avoid performance issues value
is not stored, and calculated with raw SQL. It requires to have an end
datetime on survey user inputs, allowing to compute average duration it
took people to complete survey.

Live surveys now open in a new tab instead of in-place.

Also rename some css / scss files to ease understanding. Remove unnecessary
class on survey form view.

Task-2634805
PR odoo#72298

Part-of: odoo/odoo#72298
Co-authored-by: David Beguin <dbe@odoo.com>
Co-authored-by: Mariska Archielli <ram@odoo.com>
Co-authored-by: Thibault Delavallee <tde@odoo.com>
2021-08-31 23:34:55 +00:00
alt-odoo ad5f8e2eff [FIX] survey: No crash when getting stats of answers of a survey
If for any reason the initial linked question of one possible answer was
changed and if one existing survey has already been answered using that
possibility, we currently got an Internal Server Error while we should
simply just ignore these answers when getting the statistics of that
survey.

closes odoo/odoo#75758

X-original-commit: 87096c284872f9aa99f5ae9096cee92663c4933e
Signed-off-by: Alex Tuyls <alt-odoo@users.noreply.github.com>
2021-08-31 02:33:44 +00:00
Mitul Shah ab2afb0e9d [FIX] survey: fix the warning message while sharing the survey
Currently, while trying to share the survey with 'one page per section'
layout, if the survey has only questions and no sections, a warning is
raised that says 'You cannot send an invitation for a survey that has
no questions'. It is misleading because in this case, what you do not
have is atleast one section with question(s).

This commit fixes the warning message for 'one page per section' type
of survey and gives clear idea to the user about what is missing.

TaskID-2611996

closes odoo/odoo#74694

X-original-commit: 381d18888d81f6797004c718fee5dbd9706b3122
Signed-off-by: awa-odoo <awa-odoo@users.noreply.github.com>
Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
2021-08-04 10:49:01 +00:00
Florent de Labarre bd9be9f061 [FW][FIX] survey: avoid retrospective computation
- Create a survey with passing score at 80 point
- Some user complete the quizz with 85 point, the quizz is "passed"
- If you update the passing score at 90, the quizz completed by user are now "unpassed".

This PR avoid to recompute quizz_passed.

closes odoo/odoo#74238

X-original-commit: d5355037545fb8366675b792f8cc5ed30ecca1bf
Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
2021-07-26 12:16:20 +00:00
Aurélien Warnon 8b3c1b36b7 [IMP] survey: add a "performance per section" chart
This commit adds a new chart at the end of a scored survey.

Previously, you could see your "Overall Performance", meaning what was your
percentage of correct/partially correct/incorrect/skipped answers for all
the survey scored questions.

Now, we added a new chart new to it that shows the percentage of
correct/partially correct/incorrect/skipped answers but for each section of the
survey.

This allows the user to see in which section(s) he did the most mistakes.

Task-2484885
2021-04-15 12:32:12 +00:00
Adrien Widart 0d32ed45ae [FIX] survey: allow to modify a completed survey
Updating a completed survey will raise an error with a traceback.

To reproduce the error:
(Use demo data)
1. Survey > Participations
2. Select a completed form
3. Change one answer, Save

Error: A traceback appears "[...] ValueError: Computing score requires a
question in arguments."

Here is an extract from the method concerned:
```python
@api.model
def _get_answer_score_values(self, vals, compute_speed_score=True):
    """
        [...]
    """
    user_input_id = vals.get('user_input_id')
    answer_type = vals.get('answer_type')
    question_id = vals.get('question_id')
    if not question_id:
        raise ValueError(_('Computing score requires a question in
arguments.'))
```
This method needs some information to work properly.

OPW-2488974

closes odoo/odoo#70328

X-original-commit: 62cd2c0be63738f0bbefd62de5d025990e63824f
Signed-off-by: Adrien Widart <adwid@users.noreply.github.com>
2021-05-04 12:26:35 +00:00
David Beguin a888b8ee4a [IMP] survey: allow host to go to previous question in session
PURPOSE
=======
For now, the host can't go back to the previous screen on a live session.
Why would he want to go back? Misclick, want to display again the result, other

SPECIFICATION
=============
On a live session, let the host go back to the previous screen.
Do not "restart" the questions but display the graph with the results.
This back capability is independant of the "back button" survey option.
Even if the back button is disabled on the survey configuration, the host must
still be able to go back during a session.

Task ID: 2351759

closes odoo/odoo#59659

Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
2021-04-09 11:47:20 +00:00
Lavish Chhatwani 45eb2b397f [IMP] survey: display title on certification preview
Right now while previewing the certification template, the proper title is not
displayed on the tab of browsers.

This commit improves the behavior by adding name of the certification in title
so that use can see the proper string on browser tab. For doing so, we create
a new wrapper template that sets the title for the page, and use an iframe
to loads the pdf file from existing controlloer (which returns response for the
preview pdf).

Task ID-2341847
COM PR odoo/odoo#66028
2021-03-03 16:16:00 +00:00
Dharmraj Jhala f8738b70f4 [IMP] {hr_recruitment_,website_slides_}survey: add 'user_id' field
This commit enable users to set a 'Responsible' for the survey by
adding 'user_id' field. Demo data for the same is also updated.

Task ID-2389434
COM PR odoo/odoo#62712
ENT PR odoo/enterprise#15217
UPG PR odoo/upgrade#2006
2021-02-10 17:03:59 +00:00
ijas ahammed 3010751e95 [IMP] {hr_recruitment_,website_slides_}survey: remove 'state' field
The goal of the draft state on survey is to have the survey under edition
mode before before sending it to participants. Under this mode:
  - the responsible can test it (can be done with "In Progress" mode)
  - the survey can't be answered (same as the state closed)

The risk that the survey can be leaked before being ready is really
limited. If it's a live survey, participants will have to guess the
4 digits access code and wait for the host to go to the next question.
Else, participant will have to guess the token.

Considering these facts, the use of the draft state is very limited so
'draft' state can be dropped. If we do so, we are left with only two
stages that are 'open' and 'closed'. But whether to consider survey
open or closed can be simply achieved with active field we already
have (if active=False, survey is closed, otherwise it's considered
as open).

So with this commit, we remove the state field from survey and thus
simplify the flow. It means that we no longer require 'Start Survey'
button, and so that button is also removed, and for the closed surveys,
instead of the button 'Set to draft', now we have a 'Reopen' button
which will activate the survey. And instead of displaying few buttons
after saving a record, we now display all the buttons from beginning.

Task ID-2389434
COM PR odoo/odoo#62712
ENT PR odoo/enterprise#15217
UPG PR odoo/upgrade#2006
2021-02-10 17:03:03 +00:00
Thibault Delavallée 8fbed20e98 [FIX] survey: force title on duplicate only if not already specified
No need to force a new title on duplicate if something is already given.

Task ID-2265556
PR odoo/odoo#52391

Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
2021-01-04 15:10:11 +00:00
Dharmraj Jhala 637a68a46e [IMP] survey: allow to duplicate survey with badge
Before this commit, if a badge is set on the survey, duplicating it always
results into a traceback due to sql constraint. Indeed due to uniqueness
constraints between survey and badge having the same badge for a duplicated
survey was leading to an error.

We had two options
  * duplicate the badge itself;
  * remove sql constraint and add a required on badge in view when having
    a certification (aka, survey giving a badge);

First solution is somehow limited. It means updating badge name, checking
its goal, ensuring all parameters are ok. Moreover it is quite hidden when
duplicating survey. End users will maybe not see what to are doing.

We choose to remove copy flag on flag and badge. That way end users have to
manually re-check the flag, and create a new badge. We remove the hard
constraint and set a required in the view so that functionally behavior
is the same.

Task ID-2265556
PR odoo/odoo#52391
2021-01-04 15:10:11 +00:00
Martin Trigaux 1658473bf2 [FIX] *: rephrase, correct typos
Courtesy of Transifex's translators for reporting bad/unclear sentences.

closes odoo/odoo#62564

X-original-commit: 9b3b2e8d711e3be75b1faffaf6f4f8f4ec90186e
Related: odoo/enterprise#15038
Signed-off-by: Martin Trigaux (mat) <mat@odoo.com>
2020-11-30 07:07:58 +00:00
Rachid Al Assir bc67b1ab7b [IMP] survey: order survey user inputs by last attempts
Purpose is notably to display last survey attempt as "Date of certification"
instead of first one. We therefore set an _order on survey.user_input model
(user participation to a survey) as create_date desc. When several attempts
are made the last one will be considered when doing a search with limit=1.

Closes #61362

Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
2020-11-25 08:04:40 +00:00
Martin Trigaux e433bc57ff [FIX] *: rephrase, correct typos
Courtesy of Transifex's translators for reporting bad/unclear sentences.

closes odoo/odoo#61804

X-original-commit: f5d0f4a1ebf406583889e9e04912d40c0693343e
Related: odoo/enterprise#14769
Signed-off-by: Martin Trigaux (mat) <mat@odoo.com>
2020-11-16 16:47:28 +00:00
Martin TrigauxandXavier Morel 49838338e0 [FIX] *: sanitize action content reading
The open_action_with_context was not using _for_xml_id, producing an
error when reading the action content.

In open_action, the action_name was taken from the context and needs
sanity checks. Ensure only actions from the account module can be
read and only if the user has access to the target model.
This is a limitation of the previous behaviour but, at the moment, all
known calls are made refering to an action from the account module.
Limit the scope of this method while the 14.0 is still early to avoid
having a door open to ready any action, and difficult to close later.

Remove old action fetching from the context in create_move that is no
longer used.

closes odoo/odoo#61602

X-original-commit: a39e94f7e4dc74e850650ac90bbc5f85af130bc8
Related: odoo/enterprise#14695
Signed-off-by: Martin Trigaux (mat) <mat@odoo.com>
Co-authored-by: Xavier Morel <xmo@odoo.com>
2020-11-10 16:04:29 +00:00
Martin Trigaux c59c10f1bc [FIX] *: correct typos and bad English
Courtesy of translators
Reexport .pot of modified modules

closes odoo/odoo#61010

X-original-commit: 62a18bdb372e234107fd2099a2df5f9e3a442c96
Related: odoo/enterprise#14489
Signed-off-by: Martin Trigaux (mat) <mat@odoo.com>
2020-10-29 19:23:41 +00:00
Martin Trigaux 6156f98288 [FIX] *: adapt action content retrieval
Use _for_xml_id to replace all the self.env.ref().read()[0]
This has the advantage of having a single point of control and to add
the fields filtering and model verification.

Add sudo for other operations on ir.actions.*
2020-08-17 09:09:02 +00:00
Aurélien Warnon 4abe3ea9c7 [IMP] survey: animate leaderboard in survey sessions
Purpose
=======

This commit intends to improve the animations on the leaderboard during survey
sessions. We now show both the ranking of each attendee before and after taking
into account the current question scores.

It allows attendees to see their position in the leaderboard shifting up / down
depending on how well they answered, and adds a bit more interactivity during
the session.

Specs
=====

The code changes to make this happen implied having multiple layers of
animations running one after the other.
The use of async/await in the JS allowed for a much smoother and less indented
code, simplifying the reading.

We now have 2 different "bars" to handle:
The bar that shows the previous leaderboard position.
The bar that shows the current question score.

This means we handle both jQuery items and modify their size & transition
properties depending on our animation.

Unfortunately, all these animations required a lot of testing to find fitting
timings, which means using quite a few setTimeout with "magic" delays.
These were just the most good looking ones and it feels like naming them with
a constant would not really help.

We also slightly improved the graphic font size / styling to make it easier to
read for potentially far away attendees.

Task 2235815

closes odoo/odoo#50991

Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
2020-08-04 07:47:25 +00:00
David Beguin 0941f784ef [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
2020-07-28 08:03:36 +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
David Beguin e4e049ef22 [FIX] survey: fix is_last_page_or_question
Before this commit, is_last_page_or_question was determined only in function
of next active questions : If there are no active question after the current
one, current question is the last one.

But, in conditional questions context, if the current question is conditionning
the display of latter questions, when we display the current question, we
cannot already know if we are on the last question, as user did not answered
yet.

After this commit, the current question is the last one only if
- there are no active questions that follows
- AND the current question is not conditionning the display of other questions

For page_per_section, we check the same rule for all section's questions.

Task ID: 2232973

X-original-commit: 12d962e579d2480fbf821fb381adebf47668dbcc
2020-07-28 08:03:32 +00:00
David Beguin cb67ff261f [FIX] survey: apply conditional configuration to free text section
As section with description are now considered as potential questions to
display, the method to get the next question to display needs to check if
the next section should be displayed or not, depending on conditional
configuration and user inputs.

For page_per_question and page_per_section layout, the following rule now
applies:

If the section is empty (has no sub-questions):
    Show it if section has description, else skip it. (in both layout)
If the section has sub-questions:
    If a least one sub-question is active:
        In page per section: show it.
        In page per question: show if section has description, else skip it.
    If no active sub-question: Hide it.

Apply also empty section rules to non conditional survey :
If a section is empty (no description and no active questions inside), the section
should not be displayed.

Task ID: 2230980

X-original-commit: f0ce3623e3cfc2451e3f7359ec09399e6e474c10
2020-07-28 08:03:30 +00:00
David Beguin 1c2bc40a95 [FIX] survey: count answer as incorrect only if no correct answer in survey finish page graph
Before this commit, when computing the result graph data in the survey finished
page, a user answer for a question with no correct answer was counted twice,
once as correct, once as incorrect, as :
correct_answer == question_correct_answer == none

After this commit, we count an answer as correct only if question has a correct
answer.

Task ID: 2176630

closes odoo/odoo#54755

X-original-commit: 74a00111908556bce10ea3a5e748f5a5c81f6a40
Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
2020-07-22 10:06:28 +00:00
Jeremy Kersten 76b2de42f4 [FIX] *: handle null value for boolean in sql queries
It has always been a best effort until the v13 to have false as default value
for boolean field.
Until v13: https://github.com/odoo/odoo/blob/12.0/odoo/models.py#L3645

During ORM refactoring in v13 it has been replaced by a default value in sql
From v13: https://github.com/odoo/odoo/blob/13.0/odoo/tools/sql.py#L79

But with a typo since columntype for boolean is bool and not boolean.
What's mean that in v13 we have a lot of null value for boolean (~=False)

In all cases, we try to be aware and check Falsy boolean with 'null or False'
(https://github.com/odoo/odoo/blob/13.0/odoo/osv/expression.py#L1230)

So we should do the same when we write pure sql in method bypassing the ORM.

closes odoo/odoo#53391

closes odoo/odoo#54458

Related: odoo/enterprise#11319
Related: odoo/enterprise#11838
X-original-commit: 118c9f6aafd423f415b2bbfcf8a9cfcd676d9b92
Signed-off-by: Jérémy Kersten (jke) <jke@openerp.com>
2020-07-14 15:52:59 +00:00
Martin Trigaux 400cc4f14e [FIX] *: correct all or improve code translation lookup
This commit fixes all issues detected by the new pylint
gettext-variable test.
It converts some calls to the new syntax
  _("Foo %s", bar)

to progressively migrate the code to the new syntax.

A few calls were not technically incorrect but still detected by the
linter.

  _("Foo" +
    "Bar")

has been converted to

  _("Foo"
    "Bar")

as it has the same effect and make sure the argument is of type
asteroid.Const instead of BinOp).

closes odoo/odoo#53683

Related: odoo/enterprise#11467
Signed-off-by: Raphael Collet (rco) <rco@openerp.com>
2020-06-30 10:19:59 +00:00
Aurélien Warnon 71e17248a4 [REF] survey: move from onchange to editable stored fields
PURPOSE

Try to move from onchange / default_get to stored editable computed fields.
Behavior should be the same (computed or set by user), with support of
create / write / onchange field update without additional code.

SPECIFICATIONS

Update classic fields updated in some cases by onchange and/or default methods
by fields with store=True, readonly=False. It means their value comes either
from manual user input, either from trigger based computation.

Remove onchange and default_get when possible, leading to an unique computation
method and clearing fields definition.

Also clean some fields definition inconsistencies, notably required fields
that should instead be correctly computed or default that have no real meaning.

SURVEY USE CASES

- On survey.question, the question_type field should be emptied if the question
  is a page (is_page = True)
- On survey.survey, if scoring is configured, the minimum scoring success
  should be between 0 and 100 (added SQL constraint).
- On survey.survey, the certification field cannot be True if we're in no
  scoring mode (scoring_type = 'no_scoring')
- On survey.survey, the attempts number cannot be limited (is_attempts_limited
  is False) if the access mode is public and the login is not required.
- On survey.survey, we cannot give a badge (certification_give_badge is False)
  if it's not a certification or if the login is not required.
- On survey.invite, the "subject" and "body" field are based on the template
  used (template_id field).

MISC

- As "validation_email" works with "validation_required", we removed the
  onchange on "validation_email".
- To avoid extra complexity with an onchange on "is_time_limited" and
  "time_limit", we simply default the time_limit field to 10.

LINKS

Upgrade PR odoo/upgrade#847
Task 2187377

closes odoo/odoo#46291

Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
2020-05-06 13:01:08 +00:00
Jorge Pinna PuissantandNicolas Lempereur 66a4d8f94c [FIX] survey: questions without page_id
- Create a new survey 'Test Survey';
- Add a section 'S1';
- Add a multiple lines text box question 'Q1';
- Add a section 'S2';
- Add a section 'S3';
- Don't move any of the section or question to avoid changing the
    sequences, for the moment all the sequences are equal to 10;
- Change the survey layout to 'One page per section';
- Save the survey;
- Test the survey;
- Fill the 'Q1';
- Go to the last page and Submit the survey;
- Review your answers.

Before this commit, the question is empty, this occurs because the
question page_id is not set, in _compute_page_id, the sequence of the
question should be bigger than the question of the page (in this case
the section).

Now, the _compute_page_id was change to take into account the case when
the question has the same sequence as the page (section).

opw-2222045

closes odoo/odoo#49366

X-original-commit: 99f35075e3d1e418e096a29b7440152e746a1cd5
Signed-off-by: Jorge Pinna Puissant (jpp) <jpp@odoo.com>
Co-authored-by: Nicolas Lempereur <nle@odoo.com>
2020-04-10 07:45:14 +00:00
Aurélien Warnon f4803d548b [FIX] survey: fix survey timer related issues
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-04-08 07:33:14 +00:00
Xavier Morel 4b7ac65e17 [FIX] survey: use absolute paths
On redirection, werkzeug converts locations from relative to absolute
URLs. Apparently the specific algorithm when given a relative *path*
changed between 0.14 and 0.15, or possibly these paths suddenly became
processed whereas before they were interpreted as absolute?

So in Werkzeug 0.14, `redirect('foo/bar')` was treated as
`redirect('/foo/bar')` but in 0.15 it's first urljoin-ed to the
current path before the redirection is effected.

This is an issue with slides, because survey's get_start_url returns
the url `survey/start/<access_token>` without a leading slash.

The result is that where with 0.14 the certification tour would do this:

    GET /slides_survey/slide/get_certification_url?slide_id=39&fullscreen=1
    GET /survey/start/<id>?answer_token=<token>

with 0.15 or above it does this:

    GET /slides_survey/slide/get_certification_url?slide_id=39&fullscreen=1
    GET /slides_survey/slide/survey/start/<id>?answer_token=<token>

Which weirdly enough doesn't work at all.

closes odoo/odoo#48982

X-original-commit: 82a23883748172c05d2562f244ffbc1558ce01fc
Signed-off-by: Xavier Morel (xmo) <xmo@odoo.com>
2020-04-03 14:19:01 +00:00
Thibault Delavallée 6cf824933f [IMP] survey: cascade archive of a survey to its badge
Purpose of this commit is to synchronize active status of certifications to
their badges. When archiving or activating a certification, its badge is also
archived or activated.

Task ID 2170708
Community PR odoo/odoo#46563
2020-04-03 12:59:29 +00:00
Thibault Delavallée bea9bc3d6c [IMP] mail, mass_mailing, phone, survey: call toggle_active / action_(un)archive when possible
Purpose of this commit is to call toggle_active or archive / unarchive methods
instead of manually writing on active field. Indeed this allows to trigger
business code related to archive / unarchive which is normally located
in toggle_archive (called by action_archive and action_unarchive).

Task ID 2170708
Community PR odoo/odoo#46563
2020-04-03 12:59:28 +00: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 aaf3cb50c3 [IMP] survey: improve sessions fade in/out delays
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

This commit changes the survey sessions fade in/out delay for both the host
and the attendees.

When going from one question to another, the total delay is now 1 second
(instead of 2 previously), with 500 ms for fade out and 500 ms for fade in.

The previous delay gave an impression of "slowness".

The delays and "server lag reduction" on the attendees side were adapted
accordingly.

LINKS

PR #46768
Task 2208574
2020-03-31 15:12:05 +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
Aurélien Warnon c5ae9b38d1 [FIX] survey: fix some issues
== Fix results scored question display ==

This commit fixes the display for scored choice question.
The text "Right answer" was displayed twice.

== Add default values to avoid constraints inconsistencies ==

This commit adds a 0 default values to some of our validation fields on survey
questions.

Without a default value, the ORM would store "NULL" in the fields and then
allow users to define a "min" without a "max", that would result in an error
while trying to validate the answers to that question.
Furthermore, when creating a question from the frontend, the web framework will
always send 0 for all field values anyway.

The code change adds consistency and avoids potential errors on that issue.

LINKS

Task 2208574

closes odoo/odoo#48371

Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
2020-03-31 07:33:52 +00:00
Adrian Torres 1daf8eb127 [FIX] *: set ondelete policy of required Selection fields
With this commit, Selection fields with `required=True` which are
extended via `selection_add` are given proper ondelete policies to
ensure the cleanup of records containing these extended options during
uninstall of the extending module.

This commit also cleans up leftover uninstall hooks that were being used
to handle the same set of problems prior to the ondelete mechanism being
implemented for Selection fields.

closes odoo/odoo#46325

Related: odoo/enterprise#9117
Signed-off-by: Raphael Collet (rco) <rco@openerp.com>
2020-03-30 13:42:04 +00:00
David Beguin e8f0475a38 [FIX] survey: skip section with no active questions (in conditional questions)
This commit applies conditional questions management on  the
"_get_next_page_or_question" method in "page_per_section" questions layout.

We choose the first section that has at least one active question when
searching the next section to display.
Indeed, a whole section could contain only disabled questions based on the
previously selected answers of the attendee.
(The logic is obviously reverted when "go_back" is True).

PR #48442
Task ID 2208574
2020-03-27 15:03:49 +00:00
Aurélien Warnon 826a25c7d1 [FIX] survey: fix back button behavior
This commit fixes 2 small problems when the user goes back on the survey form:

- The back button should not be shown on "page_per_question" layout if we are
  on the first page of the survey.
  Pages can be displayed on "page_per_question" layout if they have a
  description since #44271
- Can't go back on "page_per_section" layout if you are on the second page of
  the survey, introduced by 0675d68afb

LINKS

PR #48442
Task 2208574
2020-03-27 15:03:49 +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
Tiffany Chang (tic) 0ca0e681db [IMP] survey: add "most common" date results tab
Under a survey's results (i.e. summary of all user submissions) the
question type 'numerical_box' has a "Most Common" tab of its results
displaying the top 5 survey user answers. This commit adds the same tab
to question type 'date'. It is expected this tab will be most useful for
'date' questions that are scored.

Implementation was left generic to allow for other question types to
easily adopt similar display. For now, question types: 'text_box' and
'char_box' results do not have a "Most Common" tab since this currently
adds no benefit (once scoring is implemented for 'char_box', then there
may be a benefit for it). 'datetime' is also expected to not benefit
from this additional tab and requires a more complicated implementation
to handle timezone display consistently between tabs and potential
"Right answer" (see related task id: 2169184).

Upgrade PR: odoo/upgrade#835
Task ID: 2061937
2020-03-18 10:17:42 +00:00
Tiffany Chang (tic) fb7b30b2e1 [REF] survey: allow more question type scoring
Previously only the question_types 'simple_choice' and 'multiple_choice' were
scoreable and could have "correct" answer(s).

In this commit we change this behavior so that question_types 'numerical_box',
'date', and 'datetime' can also have a "correct" answer and an associated
answer_score.

Task ID: 2061937
Community PR #43014
Upgrade PR odoo/upgrade#835
2020-03-18 10:16:10 +00:00
Jérémy Hennecart 5b74f54396 [IMP] survey: allow to add a description on page
The purpose of this task is to allow the user to create pages which describe
the next survey questions. He can now edit the description in a form when he
clicks on the info icon when he creates or edits a page/section.

Page will be displayed on the frontend in all cases. This allows notably
to have pages with some text / comment for presenters when doing live
action surveys.

Task 2182886
Pr #44271

Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
2020-03-17 09:37:37 +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 0e43becd91 [IMP] survey: improve sessions answers domain
This commit improves the answers count in the context of survey sessions as
well as displayed answers to narrow them down to the "current session".

We simply use a custom domain to consider all user_inputs and user_input_lines
that have a create_date after the start of the session.

It will help users to be able to re-use the same survey multiple times and run
different sessions without having to duplicate the survey every time.

LINKS

PR #45111
Task 2191924
2020-02-27 16:40:57 +00:00