/**
  * Implements the abstract method
  *
  * @access public
  *
  * @param \UJM\ExoBundle\Entity\InteractionOpen $originalInterOpen
  *
  * Return boolean
  */
 public function processUpdate($originalInterOpen)
 {
     $originalWrs = array();
     $originalHints = array();
     foreach ($originalInterOpen->getWordResponses() as $wr) {
         $originalWrs[] = $wr;
     }
     foreach ($originalInterOpen->getInteraction()->getHints() as $hint) {
         $originalHints[] = $hint;
     }
     if ($this->request->getMethod() == 'POST') {
         $this->form->handleRequest($this->request);
         if ($this->form->isValid()) {
             $this->onSuccessUpdate($this->form->getData(), $originalWrs, $originalHints);
             return true;
         }
     }
     return false;
 }
 /**
  * Implements the abstract method.
  *
  *
  * @param \UJM\ExoBundle\Entity\InteractionOpen $originalInterOpen
  *
  * Return boolean
  */
 public function processUpdate($originalInterOpen)
 {
     $originalWrs = [];
     $originalHints = [];
     foreach ($originalInterOpen->getWordResponses() as $wr) {
         $originalWrs[] = $wr;
     }
     foreach ($originalInterOpen->getQuestion()->getHints() as $hint) {
         $originalHints[] = $hint;
     }
     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(), $originalWrs, $originalHints);
             return true;
         }
     }
     return false;
 }
Exemplo n.º 3
0
 /**
  * Get score for an open question with short answer
  *
  * @access private
  *
  * @param String $response
  * @param \UJM\ExoBundle\Entity\InteractionOpen $interOpen
  *
  * @return float
  */
 private function getScoreShortResponse($response, $interOpen)
 {
     $score = 0;
     foreach ($interOpen->getWordResponses() as $wr) {
         $pattern = '/' . $wr->getResponse() . '/';
         if (!$wr->getCaseSensitive()) {
             $pattern .= 'i';
         }
         $subject = '/' . $response . '/';
         if (preg_match($pattern, $subject)) {
             $score += $wr->getScore();
         }
     }
     return $score;
 }
Exemplo n.º 4
0
 /**
  * @param string $title
  *
  * @return Question
  */
 public function openQuestion($title)
 {
     $question = new Question();
     $question->setTitle($title);
     $question->setInvite('Invite...');
     $interactionQcm = new InteractionOpen();
     $interactionQcm->setQuestion($question);
     $this->om->persist($interactionQcm);
     $this->om->persist($question);
     return $question;
 }