added back button

This commit is contained in:
Aqqil Azman
2024-07-23 15:16:38 +08:00
parent 17e9213346
commit f46568c8d9
@@ -96,6 +96,12 @@
<div class="row" v-if="currentQuestion.answers">
<div class="col">
<div class="w-100 d-block text-center">
<button @click="goBack()"
v-if="questionIds.length"
class="btn btn-lg btn-primary d-inline-block rounded fs-20"
style="margin: 15px; padding: 15px 40px; min-width: 210px;">
Back
</button>
<button v-for="(answer, index) in currentQuestion.answers" :key="index"
@click="selectAnswer(answer.next)"
class="btn btn-lg btn-primary d-inline-block rounded fs-20"
@@ -293,6 +299,7 @@ export default {
},
currentQuestionId: null,
questionIds: [],
isLoading: false,
externalApiResponse: { data: null },
timer: null,
@@ -332,6 +339,7 @@ export default {
if (!Object.keys(this.questions[nextQuestionId]).length) this.endWork();
if (nextQuestionId === 'start_work') this.startWork();
if (nextQuestionId === 'stop_working') this.stopTimer();
this.questionIds.push(this.currentQuestionId);
this.currentQuestionId = nextQuestionId;
// call api to recorrd timestamp
@@ -345,6 +353,9 @@ export default {
this.stepTime = 0;
if (this.questions[nextQuestionId]?.load_api) this.callApi(this.questions[nextQuestionId].load_api, 'get', 'section');
},
goBack() {
this.currentQuestionId = this.questionIds.pop();
},
generateSessionId() {
return 'xxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
var r = Math.random() * 16 | 0, v = c == 'x' ? r : (r & 0x3 | 0x8);