Reputation: 197
I am trying to inherit the slide.slide.quiz.validation
in website_slides
to change the label of a button of quiz page in eLearning. No errors are showing upon upgrading my custom module and the website_slides
however there are still no changes. I already put the ff:
custom_module > static > src > js > custom_js.js
odoo.define('custom_module.quiz', function (require) {
"use strict";
var Quiz = require('website_slides.quiz').Quiz;
Quiz.include({
xmlDependencies: (Quiz.prototype.xmlDependencies || []).concat(
["/custom_module/static/src/xml/slide_quiz.xml"]
)
});
});
custom_module > static > src > xml> custom_template.xml
<?xml version="1.0" encoding="utf-8" ?>
<templates xml:space="preserve">
<t t-extend="slide.slide.quiz.validation">
<t t-jquery=".o_wslides_js_lesson_quiz_reset" t-operation="replace">
<button class="btn btn-light border o_wslides_js_lesson_quiz_reset">
Retake
</button>
</t>
</t>
</templates>
custom_module > views > assets.xml
<?xml version="1.0" ?>
<odoo>
<template id="elearning_assets" name="eLearning Assets" inherit_id="website.assets_frontend">
<xpath expr="//link[last()]" position="after">
<link rel="stylesheet" type="text/scss" href="/custom_module/static/src/scss/course.scss" />
</xpath>
<xpath expr="//script[last()]" position="after">
<script type="text/javascript" src="/custom_module/static/src/js/slides_course_quiz.js"/>
</xpath>
</template>
</odoo>
assets.xml
already included in the manifest file. I also inherited the slide.channel
model.
This is the original odoo template from website_slides > static > src > xml > slide_quiz.xml
<t t-name="slide.slide.quiz.validation">
<div id="validation">
# existing code
<div t-else="" class="d-md-flex align-items-center justify-content-between">
# existing code
<div class="ml-auto mt-3 mt-md-0">
<button t-if="widget.quiz.quizAttemptsCount > 0 && widget.slide.channelCanUpload" class="btn btn-light border o_wslides_js_lesson_quiz_reset">
Reset
</button>
<button t-if="widget.slide.completed && widget.slide.hasNext" class="btn btn-primary o_wslides_quiz_continue">
Continue <i class="fa fa-chevron-right ml-1"/>
</button>
</div>
</div>
</div>
</t>
I'm still working on resolving issues in my code, but I've reached a point where I'm stuck. I would appreciate any comments or help you can offer. Thanks in advance.
Upvotes: 1
Views: 328
Reputation: 197
It is now solved. I still use the t-operation="replace" to change the Reset button and remove the t-if condition. My doubt is correct regarding the proper loading of custom js. There is just typo error in declaring in assets. I put the <script type="text/javascript" src="/custom_module/static/src/js/slides_course_quiz.js"/>
instead of <script type="text/javascript" src="/custom_module/static/src/js/slide_course_quiz.js"/>
Upvotes: 0
Reputation: 1210
Kindly refer to the add-on extension.
<?xml version="1.0" encoding="UTF-8"?>
<templates xml:space="preserve">
<t t-extend="slide.slide.quiz.validation">
<t t-jquery=".o_wslides_quiz_join_course_message" t-operation="append">
<span t-if="widget.channel.channelEnroll == 'payment'">
<t t-if="widget.publicUser">
Sign in and buy the course to take the quiz
</t>
<t t-else="">
Buy the course to validate your answers!
</t>
</span>
</t>
</t>
</templates>
Upvotes: 0