fix: TopicMeta fixes
diff --git a/erpnext/public/js/education/lms/components/TopicCard.vue b/erpnext/public/js/education/lms/components/TopicCard.vue
index 883277d..c9cb94f 100644
--- a/erpnext/public/js/education/lms/components/TopicCard.vue
+++ b/erpnext/public/js/education/lms/components/TopicCard.vue
@@ -9,7 +9,7 @@
Content
<ul class="mb-0 mt-1">
<li v-for="content in topic.topic_content" :key="content.name">
- <router-link v-if="isLogin" tag="a" :class="'text-muted'" :to="{name: 'content', params:{program_name: program_name, topic:topic.name, course: course, type:content.content_type, content: content.content} }">
+ <router-link v-if="isLogin" tag="a" :class="'text-muted'" :to="{name: 'content', params:{program_name: program_name, topic:topic.name, course_name: course_name, type:content.content_type, content: content.content} }">
<span style="padding-right: 0.4em"></span>{{ content.content }}
</router-link>
<div v-else><span style="padding-right: 0.4em"></span>{{ content.content }}</div>
@@ -35,7 +35,7 @@
import AButton from './Button.vue';
export default {
- props: ['topic', 'course', 'program_name'],
+ props: ['topic', 'course_name', 'program_name'],
name: "TopicCard",
data() {
return {
@@ -51,7 +51,7 @@
computed: {
firstContentRoute() {
if(lms.store.checkLogin()){
- return `${this.program_name}/${this.course.name}/${this.courseMeta.content_type}/${this.courseMeta.content}`
+ return `${this.program_name}/${this.course}/${this.courseMeta.content_type}/${this.courseMeta.content}`
}
else {
return {}
@@ -93,8 +93,9 @@
if(content_type == 'Quiz') return 'fa fa-question-circle-o'
},
getCourseMeta() {
- return lms.call('get_course_meta', {
- course_name: this.course.name,
+ return lms.call('get_topic_meta', {
+ topic_name: this.topic.topic_name,
+ course_name: this.course_name,
program_name: this.program_name
})
},
diff --git a/erpnext/public/js/education/lms/pages/CoursePage.vue b/erpnext/public/js/education/lms/pages/CoursePage.vue
index 56656c5..eb64ec5 100644
--- a/erpnext/public/js/education/lms/pages/CoursePage.vue
+++ b/erpnext/public/js/education/lms/pages/CoursePage.vue
@@ -3,7 +3,7 @@
<TopSection v-bind:title="course.course_name" v-bind:description="course.description">
</TopSection>
<CardList :title="'Topics'" :description="''" :sectionType="'section-padding section-bg'">
- <TopicCard slot="card-list-slot" v-for="topic in topicData" :topic="topic" :course="course.course_name" :program_name="program_name" :key="topic.name"/>
+ <TopicCard slot="card-list-slot" v-for="topic in topicData" :topic="topic" :course_name="course_name" :program_name="program_name" :key="topic.name"/>
</CardList>
</div>
</template>
diff --git a/erpnext/public/js/education/lms/routes.js b/erpnext/public/js/education/lms/routes.js
index 4428c74..7f06c78 100644
--- a/erpnext/public/js/education/lms/routes.js
+++ b/erpnext/public/js/education/lms/routes.js
@@ -24,7 +24,7 @@
},
{
name: 'content',
- path: '/Program/:program_name/:course/:topic/:type/:content',
+ path: '/Program/:program_name/:course_name/:topic/:type/:content',
component: ContentPage,
props: true,
beforeEnter: (to, from, next) => {
diff --git a/erpnext/www/lms.py b/erpnext/www/lms.py
index b8aee4b..c2a8bd5 100644
--- a/erpnext/www/lms.py
+++ b/erpnext/www/lms.py
@@ -190,6 +190,33 @@
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):
+ """
+ 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)
+ 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']}
+ elif count == len(progress):
+ return {'flag':'Completed', 'content_type': progress[0]['content_type'], 'content': progress[0]['content']}
+ elif count < len(progress):
+ next_item = next(item for item in progress if item['is_complete']==False)
+ return {'flag':'Continue', 'content_type': next_item['content_type'], 'content': next_item['content']}
+
+@frappe.whitelist()
def get_program_progress(program_name):
import math
program = frappe.get_doc("Program", program_name)