Skip to content

Commit

Permalink
chore: confirm submit
Browse files Browse the repository at this point in the history
  • Loading branch information
nxhawk committed Jun 26, 2024
1 parent b625971 commit 076c22d
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 30 deletions.
2 changes: 1 addition & 1 deletion src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import './style.css'

const app = createApp(App)

app.use(createPinia())
app.use(createPinia());
app.use(Vue3Toastify);
app.use(VueAwesomePaginate)
app.use(router)
Expand Down
58 changes: 29 additions & 29 deletions src/views/DoExercisePage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -94,38 +94,38 @@
}
async function submitExam() {
isFirstSubmit.value = true;
// check all questions have answer from user
for (const page of examData.value.exam.pages) {
for (const q of page.questions){
if (q.warning==null || q.warning==true || !q.answer || q.answer.length <= 0) {
return toast.warning("Vui lòng trả lời hết các câu hỏi (đang bị bôi đỏ) trước khi nộp bài.", {
toastStyle: {
fontSize: '14px',
},
position: toast.POSITION.BOTTOM_RIGHT,
});
if (window.confirm("Bạn chắc chắn muốn nộp bài?")) {
isFirstSubmit.value = true;
// check all questions have answer from user
for (const page of examData.value.exam.pages) {
for (const q of page.questions){
if (q.warning==null || q.warning==true || !q.answer || q.answer.length <= 0) {
return toast.warning("Vui lòng trả lời hết các câu hỏi (đang bị bôi đỏ) trước khi nộp bài.", {
toastStyle: {
fontSize: '14px',
},
position: toast.POSITION.BOTTOM_RIGHT,
});
}
}
}
// submit answer
loadingStore.changeLoadingState(true);
const { data } = await ExamRepository.submit(examData.value.exam);
loadingStore.changeLoadingState(false);
resultsData.value = data;
isShowResults.value = true;
toast.success("Nộp bài thành công", {
toastStyle: {
fontSize: '14px',
},
position: toast.POSITION.BOTTOM_RIGHT,
});
}
// submit answer
loadingStore.changeLoadingState(true);
const { data } = await ExamRepository.submit(examData.value.exam);
loadingStore.changeLoadingState(false);
resultsData.value = data;
console.log(resultsData.value);
isShowResults.value = true;
toast.success("Nộp bài thành công", {
toastStyle: {
fontSize: '14px',
},
position: toast.POSITION.BOTTOM_RIGHT,
});
}
</script>
Expand Down

0 comments on commit 076c22d

Please sign in to comment.