예제 #1
0
 public function getPointsByAttempt(Attempt $attempt)
 {
     $points = $this->getEntityManager()->createQuery("SELECT SUM(answer.points) FROM AppBundle:UserAnswer u\n                INNER JOIN u.answer answer\n                WHERE u.attempt=" . $attempt->getId())->getSingleScalarResult();
     if ($points != null) {
         return $points;
     } else {
         return 0;
     }
 }
예제 #2
0
 /**
  * @Route("/q/{quizsession}", name="ajax_start")
  */
 public function startQuizAction($quizsession, Request $request)
 {
     $session = $request->getSession();
     $em = $this->getDoctrine()->getManager();
     $quizsession = $em->getRepository('AppBundle:QuizSession')->find($quizsession);
     $attempt = new Attempt();
     $attempt->setSession($quizsession);
     $attempt->setUser($this->getUser());
     $em->persist($attempt);
     $em->flush();
     $session->set('attempt', $attempt->getId());
     return $this->redirectToRoute('ajax_solve', array('attempt' => $attempt->getId()));
 }