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