Files
odoo_source/addons/survey/views/survey_templates_user_input_session.xml
T
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

179 lines
12 KiB
XML

<?xml version="1.0" encoding="utf-8"?>
<odoo>
<data>
<template id="user_input_session" name="Survey User Input Session" inherit_id="web.frontend_layout" primary="True">
<xpath expr="//div[@id='wrapwrap']" position="before">
<!--TODO DBE Fix me : If one day, there is a survey_livechat bridge module, put this in that module-->
<t t-set="no_livechat" t-value="True"/>
</xpath>
<xpath expr="//div[@id='wrapwrap']" position="attributes">
<attribute name="t-att-style" add="('height: 100%; overflow: auto; background: url(' + '/web/image/survey.survey/%s/background_image' % survey.id + ') no-repeat fixed center; box-shadow: inset 0 0 0 10000px rgba(255,255,255,.7); background-size: cover;') if survey and survey.background_image else 'height: 100%; overflow: auto;'"/>
</xpath>
<xpath expr="//head/t[@t-call-assets][last()]" position="after">
<t t-call-assets="survey.survey_assets" lazy_load="True"/>
<t t-call-assets="survey.survey_user_input_session_assets" lazy_load="True"/>
</xpath>
<xpath expr="//header" position="before">
<t t-set="no_header" t-value="True"/>
<t t-set="no_footer" t-value="True"/>
</xpath>
<xpath expr="//header" position="after">
<div id="wrap" class="oe_structure oe_empty"/>
</xpath>
</template>
<template id="user_input_session_open" name="Survey: Open Session">
<t t-call="survey.user_input_session">
<div class="wrap py-3 min-vh-100 align-items-center justify-content-center d-flex o_survey_session_open o_survey_session_manage"
t-att-data-survey-access-token="survey.access_token"
t-att-data-survey-id="survey.id"
t-att-data-is-start-screen="True">
<div class="w-75 p-4">
<div class="text-center">
<h1 class="mb-4" t-field="survey.title" />
<h2 class="mb-5 font-weight-normal">
<span>Go to <a t-att-href="survey.session_link" t-esc="survey.session_link" target="_blank" /></span>
<i class="fa fa-copy font-weight-normal ml-3 o_survey_session_copy" />
<input class="o_survey_session_copy_url d-none" type="text" t-att-value="survey.session_link" />
</h2>
<h2 class="font-weight-normal"><span>Waiting for attendees...</span>
<span class="ml-1 font-weight-bold o_survey_session_attendees_count" t-esc="survey.session_answer_count" />
</h2>
</div>
<a role="button"
class="font-weight-bold fa fa-chevron-right o_survey_session_navigation o_survey_session_navigation_next p-3" />
</div>
</div>
</t>
</template>
<template id="user_input_session_manage" name="Survey: Manage Session">
<t t-call="survey.user_input_session">
<t t-call="survey.user_input_session_manage_content" />
</t>
</template>
<template id="user_input_session_manage_content" name="Survey User Input Session Manage">
<t t-set="question" t-value="survey.session_question_id" />
<t t-set="is_scored_question" t-value="any(answer.answer_score for answer in question.suggested_answer_ids)" />
<t t-set="show_bar_chart" t-value="question.question_type in ['simple_choice', 'multiple_choice']" />
<t t-set="show_text_answers" t-value="question.question_type in ['char_box', 'date', 'datetime'] and not question.save_as_email and not question.save_as_nickname" />
<div class="wrap min-vh-100 align-items-center justify-content-center d-flex flex-column o_survey_session_manage"
t-att-style="'display: none;' if is_rpc_call else ''"
t-att-data-is-rpc-call="is_rpc_call"
t-att-data-survey-id="survey.id"
t-att-data-attendees-count="survey.session_answer_count"
t-att-data-survey-access-token="survey.access_token"
t-att-data-timer="survey.session_question_start_time.isoformat()"
t-att-data-time-limit-minutes="question.time_limit / 60"
t-att-data-is-scored-question="is_scored_question"
t-att-data-session-show-leaderboard="survey.session_show_leaderboard"
t-att-data-question-statistics="question_statistics_graph"
t-att-data-question-type="question.question_type"
t-att-data-has-correct-answers="any(answer.is_correct for answer in question.suggested_answer_ids)"
t-att-data-answers-validity="answers_validity"
t-att-data-is-last-question="is_last_question"
t-att-data-current-screen="'question' if is_scored_question else 'userInputs'"
t-att-data-show-bar-chart="show_bar_chart"
t-att-data-show-text-answers="show_text_answers">
<div class="p-4 d-flex flex-column o_survey_session_manage_container min-w-75 pt-6">
<h3 class="o_survey_session_link_reminder">
<span>Go to <a t-att-href="survey.session_link" t-esc="survey.session_link" target="_blank" /></span>
<i class="fa fa-copy font-weight-normal ml-3 mr-1 o_survey_session_copy" />
<input class="o_survey_session_copy_url d-none" type="text" t-att-value="survey.session_link" />
</h3>
<a role="button"
class="font-weight-bold fa fa-chevron-right o_survey_session_navigation o_survey_session_navigation_next p-3" />
<a role="button"
class="font-weight-bold fa fa-chevron-left o_survey_session_navigation o_survey_session_navigation_previous p-3 d-none" />
<div class="o_survey_session_results flex-column flex-grow-1">
<div class="row">
<div class="col-lg-8"><h1 t-esc="question.title"></h1></div>
<div class="col-lg-4 text-right d-flex flex-column justify-content-center">
<h1 t-if="question.is_time_limited" class="o_survey_timer_container">
<span class="o_survey_timer d-inline-block"/>
</h1>
<div t-if="show_bar_chart or show_text_answers">
<div class="progress" title="Attendees are answering the question...">
<div class="progress-bar o_survey_session_progress_small font-weight-bold"
role="progressbar" aria-valuenow="0" aria-valuemin="0" aria-valuemax="100">
<span class="px-2">0 / <t t-esc="survey.session_answer_count" /></span>
</div>
</div>
</div>
</div>
</div>
<div t-attf-class="d-flex flex-column flex-grow-1 #{'justify-content-center' if not show_text_answers else ''} #{'align-items-center' if show_bar_chart else ''}">
<!-- Has to stay in 'style' attribute for Chartjs -->
<div t-if="show_bar_chart" class="p-2 o_survey_session_chart"
style="position: relative; width: 75vw; height: 70vh;">
<!-- canvas element for drawing bar chart -->
<canvas />
</div>
<div t-elif="show_text_answers" class="p-2 pt-4 o_survey_session_text_answers_container">
</div>
<div t-elif="question.is_page and not is_html_empty(question.description)" class="mb-6 o_survey_manage_fontsize_14" t-field="question.description" />
<div t-else="" class="mb-6">
<h2 class="font-weight-normal mb-3">
<span>Waiting for attendees...</span>
<span>
<span class="o_survey_session_answer_count">0</span>
/
<span t-esc="survey.session_answer_count" />
</span>
</h2>
<div class="progress">
<div class="progress-bar font-weight-bold" role="progressbar" aria-valuenow="0" aria-valuemin="0" aria-valuemax="100"></div>
</div>
<fieldset disabled="disabled" class="mt-5" t-if="question.question_type == 'matrix'" t-call="survey.question_container">
<t t-set="hide_question_title" t-value="true" />
<t t-set="answer" t-value="env['survey.user_input']" />
<t t-set="survey_form_readonly" t-value="True"/>
</fieldset>
</div>
</div>
</div>
<div class="o_survey_session_leaderboard w-100 flex-column flex-grow-1" style="display: none;">
<div class="d-flex">
<h1 class="o_survey_session_leaderboard_title flex-grow-1">
<span t-if="is_last_question">Final Leaderboard</span>
<span t-else="">Leaderboard</span>
</h1>
<div t-att-class="'o_survey_leaderboard_buttons font-weight-bold %s' % 'd-none' if not is_last_question else ''">
<a href="#" role="button" class="o_survey_session_close btn btn-primary mr-4"><i class="fa fa-close"/> Close</a>
<a href="#" role="button" class="o_survey_session_close btn btn-primary" t-att-data-show-results="True"><i class="fa fa-bar-chart"/> Results</a>
</div>
</div>
<div class="justify-content-center d-flex flex-column flex-grow-1 mb-5 o_survey_session_leaderboard_container" />
</div>
</div>
</div>
</template>
<template id="user_input_session_leaderboard" name="Survey User Input Leaderboard">
<div t-if="leaderboard">
<t t-set="max_score" t-value="leaderboard[0].scoring_total or 1" />
<t t-foreach="leaderboard" t-as="leaderboard_item">
<div class="o_survey_session_leaderboard_item mb-1">
<div class="o_survey_session_leaderboard_index d-inline-block font-weight-bold align-top">
<div class="d-inline-block" t-esc="'%d.' % (leaderboard_item_index + 1)" />
<div class="d-inline-block float-right mr-2" t-esc="'%.0f p' % leaderboard_item.scoring_total" />
</div>
<!-- We keep "10rem" of space to display the points.
Then, the length of the bar is a percentage of the attendee's score compared to the max_score. -->
<t t-set="width_ratio" t-value="round(leaderboard_item.scoring_total / max_score, 3)"/>
<div class="o_survey_session_leaderboard_bar mr-1 pr-2 align-top d-inline-block text-right font-weight-bold"
t-att-style="'width: %s' % ('0%' if animate_width else ('calc(calc(%s - 18rem) * %s' % ('100%', width_ratio)))"
t-att-data-width-ratio="width_ratio">
</div>
<div class="o_survey_session_leaderboard_name d-inline-block font-weight-bold">
<span t-if="leaderboard_item.nickname" t-esc="leaderboard_item.nickname" />
<span t-else="">Anonymous</span>
</div>
</div>
</t>
</div>
</template>
</data>
</odoo>