fix(backend): Aangemaakt assignment werd niet teruggegeven.

Hier ontbreekte gewoon een await.
This commit is contained in:
Gerald Schmittinger 2025-03-13 20:45:34 +01:00
parent bec69863b4
commit 6e7a03f55b
2 changed files with 6 additions and 3 deletions

View file

@ -1,7 +1,6 @@
import { Request, Response } from 'express'; import { Request, Response } from 'express';
import { createAssignment, getAllAssignments, getAssignment, getAssignmentsSubmissions } from '../services/assignments.js'; import { createAssignment, getAllAssignments, getAssignment, getAssignmentsSubmissions } from '../services/assignments.js';
import { AssignmentDTO, mapToAssignment, mapToAssignmentDTO } from '../interfaces/assignment.js'; import { AssignmentDTO } from '../interfaces/assignment.js';
import { getAssignmentRepository, getClassRepository } from '../data/repositories.js';
// Typescript is annoy with with parameter forwarding from class.ts // Typescript is annoy with with parameter forwarding from class.ts
interface AssignmentParams { interface AssignmentParams {
@ -31,7 +30,7 @@ export async function createAssignmentHandler(req: Request<AssignmentParams>, re
return; return;
} }
const assignment = createAssignment(classid, assignmentData); const assignment = await createAssignment(classid, assignmentData);
if (!assignment) { if (!assignment) {
res.status(500).json({ error: 'Could not create assignment ' }); res.status(500).json({ error: 'Could not create assignment ' });

View file

@ -3,6 +3,9 @@ import { Class } from '../entities/classes/class.entity.js';
import { ClassDTO, mapToClassDTO } from '../interfaces/class.js'; import { ClassDTO, mapToClassDTO } from '../interfaces/class.js';
import { mapToStudentDTO, StudentDTO } from '../interfaces/student.js'; import { mapToStudentDTO, StudentDTO } from '../interfaces/student.js';
import { mapToTeacherInvitationDTO, mapToTeacherInvitationDTOIds, TeacherInvitationDTO } from '../interfaces/teacher-invitation.js'; import { mapToTeacherInvitationDTO, mapToTeacherInvitationDTOIds, TeacherInvitationDTO } from '../interfaces/teacher-invitation.js';
import {getLogger} from "../logging/initalize";
const logger = getLogger();
export async function getAllClasses(full: boolean): Promise<ClassDTO[] | string[]> { export async function getAllClasses(full: boolean): Promise<ClassDTO[] | string[]> {
const classRepository = getClassRepository(); const classRepository = getClassRepository();
@ -41,6 +44,7 @@ export async function createClass(classData: ClassDTO): Promise<Class | null> {
return newClass; return newClass;
} catch (e) { } catch (e) {
logger.error(e);
return null; return null;
} }
} }