feat: bezig met ui/ux assignment, bug in testdata
This commit is contained in:
parent
7e4e179121
commit
509db70c73
6 changed files with 227 additions and 79 deletions
|
@ -13,6 +13,7 @@ import { requireFields } from './error-helper.js';
|
|||
import { BadRequestException } from '../exceptions/bad-request-exception.js';
|
||||
import { Assignment } from '../entities/assignments/assignment.entity.js';
|
||||
import { EntityDTO } from '@mikro-orm/core';
|
||||
import { FALLBACK_LANG } from '../config.js';
|
||||
|
||||
function getAssignmentParams(req: Request): { classid: string; assignmentNumber: number; full: boolean } {
|
||||
const classid = req.params.classid;
|
||||
|
@ -38,14 +39,19 @@ export async function getAllAssignmentsHandler(req: Request, res: Response): Pro
|
|||
|
||||
export async function createAssignmentHandler(req: Request, res: Response): Promise<void> {
|
||||
const classid = req.params.classid;
|
||||
const description = req.body.description;
|
||||
const language = req.body.language;
|
||||
const learningPath = req.body.learningPath;
|
||||
const description = req.body.description || "";
|
||||
const language = req.body.language || FALLBACK_LANG;
|
||||
const learningPath = req.body.learningPath || "";
|
||||
const title = req.body.title;
|
||||
|
||||
requireFields({ description, language, learningPath, title });
|
||||
requireFields({ title });
|
||||
|
||||
const assignmentData = req.body as AssignmentDTO;
|
||||
const assignmentData = {
|
||||
description: description,
|
||||
language: language,
|
||||
learningPath: learningPath,
|
||||
title: title,
|
||||
} as AssignmentDTO;
|
||||
const assignment = await createAssignment(classid, assignmentData);
|
||||
|
||||
res.json({ assignment });
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue