fix: integratie user + errors gefixt zodat het runt + format
This commit is contained in:
		
							parent
							
								
									6c4ea0eefb
								
							
						
					
					
						commit
						1b096b411b
					
				
					 55 changed files with 858 additions and 594 deletions
				
			
		| 
						 | 
				
			
			@ -1,40 +1,44 @@
 | 
			
		|||
import { Request, Response } from 'express';
 | 
			
		||||
import { getAllClasses, getClass, getClassStudents, getClassStudentsIds, getClassTeacherInvitations } from '../services/class.js';
 | 
			
		||||
import { ClassDTO } from '../interfaces/classes.js';
 | 
			
		||||
import {
 | 
			
		||||
    getAllClasses,
 | 
			
		||||
    getClass,
 | 
			
		||||
    getClassStudents,
 | 
			
		||||
    getClassStudentsIds,
 | 
			
		||||
    getClassTeacherInvitations,
 | 
			
		||||
} from '../services/class.js';
 | 
			
		||||
 | 
			
		||||
export async function getAllClassesHandler(
 | 
			
		||||
    req: Request,
 | 
			
		||||
    res: Response,
 | 
			
		||||
    res: Response
 | 
			
		||||
): Promise<void> {
 | 
			
		||||
    const full = req.query.full === "true";
 | 
			
		||||
    const full = req.query.full === 'true';
 | 
			
		||||
    const classes = await getAllClasses(full);
 | 
			
		||||
 | 
			
		||||
    res.json({
 | 
			
		||||
        classes: classes
 | 
			
		||||
        classes: classes,
 | 
			
		||||
    });
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
export async function getClassHandler(
 | 
			
		||||
    req: Request,
 | 
			
		||||
    res: Response,
 | 
			
		||||
    res: Response
 | 
			
		||||
): Promise<void> {
 | 
			
		||||
    try {
 | 
			
		||||
        const classId = req.params.id;
 | 
			
		||||
        const cls = await getClass(classId);
 | 
			
		||||
 | 
			
		||||
        if (!cls) {
 | 
			
		||||
            res.status(404).json({ error: "Student not found" });
 | 
			
		||||
            res.status(404).json({ error: 'Student not found' });
 | 
			
		||||
            return;
 | 
			
		||||
        } else {
 | 
			
		||||
            cls.endpoints = {
 | 
			
		||||
                self: `${req.baseUrl}/${req.params.id}`,
 | 
			
		||||
                invitations: `${req.baseUrl}/${req.params.id}/invitations`,
 | 
			
		||||
                assignments: `${req.baseUrl}/${req.params.id}/assignments`,
 | 
			
		||||
                students: `${req.baseUrl}/${req.params.id}/students`,
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            res.json(cls);
 | 
			
		||||
        }
 | 
			
		||||
        cls.endpoints = {
 | 
			
		||||
            self: `${req.baseUrl}/${req.params.id}`,
 | 
			
		||||
            invitations: `${req.baseUrl}/${req.params.id}/invitations`,
 | 
			
		||||
            assignments: `${req.baseUrl}/${req.params.id}/assignments`,
 | 
			
		||||
            students: `${req.baseUrl}/${req.params.id}/students`,
 | 
			
		||||
        };
 | 
			
		||||
 | 
			
		||||
        res.json(cls);
 | 
			
		||||
    } catch (error) {
 | 
			
		||||
        console.error('Error fetching learning objects:', error);
 | 
			
		||||
        res.status(500).json({ error: 'Internal server error' });
 | 
			
		||||
| 
						 | 
				
			
			@ -43,12 +47,12 @@ export async function getClassHandler(
 | 
			
		|||
 | 
			
		||||
export async function getClassStudentsHandler(
 | 
			
		||||
    req: Request,
 | 
			
		||||
    res: Response,
 | 
			
		||||
    res: Response
 | 
			
		||||
): Promise<void> {
 | 
			
		||||
    const classId = req.params.id;
 | 
			
		||||
    const full = req.query.full === "true";
 | 
			
		||||
    const full = req.query.full === 'true';
 | 
			
		||||
 | 
			
		||||
    let students = full
 | 
			
		||||
    const students = full
 | 
			
		||||
        ? await getClassStudents(classId)
 | 
			
		||||
        : await getClassStudentsIds(classId);
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -59,10 +63,10 @@ export async function getClassStudentsHandler(
 | 
			
		|||
 | 
			
		||||
export async function getTeacherInvitationsHandler(
 | 
			
		||||
    req: Request,
 | 
			
		||||
    res: Response,
 | 
			
		||||
    res: Response
 | 
			
		||||
): Promise<void> {
 | 
			
		||||
    const classId = req.params.id;
 | 
			
		||||
    const full = req.query.full === "true"; // TODO: not implemented yet
 | 
			
		||||
    const full = req.query.full === 'true'; // TODO: not implemented yet
 | 
			
		||||
 | 
			
		||||
    const invitations = await getClassTeacherInvitations(classId, full);
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Reference in a new issue