Commit Graph
211 Commits
Author SHA1 Message Date
Xavier Morel 719e7d46e4 [CHG] core: mark a bunch of utilities as deprecated
Remove UnquoteEvalContext directly because it's unused and super specialised.

Part-of: odoo/odoo#98023
2022-08-22 16:48:27 +02:00
Adrien Schoffeniels 34c98e999d [IMP] survey: implement a tour
PURPOSE:

This commit adds a tour that is started when the survey module is
installed, and makes small changes to be able to implement the tour.

SPECS

-Implementation of the tour:
The tour suggests to the user to try and test a sample survey, and shows how
to check the results gathered for this survey.

-Changed the target of the "test" button to "self":
Since the test action is used during the tour, the test page needs to be opened
in the same tab so that the tour can continue.

Task-2794884

Part-of: odoo/odoo#87326
2022-08-17 19:47:59 +02:00
Adrien Schoffeniels 24e8e3adc3 [IMP] survey: revamp onboarding data & test surveys integration
PURPOSE:

This commit revamps the onboarding data and slightly modifies the integration
of test surveys and related filters.

SPECS

- Revamp sample surveys data:
Considering this is the data we want to push forward, it needs to be as
relevant as possible while being "light" for the db.

- Consider completed test surveys as completed surveys:
Most people expect to see the test the just did counted in the completed
surveys counter in the survey view. The filter excluding the tests surveys has
therefore also been removed from the participation view.

- Rename the filters related to the test surveys:
"Tests Only" and "Exclude Tests" are more straight to the point than
"Test Entries" and "Exclude Test Entries".

- Rename "answer(s)(ed)" at some locations:
"answer" and its various forms are used too often, which sometimes makes it
hard to understand who is who. Therefore, we replaced some of them with
synonyms.

- Set "one page per question" as the default layout. Added the "one_page"
layout in some tests for which the layout was not set.

Task-2794884

Part-of: odoo/odoo#87326
2022-08-17 19:47:58 +02:00
Noe Antoine 137eddcdb4 [IMP] survey: improve image readability and add zoom widget
Before this commit, images displayed on survey question answers
were small and hard to read, and nothing existed in order to zoom
on them properly.

AFTER THIS COMMIT

Backend:

A new field value_image_filename is added to store the names of
the image fields. They are seen when editing an answer (line).

The max_height and max_width of the images are raised to 1024 px
on their field definition in survey.question.answer to compromise
between image resolution and space, and in order to be able to
zoom on them and still see details

Survey:

A hovering frame is visible on the images, as well as a zoom in
cursor, to indicate we can click on them to zoom in. The rest of
the answer frame is the selection area. Clicking anywhere on the
modal closes it. Until then, a pointer cursor hints the feature.

A new widget SurveyImageZoomer is added. Once the user has clicked
on a choice image, a transparent modal is opened on the whole screen.
This is thought for all size devices : it can be closed by clicking
anywhere, or the cross button, or ESC key. It will always be destroyed.
Also, for small width screens, we do not take the whole height but leave
bands over and below to indicate the mobile users can leave by clicking out.

The image will be displayed in the foreground, zooming on small images
by default, by setting a min width depending on the screen width. We
also avoid using a zoom too large to avoid very low resolution.

The widget allows zooming as long as the image stays in the frame.
The user can zoom both with the mouse scrolling and + and - buttons,
sized to allow medium screen (tablets) to press them accurately.

All keys are disabled but the 'ESC' one when the Zoomer is open to
avoid (undesired) survey navigation.

Task-2566584

closes odoo/odoo#73718

Signed-off-by: Warnon Aurélien (awa) <awa@odoo.com>
2022-08-03 13:44:46 +02:00
Umesh Gupta 48737a8ffc [FIX] survey*: avoid traceback for data/demo data surveys
Currently, in demo data (or data) of some surveys, there are records of
'survey.question' having 'is_page' field value as true and 'question_type'
is not defined. When question type is not defined, default value
'simple_choice' is assigned to the 'question_type' field. Now when we
create a live session of that survey and go to the page, it tries to read
the data for bar chart but data is not available (undefined) and the
traceback is thrown. This happens  because question types 'simple_choice'
and 'multiple_choice') are expected to load a bar chart.

It used to work before commit[1] where default 'question_type' value was
being set to 'text_box' (so attempt to load bar chart was not made).

This commit improves the behavior by adapting data/demo data/test cases
and by adding a python constraint that prevents question creation of
page type if there is a question type set, and compute `question_type`
based on `is_page` field. Now that we have python constraint and a
compute method, we no longer need the `default_get` method, so it is
also removed.

commit[1] - https://github.com/odoo/odoo/commit/1fb99d79b1567d4c150dc07f309ce54a3beea8e3

taskID-2841582

closes odoo/odoo#93414

Related: odoo/enterprise#28305
Related: odoo/upgrade#3600
Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
2022-07-06 17:09:59 +02:00
dht-odoo 020046a343 [IMP] survey: improve overall usability of survey
This commit imporves the usability of scoring fields and single-multi
choice question in survey. It does the following changes:

Backend:
- if it's a scored question, respective correct answer must be provided
  otherwise it will now give a warning while trying to save
- points are hidden unless it's a scored question (and will be inline now,
  next to 'Scored' checkbox)
- compute answer_is_correct based on question type of numerical, date,
  datetime for both scored and non-scored questions.

Frontend:
- if the answer is wrong, display the answer inside a red container and below
  the wrong answer, also display the correct one in green font
- if the answer is right, display the answer in a green container
- if the answer is skipped, display the text 'Skipped' inside red container
  with lower opacity
- hide the div for question description if it's empty, to avoid unwanted
  space bewteen questions
- added two different icons 'fa-check-circle' and 'fa-times-circle' for correct
  and incorrect answers respectively for single-multi choice question
- show answer is correct and incorrect based on is_correct not on scored values
- show skipped string  for  single choice, multi choice and matrix questions in
  result page if question was skipped

closes odoo/odoo#63915

Taskid: 2276724
Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
2022-06-24 13:49:04 +02:00
Florian Charlier dae28c4b46 [IMP] base: add _is_internal method to res.users
No method was readily available to know if a user is `internal` (has
group `base.group_user`), which was inconsistent with other base groups.

_is_internal is now used in the codebase where it is clear that
`.has_group('base.group_user')` is called on a single record.

Part-of: odoo/odoo#85703
2022-06-14 09:35:57 +02:00
Adrien Schoffeniels 72c4ffc3ee [IMP] survey: improve mobile UI
PURPOSE
This commit removes a few unessential content, fixes
misalignments and removes the input autofocus on mobile devices

SPECS

Remove a few unessential content
Some contents take a considerable space on mobile without adding
essential information, requiring the user to scroll to see useful info.
These contents are now removed on mobile devices.

Fix misalignments
Some parts were misaligned on small screens, taking unnecessary space or
cutting parts of sentences. These parts have been adapted to handle
small screens.

Remove action buttons related to live sessions on small screens
Since the presentation mode doesn't look good on mobile devices
(questions have a lot of linebreaks, arrows do not always work),
and since normally no one presents a live session using a mobile
device, the action buttons "Create Live Session", "Open Session Manager"
and "Close Live Session" are now hidden on small screens.

Remove the autofocus on the first input in survey forms on mobile devices
When a new page of a survey is loaded, the first input is autofocused so
that the user can directly complete the survey without manually getting
the focus. This causes inconsistencies and undesired behaviors on mobile
devices. Especially, when the focus is set automatically on Android devices,
the soft keyboard is opened, the viewport is reduced and the view is scrolled
to the input, which involves that the user misses information about the
survey (such as the beginning of the question for long questions), or
section descriptions. The autofocus has therefore been removed for mobile
devices.

Task-2622693

Part-of: odoo/odoo#87990
2022-06-08 11:20:13 +02:00
Raphael Collet 6cf8db906f [REF] *: adapt code to new flush API
closes odoo/odoo#87527

Related: odoo/upgrade#3497
Related: odoo/enterprise#26939
Signed-off-by: Raphael Collet <rco@odoo.com>
2022-05-25 18:00:47 +02:00
Fabio Barbero fc79bd1e0e [IMP] sm modules: "neutralise" genders
Purpose
=======
Change all masculine nouns in Odoo's code to neutral nouns (when
possible), making sure that demo data is correctly handled. This is
particularly important since our code is open source, and nowadays lots
of machine learning models are trained on open source repositories.

With this small change we contribute to training more "fair" models, and
teaching models that "employee" or "user" != "he".

This also affects some text visible by the user, hence making it more
inclusive for Odoo users.

Task-2853046

closes odoo/odoo#91292

Related: odoo/enterprise#27302
Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
2022-05-16 10:09:32 +02:00
Aurélien Warnon aa66cdc596 [IMP] survey: rework survey.user_input views
PURPOSE

Globally improve the main survey.user_input form view to make it more user
friendly.
This includes fields move, new computed fields, a ribbon, ...

SPECIFICATIONS

- Make the Survey User Input model support mail.thread and mail.activity.mixin
  This lets us display the chatter on the form view and allows users to
  schedule activities.
  e.g: discuss a participation among colleagues, add activities to check some
  participation because you think the person has cheated, ...

- Add a ribbon on the form view that says "passed" or "failed" according to the
  user result

- Introduce a new "Answer" column for the questions list view that is a
  modified 'display_name' that displays the answer based on the question type ;
  This allows to see the answers at a quick glance without having to drill down
  every question to look at the "value_char_box", "value_datetime", ...

- Add the attempts count information in a stat-button, when clicked, the user
  is redirected to the list view of all survey attempts of that specific user
  for that specific survey

- Re-organize and move some fields

- Hide some advanced information into debug mode

Task-2729604

closes odoo/odoo#83781

Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
2022-05-12 22:13:46 +02:00
Patrick Hoste 727249b3d8 [IMP] survey: propagates name to title field with relational widget
PURPOSE

Currently, when creating a survey through the 'quick create' feature of a
many2one field, the name input by the user is lost and not propagated to the
survey title (the default behavior expects a 'name' field).

This commit correctly takes the passed default_name into account and uses it to
fill the survey title.

LINKS

Task-2810395

Part-of: odoo/odoo#87672
2022-04-20 16:41:02 +02:00
Pierre-Yves Dufays 22f7851272 [IMP] survey: copy conditional questions when duplicating a survey
Allow users to easily duplicate complex surveys that contain questions
displayed based on previous answers.
Currently, when duplicating a survey, the conditional settings are not copied
and the user has to re-do the entire mapping manually.

The implementation adds a post-process that recreates the orginal conditional
display mapping on the new copy of the questions.

Task-2766473

closes odoo/odoo#85117

Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
2022-03-30 11:13:02 +02:00
Vincent Schippefilt 05fc9a6733 [IMP] *: use _read_group instead of read_group
This commit modifies most of the usages of read_group and uses
_read_group instead. _read_group doesn't join automatically on the
many2one fields when no order_by is specified, making it more performant
when the "name" of the many2one is not relevant, which is the case for
most back-end cases

closes odoo/odoo#84908

Task-id: 2479334
Related: odoo/enterprise#24877
Signed-off-by: Raphael Collet <rco@odoo.com>
2022-03-02 17:10:48 +00:00
Pierre-Yves Dufays 5a97a79c54 [IMP] survey: remove column_nb from the survey_question model
Purpose:

The "column choice" is a remainder of a previous implementation in which users
could decide how the survey would look like.

Since the re-design however, this option is no longer working as we prefer
handling this ourselves:
- To make the code simpler
- Because this is not really a "game-changer" feature
- Because we prefer to decide ourselves how the answers will look like to make
sure it always looks nice

As the field is not used anymore and some customers are wondering why it does
not work, we have decided to remove it.

Specifications:

Remove the field column_nb from the survey_question model
In the form, to make sure the "Answers" group is never empty,
we'll move the "Comments" options there instead

Task 2730409

closes odoo/odoo#83645

Related: odoo/upgrade#3231
Signed-off-by: Warnon Aurélien (awa) <awa@odoo.com>
2022-02-21 12:16:57 +00:00
Florian Charlier 84ad766047 [IMP] survey: Improve UI of results statistics
PURPOSE
Various improvements of the results' statistics were required, mainly regarding
* the filtering features that were not clear and impractical
* the way answer scores was reported
* the vertical space taken by questions never answered

Among other smaller changes, the layout of `datetime`-answers questions is
harmonized with the other answer-types (grouped by value), considering that
the "time" part is important and that the "seconds" part bof that time would
only be changed if it is relevant to the question.

SPECIFICATIONS
**Filters**
It is now more convenient to filter surveys based on:
- Whether they are fully completed
- Whether they are passed
- Whether they are failed (last 2 are mutually exclusive, and only available
for scored tests)

A badge is added to show the number of surveys that match each filter option
if chosen. Note that this simple implementation does not allow to show the
number of surveys which would be displayed if the filter was removed, or
replaced, so the badges are not shown once a filter is selected.

The question/answer filters can now be removed individually.
The i.fa-filter elements used to activate them are now always visible, and are
only available for answers that have been selected at least once.

**Scoring**
Scores are added in tables next to the answers instead of as additional lines
below the question caption.

Right answers are now marked in the Graph and Data tabs instead of being simply
listed under the question.

**Unanswered questions**
To make this special case more clear to the user, a discrete alert is added
below the question. The Graph and Table tabs are removed in this case, as they
contain no information. For Multiple choice and Matrix questions, the Table tab
stays visible to show the possible answers available.

*Misc*
To follow common representation, numbers which are equal to integer values will
show as integers in answers and scores (e.g., 30.0 will show as 30), using a
sub-template.

Distinguishing the questions and results from the previous/next ones was
difficult, hence the added margins and discrete lines.

Similarly to other fields, datetime results now display one line per answer
value, with its occurrence.

Stylesheets are cleaned up.

LINKS
Task-2618399

closes odoo/odoo#77522

Related: odoo/upgrade#3168
Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
2022-01-14 13:53:56 +00:00
dht-odoo 9edc9840b6 [IMP] survey: improve technical tooltips for few fields
This commit properly formats the domain attribute of few fields so that
the technical tooltips for them do not show '\n' within the domain.

Below are the improved fields:
 - 'triggering_question_id' (for model 'survey.question')
 - 'partner_ids' (for model 'survey.invite')

Taskid-2704057

closes odoo/odoo#81631

Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
2022-01-03 11:43:38 +00:00
Patrick Hoste af6c434812 [IMP] survey: open result page in new tab
SPECIFICATION

Before this commit, when clicking on the 'See Results' button
the page was loaded on the previous one.
After this commit, the page will open in a new tab.
We also took the opportunity to replace all the '_blank' value
occurence by the 'new' value as '_blank' value is not a valid
value for the 'target' field of the 'ir.actions.act_url' model.

LINKS

Task-2700305
PR : odoo/odoo#80858

Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
2021-12-17 13:39:53 +00:00
wde-odoo 1fb99d79b1 [IMP] survey: improve survey usability in backend
PURPOSE

This commit globally improves the backend survey module usability, notably by
renaming labels, moving menu items around and cleaning unused features.

SPECIFICATIONS

These changes include (non-exhaustive list):

On questions

  - Changing labels, action helpers and modules description to be clearer;
  - Re-organizing the survey.question form view, notably to clearly distinguish
    fields related to answers and validation options;
  - Removing the "Clean test answers" server action as it can be done through
    a search + unlink;
  - Removing the allow_value_image field as we now always display the
    image field. Users simply choose to let it blank;

On surveys

  - Re-organizing the survey.survey form view fields to get a clear view of
    the various options;
  - automatically update scoring type when checking certification: if not one
    linked to scoring, update to scoring without answers;
  - set create as create_multi to speedup batch creation;
  - Changes ACL rights for user_input_line. Now, only Survey Managers can
    change answers. Survey users keep only a read access on answers, meaning
    changing what customers / people answered is now limited to managers;

Globally

  - Moving menu items and make them visible outside debug mode;
  - Answer recap on print frontend page is now visible whenever a scoring is
    applied, not only for certification, as if scoring is activated seeing
    answers is probably wanted;

Task-2600241

closes odoo/odoo#79813

Related: odoo/upgrade#3033
Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
2021-12-01 18:39:45 +00:00
David Beguin fd75481d52 [IMP] survey: add background option per section
This commit adds the background per section feature.
If the section to display has a background image configured, the background
will be refreshed using that section background image.
If the section has no background, the survey background is used.
The background is refreshed at the same time that the next question is loaded.

To ease technical maintenance and to keep it simple, the background is always
faded out/in at each page change only if there are some sections on the
survey that has a specific background image. If no background image are set on
the survey sections, the background will never be faded out.

Note: The next section to display depends on free text (section with
description) configuration and on conditional questions.
The next section to display can be the next question's section or directly
the next question itself (if the question is a section).

This section's background image implementation works both for the regular
survey form as well as the "live session" mode of the survey module.

Task-2225393

closes odoo/odoo#79156

Signed-off-by: Warnon Aurélien (awa) <awa@odoo.com>
2021-11-30 11:20:45 +00:00
Julien BankenandCarlos Valverde dfffa1ed92 [IMP] survey: add an helper to load a sample survey
When the user opens the survey module for the first time, the user may
find it difficult to create and configure a new survey as there are many
options available. To improve the onboarding experience of the user, we
will provide a new link on the action helper of the survey module (for
the kanban and the list view of the surveys).

When the user clicks on that link, the system will open a new modal. The
user will then be able to choose a sample to load. Each sample will be
pre-configured for specific purposes. We will have:

- A sample for the feedback forms
- A sample for the live presentations
- A sample for the certifications

After loading a sample, the user will be able to adapt it to fit their
needs. Thanks to the samples, the user can create a survey more easily
and more quickly.

task-2670605

closes odoo/odoo#79255

Signed-off-by: Warnon Aurélien (awa) <awa@odoo.com>
Co-authored-by: Carlos Valverde <cvs@odoo.com>
2021-11-26 10:31:45 +00:00
David Beguin d393f98a81 [IMP] survey: add question placeholder
Purpose
=======

As an Interviewer, I want my questions to be as clear as possible. To this end
I would like to be able to detail a bit which kind of answers I expect.

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

For all the question types that require an input, display a char field
"Placeholder" in the Answers tab with an helper that says:
"When set, this text will appear in the field to help participants answer."
Then on the survey, display the placeholder in the question input zone.

Task-2671388

closes odoo/odoo#78682

Related: odoo/upgrade#2998
Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
2021-11-26 10:31:41 +00:00
Thibault Delavallée d5b688956b [IMP] survey: display a list-kanban when being ungrouped
PURPOSE

When dealing with lot of surveys kanban view is not really optimal and its
state based grouping is not really helpful. Indeed we do not have total of
each coumn and there is not point adding new states, meaning most surveys
hang in the same column. This is not an optimal display.

SPECIFICATIONS

Improve ungrouped display as this is the main usage of surveys. It should
be displayed like a global list view: each card should take the whole
screen (like ``Visitor`` kanban view). Each line contains some "columns"
holding statistics. We notably use a progressbar to display a nice passed
ratio, as well as a many2one avatar widget to make survey enters the era
of amazing wow kanban views.

When grouped, display should be the old one, aka a standard card.

This is done using a small CSS hack: card template actually consists in main
templates related to two displays. Each card style is hidden depending on being
groups or ungrouped. This triggers a class that is used using CSS to hide
irrelevant content.

A ribbon is also added on kanban cards displaying an Archived danger ribbon
when survey is not active anymore. It is therefore coherent with the form
view display that also has a ribbon defined.

An override in website_slides_survey is added to add number of courses using
the survey.

Order is updated so that new surveys are on top. No need to be bloated by
old ongoing surveys when creating new one.

Finally, some labelling is done with answers to be clearer: registered (number
of raw user inputs), completed (finished answers), certified or passed (quiz
with certification activated or not).

Task-2388785

Part-of: odoo/odoo#77227
2021-11-24 14:04:20 +00:00
Thibault Delavallée f9dbd38720 [IMP] mail, various: rename custom_layout / notif_layout context usage
RATIONALE

Currently we can specify email used for notification layouting through context
use in mail composer. It is then propagated to message_post, stored on
mail.message and used to encapsulate emails sent based on posted messages.

SPECIFICATIONS

On template model: rename ``notif_layout`` parameter of ``send_mail`` to
``email_layout_xmlid`` to be coherent with naming used in other parts of the
code. Moreover it better indicates we expect an xml id.

On rating model: rename ``notif_layout`` parameter of ``rating_send_request``
to ``email_layout_xmlid``, for the same reasons as above.

In various wizards: support ``email_layout_xmlid`` context key when no field
is available, notably because this is still done manually in some wizards
like survey invite. Keep a fallback on ``notif_layout`` but remove support of
``custom_layout`` deprecated since quite a long time.

Task-2621326 (Mail: add 'view' button in 'light notification template')
Task-2647302 (Mail: add layout field in composer)

Part-of: odoo/odoo#76418
2021-11-10 09:58:09 +00:00
Didier (did) 1afcc9c368 [IMP] bus, mail, *: improve longpolling bus notification format
* = auth_signup, calendar, im_livechat, snailmail_account, survey, test_mail,
    web_editor, website_crm_iap_reveal, website_livechat

The aim of this PR is to improve/fix various flaws and limitation of the current
API, to make it easier to use and more efficient.

Notification are now defined with 3 distinct parts:

- the channel determines which client(s) should receive it
- the type determines how it should be handled
- the payload determines any extra information helpful for handling it

Channel
=======

Business code
-------------

- Record channel is introduced for ease of subscribing to and sending
  notifications to specific partners, channels, documents, ...
- String channel is still supported (but it is converted internally to the tuple
  channel).
- Tuple channel is still supported without any change (but should be avoided
  whenever possible due to its complex syntax).

The channel is no longer sent to the client. When the channel was used for
business purpose, the information it contained has been moved into either the
new type, or the payload itself.

Technical note
--------------

All channels are now internally converted to the tuple (db, ...) channel, which
is necessary for the platform code (saas/sh).

Internally, the bus.bus table is not changed, type and payload are grouped
together into what was (and still is) called message.

Type
====

Type is introduced to uniformize the way notifications are sent and handled.
All existing notifications already had some kind of manually-built type in them.
This is now officially supported at the bus API.

In client code this will allow (to be done in future commits) to register one
handler per specific type, instead of having to iterate and to filter all
received notifications on every handler.

Payload
=======

Payload (ex message) did not change, it can still be anything depending on
business needs.

Few adaptations:
- When the type was included on the payload, the type has been moved to the new
  type parameter.
- When the channel was used in business code, its data has been copied into the
  payload.

task-1891151

closes odoo/odoo#79201

X-original-commit: 543af27c7d6836ffac9e80ff8490b6ddbd849221
Related: odoo/enterprise#21998
Signed-off-by: Sébastien Theys (seb) <seb@odoo.com>
2021-10-29 16:05:23 +00:00
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