const router  = require('express').Router();
const { authMiddleware, requireRole } = require('../middleware/auth');
const c = require('../controllers/liveController');

const teacher = [authMiddleware, requireRole('teacher', 'admin')];

router.post('/',                      ...teacher,    c.create);
router.get('/:id',                    ...teacher,    c.getSession);
router.put('/:id/question',           ...teacher,    c.setQuestion);
router.get('/:id/results',            ...teacher,    c.results);
router.delete('/:id',                 ...teacher,    c.end);

router.post('/:id/answer',            authMiddleware, c.answer);
router.get('/class/:classId/active',  authMiddleware, c.getActive);

module.exports = router;
