/**
  * Update the duration built-in variable. The update will only take
  * place if the current state of the item session is INTERACTING.
  * 
  */
 public function updateDuration()
 {
     // If the current state is INTERACTING update duration built-in variable.
     if ($this->getState() === AssessmentItemSessionState::INTERACTING) {
         $timeRef = $this->getTimeReference();
         $now = new DateTime('now', new DateTimeZone('UTC'));
         $data =& $this->getDataPlaceHolder();
         $diff = $timeRef->diff($now);
         $data['duration']->getValue()->add($diff);
         $this->setTimeReference($now);
         foreach ($this->onDurationUpdate as $callBack) {
             call_user_func_array($callBack, array($this, Duration::createFromDateInterval($diff)));
         }
     }
 }
Beispiel #2
0
 public function createFromDateInterval()
 {
     $interval = new DateInterval('PT5S');
     $duration = Duration::createFromDateInterval($interval);
     $this->assertEquals(5, $duration->getSeconds(true));
 }