public function getUserQuestions(Users $user, Quizset $quizset) { try { $result = $this->getEntityManager()->createQuery('SELECT us.hashQuestion, us.hashAns1, us.hashAns2, us.hashAns3, us.id, us.idQuestion, q.content, q.ans1, q.ans2, q.ans3, q.type FROM AppBundle:QuestionToUserSet us, AppBundle:Question q WHERE us.idSet = :idset AND us.idUser = :user AND q.id = us.idQuestion ')->setParameter(':idset', $quizset->getId())->setParameter(':user', $user->getId())->execute(); if (!$result) { return false; } return $result; } catch (NoResultException $e) { return false; } }
public static function createUserSet(Users $user, Quizset $set) { $UserQuizSet = new UsersToQuizset(); $UserQuizSet->setIdSet($set->getId()); $UserQuizSet->setIdUser($user->getId()); $UserQuizSet->setMasterHash(md5($user->getId() . $user->getEmail() . time())); return $UserQuizSet; }
/** * Creates a form to delete a Users entity. * * @param Users $user The Users entity * * @return \Symfony\Component\Form\Form The form */ private function createDeleteForm(Users $user) { return $this->createFormBuilder()->setAction($this->generateUrl('users_delete', array('id' => $user->getId())))->setMethod('DELETE')->getForm(); }
/** * @Route("{id}/editando-usuario/", name="adGt-gestEditUsers", options={"expose":true}) * @ParamConverter("user", class="AppBundle:Users", options={"mapping":{"id":"id"}}) * @Method({"POST"}) */ public function gestEditUserAction(\AppBundle\Entity\Users $user) { $newObj = array(); if ($user) { $newObj['id'] = $user->getId(); $newObj['username'] = $user->getUsername(); $newObj['email'] = $user->getEmail(); } $respuesta = new \Symfony\Component\HttpFoundation\JsonResponse(); return $respuesta->setData($newObj); }
public static function createUserQuestions(Users $User, $Questions, UsersToQuizset $UsersToQuizset) { $return = array(); $masterHash = $UsersToQuizset->getMasterHash(); $setId = $UsersToQuizset->getIdSet(); $userId = $User->getId(); foreach ($Questions as $Question) { $qUserSet = new QuestionToUserSet(); $qUserSet->setIdSet($setId); $qUserSet->setIdQuestion($Question->getId()); $qUserSet->setIdUser($userId); $qUserSet->setHashQuestion(md5($Question->getId() . $masterHash . $Question->getContent())); $qUserSet->setHashAns1(md5($Question->getId() . $masterHash . $Question->getAns1())); $qUserSet->setHashAns2(md5($Question->getId() . $masterHash . $Question->getAns2())); $qUserSet->setHashAns3(md5($Question->getId() . $masterHash . $Question->getAns3())); $return[] = $qUserSet; } return $return; }