From 25e42baeafe7e5d815b426b0383f3d704c36ee45 Mon Sep 17 00:00:00 2001 From: scmmishra Date: Mon, 5 Nov 2018 13:11:37 +0530 Subject: [PATCH] Course completion logic complete --- .../components/AcademyCourseCardButton.vue | 22 +++++++++++---- .../components/ContentNavigation.vue | 28 ++++++++++++------- .../web-academy/pages/AcademyCoursePage.vue | 2 +- erpnext/www/academy.py | 14 ++++++---- 4 files changed, 44 insertions(+), 22 deletions(-) diff --git a/erpnext/public/js/education/web-academy/components/AcademyCourseCardButton.vue b/erpnext/public/js/education/web-academy/components/AcademyCourseCardButton.vue index 10e52e4ccf..7ff7a6e33c 100644 --- a/erpnext/public/js/education/web-academy/components/AcademyCourseCardButton.vue +++ b/erpnext/public/js/education/web-academy/components/AcademyCourseCardButton.vue @@ -1,5 +1,5 @@ \ No newline at end of file diff --git a/erpnext/public/js/education/web-academy/components/ContentNavigation.vue b/erpnext/public/js/education/web-academy/components/ContentNavigation.vue index 738dcd9996..1ea5fca150 100644 --- a/erpnext/public/js/education/web-academy/components/ContentNavigation.vue +++ b/erpnext/public/js/education/web-academy/components/ContentNavigation.vue @@ -1,8 +1,8 @@ @@ -12,14 +12,16 @@ export default { name: 'ContentNavigation', methods: { goNext() { - frappe.call({ - method: "erpnext.www.academy.add_activity", - args: { - enrollment: this.$root.$data.enrolledCourses[this.$route.params.course], - content_type: this.$route.params.type, - content: this.$route.params.content - } - }) + if(this.$route.params.type != "Quiz"){ + frappe.call({ + method: "erpnext.www.academy.add_activity", + args: { + enrollment: this.$root.$data.enrolledCourses[this.$route.params.course], + content_type: this.$route.params.type, + content: this.$route.params.content + } + }) + } this.$router.push({ name: 'content', params: { course: this.$route.params.course, type:this.nextContentType, content:this.nextContent }}) }, finish() { @@ -33,6 +35,12 @@ export default { } }) } + frappe.call({ + method: "erpnext.www.academy.mark_course_complete", + args: { + enrollment: this.$root.$data.enrolledCourses[this.$route.params.course] + } + }) this.$router.push({ name: 'program', params: { code: this.$route.params.code}}) } } diff --git a/erpnext/public/js/education/web-academy/pages/AcademyCoursePage.vue b/erpnext/public/js/education/web-academy/pages/AcademyCoursePage.vue index 4149f4d10e..ca5434b765 100644 --- a/erpnext/public/js/education/web-academy/pages/AcademyCoursePage.vue +++ b/erpnext/public/js/education/web-academy/pages/AcademyCoursePage.vue @@ -16,7 +16,7 @@ export default { name: "AcademyCoursePage", data() { return{ - nextContent: true, + nextContent: '', nextContentType: '', } }, diff --git a/erpnext/www/academy.py b/erpnext/www/academy.py index 69faeba85d..d68dee43c5 100644 --- a/erpnext/www/academy.py +++ b/erpnext/www/academy.py @@ -89,11 +89,8 @@ def evaluate_quiz(enrollment, quiz_response, quiz_name): """ import json quiz_response = json.loads(quiz_response) - print(quiz_response) quiz = frappe.get_doc("Quiz", quiz_name) answers, score, status = quiz.evaluate(quiz_response, quiz_name) - print("-----------------") - print(answers) result = {k: ('Correct' if v else 'Wrong') for k,v in answers.items()} result_data = [] @@ -113,7 +110,6 @@ def evaluate_quiz(enrollment, quiz_response, quiz_name): @frappe.whitelist() def get_completed_courses(email=frappe.session.user): - print("Get completed course ", email) try: student = frappe.get_doc("Student", get_student_id(email)) return student.get_completed_courses() @@ -208,5 +204,11 @@ def add_quiz_activity(enrollment, quiz_name, result_data, score, status): "status": status }) quiz_activity.save() - print(quiz_activity) - frappe.db.commit() \ No newline at end of file + frappe.db.commit() + +@frappe.whitelist() +def mark_course_complete(enrollment): + course_enrollment = frappe.get_doc("Course Enrollment", enrollment) + course_enrollment.completed = True + course_enrollment.save() + frappe.db.commit()