[IMP] survey: add a download button at the end of certification process
Purpose ======= When the user successfully takes a certification, he can download the certification document using a new "Download certification" button. (In addition to receiving an email containing the certification) Also cleaned a bit the way certifications are downloaded. Task-1941250
This commit is contained in:
committed by
jem-odoo
parent
34f7266792
commit
44ae98d3dd
@@ -367,7 +367,7 @@ class Survey(http.Controller):
|
||||
return {}
|
||||
|
||||
survey_sudo, answer_sudo = access_data['survey_sudo'], access_data['answer_sudo']
|
||||
if not survey_sudo._has_attempts_left(answer_sudo.partner_id, answer_sudo.email, answer_sudo.invite_token):
|
||||
if not answer_sudo.test_entry and not survey_sudo._has_attempts_left(answer_sudo.partner_id, answer_sudo.email, answer_sudo.invite_token):
|
||||
# prevent cheating with users creating multiple 'user_input' before their last attempt
|
||||
return {}
|
||||
|
||||
@@ -509,7 +509,7 @@ class Survey(http.Controller):
|
||||
# filter_finish: boolean => only finished surveys or not
|
||||
#
|
||||
|
||||
@http.route(['/survey/<int:survey_id>/get_certification'], type='http', auth='user', methods=['POST'], website=True)
|
||||
@http.route(['/survey/<int:survey_id>/get_certification'], type='http', auth='user', methods=['GET'], website=True)
|
||||
def survey_get_certification(self, survey_id, **kwargs):
|
||||
""" The certification document can be downloaded as long as the user has succeeded the certification """
|
||||
survey = request.env['survey.survey'].sudo().search([
|
||||
|
||||
@@ -29,6 +29,15 @@
|
||||
<div>You scored <t t-esc="answer.quizz_score" />%</div>
|
||||
<t t-if="answer.quizz_passed">
|
||||
<div>Congratulations, you have passed the test!</div>
|
||||
|
||||
<div t-if="survey.certificate" class="mt16 mb16">
|
||||
<a role="button"
|
||||
class="btn btn-primary btn-lg"
|
||||
t-att-href="'/survey/%s/get_certification' % survey.id">
|
||||
<i class="fa fa-fw fa-trophy" role="img" aria-label="Download certification" title="Download certification"/>
|
||||
Download certification
|
||||
</a>
|
||||
</div>
|
||||
</t>
|
||||
<t t-else="">
|
||||
<div>Unfortunately, you have failed the test.</div>
|
||||
|
||||
@@ -1,23 +0,0 @@
|
||||
odoo.define('website_slides_survey.certification_download', function (require) {
|
||||
'use strict';
|
||||
|
||||
var WebsiteSlides = require('website_slides.slides');
|
||||
var session = require('web.session');
|
||||
|
||||
WebsiteSlides.include({
|
||||
events: _.extend({}, WebsiteSlides.prototype.events, {
|
||||
'click .o_wslides_survey_download_certification': '_onDownloadCertificationClick'
|
||||
}),
|
||||
|
||||
/**
|
||||
* @private
|
||||
*/
|
||||
_onDownloadCertificationClick: function () {
|
||||
var surveyId = this.$('.o_wslides_survey_download_certification').data('survey_id');
|
||||
session.get_file({
|
||||
url: '/survey/' + surveyId + '/get_certification'
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
});
|
||||
@@ -5,8 +5,8 @@
|
||||
<div t-if="widget.get('slide').type === 'certification' && !widget.get('slide').certificationDone" class="o_wslides_fs_certification">
|
||||
<a class="btn btn-primary" t-att-href="'/slides/slide/' + widget.get('slide').id" target="new"><i class="fa fa-trophy"/> Pass Certification</a>
|
||||
</div>
|
||||
<div class="o_wslides_fs_certification" t-if="widget.get('slide').type === 'certification' && widget.get('slide').certificationDone">
|
||||
<a role="button" t-att-data-survey_id="widget.get('slide').certificationId" class="btn btn-primary o_wslides_survey_download_certification" href="#">
|
||||
<div class="o_wslides_fs_certification" t-if="widget.get('slide').type == 'certification' && widget.get('slide').completed">
|
||||
<a role="button" class="btn btn-primary" t-att-href="'/survey/' + widget.get('slide').certificationId + '/get_certification'">
|
||||
<i class="fa fa-fw fa-trophy" role="img" aria-label="Download certification" title="Download certification"/> Download certification
|
||||
</a>
|
||||
</div>
|
||||
|
||||
@@ -7,7 +7,6 @@
|
||||
</xpath>
|
||||
<xpath expr="//script[last()]" position="after">
|
||||
<script type="text/javascript" src="/website_slides_survey/static/src/js/slides_upload.js"/>
|
||||
<script type="text/javascript" src="/website_slides_survey/static/src/js/slides_certification_download.js"/>
|
||||
<link rel="stylesheet" type="text/scss" href="/website_slides_survey/static/src/scss/website_profile.scss"/>
|
||||
<script type="text/javascript" src="/website_slides_survey/static/src/js/slides_course_fullscreen_player.js"/>
|
||||
</xpath>
|
||||
|
||||
@@ -25,9 +25,7 @@
|
||||
<span class="row">Score : <b t-field="certificate.quizz_score"/>%</span>
|
||||
<div class="row">
|
||||
<a role="button"
|
||||
t-att-data-survey_id="certificate.survey_id.id"
|
||||
class="o_wslides_survey_download_certification"
|
||||
href="#">
|
||||
t-att-href="'/survey/%s/get_certification' % certificate.survey_id.id">
|
||||
<i class="fa fa-download"/>
|
||||
</a>
|
||||
</div>
|
||||
|
||||
@@ -15,9 +15,8 @@
|
||||
</div>
|
||||
<div t-if="slide.slide_type == 'certification' and certification_done" class="col mt32 mb8 d-flex justify-content-center">
|
||||
<a role="button"
|
||||
t-att-data-survey_id="survey_id"
|
||||
class="btn btn-primary btn-lg o_wslides_survey_download_certification"
|
||||
href="#">
|
||||
class="btn btn-primary btn-lg"
|
||||
t-att-href="'/survey/%s/get_certification' % survey_id">
|
||||
<i class="fa fa-fw fa-trophy" role="img" aria-label="Download certification" title="Download certification"/>
|
||||
Download certification
|
||||
</a>
|
||||
|
||||
Reference in New Issue
Block a user