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

92 lines
2.8 KiB
Vue
Raw Normal View History

2018-11-01 11:49:53 +00:00
<template>
2019-04-25 14:03:22 +00:00
<div class="py-3 col-md-4 col-sm-12">
2019-03-31 14:16:39 +00:00
<div class="card h-100">
<div class="card-hero-img" v-if="course.hero_image" v-bind:style="{ 'background-image': 'url(' + image + ')' }"></div>
<div v-else class="card-image-wrapper">
<div class="image-body">{{ course.course_name }}</div>
</div>
<div class='card-body'>
2018-11-01 11:49:53 +00:00
<h5 class="card-title">{{ course.course_name }}</h5>
<span class="course-list text-muted" id="getting-started">
2018-12-17 08:26:27 +00:00
Topics
<ul class="mb-0 mt-1" style="padding-left: 1.5em;">
2019-02-26 11:17:54 +00:00
<li v-for="topic in course.topics" :key="topic.name">
<div>{{ topic.topic_name }}</div>
2018-11-21 09:51:57 +00:00
</li>
2018-11-01 11:49:53 +00:00
</ul>
</span>
</div>
<div class='p-3' style="display: flex; justify-content: space-between;">
<div>
<span v-if="complete"><i class="mr-2 text-success fa fa-check-circle" aria-hidden="true"></i>Course Complete</span>
</div>
<div class='text-right'>
2019-03-31 14:16:39 +00:00
<a-button
:type="'primary'"
size="sm"
2019-03-31 14:16:39 +00:00
:route="courseRoute"
>
{{ buttonName }}
</a-button>
</div>
2018-11-01 11:49:53 +00:00
</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-02 15:21:24 +00:00
components: {
2018-11-09 06:17:09 +00:00
AButton
},
2019-02-28 09:51:43 +00:00
data() {
return {
courseDetails: {},
2019-02-28 09:51:43 +00:00
}
},
mounted() {
if(lms.store.checkLogin()) this.getCourseDetails().then(data => this.courseDetails = data)
2019-02-28 09:51:43 +00:00
},
2018-11-09 06:17:09 +00:00
computed: {
2018-12-17 08:26:27 +00:00
courseRoute() {
return `${this.program_name}/${this.course.name}`
},
complete() {
2019-02-28 09:51:43 +00:00
if(lms.store.checkProgramEnrollment(this.program_name)){
if (this.courseDetails.flag === "Completed" ) {
return true
2019-02-28 09:51:43 +00:00
}
else {
return false
2019-02-28 09:51:43 +00:00
}
}
else {
return false
2019-02-28 09:51:43 +00:00
}
},
isLogin() {
return lms.store.checkLogin()
},
buttonName() {
if(lms.store.checkProgramEnrollment(this.program_name)){
return "Start Course"
2019-02-28 09:51:43 +00:00
}
else {
return "Explore"
2019-02-28 09:51:43 +00:00
}
}
},
methods: {
getCourseDetails() {
return lms.call('get_student_course_details', {
2019-02-28 09:51:43 +00:00
course_name: this.course.name,
program_name: this.program_name
})
},
2018-11-01 11:49:53 +00:00
}
};
</script>