diff --git a/erpnext/education/doctype/program/program.py b/erpnext/education/doctype/program/program.py
index 38bdb8129b0..dbeda40775f 100644
--- a/erpnext/education/doctype/program/program.py
+++ b/erpnext/education/doctype/program/program.py
@@ -9,6 +9,6 @@ from frappe.model.document import Document
class Program(Document):
def get_course_list(self):
- course_content_list = self.get_all_children()
- course_list = [frappe.get_doc("Course", course_item.course) for course_item in course_content_list]
+ program_course_list = self.get_all_children()
+ course_list = [frappe.get_doc("Course", program_course.course) for program_course in program_course_list]
return course_list
\ No newline at end of file
diff --git a/erpnext/public/js/education/lms/components/CourseCard.vue b/erpnext/public/js/education/lms/components/CourseCard.vue
index ee4ad9571f2..b255a90cba8 100644
--- a/erpnext/public/js/education/lms/components/CourseCard.vue
+++ b/erpnext/public/js/education/lms/components/CourseCard.vue
@@ -5,24 +5,21 @@
{{ course.course_name }}
- Course Content
+ Topics
- -
-
- {{ content.content }}
-
-
{{ content.content }}
+ -
+
{{ topic.topic_name }}
-
- {{ buttonName }}
+ View Course
@@ -36,65 +33,12 @@ 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)
- },
- 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
- })
+ courseRoute() {
+ return `${this.program_name}/${this.course.name}`
},
}
};
@@ -106,11 +50,4 @@ export default {
margin-top: 1em;
}
}
- li {
- list-style-type: none;
- padding: 0;
- }
- .fa {
- font-size: 0.8em;
- }
\ No newline at end of file
diff --git a/erpnext/public/js/education/lms/components/TopicCard.vue b/erpnext/public/js/education/lms/components/TopicCard.vue
new file mode 100644
index 00000000000..a4fc808226f
--- /dev/null
+++ b/erpnext/public/js/education/lms/components/TopicCard.vue
@@ -0,0 +1,118 @@
+
+
+
+
+
+
+
{{ course.course_name }}
+
+ Topics
+
+ -
+
+ {{ topic.topic_name }}
+
+
{{ topic.topic_name }}
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/erpnext/public/js/education/lms/lms.js b/erpnext/public/js/education/lms/lms.js
index 9e902a8bd54..5fb7b7d558a 100644
--- a/erpnext/public/js/education/lms/lms.js
+++ b/erpnext/public/js/education/lms/lms.js
@@ -24,7 +24,7 @@ frappe.ready(() => {
data: store,
methods: {
updateEnrolledPrograms() {
- if(this.isLogin) {
+ if(this.checkLogin()) {
lms.call("get_program_enrollments").then(data => {
this.enrolledPrograms = data
});
@@ -32,7 +32,7 @@ frappe.ready(() => {
}
},
updateEnrolledCourses() {
- if(this.isLogin) {
+ if(this.checkLogin()) {
lms.call("get_all_course_enrollments").then(data => {
this.enrolledCourses = data
})
@@ -40,15 +40,7 @@ frappe.ready(() => {
}
},
checkLogin() {
- if(frappe.session.user === "Guest"){
- 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
+ return frappe.is_user_logged_in()
},
updateState() {
this.checkLogin()
@@ -81,7 +73,7 @@ frappe.ready(() => {
template: "",
components: { lmsRoot },
mounted() {
- if(lms.store.isLogin) lms.store.updateState()
+ lms.store.updateState()
}
});
lms.view.$router.afterEach((to, from) => {
diff --git a/erpnext/public/js/education/lms/pages/CoursePage.vue b/erpnext/public/js/education/lms/pages/CoursePage.vue
new file mode 100644
index 00000000000..bc0ccf889b0
--- /dev/null
+++ b/erpnext/public/js/education/lms/pages/CoursePage.vue
@@ -0,0 +1,47 @@
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/erpnext/public/js/education/lms/pages/ProgramPage.vue b/erpnext/public/js/education/lms/pages/ProgramPage.vue
index fd216ea17de..9d7148de93e 100644
--- a/erpnext/public/js/education/lms/pages/ProgramPage.vue
+++ b/erpnext/public/js/education/lms/pages/ProgramPage.vue
@@ -27,29 +27,11 @@ export default {
courseData: [],
}
},
- beforeMount() {
- // if(lms.store.isLogin) lms.store.updateCompletedCourses()
- },
mounted() {
this.getProgramDetails().then(data => this.program = 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: {
- // 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() {
return lms.call('get_program_details', {
program_name: this.program_name
diff --git a/erpnext/public/js/education/lms/routes.js b/erpnext/public/js/education/lms/routes.js
index b0ef17f4337..c1259c9a0c9 100644
--- a/erpnext/public/js/education/lms/routes.js
+++ b/erpnext/public/js/education/lms/routes.js
@@ -1,5 +1,6 @@
import Home from "./pages/Home.vue";
import ProgramPage from "./pages/ProgramPage.vue";
+import CoursePage from "./pages/CoursePage.vue";
import ContentPage from "./pages/ContentPage.vue";
import ListPage from "./pages/ListPage.vue";
import ProfilePage from "./pages/ProfilePage.vue";
@@ -15,9 +16,15 @@ const routes = [{
component: ProgramPage,
props: true
},
+ {
+ name: 'course',
+ path: '/Program/:program_name/:course/',
+ component: CoursePage,
+ props: true,
+ },
{
name: 'content',
- path: '/Program/:program_name/:course/:type/:content',
+ path: '/Program/:program_name/:course/:topic/:type/:content',
component: ContentPage,
props: true,
beforeEnter: (to, from, next) => {
diff --git a/erpnext/www/test_lms.py b/erpnext/www/test_lms.py
index e69de29bb2d..e63f4c913e0 100644
--- a/erpnext/www/test_lms.py
+++ b/erpnext/www/test_lms.py
@@ -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
\ No newline at end of file