fix: Profile page cards

- Only show attempted quizzes
- Show 0 percent complete if program is enrolled but unattempted
This commit is contained in:
scmmishra 2019-03-28 14:27:51 +05:30
parent c03db190d2
commit 209250ccae
2 changed files with 10 additions and 2 deletions

View File

@ -1,5 +1,5 @@
<template>
<div class='card-deck mt-3'>
<div v-if="quizData" class='card-deck mt-3'>
<div class="card">
<div class='card-body'>
<div class="row">

View File

@ -241,10 +241,16 @@ def get_program_progress(program_name):
if meta['flag'] == "Completed":
is_complete = True
progress.append({'course_name': course.course_name, 'name': course.course, 'is_complete': is_complete})
program_meta['progress'] = progress
program_meta['name'] = program_name
program_meta['program'] = program.program_name
program_meta['percentage'] = math.ceil((sum([item['is_complete'] for item in progress] * 100)/len(progress)))
try:
program_meta['percentage'] = math.ceil((sum([item['is_complete'] for item in progress] * 100)/len(progress)))
except ZeroDivisionError:
program_meta['percentage'] = 0
return program_meta
@frappe.whitelist()
@ -270,6 +276,8 @@ def get_quiz_progress(program_name):
if progress_item['content_type'] == "Quiz":
progress_item['course'] = course.course_name
progress_list.append(progress_item)
if not progress_list:
return None
quiz_meta.quiz_attempt = progress_list
quiz_meta.name = program_name
quiz_meta.program = program.program_name