[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).
This commit is contained in:
committed by
Thibault Delavallée
parent
69cd8bc675
commit
ef3ccce079
@@ -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>
|
||||
|
||||
Reference in New Issue
Block a user