2018-11-01 11:50:04 +00:00
|
|
|
<template>
|
2018-11-01 14:21:33 +00:00
|
|
|
<section class="quiz-section">
|
|
|
|
<div class='container'>
|
|
|
|
<div class="row">
|
|
|
|
<div class="col-md-8">
|
|
|
|
<h2>{{ content }}</h2>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div class="content">
|
|
|
|
<hr>
|
2018-11-02 10:59:04 +00:00
|
|
|
<div id="quiz" :name="content">
|
2018-11-01 14:21:33 +00:00
|
|
|
<div id="quiz-body">
|
2018-11-02 07:21:51 +00:00
|
|
|
<QuizSingleChoice v-for="question in quizData" :key="question.name" :question="question" @updateResponse="updateResponse"/>
|
2018-11-01 14:21:33 +00:00
|
|
|
</div>
|
|
|
|
<div class="mt-3">
|
2018-11-02 10:59:04 +00:00
|
|
|
<div>
|
|
|
|
<div v-if="submitted" id="post-quiz-actions" class="row">
|
|
|
|
<div class="col-md-8 text-left">
|
|
|
|
<h3>Your Score: <span id="result">{{ score }}</span></h3>
|
|
|
|
</div>
|
|
|
|
<div class="col-md-4 text-right">
|
|
|
|
<slot></slot>
|
|
|
|
</div>
|
2018-11-01 14:21:33 +00:00
|
|
|
</div>
|
2018-11-02 10:59:04 +00:00
|
|
|
<div v-else id="quiz-actions" class="text-right">
|
|
|
|
<button class='btn btn-outline-secondary' type="reset">Reset</button>
|
|
|
|
<button class='btn btn-primary' @click="submitQuiz" type="button">Submit</button>
|
2018-11-01 14:21:33 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
2018-11-02 10:59:04 +00:00
|
|
|
</div>
|
2018-11-01 14:21:33 +00:00
|
|
|
</div>
|
|
|
|
<div class="mt-3 text-right">
|
|
|
|
<a class="text-muted" href="/report"><i class="octicon octicon-issue-opened" title="Report"></i> Report a
|
|
|
|
Mistake</a>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</section>
|
2018-11-01 11:50:04 +00:00
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
2018-11-01 14:21:33 +00:00
|
|
|
import QuizSingleChoice from "./Quiz/QuizSingleChoice.vue"
|
2018-11-01 11:50:04 +00:00
|
|
|
export default {
|
2018-11-01 14:21:33 +00:00
|
|
|
props: ['content', 'type'],
|
2018-11-13 11:54:07 +00:00
|
|
|
name: 'Quiz',
|
2018-11-01 14:21:33 +00:00
|
|
|
data() {
|
|
|
|
return {
|
2018-11-02 07:21:51 +00:00
|
|
|
quizData: '',
|
2018-11-02 10:59:04 +00:00
|
|
|
quizResponse: {},
|
|
|
|
score: '',
|
|
|
|
submitted: false
|
2018-11-01 14:21:33 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
mounted() {
|
|
|
|
frappe.call({
|
2018-11-13 11:05:34 +00:00
|
|
|
method: "erpnext.www.lms.get_quiz_without_answers",
|
2018-11-01 14:21:33 +00:00
|
|
|
args: {
|
|
|
|
quiz_name: this.content,
|
|
|
|
}
|
|
|
|
}).then(r => {
|
|
|
|
this.quizData = r.message
|
|
|
|
});
|
|
|
|
},
|
|
|
|
components: {
|
|
|
|
QuizSingleChoice,
|
2018-11-02 07:21:51 +00:00
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
updateResponse(res) {
|
|
|
|
this.quizResponse[res.question] = (res.option)
|
2018-11-02 07:45:49 +00:00
|
|
|
},
|
|
|
|
submitQuiz() {
|
|
|
|
frappe.call({
|
2018-11-13 11:05:34 +00:00
|
|
|
method: "erpnext.www.lms.evaluate_quiz",
|
2018-11-02 07:45:49 +00:00
|
|
|
args: {
|
2018-11-13 11:17:46 +00:00
|
|
|
enrollment: lms.store.enrolledCourses[this.$route.params.course],
|
2018-11-02 10:59:04 +00:00
|
|
|
quiz_response: this.quizResponse,
|
|
|
|
quiz_name: this.content
|
2018-11-02 07:45:49 +00:00
|
|
|
}
|
2018-11-02 10:59:04 +00:00
|
|
|
}).then(r => {
|
|
|
|
this.score = r.message,
|
|
|
|
this.submitted = true,
|
|
|
|
this.quizResponse = null
|
|
|
|
});
|
2018-11-02 07:21:51 +00:00
|
|
|
}
|
|
|
|
}
|
2018-11-01 11:50:04 +00:00
|
|
|
};
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style lang="css" scoped>
|
|
|
|
</style>
|