[FIX] survey : fix review survey page
The prefill of the date field must be done after the initialisation, otherwise, it would override the value. so prefill must be done inside the .then to avoid prefill before the locale is ready. Since the datetime are real datetime in DB, we cannot give real datetime to JSON but string instead. Finally, no need to keep the div class row. Otherwise, it would put everything on same line and the jumbotorn div wouldn't be on top on the rest of the page. Special thanks to @awa-odoo that gave me his masterpiece brain to help me on this. Task ID : 1911291 Closes PR #28966
This commit is contained in:
@@ -185,7 +185,7 @@ class Survey(http.Controller):
|
||||
ret.setdefault(answer_tag, []).append(answer_value)
|
||||
else:
|
||||
_logger.warning("[survey] No answer has been found for question %s marked as non skipped" % answer_tag)
|
||||
return json.dumps(ret)
|
||||
return json.dumps(ret, default=str)
|
||||
|
||||
# AJAX scores loading for quiz correction mode
|
||||
@http.route(['/survey/scores/<model("survey.survey"):survey>/<string:token>'],
|
||||
|
||||
@@ -200,14 +200,13 @@ if(!the_form.length) {
|
||||
allowInputToggle: true,
|
||||
keyBinds: null,
|
||||
});
|
||||
// Launch prefilling
|
||||
prefill();
|
||||
if(quiz_correction_mode === true){
|
||||
display_scores();
|
||||
}
|
||||
});
|
||||
|
||||
// Launch prefilling
|
||||
prefill();
|
||||
if(quiz_correction_mode === true){
|
||||
display_scores();
|
||||
}
|
||||
|
||||
console.debug("[survey] Custom JS for survey loaded!");
|
||||
|
||||
});
|
||||
|
||||
@@ -341,39 +341,37 @@
|
||||
<div class="wrap">
|
||||
<div class="container">
|
||||
<t t-call="survey.back" />
|
||||
<div class="row">
|
||||
<div class='jumbotron mt32'>
|
||||
<h1><span t-field='survey.title'/></h1>
|
||||
<t t-if="survey.description"><div t-field='survey.description' class="oe_no_empty"/></t>
|
||||
</div>
|
||||
<div role="form" class="js_surveyform" t-att-name="'%s' % (survey.id)" t-att-data-prefill="'/survey/prefill/%s/%s' % (slug(survey), token)">
|
||||
<t t-foreach="survey.page_ids" t-as="page">
|
||||
<div class="o_page_header">
|
||||
<h1 t-field='page.title' />
|
||||
<t t-if="page.description"><div t-field='page.description' class="oe_no_empty"/></t>
|
||||
<div class='jumbotron mt32'>
|
||||
<h1><span t-field='survey.title'/></h1>
|
||||
<t t-if="survey.description"><div t-field='survey.description' class="oe_no_empty"/></t>
|
||||
</div>
|
||||
<div role="form" class="js_surveyform" t-att-name="'%s' % (survey.id)" t-att-data-prefill="'/survey/prefill/%s/%s' % (slug(survey), token)">
|
||||
<t t-foreach="survey.page_ids" t-as="page">
|
||||
<div class="o_page_header">
|
||||
<h1 t-field='page.title' />
|
||||
<t t-if="page.description"><div t-field='page.description' class="oe_no_empty"/></t>
|
||||
</div>
|
||||
<t t-foreach='page.question_ids' t-as='question'>
|
||||
<t t-set="prefix" t-value="'%s_%s_%s' % (survey.id, page.id, question.id)" />
|
||||
<div class="js_question-wrapper" t-att-id="prefix">
|
||||
<h2>
|
||||
<span t-field='question.question' />
|
||||
<span t-if="question.constr_mandatory" class="text-danger">*</span>
|
||||
<span t-if="quizz_correction" class="badge badge-pill" t-att-data-score-question="question.id"></span>
|
||||
</h2>
|
||||
<t t-if="question.description"><div class="text-muted oe_no_empty" t-field='question.description'/></t>
|
||||
<t t-if="question.type == 'free_text'"><t t-call="survey.free_text"/></t>
|
||||
<t t-if="question.type == 'textbox'"><t t-call="survey.textbox"/></t>
|
||||
<t t-if="question.type == 'numerical_box'"><t t-call="survey.numerical_box"/></t>
|
||||
<t t-if="question.type == 'date'"><t t-call="survey.date"/></t>
|
||||
<t t-if="question.type == 'simple_choice'"><t t-call="survey.simple_choice"/></t>
|
||||
<t t-if="question.type == 'multiple_choice'"><t t-call="survey.multiple_choice"/></t>
|
||||
<t t-if="question.type == 'matrix'"><t t-call="survey.matrix"/></t>
|
||||
<div class="js_errzone alert alert-danger" style="display:none;" role="alert"></div>
|
||||
</div>
|
||||
<t t-foreach='page.question_ids' t-as='question'>
|
||||
<t t-set="prefix" t-value="'%s_%s_%s' % (survey.id, page.id, question.id)" />
|
||||
<div class="js_question-wrapper" t-att-id="prefix">
|
||||
<h2>
|
||||
<span t-field='question.question' />
|
||||
<span t-if="question.constr_mandatory" class="text-danger">*</span>
|
||||
<span t-if="quizz_correction" class="badge badge-pill" t-att-data-score-question="question.id"></span>
|
||||
</h2>
|
||||
<t t-if="question.description"><div class="text-muted oe_no_empty" t-field='question.description'/></t>
|
||||
<t t-if="question.type == 'free_text'"><t t-call="survey.free_text"/></t>
|
||||
<t t-if="question.type == 'textbox'"><t t-call="survey.textbox"/></t>
|
||||
<t t-if="question.type == 'numerical_box'"><t t-call="survey.numerical_box"/></t>
|
||||
<t t-if="question.type == 'date'"><t t-call="survey.date"/></t>
|
||||
<t t-if="question.type == 'simple_choice'"><t t-call="survey.simple_choice"/></t>
|
||||
<t t-if="question.type == 'multiple_choice'"><t t-call="survey.multiple_choice"/></t>
|
||||
<t t-if="question.type == 'matrix'"><t t-call="survey.matrix"/></t>
|
||||
<div class="js_errzone alert alert-danger" style="display:none;" role="alert"></div>
|
||||
</div>
|
||||
</t>
|
||||
<hr/>
|
||||
</t>
|
||||
</div>
|
||||
<hr/>
|
||||
</t>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user