File

src/module/pdf/pdf.controller.ts

Prefix

pdf

Index

Methods

Methods

Async getAttendancePDF
getAttendancePDF(id: string, date: string, res: Response)
Decorators :
@Get('/attendance/:tutorialId/:date')
@IDField('tutorialId')
@UseGuards(TutorialGuard)
@AllowSubstitutes()
Parameters :
Name Type Optional
id string No
date string No
res Response No
Returns : Promise<void>
Async getCorrectionFilenameForTeam
getCorrectionFilenameForTeam(tutorialId: string, sheetId: string, teamId: string)
Decorators :
@Get('/grading/filename/tutorial/:tutorialId/sheet/:sheetId/team/:teamId')
@UseGuards(TutorialGuard)
@AllowCorrectors()
@IDField('tutorialId')
Parameters :
Name Type Optional
tutorialId string No
sheetId string No
teamId string No
Returns : Promise<string>
Async getCorrectionPDFForTeam
getCorrectionPDFForTeam(tutorialId: string, sheetId: string, teamId: string, res: Response)
Decorators :
@Get('/grading/tutorial/:tutorialId/sheet/:sheetId/team/:teamId')
@UseGuards(TutorialGuard)
@AllowCorrectors()
@IDField('tutorialId')
Parameters :
Name Type Optional
tutorialId string No
sheetId string No
teamId string No
res Response No
Returns : Promise<void>
Async getCorrectionZIP
getCorrectionZIP(tutorialId: string, sheetId: string, res: Response)
Decorators :
@Get('/grading/tutorial/:tutorialId/sheet/:sheetId')
@UseGuards(TutorialGuard)
@AllowCorrectors()
@IDField('tutorialId')
Parameters :
Name Type Optional
tutorialId string No
sheetId string No
res Response No
Returns : Promise<void>
Async getCorrectionZIPFilename
getCorrectionZIPFilename(tutorialId: string, sheetId: string)
Decorators :
@Get('/grading/filename/tutorial/:tutorialId/sheet/:sheetId')
@UseGuards(TutorialGuard)
@AllowCorrectors()
@IDField('tutorialId')
Parameters :
Name Type Optional
tutorialId string No
sheetId string No
Returns : Promise<string>
Async getCredentialsPDF
getCredentialsPDF(res: Response)
Decorators :
@Get('/credentials')
@UseGuards(HasRoleGuard)
Parameters :
Name Type Optional
res Response No
Returns : Promise<void>
Async getScheinexamResultPDF
getScheinexamResultPDF(id: string, clearMatriculationNos: string, res: Response)
Decorators :
@Get('/scheinexam/:id/result')
@UseGuards(HasRoleGuard)
Parameters :
Name Type Optional
id string No
clearMatriculationNos string No
res Response No
Returns : Promise<void>
Async getScheinstatusPDF
getScheinstatusPDF(clearMatriculationNos: string, res: Response)
Decorators :
@Get('/scheinoverview')
@UseGuards(HasRoleGuard)
Parameters :
Name Type Optional
clearMatriculationNos string No
res Response No
Returns : Promise<void>
import { Controller, Get, Param, Query, Res, UseGuards } from '@nestjs/common';
import { Response } from 'express';
import { AllowCorrectors } from '../../guards/decorators/allowCorrectors.decorator';
import { AllowSubstitutes } from '../../guards/decorators/allowSubstitutes.decorator';
import { IDField } from '../../guards/decorators/idField.decorator';
import { HasRoleGuard } from '../../guards/has-role.guard';
import { TutorialGuard } from '../../guards/tutorial.guard';
import { PdfService } from './pdf.service';

@Controller('pdf')
export class PdfController {
    constructor(private readonly pdfService: PdfService) {}

    @Get('/attendance/:tutorialId/:date')
    @IDField('tutorialId')
    @UseGuards(TutorialGuard)
    @AllowSubstitutes()
    async getAttendancePDF(
        @Param('tutorialId') id: string,
        @Param('date') date: string,
        @Res() res: Response
    ): Promise<void> {
        const buffer = await this.pdfService.generateAttendancePDF(id, date);

        res.contentType('pdf');
        res.send(buffer);
    }

    @Get('/scheinoverview')
    @UseGuards(HasRoleGuard)
    async getScheinstatusPDF(
        @Query('clearMatriculationNos') clearMatriculationNos: string,
        @Res() res: Response
    ): Promise<void> {
        const buffer = await this.pdfService.generateStudentScheinOverviewPDF(
            clearMatriculationNos !== 'true'
        );

        res.contentType('pdf');
        res.send(buffer);
    }

    @Get('/scheinexam/:id/result')
    @UseGuards(HasRoleGuard)
    async getScheinexamResultPDF(
        @Param('id') id: string,
        @Query('clearMatriculationNos') clearMatriculationNos: string,
        @Res() res: Response
    ): Promise<void> {
        const buffer = await this.pdfService.generateScheinexamResultPDF(
            id,
            clearMatriculationNos !== 'true'
        );

        res.contentType('pdf');
        res.send(buffer);
    }

    @Get('/credentials')
    @UseGuards(HasRoleGuard)
    async getCredentialsPDF(@Res() res: Response): Promise<void> {
        const buffer = await this.pdfService.generateCredentialsPDF();

        res.contentType('pdf');
        res.send(buffer);
    }

    @Get('/grading/tutorial/:tutorialId/sheet/:sheetId')
    @UseGuards(TutorialGuard)
    @AllowCorrectors()
    @IDField('tutorialId')
    async getCorrectionZIP(
        @Param('tutorialId') tutorialId: string,
        @Param('sheetId') sheetId: string,
        @Res() res: Response
    ): Promise<void> {
        const zipStream = await this.pdfService.generateTutorialGradingZIP({
            tutorialId,
            sheetId,
        });

        res.contentType('zip');
        zipStream.pipe(res);
    }

    @Get('/grading/tutorial/:tutorialId/sheet/:sheetId/team/:teamId')
    @UseGuards(TutorialGuard)
    @AllowCorrectors()
    @IDField('tutorialId')
    async getCorrectionPDFForTeam(
        @Param('tutorialId') tutorialId: string,
        @Param('sheetId') sheetId: string,
        @Param('teamId') teamId: string,
        @Res() res: Response
    ): Promise<void> {
        const pdfData: Buffer | NodeJS.ReadableStream = await this.pdfService.generateGradingPDF({
            teamId: { tutorialId, teamId },
            sheetId,
        });

        if (Buffer.isBuffer(pdfData)) {
            res.contentType('application/pdf');
            res.send(pdfData);
        } else if (pdfData instanceof ReadableStream) {
            res.contentType('application/zip');
            pdfData.pipe(res);
        } else {
            throw new Error('Unexpected data type for pdfData');
        }
    }

    @Get('/grading/filename/tutorial/:tutorialId/sheet/:sheetId')
    @UseGuards(TutorialGuard)
    @AllowCorrectors()
    @IDField('tutorialId')
    async getCorrectionZIPFilename(
        @Param('tutorialId') tutorialId: string,
        @Param('sheetId') sheetId: string
    ): Promise<string> {
        return this.pdfService.generateTutorialGradingFilename({
            sheetId,
            tutorialId,
        });
    }

    @Get('/grading/filename/tutorial/:tutorialId/sheet/:sheetId/team/:teamId')
    @UseGuards(TutorialGuard)
    @AllowCorrectors()
    @IDField('tutorialId')
    async getCorrectionFilenameForTeam(
        @Param('tutorialId') tutorialId: string,
        @Param('sheetId') sheetId: string,
        @Param('teamId') teamId: string
    ): Promise<string> {
        return this.pdfService.generateGradingFilename({
            sheetId,
            teamId: { teamId, tutorialId },
        });
    }
}

results matching ""

    No results matching ""