fix: TopicMeta fixes
This commit is contained in:
@@ -9,7 +9,7 @@
|
|||||||
Content
|
Content
|
||||||
<ul class="mb-0 mt-1">
|
<ul class="mb-0 mt-1">
|
||||||
<li v-for="content in topic.topic_content" :key="content.name">
|
<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 }}
|
<span style="padding-right: 0.4em"></span>{{ content.content }}
|
||||||
</router-link>
|
</router-link>
|
||||||
<div v-else><span style="padding-right: 0.4em"></span>{{ content.content }}</div>
|
<div v-else><span style="padding-right: 0.4em"></span>{{ content.content }}</div>
|
||||||
@@ -35,7 +35,7 @@
|
|||||||
import AButton from './Button.vue';
|
import AButton from './Button.vue';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
props: ['topic', 'course', 'program_name'],
|
props: ['topic', 'course_name', 'program_name'],
|
||||||
name: "TopicCard",
|
name: "TopicCard",
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
@@ -51,7 +51,7 @@ export default {
|
|||||||
computed: {
|
computed: {
|
||||||
firstContentRoute() {
|
firstContentRoute() {
|
||||||
if(lms.store.checkLogin()){
|
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 {
|
else {
|
||||||
return {}
|
return {}
|
||||||
@@ -93,8 +93,9 @@ export default {
|
|||||||
if(content_type == 'Quiz') return 'fa fa-question-circle-o'
|
if(content_type == 'Quiz') return 'fa fa-question-circle-o'
|
||||||
},
|
},
|
||||||
getCourseMeta() {
|
getCourseMeta() {
|
||||||
return lms.call('get_course_meta', {
|
return lms.call('get_topic_meta', {
|
||||||
course_name: this.course.name,
|
topic_name: this.topic.topic_name,
|
||||||
|
course_name: this.course_name,
|
||||||
program_name: this.program_name
|
program_name: this.program_name
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
<TopSection v-bind:title="course.course_name" v-bind:description="course.description">
|
<TopSection v-bind:title="course.course_name" v-bind:description="course.description">
|
||||||
</TopSection>
|
</TopSection>
|
||||||
<CardList :title="'Topics'" :description="''" :sectionType="'section-padding section-bg'">
|
<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>
|
</CardList>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ const routes = [{
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'content',
|
name: 'content',
|
||||||
path: '/Program/:program_name/:course/:topic/:type/:content',
|
path: '/Program/:program_name/:course_name/:topic/:type/:content',
|
||||||
component: ContentPage,
|
component: ContentPage,
|
||||||
props: true,
|
props: true,
|
||||||
beforeEnter: (to, from, next) => {
|
beforeEnter: (to, from, next) => {
|
||||||
|
|||||||
@@ -189,6 +189,33 @@ def get_course_meta(course_name, program_name):
|
|||||||
next_item = next(item for item in progress if item['is_complete']==False)
|
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']}
|
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()
|
@frappe.whitelist()
|
||||||
def get_program_progress(program_name):
|
def get_program_progress(program_name):
|
||||||
import math
|
import math
|
||||||
|
|||||||
Reference in New Issue
Block a user