fix: user changes
This commit is contained in:
@@ -1,24 +0,0 @@
|
||||
import { register } from '@/services/mock/registry'
|
||||
import { endpoints } from '@/services/api/endpoints'
|
||||
import { findOrThrow, paginate } from '@/services/mock/helpers'
|
||||
import { studentCourses } from '@/services/mock/fixtures/student-courses'
|
||||
|
||||
const filterByStatus = (status) => {
|
||||
if (!status) return studentCourses
|
||||
if (status === 'current') {
|
||||
return studentCourses.filter((c) => ['watching', 'waitForExam'].includes(c.status))
|
||||
}
|
||||
if (status === 'ended') {
|
||||
return studentCourses.filter((c) => ['completed', 'failed'].includes(c.status))
|
||||
}
|
||||
return studentCourses.filter((c) => c.status === status)
|
||||
}
|
||||
|
||||
register('GET', endpoints.getStudentCourses, ({ query }) => {
|
||||
const list = filterByStatus(query.status)
|
||||
return paginate(list, query)
|
||||
})
|
||||
|
||||
register('GET', endpoints.showStudentCourse, ({ params }) => ({
|
||||
data: findOrThrow(studentCourses, params.id),
|
||||
}))
|
||||
@@ -1,27 +0,0 @@
|
||||
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: 'پاسخهای شما با موفقیت ثبت شد.',
|
||||
},
|
||||
}
|
||||
})
|
||||
@@ -1,11 +0,0 @@
|
||||
import { register } from '@/services/mock/registry'
|
||||
import { endpoints } from '@/services/api/endpoints'
|
||||
import { studentLessons } from '@/services/mock/fixtures/student-lessons'
|
||||
|
||||
register('GET', endpoints.showStudentLesson, ({ params }) => {
|
||||
const lesson = studentLessons.find((l) => String(l.id) === String(params.id))
|
||||
if (lesson) return { data: lesson }
|
||||
// fallback so any term/lesson combo resolves
|
||||
const fallback = studentLessons[0]
|
||||
return { data: { ...fallback, id: params.id } }
|
||||
})
|
||||
@@ -1,14 +0,0 @@
|
||||
import { register } from '@/services/mock/registry'
|
||||
import { endpoints } from '@/services/api/endpoints'
|
||||
import { studentSessions } from '@/services/mock/fixtures/student-sessions'
|
||||
|
||||
register('GET', endpoints.showStudentSession, ({ params }) => {
|
||||
const session = studentSessions.find((s) => String(s.id) === String(params.id))
|
||||
if (session) return { data: session }
|
||||
const fallback = studentSessions[0]
|
||||
return { data: { ...fallback, id: params.id } }
|
||||
})
|
||||
|
||||
register('POST', endpoints.submitStudentSessionHomework, ({ params }) => ({
|
||||
data: { id: params.id, status: 'submitted', message: 'تکلیف با موفقیت ارسال شد' },
|
||||
}))
|
||||
@@ -1,21 +0,0 @@
|
||||
import { register } from '@/services/mock/registry'
|
||||
import { endpoints } from '@/services/api/endpoints'
|
||||
import { findOrThrow, paginate } from '@/services/mock/helpers'
|
||||
import { studentTerms } from '@/services/mock/fixtures/student-terms'
|
||||
|
||||
const CURRENT_STATUSES = new Set(['watching', 'waitForExam'])
|
||||
const ENDED_STATUSES = new Set(['completed', 'failed'])
|
||||
|
||||
register('GET', endpoints.getStudentTerms, ({ query }) => {
|
||||
let list = [...studentTerms]
|
||||
if (query.status === 'current') {
|
||||
list = list.filter((t) => CURRENT_STATUSES.has(t.status))
|
||||
} else if (query.status === 'ended') {
|
||||
list = list.filter((t) => ENDED_STATUSES.has(t.status))
|
||||
}
|
||||
return paginate(list, query)
|
||||
})
|
||||
|
||||
register('GET', endpoints.showStudentTerm, ({ params }) => ({
|
||||
data: findOrThrow(studentTerms, params.id),
|
||||
}))
|
||||
Reference in New Issue
Block a user