/** * @see \qtism\data\storage\xml\marshalling\Marshaller::unmarshall() */ protected function unmarshall(DOMElement $element) { $object = new ItemSessionControl(); if (($value = static::getDOMElementAttributeAs($element, 'maxAttempts', 'integer')) !== null) { $object->setMaxAttempts($value); } if (($value = static::getDOMElementAttributeAs($element, 'showFeedback', 'boolean')) !== null) { $object->setShowFeedback($value); } if (($value = static::getDOMElementAttributeAs($element, 'allowReview', 'boolean')) !== null) { $object->setAllowReview($value); } if (($value = static::getDOMElementAttributeAs($element, 'showSolution', 'boolean')) !== null) { $object->setShowSolution($value); } if (($value = static::getDOMElementAttributeAs($element, 'allowComment', 'boolean')) !== null) { $object->setAllowComment($value); } if (($value = static::getDOMElementAttributeAs($element, 'allowSkipping', 'boolean')) !== null) { $object->setAllowSkipping($value); } if (($value = static::getDOMElementAttributeAs($element, 'validateResponses', 'boolean')) !== null) { $object->setValidateResponses($value); } return $object; }
public function testMarshall() { $component = new ItemSessionControl(); $component->setAllowComment(true); $component->setMaxAttempts(2); $component->setValidateResponses(false); $marshaller = $this->getMarshallerFactory()->createMarshaller($component); $element = $marshaller->marshall($component); $this->assertInstanceOf('\\DOMElement', $element); $this->assertEquals('itemSessionControl', $element->nodeName); $this->assertEquals('true', $element->getAttribute('allowComment')); $this->assertEquals('2', $element->getAttribute('maxAttempts')); $this->assertEquals('false', $element->getAttribute('validateResponses')); $this->assertEquals('true', $element->getAttribute('allowReview')); $this->assertEquals('false', $element->getAttribute('showSolution')); $this->assertEquals('true', $element->getAttribute('allowSkipping')); }
public function testValidResponsesInForceValid() { $itemSession = self::instantiateBasicAssessmentItemSession(); $itemSessionControl = new ItemSessionControl(); $itemSessionControl->setValidateResponses(false); $itemSession->setItemSessionControl($itemSessionControl); $itemSession->beginItemSession(); $itemSession->beginAttempt(); $responses = new State(); $responses->setVariable(new ResponseVariable('RESPONSE', Cardinality::SINGLE, BaseType::IDENTIFIER, new Identifier('ChoiceD'))); $itemSession->endAttempt($responses); }