apps/recallassess/recallassess-api/src/api/admin/learning-group/learning-group.controller.ts
api/admin/learning-group
Methods |
|
| Async downloadPostBatHtml |
downloadPostBatHtml(id: number, learningGroupParticipantId: number)
|
Decorators :
@Get(':id/participant/:learningGroupParticipantId/post-bat-download')
|
|
Download post-BAT HTML for a participant in this learning group (admin). Uses LearningGroupParticipant ID (same as portal flow).
Returns :
Promise<string>
|
| Async downloadPreBatHtml |
downloadPreBatHtml(id: number, learningGroupParticipantId: number)
|
Decorators :
@Get(':id/participant/:learningGroupParticipantId/pre-bat-download')
|
|
Download pre-BAT HTML for a participant in this learning group (admin). Uses LearningGroupParticipant ID (same as portal flow).
Returns :
Promise<string>
|
| Async getPostBatPdfUrl |
getPostBatPdfUrl(id: number, learningGroupParticipantId: number)
|
Decorators :
@Get(':id/participant/:learningGroupParticipantId/post-bat-pdf-url')
|
|
Get post-BAT PDF download URL for a participant in this learning group (admin).
Returns :
Promise<literal type>
|
| Async getPreBatHtml |
getPreBatHtml(learningGroupId: string, participantId: string)
|
Decorators :
@Get(':learningGroupId/participant/:participantId/pre-bat-html')
|
|
Get Pre-BAT report HTML for a participant (admin JWT auth). Used by the admin panel "View Pre-BAT report" to open the report in a new window.
Returns :
Promise<string>
|
| Async getPreBatPdfUrl |
getPreBatPdfUrl(id: number, learningGroupParticipantId: number)
|
Decorators :
@Get(':id/participant/:learningGroupParticipantId/pre-bat-pdf-url')
|
|
Get pre-BAT PDF download URL for a participant in this learning group (admin).
Returns :
Promise<literal type>
|
| Async resendInvitation |
resendInvitation(id: number, participantId: number)
|
Decorators :
@Post(':id/resend-invitation/:participantId')
|
|
Resend invitation to a specific participant (by participant id). POST /api/admin/learning-group/:id/resend-invitation/:participantId
Returns :
Promise<literal type>
|
| Async updateKnowledgeReviewEmailDate | ||||||
updateKnowledgeReviewEmailDate(learningGroupParticipantId: string)
|
||||||
Decorators :
@Patch('participant/:learningGroupParticipantId/knowledge-review-email-date')
|
||||||
|
Update knowledge_review_email_date to NOW() for a learning group participant. Mirrors the update-knowledge-review-email-date.sh script.
Parameters :
Returns :
unknown
|
| Async updatePostBatInviteEmailDate | ||||||
updatePostBatInviteEmailDate(learningGroupParticipantId: string)
|
||||||
Decorators :
@Patch('participant/:learningGroupParticipantId/post-bat-invite-email-date')
|
||||||
|
Send post BAT invite email now and ensure post_bat_email_date is set (and not in the future) for a learning group participant. Used from admin UI "Update" (send now) for post BAT invite.
Parameters :
Returns :
unknown
|
import { BaseController } from "@bish-nest/core/controller/base.controller";
import {
Controller,
Get,
Header,
HttpCode,
HttpStatus,
Param,
ParseIntPipe,
Patch,
Post,
} from "@nestjs/common";
import { IntegrationService } from "@api/integration/integration.service";
import { LearningGroupService } from "./learning-group.service";
@Controller("api/admin/learning-group")
export class LearningGroupController extends BaseController<LearningGroupService> {
constructor(
service: LearningGroupService,
private readonly integrationService: IntegrationService,
) {
super(service);
}
/**
* Get Pre-BAT report HTML for a participant (admin JWT auth).
* Used by the admin panel "View Pre-BAT report" to open the report in a new window.
*/
@Get(":learningGroupId/participant/:participantId/pre-bat-html")
@Header("Content-Type", "text/html; charset=utf-8")
async getPreBatHtml(
@Param("learningGroupId") learningGroupId: string,
@Param("participantId") participantId: string,
): Promise<string> {
return this.integrationService.generatePreBatHtml(
parseInt(learningGroupId, 10),
parseInt(participantId, 10),
);
}
/**
* Download pre-BAT HTML for a participant in this learning group (admin).
* Uses LearningGroupParticipant ID (same as portal flow).
*/
@Get(":id/participant/:learningGroupParticipantId/pre-bat-download")
@Header("Content-Type", "text/html; charset=utf-8")
async downloadPreBatHtml(
@Param("id", ParseIntPipe) id: number,
@Param("learningGroupParticipantId", ParseIntPipe) learningGroupParticipantId: number,
): Promise<string> {
return this.entityService.generatePreBatHtmlForParticipant(id, learningGroupParticipantId);
}
/**
* Download post-BAT HTML for a participant in this learning group (admin).
* Uses LearningGroupParticipant ID (same as portal flow).
*/
@Get(":id/participant/:learningGroupParticipantId/post-bat-download")
@Header("Content-Type", "text/html; charset=utf-8")
async downloadPostBatHtml(
@Param("id", ParseIntPipe) id: number,
@Param("learningGroupParticipantId", ParseIntPipe) learningGroupParticipantId: number,
): Promise<string> {
return this.entityService.generatePostBatHtmlForParticipant(id, learningGroupParticipantId);
}
/**
* Get pre-BAT PDF download URL for a participant in this learning group (admin).
*/
@Get(":id/participant/:learningGroupParticipantId/pre-bat-pdf-url")
@HttpCode(HttpStatus.OK)
async getPreBatPdfUrl(
@Param("id", ParseIntPipe) id: number,
@Param("learningGroupParticipantId", ParseIntPipe) learningGroupParticipantId: number,
): Promise<{ url: string }> {
const url = await this.entityService.getPreBatPdfUrlForParticipant(id, learningGroupParticipantId);
return { url };
}
/**
* Get post-BAT PDF download URL for a participant in this learning group (admin).
*/
@Get(":id/participant/:learningGroupParticipantId/post-bat-pdf-url")
@HttpCode(HttpStatus.OK)
async getPostBatPdfUrl(
@Param("id", ParseIntPipe) id: number,
@Param("learningGroupParticipantId", ParseIntPipe) learningGroupParticipantId: number,
): Promise<{ url: string }> {
const url = await this.entityService.getPostBatPdfUrlForParticipant(id, learningGroupParticipantId);
return { url };
}
/**
* Update knowledge_review_email_date to NOW() for a learning group participant.
* Mirrors the update-knowledge-review-email-date.sh script.
*/
@Patch("participant/:learningGroupParticipantId/knowledge-review-email-date")
@HttpCode(HttpStatus.OK)
async updateKnowledgeReviewEmailDate(
@Param("learningGroupParticipantId") learningGroupParticipantId: string,
) {
return this.entityService.updateKnowledgeReviewEmailDate(parseInt(learningGroupParticipantId, 10));
}
/**
* Send post BAT invite email now and ensure post_bat_email_date is set (and not in the future)
* for a learning group participant. Used from admin UI "Update" (send now) for post BAT invite.
*/
@Patch("participant/:learningGroupParticipantId/post-bat-invite-email-date")
@HttpCode(HttpStatus.OK)
async updatePostBatInviteEmailDate(
@Param("learningGroupParticipantId") learningGroupParticipantId: string,
) {
return this.entityService.updatePostBatInviteEmailDate(parseInt(learningGroupParticipantId, 10));
}
/**
* Resend invitation to a specific participant (by participant id).
* POST /api/admin/learning-group/:id/resend-invitation/:participantId
*/
@Post(":id/resend-invitation/:participantId")
@HttpCode(HttpStatus.OK)
async resendInvitation(
@Param("id", ParseIntPipe) id: number,
@Param("participantId", ParseIntPipe) participantId: number,
): Promise<{ message: string }> {
return this.entityService.resendInvitation(id, participantId);
}
}