Course completion logic complete
This commit is contained in:
parent
a920bca044
commit
25e42baeaf
@ -1,5 +1,5 @@
|
||||
<template>
|
||||
<button :class="className" class='btn btn-primary btn-sm btn-block' @click="$router.push($route.path + '/' + course + '/' + nextContentType + '/' + nextContent)">{{ buttonName }}</button>
|
||||
<button :class="getClassName" class='btn btn-primary btn-sm btn-block' @click="$router.push($route.path + '/' + course + '/' + nextContentType + '/' + nextContent)">{{ getButtonName }}</button>
|
||||
</template>
|
||||
<script>
|
||||
export default {
|
||||
@ -12,10 +12,22 @@ export default {
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
if(this.$root.$data.checkCourseCompletion(this.course)){
|
||||
this.buttonName = 'Completed'
|
||||
this.className = 'btn-success'
|
||||
}
|
||||
this.$root.$data.updateCompletedCourses()
|
||||
}
|
||||
computed: {
|
||||
getButtonName: function() {
|
||||
if(this.$root.$data.checkCourseCompletion(this.course)){
|
||||
return 'Completed'
|
||||
}
|
||||
else{
|
||||
return 'Start'
|
||||
}
|
||||
},
|
||||
getClassName: function() {
|
||||
if(this.$root.$data.checkCourseCompletion(this.course)){
|
||||
return 'btn-success'
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
@ -1,8 +1,8 @@
|
||||
<template>
|
||||
<div class="nav-buttons">
|
||||
<button class='btn btn-outline-secondary' @click="$router.go(-1)">Back</button>
|
||||
<button v-show="nextContent" class='btn btn-primary' @click="goNext()">Next</button>
|
||||
<button v-show="!nextContent" class='btn btn-primary' @click="finish()">Finish Course</button>
|
||||
<button v-if="nextContent" class='btn btn-primary' @click="goNext()">Next</button>
|
||||
<button v-else class='btn btn-primary' @click="finish()">Finish Course</button>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
@ -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}})
|
||||
}
|
||||
}
|
||||
|
@ -16,7 +16,7 @@ export default {
|
||||
name: "AcademyCoursePage",
|
||||
data() {
|
||||
return{
|
||||
nextContent: true,
|
||||
nextContent: '',
|
||||
nextContentType: '',
|
||||
}
|
||||
},
|
||||
|
@ -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()
|
||||
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()
|
||||
|
Loading…
x
Reference in New Issue
Block a user