Skip to content
Snippets Groups Projects
Commit ef3ccce0 authored by qmo-odoo's avatar qmo-odoo Committed by Thibault Delavallée
Browse files

[FIX] website_slides_survey: fix some certifications issues in eLearning frontend

This commit fixes a few issues with courses which have certification

 * fix links to already passed certifications: currently it crashed, now it
   redirects to the certification end screen;
 * "Begin your certification now" green box link now has same behaviour
   as links in the list view. It redirects to either the start certification
   screen or the first slide in fullscreen mode. Moreover once the user has
   started the course (at least one completed slide) this box disappears as
   it is not really useful anymore;

Some dead code is removed.

Commit linked to task ID 1978530 (fixes linked to internal testing).
parent 69cd8bc6
No related branches found
No related tags found
No related merge requests found
......@@ -60,13 +60,12 @@ class Slide(models.Model):
for slide in self.filtered(lambda slide: slide.slide_type == 'certification' and slide.survey_id):
if slide.channel_id.is_member:
user_membership_id_sudo = slide.user_membership_id.sudo()
quizz_passed = user_membership_id_sudo.survey_quizz_passed
if not quizz_passed and user_membership_id_sudo.user_input_ids:
if user_membership_id_sudo.user_input_ids:
last_user_input = next(user_input for user_input in user_membership_id_sudo.user_input_ids.sorted(
lambda user_input: user_input.create_date, reverse=True
))
certification_urls[slide.id] = last_user_input._get_survey_url()
elif not user_membership_id_sudo.user_input_ids:
else:
user_input = slide.survey_id.sudo()._create_answer(
partner=self.env.user.partner_id,
check_attempts=False,
......
......@@ -9,15 +9,7 @@ Fullscreen.include({
xmlDependencies: (Fullscreen.prototype.xmlDependencies || []).concat(
["/website_slides_survey/static/src/xml/website_slides_fullscreen.xml"]
),
_preprocessSlideData: function (slidesDataList){
slidesDataList = this._super.apply(this, arguments);
slidesDataList.forEach(function (slideData, index){
if (slideData.type === "certification"){
slideData.certificationUrl = '/slides_survey/slide/get_certification_url?slide_id=' + slideData.id;
}
});
return slidesDataList;
},
/**
* Extend the _renderSlide method so that slides of type "certification"
* are also taken into account and rendered correctly
......
......@@ -7,11 +7,11 @@
</xpath>
<xpath expr="//div[@id='courseMainTabContent']//div[@id='home']/t" position="before">
<div t-if="channel.nbr_certification > 0 and channel.is_member" class="alert alert-success d-flex align-items-center justify-content-between flex-wrap">
<t t-set="first_slide" t-value="channel.slide_ids[0] if len(channel.slide_ids) > 0 else None"/>
<div t-if="channel.nbr_certification > 0 and channel.is_member and channel.completion == 0" class="alert alert-success d-flex align-items-center justify-content-between flex-wrap">
<div>Begin your <b>certification</b> today!</div>
<t t-set="first_slide" t-value="category_data[0]['slides'][0]"/>
<a t-attf-href="/slides/slide/#{slug(first_slide)}?fullscreen=1" class="btn btn-success mt-2 mt-sm-0">
<a t-attf-href="#{'/slides_survey/slide/get_certification_url?slide_id=%s' %(first_slide.id) if first_slide.slide_type == 'certification' and channel.total_slides == 1 else '/slides/slide/%s?fullscreen=1' %(slug(first_slide))}" class="btn btn-success mt-2 mt-sm-0">
<span>Start Now</span><i class="fa fa-chevron-right ml-2 align-middle"/>
</a>
</div>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment