-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from USNightOwl/feat/do-exercise
Feat - Handle do exercise
- Loading branch information
Showing
9 changed files
with
241 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,23 @@ | ||
import AxiosClient from "./axios"; | ||
|
||
const resource = "/category"; | ||
const resourceExam = "/exam"; | ||
|
||
export default { | ||
get(classId: string, currentPage: number) { | ||
return AxiosClient.get(`${resource}/${classId}/exams?page=${currentPage}`); | ||
}, | ||
getOne(exerciseId: string) { | ||
return AxiosClient.get(`/exam/${exerciseId}`); | ||
return AxiosClient.get(`${resourceExam}/${exerciseId}`); | ||
}, | ||
search(searchText: string, page: number) { | ||
return AxiosClient.post('/search', { | ||
keyword: searchText, | ||
page: page || 1, | ||
}); | ||
}, | ||
submit(formData: any) { | ||
return AxiosClient.post(`${resourceExam}/submit`, formData); | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<template lang=""> | ||
<button | ||
:class="cn('border rounded px-4 py-2 hover:text-white flex items-center justify-center gap-2 transition ease-linear w-full md:w-fit', props.className)" | ||
@click="props.func" | ||
> | ||
<slot/> | ||
</button> | ||
</template> | ||
|
||
<script setup> | ||
import { cn } from "@/utils/cn"; | ||
const props = defineProps({ | ||
className: { | ||
type: String, | ||
}, | ||
func: { | ||
type: Function, | ||
required: true | ||
} | ||
}) | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<template lang=""> | ||
<i class="block md:mb-8 mb-5 text-base md:text-xl md:px-8 px-2" v-html="quote"> | ||
</i> | ||
</template> | ||
|
||
<script setup> | ||
import { ref, onMounted } from "vue"; | ||
const quote = ref(""); | ||
onMounted(async ()=> { | ||
const API_KEY = "SltTB9eBPK6on57H/Vlygg==1GGt23U1uXtMedKH"; | ||
const response = await fetch("https://api.api-ninjas.com/v1/quotes?category=learning", { | ||
headers: { | ||
'x-api-key': API_KEY, | ||
} | ||
}); | ||
const quoteData = await response.json(); | ||
quote.value = `${quoteData[0].quote} - <b>${quoteData[0].author}</b>`; | ||
}); | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
<template lang=""> | ||
<div class="text-center"> | ||
<h1 class="text-3xl md:text-4xl my-4 md:my-6 font-bold"> | ||
{{ isSubmitHaveNiceResult(props.results.score)?"Xin chúc mừng!":"Bạn có thể thử lại lần nữa."}} | ||
</h1> | ||
<p>Với <span class="text-green-500 font-bold">{{ props.results.correctAnswers }}/{{ props.results.totalQuestion }}</span> câu trả lời đúng. Điểm của bạn là</p> | ||
<h1 | ||
:class="'text-4xl font-bold my-6 ' + (isSubmitHaveNiceResult(props.results.score)?'text-green-500':'text-red-400')" | ||
>{{ props.results.score }}</h1> | ||
<div class="flex md:flex-row flex-col gap-3 md:gap-5 flex-wrap md:my-10 my-5 justify-center items-center px-2"> | ||
<ButtonUtils | ||
className="bg-[#f0f9eb] border-[#c2e7b0] hover:bg-[#67c23a] text-[#67c23a]" | ||
:func="handleTryAgain" | ||
> | ||
<Icon icon="pi-sync"/> | ||
Thử làm lại | ||
</ButtonUtils> | ||
|
||
<ButtonUtils | ||
className="bg-[#fdf6ec] border-[#f5dab1] hover:bg-[#e6a23c] text-[#e6a23c]" | ||
:func="handleShowResults" | ||
> | ||
<Icon icon="pi-file-check"/> | ||
Xem đáp án chi tiết | ||
</ButtonUtils> | ||
|
||
<ButtonUtils | ||
className="bg-[#f4f4f5] border-[#d3d4d6] hover:bg-[#909399] text-[#909399]" | ||
:func="handleDoMore" | ||
> | ||
<Icon icon="pi-send"/> | ||
Làm các đề khác | ||
</ButtonUtils> | ||
</div> | ||
|
||
<Quote/> | ||
</div> | ||
</template> | ||
|
||
<script setup> | ||
import ButtonUtils from "@/components/Button/ButtonUtils.vue"; | ||
import Icon from "@/components/Icon.vue"; | ||
import Quote from "@/components/DoExercise/Quote.vue"; | ||
import router from "@/router"; | ||
const props = defineProps({ | ||
slug: { | ||
type: String, | ||
required: true, | ||
}, | ||
results: { | ||
type: Object, | ||
required: true, | ||
} | ||
}); | ||
function isSubmitHaveNiceResult(score) { | ||
return score >= 5; | ||
} | ||
function handleTryAgain() { | ||
window.location.reload(); | ||
} | ||
function handleDoMore() { | ||
router.push({ name: 'exercise', params: { classId: props.slug } }); | ||
} | ||
function handleShowResults() { | ||
alert("This feature will show the results and implement later"); | ||
} | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import { ClassValue, clsx } from "clsx"; | ||
import { twMerge } from "tailwind-merge"; | ||
|
||
export function cn(...inputs: ClassValue[]) { | ||
return twMerge(clsx(inputs)); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters