github-actions[bot]
Deploy Backend from GitHub Actions Commit: ca37b2a1c9dd5c702619ea7ae7b3260d2fb5663d
b185a6d | import { | |
| Controller, | |
| Get, | |
| Post, | |
| Body, | |
| Query, | |
| Put, | |
| Delete, | |
| Param, | |
| UseGuards, | |
| Req, | |
| } from "@nestjs/common"; | |
| import { FlashcardsService } from "./flashcards.service"; | |
| import { ApiTags, ApiOperation, ApiBearerAuth } from "@nestjs/swagger"; | |
| import { JwtAuthGuard } from "../auth/jwt-auth.guard"; | |
| import { RolesGuard } from "../auth/roles.guard"; | |
| import { Roles } from "../auth/roles.decorator"; | |
| import { ReviewCardDto } from "./dto/review-card.dto"; | |
| import { CreateFlashcardDto } from "./dto/create-flashcard.dto"; | |
| import { UpdateFlashcardDto } from "./dto/update-flashcard.dto"; | |
| ("Spaced Repetition Flashcards") | |
| ("flashcards") | |
| (JwtAuthGuard, RolesGuard) | |
| () | |
| export class FlashcardsController { | |
| constructor(private flashcardsService: FlashcardsService) {} | |
| ("due") | |
| ({ summary: "Retrieve due flashcards for study" }) | |
| async getDueFlashcards( | |
| ("courseId") courseId?: string, | |
| () req?: any, | |
| ) { | |
| return this.flashcardsService.getDueFlashcards(req.user.id, courseId); | |
| } | |
| ("review") | |
| ({ | |
| summary: "Submit review scores to update spaced repetition times", | |
| }) | |
| async recordReviewScore(() dto: ReviewCardDto, () req: any) { | |
| return this.flashcardsService.recordReviewScore( | |
| req.user.id, | |
| dto.flashcardId, | |
| dto.ease, | |
| ); | |
| } | |
| () | |
| ("admin") | |
| ({ summary: "Create a new flashcard (Admin)" }) | |
| async createFlashcard(() dto: CreateFlashcardDto) { | |
| return this.flashcardsService.create(dto); | |
| } | |
| () | |
| ({ summary: "List all flashcards" }) | |
| async getFlashcards(("nodeId") nodeId?: string) { | |
| return this.flashcardsService.findAll(nodeId); | |
| } | |
| (":id") | |
| ("admin") | |
| ({ summary: "Get details of a single flashcard (Admin)" }) | |
| async getFlashcardById(("id") id: string) { | |
| return this.flashcardsService.findById(id); | |
| } | |
| (":id") | |
| ("admin") | |
| ({ summary: "Update a flashcard (Admin)" }) | |
| async updateFlashcard( | |
| ("id") id: string, | |
| () dto: UpdateFlashcardDto, | |
| ) { | |
| return this.flashcardsService.update(id, dto); | |
| } | |
| (":id") | |
| ("admin") | |
| ({ summary: "Delete a flashcard (Admin)" }) | |
| async deleteFlashcard(("id") id: string) { | |
| return this.flashcardsService.remove(id); | |
| } | |
| ("nodes/:nodeId/bulk") | |
| ("admin") | |
| ({ | |
| summary: "Bulk import flashcards for a concept node (Admin)", | |
| }) | |
| async bulkImport( | |
| ("nodeId") nodeId: string, | |
| () | |
| dto: { flashcards: { question: string; answer: string; tag?: string }[] }, | |
| ) { | |
| return this.flashcardsService.bulkImport(nodeId, dto.flashcards); | |
| } | |
| } | |