Quiz UI Working
This commit is contained in:
parent
f9e8e4e2d3
commit
cd0cab78a5
@ -1,14 +1,15 @@
|
||||
<template>
|
||||
<div class="nav-buttons">
|
||||
<button class='btn btn-outline-secondary' @click="$router.go(-1)">Previous</button>
|
||||
<button class='btn btn-primary' @click="$router.push({ name: 'content', params: { course: $route.params.course, type:nextContentType, content:nextContent }})">Next</button>
|
||||
<button class='btn btn-outline-secondary' @click="$router.go(-1)">Back</button>
|
||||
<button v-if="nextContent" class='btn btn-primary' @click="$router.push({ name: 'content', params: { course: $route.params.course, type:nextContentType, content:nextContent }})">Next</button>
|
||||
<button v-else class='btn btn-primary' @click="$router.push({ name: 'program', params: { code: $route.params.code}})">Finish Course</button>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
props: ['nextContent', 'nextContentType'],
|
||||
name: 'ContentNavigation',
|
||||
name: 'ContentNavigation'
|
||||
};
|
||||
</script>
|
||||
|
||||
|
@ -8,25 +8,27 @@
|
||||
</div>
|
||||
<div class="content">
|
||||
<hr>
|
||||
<form id="quiz" :name="content">
|
||||
<div id="quiz" :name="content">
|
||||
<div id="quiz-body">
|
||||
<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">
|
||||
<button class='btn btn-outline-secondary' type="reset">Reset</button>
|
||||
<button class='btn btn-primary' @click="submitQuiz" type="button">Submit</button>
|
||||
</div>
|
||||
<div id="post-quiz-actions" class="row" hidden="hidden">
|
||||
<div>
|
||||
<div v-if="submitted" id="post-quiz-actions" class="row">
|
||||
<div class="col-md-8 text-left">
|
||||
<h3>Your Score: <span id="result"></span></h3>
|
||||
<h3>Your Score: <span id="result">{{ score }}</span></h3>
|
||||
</div>
|
||||
<div class="col-md-4 text-right">
|
||||
<slot></slot>
|
||||
</div>
|
||||
</div>
|
||||
<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>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
<div class="mt-3 text-right">
|
||||
<a class="text-muted" href="/report"><i class="octicon octicon-issue-opened" title="Report"></i> Report a
|
||||
@ -37,6 +39,7 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
debugger
|
||||
import QuizSingleChoice from "./Quiz/QuizSingleChoice.vue"
|
||||
export default {
|
||||
props: ['content', 'type'],
|
||||
@ -44,7 +47,9 @@ export default {
|
||||
data() {
|
||||
return {
|
||||
quizData: '',
|
||||
quizResponse: {}
|
||||
quizResponse: {},
|
||||
score: '',
|
||||
submitted: false
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
@ -68,9 +73,14 @@ export default {
|
||||
frappe.call({
|
||||
method: "erpnext.www.academy.evaluate_quiz",
|
||||
args: {
|
||||
quiz_response: this.quizResponse;
|
||||
quiz_response: this.quizResponse,
|
||||
quiz_name: this.content
|
||||
}
|
||||
})
|
||||
}).then(r => {
|
||||
this.score = r.message,
|
||||
this.submitted = true,
|
||||
this.quizResponse = null
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
|
@ -3,12 +3,11 @@
|
||||
<h5>{{ question.question }}</h5>
|
||||
<div class="options ml-2">
|
||||
<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">
|
||||
<input class="form-check-input" type="radio" :name="question.name" :id="option.name" :value="option.name" @change="emitResponse(question.name, option.name)">
|
||||
<label class="form-check-label" :for="option.name">
|
||||
{{ option.option }}
|
||||
</label>
|
||||
</div>
|
||||
<span>Picked: {{ picked }}</span>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
@ -17,11 +16,6 @@
|
||||
export default {
|
||||
props: ['question'],
|
||||
name: 'QuizSingleChoice',
|
||||
data() {
|
||||
return {
|
||||
picked: ''
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
emitResponse(q, o) {
|
||||
this.$emit('updateResponse', {'question':q , 'option': o})
|
||||
|
Loading…
x
Reference in New Issue
Block a user