apps/recallassess/recallassess-api/src/api/admin/participant/participant.controller.ts
api/admin/participant
Methods |
|
| Async add |
add()
|
Decorators :
@Post()
|
|
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 :
Returns :
unknown
|
| Async resetPassword | |||||||||
resetPassword(id: string, dto: ParticipantResetPasswordDto)
|
|||||||||
Decorators :
@Post(':id/reset-password')
|
|||||||||
|
Reset participant password POST /api/admin/participant/:id/reset-password
Parameters :
Returns :
unknown
|
| Async setDevMode | |||||||||
setDevMode(id: number, dto: ParticipantSetDevModeDto)
|
|||||||||
Decorators :
@Put(':id/dev-mode')
|
|||||||||
|
Set participant dev mode (show correct answers in assessments) PUT /api/admin/participant/:id/dev-mode
Parameters :
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);
}
}