Quiz: Save responses as an object
diff --git a/erpnext/education/doctype/quiz/quiz.json b/erpnext/education/doctype/quiz/quiz.json
index 6284d92..25b9690 100644
--- a/erpnext/education/doctype/quiz/quiz.json
+++ b/erpnext/education/doctype/quiz/quiz.json
@@ -154,7 +154,7 @@
"issingle": 0,
"istable": 0,
"max_attachments": 0,
- "modified": "2018-10-17 06:57:18.235274",
+ "modified": "2018-11-02 10:58:56.590859",
"modified_by": "Administrator",
"module": "Education",
"name": "Quiz",
@@ -179,6 +179,25 @@
"share": 1,
"submit": 0,
"write": 1
+ },
+ {
+ "amend": 0,
+ "cancel": 0,
+ "create": 0,
+ "delete": 0,
+ "email": 1,
+ "export": 1,
+ "if_owner": 0,
+ "import": 0,
+ "permlevel": 0,
+ "print": 1,
+ "read": 1,
+ "report": 1,
+ "role": "LMS User",
+ "set_user_permissions": 0,
+ "share": 1,
+ "submit": 0,
+ "write": 0
}
],
"quick_entry": 1,
diff --git a/erpnext/public/js/education/web-academy/components/ContentQuiz.vue b/erpnext/public/js/education/web-academy/components/ContentQuiz.vue
index adff3cc..3828cdf 100644
--- a/erpnext/public/js/education/web-academy/components/ContentQuiz.vue
+++ b/erpnext/public/js/education/web-academy/components/ContentQuiz.vue
@@ -6,11 +6,12 @@
<h2>{{ content }}</h2>
</div>
</div>
+ {{ quizResponse }}
<div class="content">
<hr>
<form id="quiz" :name="content">
<div id="quiz-body">
- <QuizSingleChoice v-for="question in quizData" :key="question.name" :question="question"/>
+ <QuizSingleChoice v-for="question in quizData" :key="question.name" :question="question" @updateResponse="updateResponse"/>
</div>
<div class="mt-3">
<div id="quiz-actions" class="text-right">
@@ -43,7 +44,8 @@
name: 'ContentQuiz',
data() {
return {
- quizData: ''
+ quizData: '',
+ quizResponse: {}
}
},
mounted() {
@@ -58,7 +60,12 @@
},
components: {
QuizSingleChoice,
- }
+ },
+ methods: {
+ updateResponse(res) {
+ this.quizResponse[res.question] = (res.option)
+ }
+ }
};
</script>
diff --git a/erpnext/public/js/education/web-academy/components/Quiz/QuizSingleChoice.vue b/erpnext/public/js/education/web-academy/components/Quiz/QuizSingleChoice.vue
index 0e28a14..492c265 100644
--- a/erpnext/public/js/education/web-academy/components/Quiz/QuizSingleChoice.vue
+++ b/erpnext/public/js/education/web-academy/components/Quiz/QuizSingleChoice.vue
@@ -2,12 +2,13 @@
<div class="question mt-4">
<h5>{{ question.question }}</h5>
<div class="options ml-2">
- <div v-for="option in question.options" class="form-check pb-1">
- <input class="form-check-input" type="radio" :name="question.name" :id="option.option" :value="option.option">
- <label class="form-check-label" :for="option.option">
+ <div v-for="option in question.options" :key="option.name" class="form-check pb-1">
+ <input class="form-check-input" type="radio" :name="question.name" :id="option.name" :value="option.name" @change="emitResponse(question.name, option.name)" v-model="picked">
+ <label class="form-check-label" :for="option.name">
{{ option.option }}
</label>
</div>
+ <span>Picked: {{ picked }}</span>
</div>
</div>
</template>
@@ -16,6 +17,16 @@
export default {
props: ['question'],
name: 'QuizSingleChoice',
+ data() {
+ return {
+ picked: ''
+ }
+ },
+ methods: {
+ emitResponse(q, o) {
+ this.$emit('updateResponse', {'question':q , 'option': o})
+ }
+ }
};
</script>