mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-30 02:14:48 +00:00
Course completion logic complete
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
<template>
|
<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>
|
</template>
|
||||||
<script>
|
<script>
|
||||||
export default {
|
export default {
|
||||||
@@ -12,10 +12,22 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
if(this.$root.$data.checkCourseCompletion(this.course)){
|
this.$root.$data.updateCompletedCourses()
|
||||||
this.buttonName = 'Completed'
|
}
|
||||||
this.className = 'btn-success'
|
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>
|
</script>
|
||||||
@@ -1,8 +1,8 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="nav-buttons">
|
<div class="nav-buttons">
|
||||||
<button class='btn btn-outline-secondary' @click="$router.go(-1)">Back</button>
|
<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-if="nextContent" class='btn btn-primary' @click="goNext()">Next</button>
|
||||||
<button v-show="!nextContent" class='btn btn-primary' @click="finish()">Finish Course</button>
|
<button v-else class='btn btn-primary' @click="finish()">Finish Course</button>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
@@ -12,14 +12,16 @@ export default {
|
|||||||
name: 'ContentNavigation',
|
name: 'ContentNavigation',
|
||||||
methods: {
|
methods: {
|
||||||
goNext() {
|
goNext() {
|
||||||
frappe.call({
|
if(this.$route.params.type != "Quiz"){
|
||||||
method: "erpnext.www.academy.add_activity",
|
frappe.call({
|
||||||
args: {
|
method: "erpnext.www.academy.add_activity",
|
||||||
enrollment: this.$root.$data.enrolledCourses[this.$route.params.course],
|
args: {
|
||||||
content_type: this.$route.params.type,
|
enrollment: this.$root.$data.enrolledCourses[this.$route.params.course],
|
||||||
content: this.$route.params.content
|
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 }})
|
this.$router.push({ name: 'content', params: { course: this.$route.params.course, type:this.nextContentType, content:this.nextContent }})
|
||||||
},
|
},
|
||||||
finish() {
|
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}})
|
this.$router.push({ name: 'program', params: { code: this.$route.params.code}})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ export default {
|
|||||||
name: "AcademyCoursePage",
|
name: "AcademyCoursePage",
|
||||||
data() {
|
data() {
|
||||||
return{
|
return{
|
||||||
nextContent: true,
|
nextContent: '',
|
||||||
nextContentType: '',
|
nextContentType: '',
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -89,11 +89,8 @@ def evaluate_quiz(enrollment, quiz_response, quiz_name):
|
|||||||
"""
|
"""
|
||||||
import json
|
import json
|
||||||
quiz_response = json.loads(quiz_response)
|
quiz_response = json.loads(quiz_response)
|
||||||
print(quiz_response)
|
|
||||||
quiz = frappe.get_doc("Quiz", quiz_name)
|
quiz = frappe.get_doc("Quiz", quiz_name)
|
||||||
answers, score, status = quiz.evaluate(quiz_response, 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 = {k: ('Correct' if v else 'Wrong') for k,v in answers.items()}
|
||||||
result_data = []
|
result_data = []
|
||||||
@@ -113,7 +110,6 @@ def evaluate_quiz(enrollment, quiz_response, quiz_name):
|
|||||||
|
|
||||||
@frappe.whitelist()
|
@frappe.whitelist()
|
||||||
def get_completed_courses(email=frappe.session.user):
|
def get_completed_courses(email=frappe.session.user):
|
||||||
print("Get completed course ", email)
|
|
||||||
try:
|
try:
|
||||||
student = frappe.get_doc("Student", get_student_id(email))
|
student = frappe.get_doc("Student", get_student_id(email))
|
||||||
return student.get_completed_courses()
|
return student.get_completed_courses()
|
||||||
@@ -208,5 +204,11 @@ def add_quiz_activity(enrollment, quiz_name, result_data, score, status):
|
|||||||
"status": status
|
"status": status
|
||||||
})
|
})
|
||||||
quiz_activity.save()
|
quiz_activity.save()
|
||||||
print(quiz_activity)
|
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()
|
frappe.db.commit()
|
||||||
Reference in New Issue
Block a user