Deletes a paper from an exercise.

@EXT\Route("/{id}", name="ujm_exercise_delete_paper")
@EXT\Method("DELETE")
@EXT\ParamConverter("paper", class="UJMExoBundle:Attempt\Paper", options={"mapping": {"id": "uuid"}})

@param Paper $paper

@return JsonResponse
497199
public function deleteAction(Paper $paper)
    {
        $this->assertHasPermission('MANAGE_PAPERS', $paper->getExercise());

        try {
            $this->paperManager->delete($paper);
        } catch (InvalidDataException $e) {
            return new JsonResponse($e->getErrors(), 422);
        }

        return new JsonResponse(null, 204);
    }
1211300
public function deleteAction(Request $request, $id)
    {
        $this->init($request);
        /* @var Node $node */
        $node = $this->em->getRepository('KunstmaanNodeBundle:Node')->find($id);

        $this->denyAccessUnlessGranted(PermissionMap::PERMISSION_DELETE, $node);

        $nodeTranslation = $node->getNodeTranslation($this->locale, true);
        $nodeVersion = $nodeTranslation->getPublicNodeVersion();
        $page = $nodeVersion->getRef($this->em);

        $this->get('event_dispatcher')->dispatch(
            Events::PRE_DELETE,
            new NodeEvent($node, $nodeTranslation, $nodeVersion, $page)
        );

        $node->setDeleted(true);
        $this->em->persist($node);

        $children = $node->getChildren();
        $this->deleteNodeChildren($this->em, $this->user, $this->locale, $children);
        $this->em->flush();

        $event = new NodeEvent($node, $nodeTranslation, $nodeVersion, $page);
        $this->get('event_dispatcher')->dispatch(Events::POST_DELETE, $event);
        if (null === $response = $event->getResponse()) {
            $nodeParent = $node->getParent();
            // Check if we have a parent. Otherwise redirect to pages overview.
            if ($nodeParent) {
                $url = $this->get('router')->generate(
                    'KunstmaanNodeBundle_nodes_edit',
                    array('id' => $nodeParent->getId())
                );
            } else {
                $url = $this->get('router')->generate(
                    'KunstmaanNodeBundle_nodes'
                );
            }
            $response = new RedirectResponse($url);
        }

        $this->addFlash(
            FlashTypes::SUCCESS,
            $this->get('translator')->trans('kuma_node.admin.delete.flash.success')
        );

        return $response;
    }
562022
public function isFullyEvaluated(Paper $paper)
    {
        return 0 === (int) $this->getEntityManager()
            ->createQuery('
                SELECT COUNT(a)
                FROM UJM\ExoBundle\Entity\Attempt\Answer AS a
                WHERE a.paper = :paper
                  AND a.score IS NULL
            ')
            ->setParameters([
                'paper' => $paper,
            ])
            ->getSingleScalarResult();
    }
118927
public function deleteAction($id)
    {
        $documentManager = $this->getDocumentManager();
        $document = $documentManager->find($id);
        $documentManager->remove($document);
        $documentManager->flush();

        return $this->handleView($this->view(null));
    }
1258403
public function deleteAction(Request $request, $id)
    {
        $manager = $this->get('opifer.content.content_manager');
        $content = $manager->getRepository()->find($id);

        $em = $this->get('doctrine')->getManager();
        $em->remove($content);
        $em->flush();

        return new JsonResponse(['success' => true]);
    }
69185
public function deleteAction(MeasureUnit $measureunit, Request $request)
    {
        $form = $this->createDeleteForm($measureunit->getId(), 'admin_shop_measure_unit_delete');
        if ($form->handleRequest($request)->isValid()) {
            $em = $this->getDoctrine()->getManager();
            $em->remove($measureunit);
            $em->flush();
        }

        return $this->redirect($this->generateUrl('admin_shop_measure_unit'));
    }
277869
public function deleteAction($articleUuid, $uuid, Request $request)
    {
        $locale = $this->getRequestParameter($request, 'locale', true);

        $documentManager = $this->getDocumentManager();
        $document = $documentManager->find($uuid, $locale);
        $documentManager->remove($document);
        $documentManager->flush();

        return $this->handleView($this->view(null));
    }
929219
public function delete(Post $post)
    {
        $this->authorize(PostsPolicy::PERMISSION_DELETE);

        try {
            $post->trashed() ? $post->forceDelete() : $post->delete();

            return $this->jsonResponseSuccess([
                'message' => $this->transNotification('deleted', ['title' => $post->title], $post->toArray())
            ]);
        }
        catch(\Exception $e) {
            return $this->jsonResponseError(['message' => $e->getMessage()], 500);
        }
    }
1237347
public function deleteOne($document, $options = [])
    {
        $query = new DeleteOne($this->documentManager, $this, $document, $options);
        if (isset($options['getQuery']) && $options['getQuery']) {
            return $query;
        } else {
            return $query->execute();
        }
    }
1228321
public function setPage($page)
    {
        if (!isset($this->_persistence) || !($this->_persistence instanceof IPersistance)) {
            throw new Exception("Repository Exception : No existe la interfaz de la persistencia o no implementa la interfaz IPersistance.");
        }

        $limit = $this->_persistence->getLimit();

        if (!isset($limit)) {
            throw new Exception("Repository Exception : No estña seteado el limite de la operación de lectura.");
        }

        $this->_persistence->setOffset($limit * $page);

        return $this;
    }
404391
public function deleteAction($id)
    {
        $em = $this->getDoctrine()->getManager();
        $em->remove($this->getImage($id));
        $em->flush();

        return new Response();
    }
590839
private function hardDelete(Page $page)
    {
        if (!$page->isDeleted()) {
            throw new BadRequestHttpException('Page is not in trash, cannot remove it.');
        }

        if (true === $page->isRoot()) {
            throw new BadRequestHttpException('Cannot remove root page of a site.');
        }

        $this->granted('DELETE', $page);

        $this->getPageRepository()->deletePage($page);
    }
104032
public function generateResourceEvaluation(Paper $paper, $finished)
    {
        $totalScoreOn = $paper->getExercise()->getTotalScoreOn();
        $total = $totalScoreOn ? $totalScoreOn : $this->calculateTotal($paper);
        $score = $this->calculateScore($paper, $total);
        $successScore = $paper->getExercise()->getSuccessScore();
        $data = [
            'paper' => [
                'id' => $paper->getId(),
                'uuid' => $paper->getUuid(),
            ],
        ];

        if ($finished) {
            if (is_null($successScore)) {
                $status = AbstractResourceEvaluation::STATUS_COMPLETED;
            } else {
                $percentScore = 100 === $totalScoreOn ? $score : $this->calculateScore($paper, 100);
                $status = $percentScore >= $successScore ?
                    AbstractResourceEvaluation::STATUS_PASSED :
                    AbstractResourceEvaluation::STATUS_FAILED;
            }
        } else {
            $status = AbstractResourceEvaluation::STATUS_INCOMPLETE;
        }
        $nbQuestions = 0;
        $structure = json_decode($paper->getStructure(), true);

        if (isset($structure['steps'])) {
            foreach ($structure['steps'] as $step) {
                $nbQuestions += count($step['items']); // TODO : remove content items
            }
        }
        $nbAnswers = 0;

        foreach ($paper->getAnswers() as $answer) {
            if (!is_null($answer->getData())) {
                ++$nbAnswers;
            }
        }

        return $this->resourceEvalManager->createResourceEvaluation(
            $paper->getExercise()->getResourceNode(),
            $paper->getUser(),
            null,
            [
                'status' => $status,
                'score' => $score,
                'scoreMax' => $total,
                'progression' => $nbQuestions > 0 ? floor(($nbAnswers / $nbQuestions) * 100) : null,
                'data' => $data,
            ]
        );
    }
1046870
public function delete()
    {
        if (null === $this->alPage) {
            throw new General\ArgumentIsEmptyException('exception_no_pages_selected_delete_skipped');
        }

        if (0 !== $this->alPage->getIsHome()) {
            throw new PageException\RemoveHomePageException("exception_home_page_cannot_be_removed");
        }

        $this->dispatchBeforeOperationEvent(
            '\RedKiteLabs\RedKiteCms\RedKiteCmsBundle\Core\Event\Content\Page\BeforePageDeletingEvent',
            PageEvents::BEFORE_DELETE_PAGE,
            array(),
            array(
                'message' => 'exception_page_deleting_aborted',
                'domain' => 'exceptions',
            )
        );

        try {
            $this->pageRepository->startTransaction();
            $this->pageRepository->setRepositoryObject($this->alPage);
            $result = $this->pageRepository->delete();
            if ($result) {
                $eventName = PageEvents::BEFORE_DELETE_PAGE_COMMIT;
                $result = !$this->eventsHandler
                                ->createEvent($eventName, '\RedKiteLabs\RedKiteCms\RedKiteCmsBundle\Core\Event\Content\Page\BeforeDeletePageCommitEvent', array($this, array()))
                                ->dispatch()
                                ->getEvent($eventName)
                                ->isAborted();
            }

            if (false !== $result) {
                $this->pageRepository->commit();

                $this->eventsHandler
                     ->createEvent(PageEvents::AFTER_DELETE_PAGE, '\RedKiteLabs\RedKiteCms\RedKiteCmsBundle\Core\Event\Content\Page\AfterPageDeletedEvent', array($this))
                     ->dispatch();

                return $result;
            }
            $this->pageRepository->rollBack();

            return $result;
        } catch (\Exception $e) {
            if (isset($this->pageRepository) && $this->pageRepository !== null) {
                $this->pageRepository->rollBack();
            }

            throw $e;
        }
    }
479054
public function destroy(Request $request, $page)
    {
        // Set roles that have access
        $request->user()->authorizeRoles(['admin', 'editor']);

        $page = Page::withTrashed()->findOrFail($page);

        if ($page->trashed() && !$request->input('confirm_delete')) {
            return redirect()->route('admin.pages.page.delete', $page);
        }

        if ($request->input('confirm_delete')) {
            $page->forceDelete();
            return redirect()->route('admin.pages.index.trashed');
        }

        $page->status = 1;
        $page->save();
        $page->delete();

        flash('Page has been moved to trash')->success();

        return back();
    }
956164
public function destroy(PageRequest $request, Page $page)
    {
        try {
            $page->delete();
            $message = trans('messages.success.deleted', ['Module' => trans('page::page.name')]);
            $code    = 202;
            $status  = 'success';
            $url     = guard_url('page/page/0');
        } catch (Exception $e) {
            $message = $e->getMessage();
            $code    = 400;
            $status  = 'error';
            $url     = guard_url('page/page/' . $page->getRouteKey());
        }
        return compact('message', 'code', 'status', 'url');
    }
1165202
public function delete(Paper $paper)
    {
        $this->om->remove($paper);
        $this->om->flush();
    }