Changed the IDs to now be words and allows the assignment to be like chosen
This commit is contained in:
@@ -102,6 +102,7 @@ const generateExams = async (
|
||||
|
||||
async function POST(req: NextApiRequest, res: NextApiResponse) {
|
||||
const {
|
||||
examIDs,
|
||||
selectedModules,
|
||||
assignees,
|
||||
// Generate multiple true would generate an unique exam for each user
|
||||
@@ -111,6 +112,7 @@ async function POST(req: NextApiRequest, res: NextApiResponse) {
|
||||
instructorGender,
|
||||
...body
|
||||
} = req.body as {
|
||||
examIDs?: {id: string; module: Module}[];
|
||||
selectedModules: Module[];
|
||||
assignees: string[];
|
||||
generateMultiple: Boolean;
|
||||
@@ -121,7 +123,9 @@ async function POST(req: NextApiRequest, res: NextApiResponse) {
|
||||
instructorGender?: InstructorGender;
|
||||
};
|
||||
|
||||
const exams: ExamWithUser[] = await generateExams(generateMultiple, selectedModules, assignees, variant, instructorGender);
|
||||
const exams: ExamWithUser[] = !!examIDs
|
||||
? examIDs.flatMap((e) => assignees.map((a) => ({...e, assignee: a})))
|
||||
: await generateExams(generateMultiple, selectedModules, assignees, variant, instructorGender);
|
||||
|
||||
if (exams.length === 0) {
|
||||
res.status(400).json({ok: false, error: "No exams found for the selected modules"});
|
||||
|
||||
Reference in New Issue
Block a user