fix: Showing Topic Progress
diff --git a/erpnext/education/doctype/student/student.py b/erpnext/education/doctype/student/student.py
index dbd154b..c4b3398 100644
--- a/erpnext/education/doctype/student/student.py
+++ b/erpnext/education/doctype/student/student.py
@@ -41,8 +41,8 @@
def after_insert(self):
self.create_student()
-
- def create_student(self):
+
+ def create_student(self):
"""Create a website user for student creation if not already exists"""
if self.user == None:
student_user = frappe.get_doc({
@@ -100,7 +100,6 @@
status, score, result = check_quiz_completion(content, course_enrollment_name)
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({
diff --git a/erpnext/public/js/education/lms/components/TopicCard.vue b/erpnext/public/js/education/lms/components/TopicCard.vue
index 554314c..9a3a2c2 100644
--- a/erpnext/public/js/education/lms/components/TopicCard.vue
+++ b/erpnext/public/js/education/lms/components/TopicCard.vue
@@ -39,11 +39,11 @@
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 @@
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 @@
},
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 @@
},
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 @@
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
})
},
}
diff --git a/erpnext/www/lms.py b/erpnext/www/lms.py
index 702377e..c635567 100644
--- a/erpnext/www/lms.py
+++ b/erpnext/www/lms.py
@@ -189,26 +189,19 @@
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):