|
|
@ -219,7 +219,6 @@ def get_quiz(quiz_name, course): |
|
|
|
try: |
|
|
|
quiz = frappe.get_doc("Quiz", quiz_name) |
|
|
|
questions = quiz.get_questions() |
|
|
|
duration = quiz.duration |
|
|
|
except: |
|
|
|
frappe.throw(_("Quiz {0} does not exist").format(quiz_name), frappe.DoesNotExistError) |
|
|
|
return None |
|
|
@ -236,15 +235,17 @@ def get_quiz(quiz_name, course): |
|
|
|
return { |
|
|
|
'questions': questions, |
|
|
|
'activity': None, |
|
|
|
'duration':duration |
|
|
|
'is_time_bound': quiz.is_time_bound, |
|
|
|
'duration':quiz.duration |
|
|
|
} |
|
|
|
|
|
|
|
student = get_current_student() |
|
|
|
course_enrollment = get_enrollment("course", course, student.name) |
|
|
|
status, score, result, time_taken = check_quiz_completion(quiz, course_enrollment) |
|
|
|
return { |
|
|
|
'questions': questions, |
|
|
|
'questions': questions, |
|
|
|
'activity': {'is_complete': status, 'score': score, 'result': result, 'time_taken': time_taken}, |
|
|
|
'is_time_bound': quiz.is_time_bound, |
|
|
|
'duration': quiz.duration |
|
|
|
} |
|
|
|
|
|
|
@ -372,9 +373,9 @@ def check_content_completion(content_name, content_type, enrollment_name): |
|
|
|
def check_quiz_completion(quiz, enrollment_name): |
|
|
|
attempts = frappe.get_all("Quiz Activity", |
|
|
|
filters={ |
|
|
|
'enrollment': enrollment_name, |
|
|
|
'enrollment': enrollment_name, |
|
|
|
'quiz': quiz.name |
|
|
|
}, |
|
|
|
}, |
|
|
|
fields=["name", "activity_date", "score", "status", "time_taken"] |
|
|
|
) |
|
|
|
status = False if quiz.max_attempts == 0 else bool(len(attempts) >= quiz.max_attempts) |
|
|
@ -389,4 +390,4 @@ def check_quiz_completion(quiz, enrollment_name): |
|
|
|
time_taken = attempts[0]['time_taken'] |
|
|
|
if result == 'Pass': |
|
|
|
status = True |
|
|
|
return status, score, result, time_taken |
|
|
|
return status, score, result, time_taken |
|
|
|