File

src/module/markdown/markdown.controller.ts

Prefix

markdown

Index

Methods

Methods

getHTMLFromMarkdown
getHTMLFromMarkdown(body: MarkdownHTMLDTO)
Decorators :
@Post('/html')
@UseGuards(AuthenticatedGuard)
@UsePipes(ValidationPipe)
@HttpCode(HttpStatus.OK)
Parameters :
Name Type Optional
body MarkdownHTMLDTO No
Returns : IMarkdownHTML
Async getMarkdown
getMarkdown(sheetId: string, tutorialId: string, teamId: string)
Decorators :
@Get('/grading/:sheetId/tutorial/:tutorialId/team/:teamId')
@UseGuards(TutorialGuard)
@AllowCorrectors()
@IDField('tutorialId')
Parameters :
Name Type Optional
sheetId string No
tutorialId string No
teamId string No
Async getMarkdownForStudentGrading
getMarkdownForStudentGrading(entityId: string, studentId: string)
Decorators :
@Get('/grading/:entityId/student/:studentId')
@UseGuards(StudentGuard)
@AllowCorrectors()
@IDField('studentId')
Parameters :
Name Type Optional
entityId string No
studentId string No
import {
    Body,
    Controller,
    Get,
    HttpCode,
    HttpStatus,
    Param,
    Post,
    UseGuards,
    UsePipes,
    ValidationPipe,
} from '@nestjs/common';
import { AuthenticatedGuard } from '../../guards/authenticated.guard';
import { AllowCorrectors } from '../../guards/decorators/allowCorrectors.decorator';
import { IDField } from '../../guards/decorators/idField.decorator';
import { StudentGuard } from '../../guards/student.guard';
import { TutorialGuard } from '../../guards/tutorial.guard';
import {
    IMarkdownHTML,
    IStudentMarkdownData,
    ITeamMarkdownData,
} from '../../shared/model/Markdown';
import { MarkdownService } from './markdown.service';
import { MarkdownHTMLDTO } from './markdown.types';

@Controller('markdown')
export class MarkdownController {
    constructor(private readonly markdownService: MarkdownService) {}

    @Post('/html')
    @UseGuards(AuthenticatedGuard)
    @UsePipes(ValidationPipe)
    @HttpCode(HttpStatus.OK)
    getHTMLFromMarkdown(@Body() body: MarkdownHTMLDTO): IMarkdownHTML {
        const html = this.markdownService.generateHTMLFromMarkdown(body.markdown);
        return { html };
    }

    @Get('/grading/:sheetId/tutorial/:tutorialId/team/:teamId')
    @UseGuards(TutorialGuard)
    @AllowCorrectors()
    @IDField('tutorialId')
    async getMarkdown(
        @Param('sheetId') sheetId: string,
        @Param('tutorialId') tutorialId: string,
        @Param('teamId') teamId: string
    ): Promise<ITeamMarkdownData[]> {
        const gradings = await this.markdownService.getTeamGrading({
            teamId: { tutorialId, teamId },
            sheetId,
        });

        return gradings.markdownData;
    }

    @Get('/grading/:entityId/student/:studentId')
    @UseGuards(StudentGuard)
    @AllowCorrectors()
    @IDField('studentId')
    async getMarkdownForStudentGrading(
        @Param('entityId') entityId: string,
        @Param('studentId') studentId: string
    ): Promise<IStudentMarkdownData> {
        return await this.markdownService.getStudentGrading(studentId, entityId);
    }
}

results matching ""

    No results matching ""