Quiz: Save responses as an object
This commit is contained in:
parent
d2e040b6f1
commit
cfc35f4424
@ -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,
|
||||
|
@ -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 @@ export default {
|
||||
name: 'ContentQuiz',
|
||||
data() {
|
||||
return {
|
||||
quizData: ''
|
||||
quizData: '',
|
||||
quizResponse: {}
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
@ -58,7 +60,12 @@ export default {
|
||||
},
|
||||
components: {
|
||||
QuizSingleChoice,
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
updateResponse(res) {
|
||||
this.quizResponse[res.question] = (res.option)
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
|
@ -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>
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user