/** * Implements the abstract method. * * * @param \UJM\ExoBundle\Entity\InteractionMatching $originalInterMatching * * Return boolean */ public function processUpdate($originalInterMatching) { $originalLabel = []; $originalProposal = []; $originalHints = []; //create an array of currente Label of the database foreach ($originalInterMatching->getLabels() as $label) { $originalLabel[] = $label; } foreach ($originalInterMatching->getProposals() as $proposal) { $originalProposal[] = $proposal; } foreach ($originalInterMatching->getQuestion()->getHints() as $hints) { $originalHints[] = $hints; } if ($this->request->getMethod() == 'POST') { $this->form->handleRequest($this->request); // Uses the default category if no category selected $this->checkCategory(); if ($this->form->isValid()) { $this->onSuccessUpdate($this->form->getData(), $originalLabel, $originalProposal, $originalHints); return true; } } return false; }
/** * Implements the abstract method * * @access public * * @param \UJM\ExoBundle\Entity\InteractionMatching $originalInterMatching * * Return boolean */ public function processUpdate($originalInterMatching) { $originalLabel = array(); $originalProposal = array(); $originalHints = array(); //create an array of currente Label of the database foreach ($originalInterMatching->getLabels() as $label) { $originalLabel[] = $label; } foreach ($originalInterMatching->getProposals() as $proposal) { $originalProposal[] = $proposal; } foreach ($originalInterMatching->getInteraction()->getHints() as $hints) { $originalHints[] = $hints; } if ($this->request->getMethod() == 'POST') { $this->form->handleRequest($this->request); if ($this->form->isValid()) { $this->onSuccessUpdate($this->form->getData(), $originalLabel, $originalProposal, $originalHints); return TRUE; } } return FALSE; }
public function matchQuestion($title, $labels = [], $proposals = []) { $question = new Question(); $question->setTitle($title); $question->setInvite('Invite...'); if (!$this->matchType) { $this->matchType = $this->om->getRepository('UJMExoBundle:TypeMatching')->findOneByCode(1); } $interactionMatching = new InteractionMatching(); $interactionMatching->setQuestion($question); $interactionMatching->setShuffle(false); $interactionMatching->setTypeMatching($this->matchType); for ($i = 0, $max = count($labels); $i < $max; ++$i) { $labels[$i]->setOrdre($i); $interactionMatching->addLabel($labels[$i]); } for ($i = 0, $max = count($proposals); $i < $max; ++$i) { $proposals[$i]->setOrdre($i + 1); $interactionMatching->addProposal($proposals[$i]); } $this->om->persist($interactionMatching); $this->om->persist($question); return $question; }
/** * init array of rights responses indexed by labelId. * * * @param \UJM\ExoBundle\Entity\InteractionMatching $interMatching * * @return mixed[] */ public function initTabRightResponse($interMatching) { $tabRightResponse = array(); //array of rights responses indexed by labelId foreach ($interMatching->getProposals() as $proposal) { $associateLabel = $proposal->getAssociatedLabel(); if ($associateLabel != null) { foreach ($associateLabel as $associatedLabel) { $index = $associatedLabel->getId(); if (isset($tabRightResponse[$index])) { $tabRightResponse[$index] .= '-' . $proposal->getId(); } else { $tabRightResponse[$index] = $proposal->getId(); } } } } //add in $tabRightResponse label empty foreach ($interMatching->getLabels() as $label) { if (!isset($tabRightResponse[$label->getId()])) { $tabRightResponse[$label->getId()] = null; } } return $tabRightResponse; }