/**
  * @EXT\Route(
  *     "/card/{card}/suspend/{suspend}",
  *     name="claroline_suspend_card"
  * )
  *
  * @param Card $card
  * @param $suspend
  *
  * @return JsonResponse
  */
 public function suspendCardAction(Card $card, $suspend)
 {
     $this->assertCanOpen($card->getNote()->getDeck());
     $user = $this->tokenStorage->getToken()->getUser();
     $cardLearning = $this->cardLearningMgr->getCardLearning($card, $user);
     $cardLearning->setPainful($suspend);
     $this->cardLearningMgr->save($cardLearning);
     return new JsonResponse($card->getId());
 }
 /**
  * @EXT\Route(
  *     "/note/create/deck/{deck}/note_type/{noteType}",
  *     name="claroline_create_note"
  * )
  * @EXT\Method("POST")
  *
  * @param Request  $request
  * @param Deck     $deck
  * @param NoteType $noteType
  *
  * @return JsonResponse
  */
 public function createNoteAction(Request $request, Deck $deck, NoteType $noteType)
 {
     $fields = $request->request->get('fields', false);
     $response = new JsonResponse();
     $this->assertCanCreate($deck);
     if ($fields) {
         $note = new Note();
         $note->setDeck($deck);
         $note->setNoteType($noteType);
         foreach ($fields as $field) {
             if ($field['fieldValue']['type'] === 'text') {
                 $fieldValue = new FieldValueText();
                 $fieldValue->setValue($field['fieldValue']['value']);
             }
             if ($field['fieldValue']['type'] === 'image') {
                 $fieldValue = new FieldValueImage();
                 $fieldValue->setValue($field['fieldValue']['value']);
                 $fieldValue->setAlt($field['fieldValue']['alt']);
             }
             $fieldValue->setFieldLabel($noteType->getFieldLabel($field['id']));
             $fieldValue->setNote($note);
             $note->addFieldValue($fieldValue);
         }
         foreach ($noteType->getCardTypes() as $cardType) {
             $card = new Card();
             $card->setCardType($cardType);
             $card->setNote($note);
             $note->addCard($card);
         }
         $note = $this->manager->create($note);
         $context = new SerializationContext();
         $context->setGroups('api_flashcard_deck');
         $response->setData(json_decode($this->serializer->serialize($note, 'json', $context)));
     } else {
         $response->setData('Field "fields" is missing');
         $response->setStatusCode(422);
     }
     return $response;
 }