Using lms.call across the Vue app

This commit is contained in:
scmmishra 2018-11-19 15:12:39 +05:30 committed by Aditya Hase
parent 0a4902f8b5
commit 80ecc56cbe
5 changed files with 68 additions and 70 deletions

View File

@ -11,10 +11,10 @@ export default {
props: ['nextContent', 'nextContentType'],
name: 'ContentNavigation',
methods: {
goNext() {
addActivity() {
if(this.$route.params.type != "Quiz"){
frappe.call({
method: "erpnext.www.lms.add_activity",
lms.call({
method: "add_activity",
args: {
enrollment: lms.store.enrolledCourses[this.$route.params.course],
content_type: this.$route.params.type,
@ -22,29 +22,14 @@ export default {
}
})
}
},
goNext() {
this.addActivity()
this.$router.push({ name: 'content', params: { course: this.$route.params.course, type:this.nextContentType, content:this.nextContent }})
},
finish() {
if(this.$route.params.type != "Quiz"){
frappe.call({
method: "erpnext.www.lms.add_activity",
args: {
enrollment: lms.store.enrolledCourses[this.$route.params.course],
content_type: this.$route.params.type,
content: this.$route.params.content
}
})
}
frappe.call({
method: "erpnext.www.lms.mark_course_complete",
args: {
enrollment: lms.store.enrolledCourses[this.$route.params.course]
}
})
// lms.store.addCompletedCourses(this.$route.params.course)
lms.store.updateCompletedCourses()
this.addActivity()
this.$router.push({ name: 'program', params: { program_name: this.$route.params.program_name}})
//
lms.trigger('course-completed', course_name);
}

View File

@ -52,32 +52,35 @@ export default {
}
},
mounted() {
frappe.call({
method: "erpnext.www.lms.get_quiz_without_answers",
args: {
quiz_name: this.content,
}
}).then(r => {
this.quizData = r.message
this.getQuizWithoutAnswers().then(data => {
this.quizData = data
});
},
components: {
QuizSingleChoice,
},
methods: {
getQuizWithoutAnswers() {
return lms.call({
method: "get_quiz_without_answers",
args: {
quiz_name: this.content,
}
})
},
updateResponse(res) {
this.quizResponse[res.question] = (res.option)
},
submitQuiz() {
frappe.call({
method: "erpnext.www.lms.evaluate_quiz",
lms.call({
method: "evaluate_quiz",
args: {
enrollment: lms.store.enrolledCourses[this.$route.params.course],
quiz_response: this.quizResponse,
quiz_name: this.content
}
}).then(r => {
this.score = r.message,
}).then(data => {
this.score = data,
this.submitted = true,
this.quizResponse = null
});

View File

@ -17,36 +17,41 @@ export default {
},
mounted() {
if(this.isLoggedIn && this.$route.name == 'program'){
frappe.call({
method: "erpnext.www.lms.get_continue_data",
this.getContinueData().then( data => {
this.nextContent = data.content,
this.nextContentType = data.content_type,
this.nextCourse = data.course
})
}
this.computeButtons()
},
methods: {
computeButtons(){
if(this.isLoggedIn){
if(lms.store.enrolledPrograms.has(this.$route.params.program_name)){
if(this.$route.name == 'home'){
this.buttonName = 'Explore Courses'
}
else if(this.$route.name == 'program'){
this.buttonName = 'Start Course'
}
}
else {
this.buttonName = 'Enroll Now'
}
}
else{
this.buttonName = 'Sign Up'
}
},
getContinueData() {
lms.call({
method: "get_continue_data",
args: {
program_name: this.$route.params.program_name
}
}).then( r => {
this.nextContent = r.message.content,
this.nextContentType = r.message.content_type,
this.nextCourse = r.message.course
})
}
if(this.isLoggedIn){
if(lms.store.enrolledPrograms.has(this.$route.params.program_name)){
if(this.$route.name == 'home'){
this.buttonName = 'Explore Courses'
}
else if(this.$route.name == 'program'){
this.buttonName = 'Start Course'
}
}
else {
this.buttonName = 'Enroll Now'
}
}
else{
this.buttonName = 'Sign Up'
}
},
methods: {
},
primaryAction() {
if(this.$route.name == 'home'){
return
@ -55,8 +60,8 @@ export default {
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.lms.enroll_in_program",
lms.call({
method: "enroll_in_program",
args:{
program_name: this.$route.params.program_name,
student_email_id: frappe.session.user

View File

@ -66,7 +66,7 @@ frappe.ready(() => {
template: "<lms-root/>",
components: { lmsRoot },
mounted() {
lms.store.updateState()
if(lms.store.isLogin) lms.store.updateState()
}
});

View File

@ -34,18 +34,23 @@ export default {
},
},
mounted() {
frappe.call({
method: "erpnext.www.lms.get_next_content",
args:{
content: this.content,
content_type: this.type,
course: this.course
}
}).then(r => {
this.getNextContent().then(data => {
this.nextContent = r.message.content,
this.nextContentType = r.message.content_type
});
},
methods: {
getNextContent(){
return lms.call({
method: "get_next_content",
args:{
content: this.content,
content_type: this.type,
course: this.course
}
});
}
},
components: {
Article,
Video,