fix: quiz timer issues

This commit is contained in:
pateljannat 2021-06-08 17:05:44 +05:30
parent 3f1231b77c
commit bbf07d9214
3 changed files with 12 additions and 12 deletions

View File

@ -219,7 +219,6 @@ def get_quiz(quiz_name, course):
try: try:
quiz = frappe.get_doc("Quiz", quiz_name) quiz = frappe.get_doc("Quiz", quiz_name)
questions = quiz.get_questions() questions = quiz.get_questions()
duration = quiz.duration
except: except:
frappe.throw(_("Quiz {0} does not exist").format(quiz_name), frappe.DoesNotExistError) frappe.throw(_("Quiz {0} does not exist").format(quiz_name), frappe.DoesNotExistError)
return None return None
@ -236,7 +235,8 @@ def get_quiz(quiz_name, course):
return { return {
'questions': questions, 'questions': questions,
'activity': None, 'activity': None,
'duration':duration 'is_time_bound': quiz.is_time_bound,
'duration': quiz.duration
} }
student = get_current_student() student = get_current_student()
@ -245,6 +245,7 @@ def get_quiz(quiz_name, course):
return { return {
'questions': questions, 'questions': questions,
'activity': {'is_complete': status, 'score': score, 'result': result, 'time_taken': time_taken}, 'activity': {'is_complete': status, 'score': score, 'result': result, 'time_taken': time_taken},
'is_time_bound': quiz.is_time_bound,
'duration': quiz.duration 'duration': quiz.duration
} }

View File

@ -20,10 +20,8 @@ class Quiz {
} }
make(data) { make(data) {
if (data.duration) { if (data.is_time_bound) {
const timer_display = document.createElement("div"); $(".lms-timer").removeClass("hide")
timer_display.classList.add("lms-timer", "float-right", "font-weight-bold");
document.getElementsByClassName("lms-title")[0].appendChild(timer_display);
if (!data.activity || (data.activity && !data.activity.is_complete)) { if (!data.activity || (data.activity && !data.activity.is_complete)) {
this.initialiseTimer(data.duration); this.initialiseTimer(data.duration);
this.is_time_bound = true; this.is_time_bound = true;
@ -118,7 +116,7 @@ class Quiz {
quiz_response: this.get_selected(), quiz_response: this.get_selected(),
course: this.course, course: this.course,
program: this.program, program: this.program,
time_taken: this.is_time_bound ? this.time_taken : "" time_taken: this.is_time_bound ? this.time_taken : 0
}).then(res => { }).then(res => {
this.submit_btn.remove() this.submit_btn.remove()
if (!res.message) { if (!res.message) {

View File

@ -64,6 +64,7 @@
</div> </div>
<div class="lms-title"> <div class="lms-title">
<h2>{{ content.name }} <span class="small text-muted">({{ position + 1 }}/{{length}})</span></h2> <h2>{{ content.name }} <span class="small text-muted">({{ position + 1 }}/{{length}})</span></h2>
<div class="lms-timer float-right fond-weight-bold hide"></div>
</div> </div>
{% endmacro %} {% endmacro %}