brotherton-erpnext/erpnext/public/js/education/lms/components/CourseCard.vue

116 lines
3.7 KiB
Vue
Raw Normal View History

2018-11-01 11:49:53 +00:00
<template>
<div class="card mt-3" data-list="getting-started">
<div class='card-body'>
<div class="row">
<div class="course-details col-xs-8 col-sm-9 col-md-10">
<h5 class="card-title">{{ course.course_name }}</h5>
<span class="course-list text-muted" id="getting-started">
Course Content
<ul class="mb-0 mt-1">
2018-11-21 09:51:57 +00:00
<li v-for="content in course.course_content" :key="content.name">
2018-11-24 15:01:35 +00:00
<router-link v-if="isLogin" tag="a" :class="'text-muted'" :to="{name: 'content', params:{program_name: program_name, course: course.name, type:content.content_type, content: content.content} }">
2018-11-21 09:51:57 +00:00
<span style="padding-right: 0.4em"><i :class="iconClass(content.content_type)"></i></span>{{ content.content }}
</router-link>
2018-11-24 15:01:35 +00:00
<div v-else><span style="padding-right: 0.4em"><i :class="iconClass(content.content_type)"></i></span>{{ content.content }}</div>
2018-11-21 09:51:57 +00:00
</li>
2018-11-01 11:49:53 +00:00
</ul>
</span>
</div>
2018-11-12 07:20:54 +00:00
<div class='course-buttons text-center col-xs-4 col-sm-3 col-md-2'>
2018-12-06 14:43:20 +00:00
<a-button v-if="isLogin"
2018-11-12 07:20:54 +00:00
:type="buttonType"
size="sm btn-block"
2018-11-09 06:17:09 +00:00
:route="firstContentRoute"
>
2018-12-06 14:43:20 +00:00
{{ buttonName }}
2018-11-09 06:17:09 +00:00
</a-button>
2018-11-01 11:49:53 +00:00
</div>
</div>
</div>
</div>
</template>
<script>
2018-11-12 07:20:54 +00:00
import AButton from './Button.vue';
2018-11-02 15:21:24 +00:00
2018-11-01 11:49:53 +00:00
export default {
2018-11-22 10:03:30 +00:00
props: ['course', 'program_name'],
2018-11-13 11:54:07 +00:00
name: "CourseCard",
2018-11-22 10:03:30 +00:00
data() {
return {
courseMeta: {}
}
},
mounted() {
2018-11-30 07:17:18 +00:00
if(lms.store.checkLogin()) this.getCourseMeta().then(data => this.courseMeta = data)
2018-11-22 10:03:30 +00:00
},
2018-11-02 15:21:24 +00:00
components: {
2018-11-09 06:17:09 +00:00
AButton
},
computed: {
firstContentRoute() {
2018-12-06 14:43:20 +00:00
if(lms.store.checkLogin()){
return `${this.program_name}/${this.course.name}/${this.courseMeta.content_type}/${this.courseMeta.content}`
}
else {
return {}
}
2018-11-12 07:20:54 +00:00
},
buttonType() {
2018-12-06 14:43:20 +00:00
if(lms.store.checkProgramEnrollment(this.program_name)){
if (this.courseMeta.flag == "Start Course" ){
2018-11-12 07:20:54 +00:00
return "primary"
2018-12-06 14:43:20 +00:00
}
else if (this.courseMeta.flag == "Completed" ) {
return "success"
}
else if (this.courseMeta.flag == "Continue" ) {
return "info"
}
2018-11-12 07:20:54 +00:00
}
2018-11-13 06:52:49 +00:00
else {
return " hidden"
}
2018-11-26 06:29:12 +00:00
},
isLogin() {
2018-12-06 14:43:20 +00:00
return lms.store.checkProgramEnrollment(this.program_name)
},
buttonName() {
if(lms.store.checkLogin()){
return this.courseMeta.flag
}
else {
return "Enroll"
}
2018-11-26 11:22:45 +00:00
}
2018-11-21 09:51:57 +00:00
},
methods: {
iconClass(content_type) {
if(content_type == 'Video') return 'fa fa-play'
if(content_type == 'Article') return 'fa fa-file-text-o'
if(content_type == 'Quiz') return 'fa fa-question-circle-o'
2018-11-22 10:03:30 +00:00
},
getCourseMeta() {
return lms.call('get_course_meta', {
course_name: this.course.name,
program_name: this.program_name
2018-11-22 10:03:30 +00:00
})
},
2018-11-01 11:49:53 +00:00
}
};
</script>
<style scoped>
@media only screen and (max-width: 576px) {
2018-11-21 09:51:57 +00:00
.course-buttons {
margin-top: 1em;
}
}
li {
list-style-type: none;
padding: 0;
2018-11-21 09:51:57 +00:00
}
.fa {
font-size: 0.8em;
2018-11-01 11:49:53 +00:00
}
</style>