mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-25 16:04:46 +00:00
feat: Timer in LMS Quiz (#24246)
* feat: new fields in quiz doctypes * feat: timer in lms quiz * fix: variable initialisation * fix: context, exception fix * fix:sider * fix:sider * fix: indentation * fix: timer * fix: sider * fix: return value and format * fix: show time taken only after all attempts are over * fix: sider Co-authored-by: pateljannat <jannatpatel@MacBook-Air.local> Co-authored-by: Marica <maricadsouza221197@gmail.com>
This commit is contained in:
@@ -62,7 +62,7 @@
|
||||
{{_('Back to Course')}}
|
||||
</a>
|
||||
</div>
|
||||
<div>
|
||||
<div class="lms-title">
|
||||
<h2>{{ content.name }} <span class="small text-muted">({{ position + 1 }}/{{length}})</span></h2>
|
||||
</div>
|
||||
{% endmacro %}
|
||||
@@ -169,14 +169,51 @@
|
||||
const next_url = '/lms/course?name={{ course }}&program={{ program }}'
|
||||
{% endif %}
|
||||
frappe.ready(() => {
|
||||
const quiz = new Quiz(document.getElementById('quiz-wrapper'), {
|
||||
name: '{{ content.name }}',
|
||||
course: '{{ course }}',
|
||||
program: '{{ program }}',
|
||||
quiz_exit_button: quiz_exit_button,
|
||||
next_url: next_url
|
||||
})
|
||||
window.quiz = quiz;
|
||||
{% if content.is_time_bound %}
|
||||
var duration = get_duration("{{content.duration}}")
|
||||
var d = frappe.msgprint({
|
||||
title: __('Important Notice'),
|
||||
indicator: "red",
|
||||
message: __(`This is a Time-Bound Quiz. <br><br>
|
||||
A timer for <b>${duration}</b> will start, once you click on <b>Proceed</b>. <br><br>
|
||||
If you fail to submit before the time is up, the Quiz will be submitted automatically.`),
|
||||
primary_action: {
|
||||
label: __("Proceed"),
|
||||
action: () => {
|
||||
create_quiz();
|
||||
d.hide();
|
||||
}
|
||||
},
|
||||
secondary_action: {
|
||||
action: () => {
|
||||
d.hide();
|
||||
window.location.href = "/lms/course?name={{ course }}&program={{ program }}";
|
||||
},
|
||||
label: __("Go Back"),
|
||||
}
|
||||
});
|
||||
{% else %}
|
||||
create_quiz();
|
||||
{% endif %}
|
||||
function create_quiz() {
|
||||
const quiz = new Quiz(document.getElementById('quiz-wrapper'), {
|
||||
name: '{{ content.name }}',
|
||||
course: '{{ course }}',
|
||||
program: '{{ program }}',
|
||||
quiz_exit_button: quiz_exit_button,
|
||||
next_url: next_url
|
||||
})
|
||||
window.quiz = quiz;
|
||||
}
|
||||
function get_duration(seconds){
|
||||
var hours = append_zero(Math.floor(seconds / 3600));
|
||||
var minutes = append_zero(Math.floor(seconds % 3600 / 60));
|
||||
var seconds = append_zero(Math.floor(seconds % 3600 % 60));
|
||||
return `${hours}:${minutes}:${seconds}`;
|
||||
}
|
||||
function append_zero(time) {
|
||||
return time > 9 ? time : "0" + time;
|
||||
}
|
||||
})
|
||||
{% endif %}
|
||||
|
||||
|
||||
@@ -42,7 +42,9 @@
|
||||
<section class="top-section" style="padding: 6rem 0rem;">
|
||||
<div class='container pb-5'>
|
||||
<h1>{{ education_settings.portal_title }}</h1>
|
||||
<p class='lead'>{{ education_settings.description }}</p>
|
||||
{% if education_settings.description %}
|
||||
<p class='lead'>{{ education_settings.description }}</p>
|
||||
{% endif %}
|
||||
<p class="mt-4">
|
||||
{% if frappe.session.user == 'Guest' %}
|
||||
<a class="btn btn-primary btn-lg" href="/login#signup">{{_('Sign Up')}}</a>
|
||||
@@ -51,13 +53,15 @@
|
||||
</div>
|
||||
<div class='container'>
|
||||
<div class="row mt-5">
|
||||
{% for program in featured_programs %}
|
||||
{{ program_card(program.program, program.has_access) }}
|
||||
{% endfor %}
|
||||
{% if featured_programs %}
|
||||
{% for program in featured_programs %}
|
||||
{{ program_card(program.program, program.has_access) }}
|
||||
{% endfor %}
|
||||
{% for n in range( (3 - (featured_programs|length)) %3) %}
|
||||
{{ null_card() }}
|
||||
{% endfor %}
|
||||
{% else %}
|
||||
<p class="lead">You have not enrolled in any program. Contact your Instructor.</p>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -35,7 +35,7 @@ def get_contents(topic, course, program):
|
||||
progress.append({'content': content, 'content_type': content.doctype, 'completed': status})
|
||||
elif content.doctype == 'Quiz':
|
||||
if student:
|
||||
status, score, result = utils.check_quiz_completion(content, course_enrollment.name)
|
||||
status, score, result, time_taken = utils.check_quiz_completion(content, course_enrollment.name)
|
||||
else:
|
||||
status = False
|
||||
score = None
|
||||
|
||||
Reference in New Issue
Block a user