36 lines
1.1 KiB
JavaScript
36 lines
1.1 KiB
JavaScript
const express = require('express');
|
|
const router = express.Router();
|
|
const questionController = require('../controllers/question.controller');
|
|
const { verifyToken, isAdmin } = require('../middleware/auth.middleware');
|
|
|
|
/**
|
|
* @route POST /api/admin/questions
|
|
* @desc Create a new question (Admin only)
|
|
* @access Admin
|
|
* @body {
|
|
* questionText, questionType, options, correctAnswer,
|
|
* difficulty, points, explanation, categoryId, tags, keywords
|
|
* }
|
|
*/
|
|
router.post('/questions', verifyToken, isAdmin, questionController.createQuestion);
|
|
|
|
/**
|
|
* @route PUT /api/admin/questions/:id
|
|
* @desc Update a question (Admin only)
|
|
* @access Admin
|
|
* @body {
|
|
* questionText?, questionType?, options?, correctAnswer?,
|
|
* difficulty?, points?, explanation?, categoryId?, tags?, keywords?, isActive?
|
|
* }
|
|
*/
|
|
router.put('/questions/:id', verifyToken, isAdmin, questionController.updateQuestion);
|
|
|
|
/**
|
|
* @route DELETE /api/admin/questions/:id
|
|
* @desc Delete a question - soft delete (Admin only)
|
|
* @access Admin
|
|
*/
|
|
router.delete('/questions/:id', verifyToken, isAdmin, questionController.deleteQuestion);
|
|
|
|
module.exports = router;
|