Fixed course and content page
diff --git a/erpnext/education/doctype/course_enrollment/course_enrollment.json b/erpnext/education/doctype/course_enrollment/course_enrollment.json
index 5de7f21..a5b4289 100644
--- a/erpnext/education/doctype/course_enrollment/course_enrollment.json
+++ b/erpnext/education/doctype/course_enrollment/course_enrollment.json
@@ -62,7 +62,7 @@
    "in_filter": 0, 
    "in_global_search": 0, 
    "in_list_view": 0, 
-   "in_standard_filter": 0, 
+   "in_standard_filter": 1, 
    "label": "Student", 
    "length": 0, 
    "no_copy": 0, 
@@ -190,7 +190,7 @@
  "issingle": 0, 
  "istable": 0, 
  "max_attachments": 0, 
- "modified": "2018-11-07 21:16:34.764628", 
+ "modified": "2018-11-09 19:23:07.967967", 
  "modified_by": "Administrator", 
  "module": "Education", 
  "name": "Course Enrollment", 
diff --git a/erpnext/public/js/education/academy/components/AcademyCourseCard.vue b/erpnext/public/js/education/academy/components/AcademyCourseCard.vue
index eda382f..16ffc55 100644
--- a/erpnext/public/js/education/academy/components/AcademyCourseCard.vue
+++ b/erpnext/public/js/education/academy/components/AcademyCourseCard.vue
@@ -11,29 +11,13 @@
                     </ul>
                 </span>
             </div>
-            <div v-if="$root.$data.isLogin" class='course-buttons text-center col-xs-4 col-sm-3 col-md-2'>
-                <!-- <AcademyCourseCardButton
-                    v-if="this.$root.$data.checkProgramEnrollment(this.$route.params.code)"
-                    :course="course.name"
-                    :nextContent="nextContent"
-                    :nextContentType="nextContentType"
-                /> -->
-
+            <div class='course-buttons text-center col-xs-4 col-sm-3 col-md-2'>
                 <a-button
-                    v-if="showCompleted"
-                    type="success"
-                    size="sm"
+                    :type="buttonType"
+                    size="sm btn-block"
                     :route="firstContentRoute"
                 >
-                    Completed
-                </a-button>
-                <a-button
-                    v-if="showStart"
-                    type="primary"
-                    size="sm"
-                    :route="firstContentRoute"
-                >
-                    Start
+                    {{ courseMeta.flag }}
                 </a-button>
             </div>
         </div>
@@ -42,44 +26,36 @@
 </template>
 
 <script>
-import AButton from './Button';
+import AButton from './Button.vue';
 import AcademyCourseCardButton from './AcademyCourseCardButton.vue'
 
 export default {
-    props: ['course'],
+    props: ['course', 'courseMeta', 'program_name'],
     name: "AcademyCourseCard",
-    data() {
-        return {
-            nextContent: '',
-            nextContentType: ''
-        }
-    },
-    mounted() {
-        if(this.$root.$data.checkLogin()) {
-            frappe.call({
-                method: "erpnext.www.academy.get_starting_content",
-                args: {
-                    course_name: this.course.name
-                }
-            }).then(r => {
-                this.nextContent = r.message.content,
-                this.nextContentType = r.message.content_type
-            });
-        }
-    },
     components: {
         AcademyCourseCardButton,
         AButton
     },
     computed: {
         showStart() {
-            return academy.loggedIn && !this.course.completed;
+            return academy.loggedIn && !this.courseMeta.flag == "Completed";
         },
         showCompleted() {
-            return academy.loggedIn && this.course.completed;
+            return academy.loggedIn && this.courseMeta.flag == "Completed";
         },
         firstContentRoute() {
-            return `${course.name}/${course.content_type}/${data.content}`
+            return `${this.program_name}/${this.course.name}/${this.courseMeta.content_type}/${this.courseMeta.content}`
+        },
+        buttonType() {
+            if (this.courseMeta.flag == "Start" ){
+                return "primary"
+            }
+            else if (this.courseMeta.flag == "Complete" ) {
+                return "success"
+            }
+            else {
+                return "info"
+            }
         }
     }
 };
diff --git a/erpnext/public/js/education/academy/components/AcademyCourseCardButton.vue b/erpnext/public/js/education/academy/components/AcademyCourseCardButton.vue
index b0d8859..698eca0 100644
--- a/erpnext/public/js/education/academy/components/AcademyCourseCardButton.vue
+++ b/erpnext/public/js/education/academy/components/AcademyCourseCardButton.vue
@@ -13,7 +13,7 @@
     },
     computed: {
         getButtonName: function() {
-            if(this.$root.$data.checkCourseCompletion(this.course)){
+            if(academy.store.checkCourseCompletion(this.course)){
                 return 'Completed'
             }
             else{
@@ -21,7 +21,7 @@
             }
         },
         getClassName: function() {
-            if(this.$root.$data.checkCourseCompletion(this.course)){
+            if(academy.store.checkCourseCompletion(this.course)){
                 return 'btn-success'
             }
         }
diff --git a/erpnext/public/js/education/academy/components/AcademyTopSectionButton.vue b/erpnext/public/js/education/academy/components/AcademyTopSectionButton.vue
index 8cc3a7b..2bab29d 100644
--- a/erpnext/public/js/education/academy/components/AcademyTopSectionButton.vue
+++ b/erpnext/public/js/education/academy/components/AcademyTopSectionButton.vue
@@ -8,7 +8,7 @@
     data() {
         return {
             buttonName: '',
-            isLoggedIn: this.$root.$data.checkLogin(),
+            isLoggedIn: academy.store.checkLogin(),
             nextContent: '',
             nextContentType: '',
             nextCourse: '',
@@ -20,7 +20,7 @@
                 frappe.call({
                     method: "erpnext.www.academy.get_continue_data",
                     args: {
-                        program_name: this.$route.params.code
+                        program_name: this.$route.params.program_name
                     }
                 }).then( r => {
                     this.nextContent = r.message.content,
@@ -30,7 +30,7 @@
         }
 
         if(this.isLoggedIn){
-            if(this.$root.$data.checkProgramEnrollment(this.$route.params.code)){
+            if(academy.store.checkProgramEnrollment(this.$route.params.program_name)){
             	if(this.$route.name == 'home'){
                     this.buttonName = 'Explore Courses'
             	}
@@ -51,18 +51,18 @@
             if(this.$route.name == 'home'){
                 return
             }
-            else if(this.$route.name == 'program' && this.$root.$data.checkProgramEnrollment(this.$route.params.code)){
-                this.$router.push({ name: 'content', params: { code: this.$route.params.code, course: this.nextCourse, type: this.nextContentType, content: this.nextContent}})
+            else if(this.$route.name == 'program' && academy.store.checkProgramEnrollment(this.$route.params.program_name)){
+                this.$router.push({ name: 'content', params: { program_name: this.$route.params.program_name, course: this.nextCourse, type: this.nextContentType, content: this.nextContent}})
             }
             else {
                 frappe.call({
                 method: "erpnext.www.academy.enroll_in_program",
                 args:{
-                    program_name: this.$route.params.code,
+                    program_name: this.$route.params.program_name,
                     student_email_id: frappe.session.user
                 }
                 })
-                this.$root.$data.updateEnrolledPrograms()
+                academy.store.updateEnrolledPrograms()
             }
         },
     }
diff --git a/erpnext/public/js/education/academy/components/ContentNavigation.vue b/erpnext/public/js/education/academy/components/ContentNavigation.vue
index 7fa20a5..8c8280c 100644
--- a/erpnext/public/js/education/academy/components/ContentNavigation.vue
+++ b/erpnext/public/js/education/academy/components/ContentNavigation.vue
@@ -16,7 +16,7 @@
 				frappe.call({
 					method: "erpnext.www.academy.add_activity",
 					args: {
-						enrollment: this.$root.$data.enrolledCourses[this.$route.params.course],
+						enrollment: academy.store.enrolledCourses[this.$route.params.course],
 						content_type: this.$route.params.type,
 						content: this.$route.params.content
 					}
@@ -29,7 +29,7 @@
 				frappe.call({
 					method: "erpnext.www.academy.add_activity",
 					args: {
-						enrollment: this.$root.$data.enrolledCourses[this.$route.params.course],
+						enrollment: academy.store.enrolledCourses[this.$route.params.course],
 						content_type: this.$route.params.type,
 						content: this.$route.params.content
 					}
@@ -38,12 +38,12 @@
 			frappe.call({
 					method: "erpnext.www.academy.mark_course_complete",
 					args: {
-						enrollment: this.$root.$data.enrolledCourses[this.$route.params.course]
+						enrollment: academy.store.enrolledCourses[this.$route.params.course]
 					}
 				})
-			// this.$root.$data.addCompletedCourses(this.$route.params.course)
-			this.$root.$data.updateCompletedCourses()
-			this.$router.push({ name: 'program', params: { code: this.$route.params.code}})
+			// academy.store.addCompletedCourses(this.$route.params.course)
+			academy.store.updateCompletedCourses()
+			this.$router.push({ name: 'program', params: { program_name: this.$route.params.program_name}})
 
 			//
 			academy.trigger('course-completed', course_name);
diff --git a/erpnext/public/js/education/academy/components/ContentQuiz.vue b/erpnext/public/js/education/academy/components/ContentQuiz.vue
index 7044d76..b13b5e6 100644
--- a/erpnext/public/js/education/academy/components/ContentQuiz.vue
+++ b/erpnext/public/js/education/academy/components/ContentQuiz.vue
@@ -72,7 +72,7 @@
 			frappe.call({
 				method: "erpnext.www.academy.evaluate_quiz",
 				args: {
-                    enrollment: this.$root.$data.enrolledCourses[this.$route.params.course],
+                    enrollment: academy.store.enrolledCourses[this.$route.params.course],
 					quiz_response: this.quizResponse,
                     quiz_name: this.content
 				}
diff --git a/erpnext/public/js/education/academy/pages/AcademyCoursePage.vue b/erpnext/public/js/education/academy/pages/AcademyCoursePage.vue
index ca5434b..81cf4ff 100644
--- a/erpnext/public/js/education/academy/pages/AcademyCoursePage.vue
+++ b/erpnext/public/js/education/academy/pages/AcademyCoursePage.vue
@@ -12,7 +12,7 @@
 import ContentNavigation from "../components/ContentNavigation.vue"
 
 export default {
-	props:['code', 'course', 'type', 'content'],
+	props:['program_name', 'course', 'type', 'content'],
 	name: "AcademyCoursePage",
 	data() {
 		return{
diff --git a/erpnext/public/js/education/academy/pages/AcademyProgramPage.vue b/erpnext/public/js/education/academy/pages/AcademyProgramPage.vue
index 7bea1ed..607524a 100644
--- a/erpnext/public/js/education/academy/pages/AcademyProgramPage.vue
+++ b/erpnext/public/js/education/academy/pages/AcademyProgramPage.vue
@@ -1,12 +1,11 @@
 <template>
 <div>
 	<AcademyTopSection v-bind:title="program.program_name" v-bind:description="program.description">
-        <!-- <AcademyTopSectionButton/> -->
-		<a-button @click="startCourse">Start Course</a-button>
-		<a-button @click="continueCourse">Continue Course</a-button>
+		<!-- <a-button @click="startCourse">Start Course</a-button>
+		<a-button @click="continueCourse">Continue Course</a-button> -->
     </AcademyTopSection>
 	<AcademyList :title="'Courses'" :description="''">
-        <AcademyCourseCard v-for="course in course_list" :course="course" :key="course.name"/>
+        <AcademyCourseCard v-for="course in course_data" :course="course.course" :program_name="program_name" :courseMeta="course.meta" :key="course.meta.flag"/>
     </AcademyList>
 </div>
 </template>
@@ -15,7 +14,6 @@
 import AcademyTopSection from "../components/AcademyTopSection.vue"
 import AcademyList from "../components/AcademyList.vue"
 import AcademyCourseCard from "../components/AcademyCourseCard.vue"
-import AcademyTopSectionButton from "../components/AcademyTopSectionButton.vue";
 
 
 export default {
@@ -25,26 +23,25 @@
         AButton: Button,
 		AcademyTopSection,
 		AcademyList,
-		AcademyCourseCard,
-        AcademyTopSectionButton
+		AcademyCourseCard
 	},
 	data() {
 		return {
 			program: {},
-			course_list: []
+			course_data: []
 		}
 	},
     beforeMount() {
-        if(this.$root.$data.isLogin) this.$root.$data.updateCompletedCourses()
+        if(academy.store.isLogin) academy.store.updateCompletedCourses()
     },
 	mounted() {
 		this.getProgramDetails().then(data => this.program = data);
-		this.getCourses().then(data => this.course_list = data);
+		this.getCourses().then(data => this.course_data = data);
 		
-		academy.on(`course-completed`, (course_name) => {
-			const course = this.course_list.findIndex(c => c.name === course_name);
-			this.course_list[course].completed = true;
-		});
+		// academy.on(`course-completed`, (course_name) => {
+		// 	const course = this.course_data.findIndex(c => c.name === course_name);
+		// 	this.course_data[course].completed = true;
+		// });
 	},
 	methods: {
 		startCourse() {
diff --git a/erpnext/public/js/education/academy/routes.js b/erpnext/public/js/education/academy/routes.js
index 7896b1d..8e4e865 100644
--- a/erpnext/public/js/education/academy/routes.js
+++ b/erpnext/public/js/education/academy/routes.js
@@ -5,7 +5,7 @@
 const routes = [
 	{name: 'home', path: '', component: AcademyHome},
 	{name: 'program', path: '/Program/:program_name', component: AcademyProgramPage, props: true},
-	{name: 'content', path: '/Program/:code/:course/:type/:content', component: AcademyCoursePage, props: true},
+	{name: 'content', path: '/Program/:program_name/:course/:type/:content', component: AcademyCoursePage, props: true},
 ];
 
 export default routes;
\ No newline at end of file
diff --git a/erpnext/www/academy.py b/erpnext/www/academy.py
index 87eabcb..48cbbc4 100644
--- a/erpnext/www/academy.py
+++ b/erpnext/www/academy.py
@@ -33,6 +33,14 @@
 	is_enrolled = check_program_enrollment(program_name)
 	return {'program': program, 'is_enrolled': is_enrolled}
 
+@frappe.whitelist(allow_guest=True)
+def get_program_details(program_name):
+	try:
+		program = frappe.get_doc('Program', program_name)
+		return program
+	except:
+		return None
+
 
 def get_enrollment(course_name):
 	student = get_student_id(frappe.session.user)
@@ -68,14 +76,6 @@
 
 # Functions to get program & course details
 @frappe.whitelist(allow_guest=True)
-def get_program_details(program_name):
-	try:
-		program = frappe.get_doc('Program', program_name)
-		return program
-	except:
-		return None
-
-@frappe.whitelist(allow_guest=True)
 def get_courses(program_name):
 	program = frappe.get_doc('Program', program_name)
 	courses = program.get_course_list()
@@ -84,6 +84,8 @@
 
 @frappe.whitelist()
 def get_continue_content(course_name):
+	if(frappe.session.user == "Guest"):
+		return None
 	enrollment = get_enrollment(course_name)
 	course = frappe.get_doc("Course", enrollment.course)
 	last_activity = enrollment.get_last_activity()
@@ -203,15 +205,16 @@
 
 @frappe.whitelist()
 def enroll_all_courses_in_program(program_enrollment, student):
-	course_list = [course.name for course in get_courses(program_enrollment.program)]
+	program = frappe.get_doc("Program", program_enrollment.program)
+	course_list = [course.course for course in program.get_all_children()]
 	for course_name in course_list:
 		student.enroll_in_course(course_name=course_name, program_enrollment=program_enrollment.name)
 
 @frappe.whitelist()
-def enroll_in_program(program_name, student_email_id):
-	if(not get_student_id(student_email_id)):
-		create_student(student_email_id)
-	student = frappe.get_doc("Student", get_student_id(student_email_id))
+def enroll_in_program(program_name):
+	if(not get_student_id(frappe.session.user)):
+		create_student(frappe.session.user)
+	student = frappe.get_doc("Student", get_student_id(frappe.session.user))
 	program_enrollment = student.enroll_in_program(program_name)
 	enroll_all_courses_in_program(program_enrollment, student)