fix: Showing Topic Progress
This commit is contained in:
parent
b17d289bda
commit
de5f71ae9e
@ -101,7 +101,6 @@ class Student(Document):
|
||||
progress.append({'content': content.name, 'content_type': content.doctype, 'is_complete': status, 'score': score, 'result': result})
|
||||
return progress
|
||||
|
||||
|
||||
def enroll_in_program(self, program_name):
|
||||
enrollment = frappe.get_doc({
|
||||
"doctype": "Program Enrollment",
|
||||
|
@ -39,11 +39,11 @@ export default {
|
||||
name: "TopicCard",
|
||||
data() {
|
||||
return {
|
||||
courseMeta: {}
|
||||
topicMeta: {}
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
if(lms.store.checkLogin()) this.getCourseMeta().then(data => this.courseMeta = data)
|
||||
if(lms.store.checkLogin()) this.getTopicMeta().then(data => this.topicMeta = data)
|
||||
},
|
||||
components: {
|
||||
AButton
|
||||
@ -51,7 +51,7 @@ export default {
|
||||
computed: {
|
||||
firstContentRoute() {
|
||||
if(lms.store.checkLogin()){
|
||||
return `/Program/${this.program_name}/${this.course_name}/${this.topic.name}/${this.courseMeta.content_type}/${this.courseMeta.content}`
|
||||
return `/Program/${this.program_name}/${this.course_name}/${this.topic.name}/${this.topicMeta.content_type}/${this.topicMeta.content}`
|
||||
}
|
||||
else {
|
||||
return {}
|
||||
@ -59,13 +59,13 @@ export default {
|
||||
},
|
||||
buttonType() {
|
||||
if(lms.store.checkProgramEnrollment(this.program_name)){
|
||||
if (this.courseMeta.flag == "Start Course" ){
|
||||
if (this.topicMeta.flag == "Start Topic" ){
|
||||
return "primary"
|
||||
}
|
||||
else if (this.courseMeta.flag == "Completed" ) {
|
||||
else if (this.topicMeta.flag == "Completed" ) {
|
||||
return "success"
|
||||
}
|
||||
else if (this.courseMeta.flag == "Continue" ) {
|
||||
else if (this.topicMeta.flag == "Continue" ) {
|
||||
return "info"
|
||||
}
|
||||
}
|
||||
@ -75,11 +75,11 @@ export default {
|
||||
},
|
||||
isLogin() {
|
||||
// return lms.store.checkProgramEnrollment(this.program_name)
|
||||
return true
|
||||
return lms.store.checkLogin()
|
||||
},
|
||||
buttonName() {
|
||||
if(lms.store.checkLogin()){
|
||||
return this.courseMeta.flag
|
||||
return this.topicMeta.flag
|
||||
}
|
||||
else {
|
||||
return "Enroll"
|
||||
@ -92,11 +92,10 @@ export default {
|
||||
if(content_type == 'Article') return 'fa fa-file-text-o'
|
||||
if(content_type == 'Quiz') return 'fa fa-question-circle-o'
|
||||
},
|
||||
getCourseMeta() {
|
||||
getTopicMeta() {
|
||||
return lms.call('get_topic_meta', {
|
||||
topic_name: this.topic.topic_name,
|
||||
topic_name: this.topic.name,
|
||||
course_name: this.course_name,
|
||||
program_name: this.program_name
|
||||
})
|
||||
},
|
||||
}
|
||||
|
@ -189,26 +189,19 @@ def get_course_meta(course_name, program_name):
|
||||
return {'flag':'Continue', 'content_type': next_item['content_type'], 'content': next_item['content']}
|
||||
|
||||
@frappe.whitelist()
|
||||
def get_topic_meta(topic_name, course_name, program_name):
|
||||
def get_topic_meta(topic_name, course_name):
|
||||
"""
|
||||
Return the porgress of a course in a program as well as the content to continue from.
|
||||
:param topic_name:
|
||||
:param course_name:
|
||||
:param program_name:
|
||||
"""
|
||||
print(locals())
|
||||
course_enrollment = utils.get_course_enrollment(course_name)
|
||||
program_enrollment = utils.get_program_enrollment(program_name)
|
||||
student = frappe.get_doc("Student", utils.get_current_student())
|
||||
if not program_enrollment:
|
||||
return None
|
||||
if not course_enrollment:
|
||||
utils.enroll_in_course(course_name, program_name)
|
||||
progress = course_enrollment.get_progress(student)
|
||||
print(progress)
|
||||
topic = frappe.get_doc("Topic", topic_name)
|
||||
progress = student.get_topic_progress(course_enrollment.name, topic)
|
||||
count = sum([activity['is_complete'] for activity in progress])
|
||||
if count == 0:
|
||||
return {'flag':'Start Course', 'content_type': progress[0]['content_type'], 'content': progress[0]['content']}
|
||||
return {'flag':'Start Topic', 'content_type': progress[0]['content_type'], 'content': progress[0]['content']}
|
||||
elif count == len(progress):
|
||||
return {'flag':'Completed', 'content_type': progress[0]['content_type'], 'content': progress[0]['content']}
|
||||
elif count < len(progress):
|
||||
|
Loading…
x
Reference in New Issue
Block a user