2024-03-01 11:43:31 +03:00
|
|
|
const router = require('express').Router()
|
|
|
|
const fs = require('node:fs')
|
|
|
|
const path = require('node:path')
|
2022-11-27 16:34:37 +03:00
|
|
|
|
2024-03-28 18:59:16 +03:00
|
|
|
const timer =
|
2024-08-29 08:10:03 +03:00
|
|
|
(time = 1000) =>
|
2024-03-28 18:59:16 +03:00
|
|
|
(_req, _res, next) =>
|
|
|
|
setTimeout(next, time)
|
|
|
|
|
|
|
|
router.use(timer())
|
|
|
|
|
2024-03-01 12:49:55 +03:00
|
|
|
router.get('/course/list', (req, res) => {
|
|
|
|
res.send(require('../mocks/courses/list/success.json'))
|
2024-02-13 21:09:49 +03:00
|
|
|
})
|
|
|
|
|
2024-08-29 08:10:03 +03:00
|
|
|
router.get('/course/:id', (_req, res) => {
|
|
|
|
res.send(require('../mocks/courses/by-id/success.json'))
|
|
|
|
})
|
|
|
|
|
2024-03-01 12:49:55 +03:00
|
|
|
router.get('/course/students/:courseId', (req, res) => {
|
|
|
|
res.send(require('../mocks/courses/all-students/success.json'))
|
|
|
|
})
|
|
|
|
|
|
|
|
router.post('/course', (req, res) => {
|
|
|
|
res.send(require('../mocks/courses/create/success.json'))
|
|
|
|
})
|
|
|
|
|
2024-08-29 08:10:03 +03:00
|
|
|
router.post('/course/toggle-exam-with-jury/:id', (req, res) => {
|
|
|
|
res.send({ success: true })
|
|
|
|
})
|
|
|
|
|
2024-03-01 12:49:55 +03:00
|
|
|
router.get('/lesson/list/:courseId', (req, res) => {
|
2024-02-28 23:43:36 +03:00
|
|
|
res.send(require('../mocks/lessons/list/success.json'))
|
|
|
|
})
|
|
|
|
|
2024-03-01 11:43:31 +03:00
|
|
|
router.post('/lesson', (req, res) => {
|
|
|
|
res.send(require('../mocks/lessons/create/success.json'))
|
|
|
|
})
|
|
|
|
|
|
|
|
router.post('/lesson/access-code', (req, res) => {
|
2024-03-28 18:59:16 +03:00
|
|
|
const answer = fs.readFileSync(
|
|
|
|
path.resolve(__dirname, '../mocks/lessons/access-code/create/success.json'),
|
|
|
|
)
|
2024-03-01 11:43:31 +03:00
|
|
|
// res.send(require('../mocks/lessons/access-code/create/success.json'))
|
|
|
|
res.send(answer)
|
|
|
|
})
|
|
|
|
|
|
|
|
router.get('/lesson/access-code/:accessCode', (req, res) => {
|
2024-03-01 12:16:13 +03:00
|
|
|
res.status(400).send(require('../mocks/lessons/access-code/get/error.json'))
|
2024-03-01 11:43:31 +03:00
|
|
|
})
|
|
|
|
|
2024-03-01 12:16:13 +03:00
|
|
|
router.get('/lesson/:lessonId', (req, res) => {
|
2024-03-01 11:43:31 +03:00
|
|
|
res.send(require('../mocks/lessons/byid/success.json'))
|
|
|
|
})
|
|
|
|
|
2024-04-02 16:17:24 +03:00
|
|
|
router.delete('/lesson/:lessonId', (req, res) => {
|
|
|
|
res.send({ success: true, body: { ok: true }})
|
|
|
|
})
|
|
|
|
|
2024-04-02 16:27:22 +03:00
|
|
|
router.put('/lesson', (req, res) => {
|
2024-04-02 16:17:24 +03:00
|
|
|
res.send({ success: true, body: req.body })
|
|
|
|
})
|
|
|
|
|
2024-03-01 11:43:31 +03:00
|
|
|
module.exports = router
|