Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 | 7x 7x 7x | import { Request, Response } from 'express'; import * as companiesService from '../services/companies_service'; import { handleError } from '../utils/handle_error'; const getQuizzesByTags = async (req: Request, res: Response): Promise<void> => { try { const tagsQueryParams: string = typeof req.query.tags === 'string' ? req.query.tags : ''; const tags = tagsQueryParams.split(','); const quizzes = await companiesService.searchQuizzesByTags(tags); res.json(quizzes); } catch (err) { handleError(err, res); } }; const getGeneratedQuizBySubject = async (req: Request, res: Response): Promise<void> => { try { const { subject } = req.body; if (!subject) { res.status(400).json({ error: 'Missing required fields' }); return; } const generatedQuiz = await companiesService.generateQuiz(subject); res.json(generatedQuiz); } catch (err) { handleError(err, res); } }; const getGradedQuizByAnsweredQuiz = async (req: Request, res: Response): Promise<void> => { try { const answeredQuiz = req.body; if (!answeredQuiz) { res.status(400).json({ error: 'Missing required fields' }); return; } const gradedQuiz = await companiesService.gradeQuiz(answeredQuiz); res.json(gradedQuiz); } catch (err) { handleError(err, res); } }; export default { getQuizzesByTags, getGeneratedQuizBySubject, getGradedQuizByAnsweredQuiz }; |