Exemplo n.º 1
0
 /**
  * Unmarshall a DOMElement object corresponding to a QTI timeLimits element.
  *
  * @param \DOMElement $element A DOMElement object.
  * @return \qtism\data\QtiComponent A TimeLimits object.
  * @throws \qtism\data\storage\xml\marshalling\UnmarshallingException If the attribute 'allowLateSubmission' is not a valid boolean value.
  */
 protected function unmarshall(DOMElement $element)
 {
     $object = new TimeLimits();
     if (($value = static::getDOMElementAttributeAs($element, 'minTime', 'string')) !== null) {
         $object->setMinTime(StorageUtils::stringToDatatype("PT{$value}S", BaseType::DURATION));
     }
     if (($value = static::getDOMElementAttributeAs($element, 'maxTime', 'string')) !== null) {
         $object->setMaxTime(StorageUtils::stringToDatatype("PT{$value}S", BaseType::DURATION));
     }
     if (($value = static::getDOMElementAttributeAs($element, 'allowLateSubmission', 'boolean')) !== null) {
         $object->setAllowLateSubmission($value);
     }
     return $object;
 }
 /**
  * @depends testEndAttemptTimeOverflowNoLateSubmission
  */
 public function testEndAttemptTimeOverflowWithLateSubmission()
 {
     $session = self::instantiateBasicAssessmentItemSession();
     $timeLimits = new TimeLimits(null, new QtiDuration('PT30S'));
     $timeLimits->setAllowLateSubmission(true);
     $session->setTimeLimits($timeLimits);
     // The session is time-tracked and begins 2014-07-14 at 1 PM.
     $session->setTime(self::createDate('2014-07-14 13:00:00'));
     $session->beginItemSession();
     // The candidate spent 2 seconds to begin his first attempt.
     $session->setTime(self::createDate('2014-07-14 13:00:02'));
     $session->beginAttempt();
     // The candidate spent 60 seconds on the attempt.
     $session->setTime(self::createDate('2014-07-14 13:01:02'));
     $session->endAttempt(new State(array(new ResponseVariable('RESPONSE', Cardinality::SINGLE, BaseType::IDENTIFIER, new QtiIdentifier('ChoiceB')))));
     // The attempt is taken into account because allowLateSubmission = true.
     $this->assertEquals(1, $session['numAttempts']->getValue());
     // The session is closed.
     $this->assertEquals(AssessmentItemSessionState::CLOSED, $session->getState());
 }