예제 #1
0
 /**
  * implement the abstract method
  * Get score max possible for a QCM.
  *
  *
  * @param \UJM\ExoBundle\Entity\InteractionQCM $interQCM
  *
  * @return float
  */
 public function maxScore($interQCM = null)
 {
     $scoreMax = 0;
     if (!$interQCM->getWeightResponse()) {
         $scoreMax = $interQCM->getScoreRightResponse();
     } else {
         foreach ($interQCM->getChoices() as $choice) {
             if ($choice->getRightResponse()) {
                 $scoreMax += $choice->getWeight();
             }
         }
     }
     return $scoreMax;
 }
 /**
  * Implements the abstract method
  *
  * @access public
  *
  * @param \UJM\ExoBundle\Entity\InteractionQCM $originalInterQCM
  *
  * Return boolean
  */
 public function processUpdate($originalInterQCM)
 {
     $originalChoices = array();
     $originalHints = array();
     // Create an array of the current Choice objects in the database
     foreach ($originalInterQCM->getChoices() as $choice) {
         $originalChoices[] = $choice;
     }
     foreach ($originalInterQCM->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(), $originalChoices, $originalHints);
             return true;
         }
     }
     return false;
 }