fix
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
import { register } from '@/services/mock/registry'
|
||||
import { endpoints } from '@/services/api/endpoints'
|
||||
import { studentExams } from '@/services/mock/fixtures/student-exams'
|
||||
|
||||
register('GET', endpoints.showStudentExam, ({ params }) => {
|
||||
const exam = studentExams.find((e) => String(e.id) === String(params.id))
|
||||
if (exam) return { data: exam }
|
||||
const fallback = studentExams[1]
|
||||
return { data: { ...fallback, id: params.id } }
|
||||
})
|
||||
|
||||
register('POST', endpoints.startStudentExamAttempt, ({ params }) => ({
|
||||
data: { id: params.id, status: 'started', message: 'آزمون آغاز شد' },
|
||||
}))
|
||||
|
||||
register('POST', endpoints.submitStudentExamAttempt, ({ params, data }) => {
|
||||
const answers = data?.answers || {}
|
||||
const total = Object.keys(answers).length
|
||||
return {
|
||||
data: {
|
||||
id: params.id,
|
||||
submitted: true,
|
||||
score: total > 0 ? (12 + Math.random() * 6).toFixed(2) : 0,
|
||||
message: 'پاسخهای شما با موفقیت ثبت شد.',
|
||||
},
|
||||
}
|
||||
})
|
||||
Reference in New Issue
Block a user