Skip to content

Commit

Permalink
feat: Update FlashcardBehaviorController to return refreshed flashcar…
Browse files Browse the repository at this point in the history
…d data and adjust query in FlashcardRepository
  • Loading branch information
MrAnyx committed Jan 13, 2025
1 parent f2dd906 commit ee2b5ca
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
5 changes: 4 additions & 1 deletion src/Controller/Flashcard/FlashcardBehaviorController.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,11 +91,14 @@ public function resetFlashcard(
ReviewRepository $reviewRepository,
#[Resource(FlashcardVoter::OWNER)] Flashcard $flashcard,
#[CurrentUser] User $user,
EntityManagerInterface $em
): JsonResponse {
$reviewRepository->resetBy($user, $flashcard);
$flashcardRepository->resetBy($user, $flashcard);

return $this->json(null, Response::HTTP_NO_CONTENT);
$em->refresh($flashcard);

return $this->json($flashcard, context: ['groups' => ['read:flashcard:user', 'read:unit:user', 'read:topic:user']]);
}

#[Route('/flashcards/session', name: 'session_flashcard', methods: ['GET'])]
Expand Down
2 changes: 1 addition & 1 deletion src/Repository/FlashcardRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ public function resetBy(User $user, Flashcard|Unit|Topic|null $resetBy = null)
} elseif ($resetBy instanceof Unit) {
$flashcardsToReset->andWhere('u2 = :resetBy');
} elseif ($resetBy instanceof Topic) {
$flashcardsToReset->andWhere('u2.topic = :resetBy');
$flashcardsToReset->andWhere('t2 = :resetBy');
}

$qb = $this->createQueryBuilder('f');
Expand Down

0 comments on commit ee2b5ca

Please sign in to comment.