Created
October 1, 2011 00:41
-
-
Save cordoval/1255424 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| namespace EIP\ProgramBundle\Controller; | |
| use Symfony\Bundle\FrameworkBundle\Controller\Controller; | |
| use EIP\ProgramBundle\Entity\Question; | |
| use EIP\ProgramBundle\Form\BiometricsType; | |
| use EIP\ProgramBundle\Entity\ParticipantAnswer; | |
| use Symfony\Component\HttpFoundation\Request; | |
| /** | |
| * Biometrics controller. | |
| * | |
| */ | |
| class BiometricsController extends Controller | |
| { | |
| /** | |
| * Displays a form to create a new Biometrics entity. | |
| * | |
| */ | |
| public function newAction() | |
| { | |
| $em = $this->getDoctrine()->getEntityManager(); | |
| $query = $em->createQuery(' | |
| SELECT q, a FROM EIPProgramBundle:Question q | |
| LEFT JOIN q.attributes a | |
| WHERE q.active = 1 | |
| AND q.questionSetId = 1 | |
| Order By q.sortOrder ASC' | |
| ); | |
| $questions = $query->getResult(); | |
| $form = $this->createForm(new BiometricsType(), $questions); | |
| return $this->render('EIPProgramBundle:Biometrics:new.html.twig', array( | |
| 'entity' => $questions, | |
| 'form' => $form->createView() | |
| )); | |
| } | |
| /** | |
| * Creates a new Biometrics entity. | |
| * | |
| */ | |
| public function createAction() | |
| { | |
| $entity = new Question(); | |
| $request = $this->getRequest(); | |
| $request2 = Request::createFromGlobals(); | |
| foreach ($request2->request->get() as $field) { | |
| echo "<pre>"; | |
| print_r($field); | |
| echo "</pre>"; | |
| } | |
| $form = $this->createForm(new BiometricsType(), $entity); | |
| $form->bindRequest($request); | |
| if ($form->isValid()) { | |
| $em = $this->getDoctrine()->getEntityManager(); | |
| $em->persist($entity); | |
| $em->flush(); | |
| return $this->redirect($this->generateUrl('admin_show', array('id' => $entity->getId()))); | |
| } | |
| return $this->render('EIPProgramBundle:Biometrics:new.html.twig', array( | |
| 'entity' => $entity, | |
| 'form' => $form->createView() | |
| )); | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| namespace EIP\ProgramBundle\Form; | |
| use Symfony\Component\Form\AbstractType; | |
| use Symfony\Component\Form\FormBuilder; | |
| class BiometricsType extends AbstractType | |
| { | |
| public function buildForm(FormBuilder $builder, array $options) | |
| { | |
| foreach ($options['data'] as $question) { | |
| $name = $question->getDisplayText(); | |
| $type = $question->getType()->getQuestionType(); | |
| $attributes = $question->getAttributes(); | |
| $fieldOptions = array(); | |
| foreach ($attributes as $attribute) { | |
| if ($attribute->getName() === "choices") { | |
| $fieldOptions['choices'][] = $attribute->getValue(); | |
| } elseif ($attribute->getName() != "") { | |
| $fieldOptions[$attribute->getName()] = $attribute->getValue(); | |
| } | |
| } | |
| $builder->add($name, $type, $fieldOptions); | |
| } | |
| } | |
| public function getName() | |
| { | |
| return 'eip_programbundle_biometricstype'; | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| namespace EIP\ProgramBundle\Entity; | |
| use Doctrine\ORM\Mapping as ORM; | |
| /** | |
| * @ORM\Entity | |
| * @ORM\Table(name="participant_answer") | |
| */ | |
| class ParticipantAnswer | |
| { | |
| /** | |
| * @ORM\Id | |
| * @ORM\Column(type="integer") | |
| * @ORM\GeneratedValue(strategy="AUTO") | |
| */ | |
| private $id; | |
| /** | |
| * @ORM\Column(type="integer") | |
| */ | |
| private $participantId; | |
| /** | |
| * @ORM\ManyToOne(targetEntity="Question") | |
| * @ORM\JoinColumns({ | |
| * @ORM\JoinColumn(name="questionId", referencedColumnName="id") | |
| * }) | |
| */ | |
| private $question; | |
| /** | |
| * @ORM\Column(type="string", length="50") | |
| */ | |
| private $answer; | |
| /** | |
| * @ORM\Column(type="integer") | |
| */ | |
| private $participantActivityId; | |
| /** | |
| * @ORM\Column(type="integer") | |
| */ | |
| private $participantClassRoomSessionId; | |
| /** | |
| * Get id | |
| * | |
| * @return integer | |
| */ | |
| public function getId() | |
| { | |
| return $this->id; | |
| } | |
| /** | |
| * Set participantId | |
| * | |
| * @param integer $participantId | |
| */ | |
| public function setParticipantId($participantId) | |
| { | |
| $this->participantId = $participantId; | |
| } | |
| /** | |
| * Get participantId | |
| * | |
| * @return integer | |
| */ | |
| public function getParticipantId() | |
| { | |
| return $this->participantId; | |
| } | |
| /** | |
| * Set answer | |
| * | |
| * @param string $answer | |
| */ | |
| public function setAnswer($answer) | |
| { | |
| $this->answer = $answer; | |
| } | |
| /** | |
| * Get answer | |
| * | |
| * @return string | |
| */ | |
| public function getAnswer() | |
| { | |
| return $this->answer; | |
| } | |
| /** | |
| * Set participantActivityId | |
| * | |
| * @param integer $participantActivityId | |
| */ | |
| public function setParticipantActivityId($participantActivityId) | |
| { | |
| $this->participantActivityId = $participantActivityId; | |
| } | |
| /** | |
| * Get participantActivityId | |
| * | |
| * @return integer | |
| */ | |
| public function getParticipantActivityId() | |
| { | |
| return $this->participantActivityId; | |
| } | |
| /** | |
| * Set participantClassRoomSessionId | |
| * | |
| * @param integer $participantClassRoomSessionId | |
| */ | |
| public function setParticipantClassRoomSessionId($participantClassRoomSessionId) | |
| { | |
| $this->participantClassRoomSessionId = $participantClassRoomSessionId; | |
| } | |
| /** | |
| * Get participantClassRoomSessionId | |
| * | |
| * @return integer | |
| */ | |
| public function getParticipantClassRoomSessionId() | |
| { | |
| return $this->participantClassRoomSessionId; | |
| } | |
| /** | |
| * Set question | |
| * | |
| * @param EIP\ProgramBundle\Entity\Question $question | |
| */ | |
| public function setQuestion(\EIP\ProgramBundle\Entity\Question $question) | |
| { | |
| $this->question = $question; | |
| } | |
| /** | |
| * Get question | |
| * | |
| * @return EIP\ProgramBundle\Entity\Question | |
| */ | |
| public function getQuestion() | |
| { | |
| return $this->question; | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| namespace EIP\ProgramBundle\Entity; | |
| use Doctrine\ORM\Mapping as ORM; | |
| /** | |
| * @ORM\Entity | |
| * @ORM\Table(name="question_attribute") | |
| */ | |
| class QuestionAttributes | |
| { | |
| /** | |
| * @ORM\Id | |
| * @ORM\Column(type="integer") | |
| * @ORM\GeneratedValue(strategy="AUTO") | |
| */ | |
| private $id; | |
| /** | |
| * @ORM\ManyToOne(targetEntity="Question", inversedBy="attributes") | |
| * @ORM\JoinColumns({ | |
| * @ORM\JoinColumn(name="questionId", referencedColumnName="id") | |
| * }) | |
| */ | |
| private $question; | |
| /** | |
| * @ORM\Column(type="string", length="50") | |
| */ | |
| private $name; | |
| /** | |
| * @ORM\Column(type="string", length="50") | |
| */ | |
| private $value; | |
| /** | |
| * Get id | |
| * | |
| * @return integer | |
| */ | |
| public function getId() | |
| { | |
| return $this->id; | |
| } | |
| /** | |
| * Set name | |
| * | |
| * @param string $name | |
| */ | |
| public function setName($name) | |
| { | |
| $this->name = $name; | |
| } | |
| /** | |
| * Get name | |
| * | |
| * @return string | |
| */ | |
| public function getName() | |
| { | |
| return $this->name; | |
| } | |
| /** | |
| * Set value | |
| * | |
| * @param string $value | |
| */ | |
| public function setValue($value) | |
| { | |
| $this->value = $value; | |
| } | |
| /** | |
| * Get name | |
| * | |
| * @return string | |
| */ | |
| public function getValue() | |
| { | |
| return $this->value; | |
| } | |
| /** | |
| * Set Question | |
| * | |
| * @param integer $question | |
| */ | |
| public function setQuestion($question) | |
| { | |
| $this->question = $question; | |
| } | |
| /** | |
| * Get Question | |
| * | |
| * @return integer | |
| */ | |
| public function getQuestion() | |
| { | |
| return $this->question; | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| namespace EIP\ProgramBundle\Entity; | |
| use Doctrine\ORM\Mapping as ORM; | |
| use Doctrine\Common\Collections\ArrayCollection; | |
| /** | |
| * @ORM\Entity | |
| * @ORM\Table(name="question") | |
| */ | |
| class Question | |
| { | |
| /** | |
| * @ORM\Id | |
| * @ORM\Column(type="integer") | |
| * @ORM\GeneratedValue(strategy="AUTO") | |
| */ | |
| private $id; | |
| /** | |
| * @ORM\Column(type="string", length="200") | |
| */ | |
| private $displayText; | |
| /** | |
| * @ORM\Column(type="integer") | |
| */ | |
| private $unitId; | |
| /** | |
| * @ORM\Column(type="integer") | |
| */ | |
| private $sortOrder; | |
| /** | |
| * @ORM\OneToOne(targetEntity="QuestionType") | |
| * @ORM\JoinColumn(name="questionTypeId", referencedColumnName="id") | |
| */ | |
| private $type; | |
| /** | |
| * @ORM\OneToMany(targetEntity="QuestionAttributes", mappedBy="question", cascade={"persist", "remove"}) | |
| */ | |
| private $attributes; | |
| /** | |
| * @ORM\Column(type="integer") | |
| */ | |
| private $questionSetId; | |
| /** | |
| * @ORM\Column(type="integer") | |
| */ | |
| private $active; | |
| /** | |
| * @ORM\Column(type="datetime") | |
| */ | |
| private $updatedOn; | |
| /** | |
| * @ORM\Column(type="integer") | |
| */ | |
| private $updatedBy; | |
| public function __construct() | |
| { | |
| $this->attributes = new ArrayCollection(); | |
| } | |
| /** | |
| * Get id | |
| * | |
| * @return integer | |
| */ | |
| public function getId() | |
| { | |
| return $this->id; | |
| } | |
| /** | |
| * Set displayText | |
| * | |
| * @param string $displayText | |
| */ | |
| public function setDisplayText($displayText) | |
| { | |
| $this->displayText = $displayText; | |
| } | |
| /** | |
| * Get displayText | |
| * | |
| * @return string | |
| */ | |
| public function getDisplayText() | |
| { | |
| return $this->displayText; | |
| } | |
| /** | |
| * Set unitId | |
| * | |
| * @param integer $unitId | |
| */ | |
| public function setUnitId($unitId) | |
| { | |
| $this->unitId = $unitId; | |
| } | |
| /** | |
| * Get unitId | |
| * | |
| * @return integer | |
| */ | |
| public function getUnitId() | |
| { | |
| return $this->unitId; | |
| } | |
| /** | |
| * Set sortOrder | |
| * | |
| * @param integer $sortOrder | |
| */ | |
| public function setSortOrder($sortOrder) | |
| { | |
| $this->sortOrder = $sortOrder; | |
| } | |
| /** | |
| * Get sortOrder | |
| * | |
| * @return integer | |
| */ | |
| public function getSortOrder() | |
| { | |
| return $this->sortOrder; | |
| } | |
| /** | |
| * Set type | |
| * | |
| * @param integer $type | |
| */ | |
| public function setType($type) | |
| { | |
| $this->type = $type; | |
| } | |
| /** | |
| * Get type | |
| * | |
| * @return integer | |
| */ | |
| public function getType() | |
| { | |
| return $this->type; | |
| } | |
| /** | |
| * Set questionSetId | |
| * | |
| * @param integer $questionSetId | |
| */ | |
| public function setQuestionSetId($questionSetId) | |
| { | |
| $this->questionSetId = $questionSetId; | |
| } | |
| /** | |
| * Get questionSetId | |
| * | |
| * @return integer | |
| */ | |
| public function getQuestionSetId() | |
| { | |
| return $this->questionSetId; | |
| } | |
| /** | |
| * Set active | |
| * | |
| * @param boolean $active | |
| */ | |
| public function setActive($active) | |
| { | |
| $this->active = $active; | |
| } | |
| /** | |
| * Is active | |
| * | |
| * @return boolean | |
| */ | |
| public function isActive() | |
| { | |
| return $this->active; | |
| } | |
| /** | |
| * Set updatedOn | |
| * | |
| */ | |
| public function setUpdatedOn() | |
| { | |
| $this->updatedOn = new \DateTime(); | |
| } | |
| /** | |
| * Get updatedOn | |
| * | |
| * @return datetime | |
| */ | |
| public function getUpdatedOn() | |
| { | |
| return $this->updatedOn; | |
| } | |
| /** | |
| * Set updatedBy | |
| * | |
| * @param integer $updatedBy | |
| */ | |
| public function setUpdatedBy($updatedBy) | |
| { | |
| $this->updatedBy = $updatedBy; | |
| } | |
| /** | |
| * Get questionAttributeId | |
| * | |
| * @return integer | |
| */ | |
| public function getUpdatedBy() | |
| { | |
| return $this->updatedBy; | |
| } | |
| /* | |
| * Get attributes | |
| * | |
| * @return array | |
| */ | |
| public function getAttributes() | |
| { | |
| return $this->attributes; | |
| } | |
| /** | |
| * Get active | |
| * | |
| * @return integer | |
| */ | |
| public function getActive() | |
| { | |
| return $this->active; | |
| } | |
| /** | |
| * Add attributes | |
| * | |
| * @param EIP\ProgramBundle\Entity\QuestionAttributes $attributes | |
| */ | |
| public function addQuestionAttributes(\EIP\ProgramBundle\Entity\QuestionAttributes $attributes) | |
| { | |
| $this->attributes[] = $attributes; | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| namespace EIP\ProgramBundle\Entity; | |
| use Doctrine\ORM\Mapping as ORM; | |
| /** | |
| * @ORM\Entity | |
| * @ORM\Table(name="question_type") | |
| */ | |
| class QuestionType | |
| { | |
| /** | |
| * @ORM\Id | |
| * @ORM\Column(type="integer") | |
| * @ORM\GeneratedValue(strategy="AUTO") | |
| */ | |
| private $id; | |
| /** | |
| * @ORM\Column(type="string", length="50") | |
| */ | |
| private $questionType; | |
| /** | |
| * @ORM\Column(type="string", length="50") | |
| */ | |
| private $displayText; | |
| /** | |
| * @ORM\Column(type="datetime") | |
| */ | |
| private $updatedOn; | |
| /** | |
| * @ORM\Column(type="integer") | |
| */ | |
| private $updatedBy; | |
| /** | |
| * Get id | |
| * | |
| * @return integer | |
| */ | |
| public function getId() | |
| { | |
| return $this->id; | |
| } | |
| /** | |
| * Set questionType | |
| * | |
| * @param string $questionType | |
| */ | |
| public function setQuestionType($questionType) | |
| { | |
| $this->questionType = $questionType; | |
| } | |
| /** | |
| * Get questionType | |
| * | |
| * @return string | |
| */ | |
| public function getQuestionType() | |
| { | |
| return $this->questionType; | |
| } | |
| /** | |
| * Set displayText | |
| * | |
| * @param string $displayText | |
| */ | |
| public function setDisplayText($displayText) | |
| { | |
| $this->displayText = $displayText; | |
| } | |
| /** | |
| * Get displayText | |
| * | |
| * @return string | |
| */ | |
| public function getDisplayText() | |
| { | |
| return $this->displayText; | |
| } | |
| /** | |
| * Set updatedOn | |
| * | |
| * @param datetime $updatedOn | |
| */ | |
| public function setUpdatedOn($updatedOn) | |
| { | |
| $this->updatedOn = new \DateTime(); | |
| } | |
| /** | |
| * Get updatedOn | |
| * | |
| * @return datetime | |
| */ | |
| public function getUpdatedOn() | |
| { | |
| return $this->updatedOn; | |
| } | |
| /** | |
| * Set updatedBy | |
| * | |
| * @param integer $updatedBy | |
| */ | |
| public function setUpdatedBy($updatedBy) | |
| { | |
| $this->updatedBy = $updatedBy; | |
| } | |
| /** | |
| * Get questionAttributeId | |
| * | |
| * @return integer | |
| */ | |
| public function getUpdatedBy() | |
| { | |
| return $this->updatedBy; | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment