mirror of
https://github.com/frappe/erpnext.git
synced 2026-06-08 15:42:52 +00:00
Quiz: Save responses as an object
This commit is contained in:
@@ -154,7 +154,7 @@
|
|||||||
"issingle": 0,
|
"issingle": 0,
|
||||||
"istable": 0,
|
"istable": 0,
|
||||||
"max_attachments": 0,
|
"max_attachments": 0,
|
||||||
"modified": "2018-10-17 06:57:18.235274",
|
"modified": "2018-11-02 10:58:56.590859",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"module": "Education",
|
"module": "Education",
|
||||||
"name": "Quiz",
|
"name": "Quiz",
|
||||||
@@ -179,6 +179,25 @@
|
|||||||
"share": 1,
|
"share": 1,
|
||||||
"submit": 0,
|
"submit": 0,
|
||||||
"write": 1
|
"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,
|
"quick_entry": 1,
|
||||||
|
|||||||
@@ -6,11 +6,12 @@
|
|||||||
<h2>{{ content }}</h2>
|
<h2>{{ content }}</h2>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
{{ quizResponse }}
|
||||||
<div class="content">
|
<div class="content">
|
||||||
<hr>
|
<hr>
|
||||||
<form id="quiz" :name="content">
|
<form id="quiz" :name="content">
|
||||||
<div id="quiz-body">
|
<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>
|
||||||
<div class="mt-3">
|
<div class="mt-3">
|
||||||
<div id="quiz-actions" class="text-right">
|
<div id="quiz-actions" class="text-right">
|
||||||
@@ -43,7 +44,8 @@ export default {
|
|||||||
name: 'ContentQuiz',
|
name: 'ContentQuiz',
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
quizData: ''
|
quizData: '',
|
||||||
|
quizResponse: {}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
@@ -58,6 +60,11 @@ export default {
|
|||||||
},
|
},
|
||||||
components: {
|
components: {
|
||||||
QuizSingleChoice,
|
QuizSingleChoice,
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
updateResponse(res) {
|
||||||
|
this.quizResponse[res.question] = (res.option)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@@ -2,12 +2,13 @@
|
|||||||
<div class="question mt-4">
|
<div class="question mt-4">
|
||||||
<h5>{{ question.question }}</h5>
|
<h5>{{ question.question }}</h5>
|
||||||
<div class="options ml-2">
|
<div class="options ml-2">
|
||||||
<div v-for="option in question.options" class="form-check pb-1">
|
<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.option" :value="option.option">
|
<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.option">
|
<label class="form-check-label" :for="option.name">
|
||||||
{{ option.option }}
|
{{ option.option }}
|
||||||
</label>
|
</label>
|
||||||
</div>
|
</div>
|
||||||
|
<span>Picked: {{ picked }}</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
@@ -16,6 +17,16 @@
|
|||||||
export default {
|
export default {
|
||||||
props: ['question'],
|
props: ['question'],
|
||||||
name: 'QuizSingleChoice',
|
name: 'QuizSingleChoice',
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
picked: ''
|
||||||
|
}
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
emitResponse(q, o) {
|
||||||
|
this.$emit('updateResponse', {'question':q , 'option': o})
|
||||||
|
}
|
||||||
|
}
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user