mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-30 02:14:48 +00:00
[Major][Breaking] More changes
This commit is contained in:
@@ -9,6 +9,6 @@ from frappe.model.document import Document
|
|||||||
class Program(Document):
|
class Program(Document):
|
||||||
|
|
||||||
def get_course_list(self):
|
def get_course_list(self):
|
||||||
course_content_list = self.get_all_children()
|
program_course_list = self.get_all_children()
|
||||||
course_list = [frappe.get_doc("Course", course_item.course) for course_item in course_content_list]
|
course_list = [frappe.get_doc("Course", program_course.course) for program_course in program_course_list]
|
||||||
return course_list
|
return course_list
|
||||||
@@ -5,24 +5,21 @@
|
|||||||
<div class="course-details col-xs-8 col-sm-9 col-md-10">
|
<div class="course-details col-xs-8 col-sm-9 col-md-10">
|
||||||
<h5 class="card-title">{{ course.course_name }}</h5>
|
<h5 class="card-title">{{ course.course_name }}</h5>
|
||||||
<span class="course-list text-muted" id="getting-started">
|
<span class="course-list text-muted" id="getting-started">
|
||||||
Course Content
|
Topics
|
||||||
<ul class="mb-0 mt-1">
|
<ul class="mb-0 mt-1">
|
||||||
<li v-for="content in course.course_content" :key="content.name">
|
<li v-for="topic in course.course_topic" :key="topic.name">
|
||||||
<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} }">
|
<div><span style="padding-right: 0.4em"></span>{{ topic.topic_name }}</div>
|
||||||
<span style="padding-right: 0.4em"><i :class="iconClass(content.content_type)"></i></span>{{ content.content }}
|
|
||||||
</router-link>
|
|
||||||
<div v-else><span style="padding-right: 0.4em"><i :class="iconClass(content.content_type)"></i></span>{{ content.content }}</div>
|
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
<div class='course-buttons text-center col-xs-4 col-sm-3 col-md-2'>
|
<div class='course-buttons text-center col-xs-4 col-sm-3 col-md-2'>
|
||||||
<a-button v-if="isLogin"
|
<a-button
|
||||||
:type="buttonType"
|
:type="'primary'"
|
||||||
size="sm btn-block"
|
size="sm btn-block"
|
||||||
:route="firstContentRoute"
|
:route="courseRoute"
|
||||||
>
|
>
|
||||||
{{ buttonName }}
|
View Course
|
||||||
</a-button>
|
</a-button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -36,65 +33,12 @@ import AButton from './Button.vue';
|
|||||||
export default {
|
export default {
|
||||||
props: ['course', 'program_name'],
|
props: ['course', 'program_name'],
|
||||||
name: "CourseCard",
|
name: "CourseCard",
|
||||||
data() {
|
|
||||||
return {
|
|
||||||
courseMeta: {}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
mounted() {
|
|
||||||
if(lms.store.checkLogin()) this.getCourseMeta().then(data => this.courseMeta = data)
|
|
||||||
},
|
|
||||||
components: {
|
components: {
|
||||||
AButton
|
AButton
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
firstContentRoute() {
|
courseRoute() {
|
||||||
if(lms.store.checkLogin()){
|
return `${this.program_name}/${this.course.name}`
|
||||||
return `${this.program_name}/${this.course.name}/${this.courseMeta.content_type}/${this.courseMeta.content}`
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
return {}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
buttonType() {
|
|
||||||
if(lms.store.checkProgramEnrollment(this.program_name)){
|
|
||||||
if (this.courseMeta.flag == "Start Course" ){
|
|
||||||
return "primary"
|
|
||||||
}
|
|
||||||
else if (this.courseMeta.flag == "Completed" ) {
|
|
||||||
return "success"
|
|
||||||
}
|
|
||||||
else if (this.courseMeta.flag == "Continue" ) {
|
|
||||||
return "info"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
return " hidden"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
isLogin() {
|
|
||||||
return lms.store.checkProgramEnrollment(this.program_name)
|
|
||||||
},
|
|
||||||
buttonName() {
|
|
||||||
if(lms.store.checkLogin()){
|
|
||||||
return this.courseMeta.flag
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
return "Enroll"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
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'
|
|
||||||
},
|
|
||||||
getCourseMeta() {
|
|
||||||
return lms.call('get_course_meta', {
|
|
||||||
course_name: this.course.name,
|
|
||||||
program_name: this.program_name
|
|
||||||
})
|
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -106,11 +50,4 @@ export default {
|
|||||||
margin-top: 1em;
|
margin-top: 1em;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
li {
|
|
||||||
list-style-type: none;
|
|
||||||
padding: 0;
|
|
||||||
}
|
|
||||||
.fa {
|
|
||||||
font-size: 0.8em;
|
|
||||||
}
|
|
||||||
</style>
|
</style>
|
||||||
118
erpnext/public/js/education/lms/components/TopicCard.vue
Normal file
118
erpnext/public/js/education/lms/components/TopicCard.vue
Normal file
@@ -0,0 +1,118 @@
|
|||||||
|
|
||||||
|
<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">
|
||||||
|
Topics
|
||||||
|
<ul class="mb-0 mt-1">
|
||||||
|
<li v-for="topic in course.course_topic" :key="topic.name">
|
||||||
|
<router-link v-if="isLogin" tag="a" :class="'text-muted'" :to="{name: 'course', params:{program_name: program_name, topic:topic.topic, course: course.name} }">
|
||||||
|
<span style="padding-right: 0.4em"></span>{{ topic.topic_name }}
|
||||||
|
</router-link>
|
||||||
|
<div v-else><span style="padding-right: 0.4em"></span>{{ topic.topic_name }}</div>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
<div class='course-buttons text-center col-xs-4 col-sm-3 col-md-2'>
|
||||||
|
<a-button v-if="isLogin"
|
||||||
|
:type="buttonType"
|
||||||
|
size="sm btn-block"
|
||||||
|
:route="firstContentRoute"
|
||||||
|
>
|
||||||
|
{{ buttonName }}
|
||||||
|
</a-button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import AButton from './Button.vue';
|
||||||
|
|
||||||
|
export default {
|
||||||
|
props: ['course', 'program_name'],
|
||||||
|
name: "CourseCard",
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
courseMeta: {}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
mounted() {
|
||||||
|
if(lms.store.checkLogin()) this.getCourseMeta().then(data => this.courseMeta = data)
|
||||||
|
},
|
||||||
|
components: {
|
||||||
|
AButton
|
||||||
|
},
|
||||||
|
computed: {
|
||||||
|
firstContentRoute() {
|
||||||
|
if(lms.store.checkLogin()){
|
||||||
|
return `${this.program_name}/${this.course.name}/${this.courseMeta.content_type}/${this.courseMeta.content}`
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return {}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
buttonType() {
|
||||||
|
if(lms.store.checkProgramEnrollment(this.program_name)){
|
||||||
|
if (this.courseMeta.flag == "Start Course" ){
|
||||||
|
return "primary"
|
||||||
|
}
|
||||||
|
else if (this.courseMeta.flag == "Completed" ) {
|
||||||
|
return "success"
|
||||||
|
}
|
||||||
|
else if (this.courseMeta.flag == "Continue" ) {
|
||||||
|
return "info"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return " hidden"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
isLogin() {
|
||||||
|
// return lms.store.checkProgramEnrollment(this.program_name)
|
||||||
|
return true
|
||||||
|
},
|
||||||
|
buttonName() {
|
||||||
|
if(lms.store.checkLogin()){
|
||||||
|
return this.courseMeta.flag
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return "Enroll"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
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'
|
||||||
|
},
|
||||||
|
getCourseMeta() {
|
||||||
|
return lms.call('get_course_meta', {
|
||||||
|
course_name: this.course.name,
|
||||||
|
program_name: this.program_name
|
||||||
|
})
|
||||||
|
},
|
||||||
|
}
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
@media only screen and (max-width: 576px) {
|
||||||
|
.course-buttons {
|
||||||
|
margin-top: 1em;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
li {
|
||||||
|
list-style-type: none;
|
||||||
|
padding: 0;
|
||||||
|
|
||||||
|
.fa {
|
||||||
|
font-size: 0.8em;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@@ -24,7 +24,7 @@ frappe.ready(() => {
|
|||||||
data: store,
|
data: store,
|
||||||
methods: {
|
methods: {
|
||||||
updateEnrolledPrograms() {
|
updateEnrolledPrograms() {
|
||||||
if(this.isLogin) {
|
if(this.checkLogin()) {
|
||||||
lms.call("get_program_enrollments").then(data => {
|
lms.call("get_program_enrollments").then(data => {
|
||||||
this.enrolledPrograms = data
|
this.enrolledPrograms = data
|
||||||
});
|
});
|
||||||
@@ -32,7 +32,7 @@ frappe.ready(() => {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
updateEnrolledCourses() {
|
updateEnrolledCourses() {
|
||||||
if(this.isLogin) {
|
if(this.checkLogin()) {
|
||||||
lms.call("get_all_course_enrollments").then(data => {
|
lms.call("get_all_course_enrollments").then(data => {
|
||||||
this.enrolledCourses = data
|
this.enrolledCourses = data
|
||||||
})
|
})
|
||||||
@@ -40,15 +40,7 @@ frappe.ready(() => {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
checkLogin() {
|
checkLogin() {
|
||||||
if(frappe.session.user === "Guest"){
|
return frappe.is_user_logged_in()
|
||||||
if (lms.debug) console.log('No Session')
|
|
||||||
this.isLogin = false
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
if (lms.debug) console.log('Current User: ', frappe.session.user)
|
|
||||||
this.isLogin = true
|
|
||||||
}
|
|
||||||
return this.isLogin
|
|
||||||
},
|
},
|
||||||
updateState() {
|
updateState() {
|
||||||
this.checkLogin()
|
this.checkLogin()
|
||||||
@@ -81,7 +73,7 @@ frappe.ready(() => {
|
|||||||
template: "<lms-root/>",
|
template: "<lms-root/>",
|
||||||
components: { lmsRoot },
|
components: { lmsRoot },
|
||||||
mounted() {
|
mounted() {
|
||||||
if(lms.store.isLogin) lms.store.updateState()
|
lms.store.updateState()
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
lms.view.$router.afterEach((to, from) => {
|
lms.view.$router.afterEach((to, from) => {
|
||||||
|
|||||||
47
erpnext/public/js/education/lms/pages/CoursePage.vue
Normal file
47
erpnext/public/js/education/lms/pages/CoursePage.vue
Normal file
@@ -0,0 +1,47 @@
|
|||||||
|
<template>
|
||||||
|
<div>
|
||||||
|
<TopSection v-bind:title="program.program_name" v-bind:description="program.description">
|
||||||
|
</TopSection>
|
||||||
|
<CardList :title="'Courses'" :description="''" :sectionType="'section-padding section-bg'">
|
||||||
|
<CourseCard slot="card-list-slot" v-for="course in courseData" :course="course" :program_name="program_name" :key="course.name"/>
|
||||||
|
</CardList>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
<script>
|
||||||
|
import TopSection from "../components/TopSection.vue"
|
||||||
|
import CardList from "../components/CardList.vue"
|
||||||
|
import CourseCard from "../components/CourseCard.vue"
|
||||||
|
|
||||||
|
|
||||||
|
export default {
|
||||||
|
props: ['program_name'],
|
||||||
|
name: "CoursePage",
|
||||||
|
components: {
|
||||||
|
TopSection,
|
||||||
|
CardList,
|
||||||
|
CourseCard
|
||||||
|
},
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
program: {},
|
||||||
|
courseData: [],
|
||||||
|
}
|
||||||
|
},
|
||||||
|
mounted() {
|
||||||
|
this.getProgramDetails().then(data => this.program = data);
|
||||||
|
this.getCourses().then(data => this.courseData = data);
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
getProgramDetails() {
|
||||||
|
return lms.call('get_program_details', {
|
||||||
|
program_name: this.program_name
|
||||||
|
});
|
||||||
|
},
|
||||||
|
getCourses() {
|
||||||
|
return lms.call('get_courses', {
|
||||||
|
program_name: this.program_name
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
</script>
|
||||||
@@ -27,29 +27,11 @@ export default {
|
|||||||
courseData: [],
|
courseData: [],
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
beforeMount() {
|
|
||||||
// if(lms.store.isLogin) lms.store.updateCompletedCourses()
|
|
||||||
},
|
|
||||||
mounted() {
|
mounted() {
|
||||||
this.getProgramDetails().then(data => this.program = data);
|
this.getProgramDetails().then(data => this.program = data);
|
||||||
this.getCourses().then(data => this.courseData = data);
|
this.getCourses().then(data => this.courseData = data);
|
||||||
// lms.on(`course-completed`, (course_name) => {
|
|
||||||
// const course = this.courseData.findIndex(c => c.name === course_name);
|
|
||||||
// this.courseData[course].completed = true;
|
|
||||||
// });
|
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
// startCourse() {
|
|
||||||
// this.getContentForNextCourse()
|
|
||||||
// .then((data) =>
|
|
||||||
// this.$router.push(`/Program/${this.program_name}/${data.course}/${data.content_type}/${data.content}`)
|
|
||||||
// )
|
|
||||||
// },
|
|
||||||
// getContentForNextCourse() {
|
|
||||||
// return lms.call('get_continue_data', {
|
|
||||||
// program_name: this.program_name
|
|
||||||
// });
|
|
||||||
// },
|
|
||||||
getProgramDetails() {
|
getProgramDetails() {
|
||||||
return lms.call('get_program_details', {
|
return lms.call('get_program_details', {
|
||||||
program_name: this.program_name
|
program_name: this.program_name
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import Home from "./pages/Home.vue";
|
import Home from "./pages/Home.vue";
|
||||||
import ProgramPage from "./pages/ProgramPage.vue";
|
import ProgramPage from "./pages/ProgramPage.vue";
|
||||||
|
import CoursePage from "./pages/CoursePage.vue";
|
||||||
import ContentPage from "./pages/ContentPage.vue";
|
import ContentPage from "./pages/ContentPage.vue";
|
||||||
import ListPage from "./pages/ListPage.vue";
|
import ListPage from "./pages/ListPage.vue";
|
||||||
import ProfilePage from "./pages/ProfilePage.vue";
|
import ProfilePage from "./pages/ProfilePage.vue";
|
||||||
@@ -15,9 +16,15 @@ const routes = [{
|
|||||||
component: ProgramPage,
|
component: ProgramPage,
|
||||||
props: true
|
props: true
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
name: 'course',
|
||||||
|
path: '/Program/:program_name/:course/',
|
||||||
|
component: CoursePage,
|
||||||
|
props: true,
|
||||||
|
},
|
||||||
{
|
{
|
||||||
name: 'content',
|
name: 'content',
|
||||||
path: '/Program/:program_name/:course/:type/:content',
|
path: '/Program/:program_name/:course/:topic/:type/:content',
|
||||||
component: ContentPage,
|
component: ContentPage,
|
||||||
props: true,
|
props: true,
|
||||||
beforeEnter: (to, from, next) => {
|
beforeEnter: (to, from, next) => {
|
||||||
|
|||||||
@@ -0,0 +1,11 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
# Copyright (c) 2018, Frappe Technologies and Contributors
|
||||||
|
# See license.txt
|
||||||
|
from __future__ import unicode_literals
|
||||||
|
from erpnext.education.doctype.program.test_program import make_program_and_linked_courses
|
||||||
|
|
||||||
|
import frappe
|
||||||
|
import unittest
|
||||||
|
|
||||||
|
class TestLms(unittest.TestCase):
|
||||||
|
pass
|
||||||
Reference in New Issue
Block a user