File

apps/recallassess/recallassess-api/src/api/admin/participant/participant.controller.ts

Prefix

api/admin/participant

Extends

Index

Methods

Methods

Async add
add()
Decorators :
@Post()
@HttpCode(HttpStatus.METHOD_NOT_ALLOWED)
Returns : Promise<never>
Async getCourses
getCourses(id: number)
Decorators :
@Get(':id/courses')

Get courses (e-learning enrollments) for a participant. GET /api/admin/participant/:id/courses

Parameters :
Name Type Optional
id number No
Returns : unknown
Async resetPassword
resetPassword(id: string, dto: ParticipantResetPasswordDto)
Decorators :
@Post(':id/reset-password')
@HttpCode(HttpStatus.OK)

Reset participant password POST /api/admin/participant/:id/reset-password

Parameters :
Name Type Optional
id string No
dto ParticipantResetPasswordDto No
Returns : unknown
Async setDevMode
setDevMode(id: number, dto: ParticipantSetDevModeDto)
Decorators :
@Put(':id/dev-mode')
@HttpCode(HttpStatus.OK)

Set participant dev mode (show correct answers in assessments) PUT /api/admin/participant/:id/dev-mode

Parameters :
Name Type Optional
id number No
dto ParticipantSetDevModeDto No
Returns : unknown
import { BaseController } from "@bish-nest/core/controller/base.controller";
import { Body, Controller, Get, HttpCode, HttpStatus, MethodNotAllowedException, Param, ParseIntPipe, Post, Put } from "@nestjs/common";
import { ParticipantResetPasswordDto } from "./dto/participant-reset-password.dto";
import { ParticipantSetDevModeDto } from "./dto/participant-set-dev-mode.dto";
import { ParticipantService } from "./participant.service";

@Controller("api/admin/participant")
export class ParticipantController extends BaseController<ParticipantService> {
  constructor(private participantService: ParticipantService) {
    super(participantService);
  }

  /**
   * Get courses (e-learning enrollments) for a participant.
   * GET /api/admin/participant/:id/courses
   */
  @Get(":id/courses")
  async getCourses(@Param("id", ParseIntPipe) id: number) {
    return await this.participantService.findCoursesByParticipantId(id);
  }

  // Override add method - participants are created via signup, not through admin panel
  @Post()
  @HttpCode(HttpStatus.METHOD_NOT_ALLOWED)
  async add(): Promise<never> {
    throw new MethodNotAllowedException("Participant creation is not allowed through the admin panel. Participants are created via the signup process.");
  }

  /**
   * Reset participant password
   * POST /api/admin/participant/:id/reset-password
   */
  @Post(":id/reset-password")
  @HttpCode(HttpStatus.OK)
  async resetPassword(@Param("id") id: string, @Body() dto: ParticipantResetPasswordDto) {
    const participantId = parseInt(id, 10);
    return await this.participantService.resetPassword(participantId, dto.password);
  }

  /**
   * Set participant dev mode (show correct answers in assessments)
   * PUT /api/admin/participant/:id/dev-mode
   */
  @Put(":id/dev-mode")
  @HttpCode(HttpStatus.OK)
  async setDevMode(
    @Param("id", ParseIntPipe) id: number,
    @Body() dto: ParticipantSetDevModeDto,
  ) {
    return await this.participantService.setDevMode(id, dto.is_dev);
  }
}

results matching ""

    No results matching ""