public function testIsNull() { $outcome = new OutcomeVariable('var1', Cardinality::SINGLE, BaseType::STRING); $this->assertTrue($outcome->isNull()); $outcome->setValue(new QtiString('')); $this->assertTrue($outcome->isNull()); $outcome->setValue(new QtiString('String!')); $this->assertFalse($outcome->isNull()); $outcome = new OutcomeVariable('var1', Cardinality::SINGLE, BaseType::INTEGER); $this->assertTrue($outcome->isNull()); $outcome->setValue(new QtiInteger(0)); $this->assertFalse($outcome->isNull()); $outcome->setValue(new QtiInteger(-1)); $this->assertFalse($outcome->isNull()); $outcome->setValue(new QtiInteger(100)); $this->assertFalse($outcome->isNull()); $outcome = new OutcomeVariable('var1', Cardinality::SINGLE, BaseType::FLOAT); $this->assertTrue($outcome->isNull()); $outcome->setValue(new QtiFloat(0.25)); $this->assertFalse($outcome->isNull()); $outcome->setValue(new QtiFloat(-1.2)); $this->assertFalse($outcome->isNull()); $outcome->setValue(new QtiFloat(100.12)); $this->assertFalse($outcome->isNull()); $outcome = new OutcomeVariable('var1', Cardinality::SINGLE, BaseType::BOOLEAN); $this->assertTrue($outcome->isNull()); $outcome->setValue(new QtiBoolean(true)); $this->assertFalse($outcome->isNull()); $outcome->setValue(new QtiBoolean(false)); $this->assertFalse($outcome->isNull()); $outcome = new OutcomeVariable('var1', Cardinality::MULTIPLE, BaseType::BOOLEAN); $this->assertTrue($outcome->isNull()); $value = $outcome->getValue(); $value[] = new QtiBoolean(true); $this->assertFalse($outcome->isNull()); $outcome = new OutcomeVariable('var1', Cardinality::ORDERED, BaseType::STRING); $this->assertTrue($outcome->isNull()); $value = $outcome->getValue(); $value[] = new QtiString('string!'); $this->assertFalse($outcome->isNull()); $outcome = new OutcomeVariable('var1', Cardinality::RECORD); $this->assertTrue($outcome->isNull()); $value = $outcome->getValue(); $value['point1'] = new QtiPoint(100, 200); $this->assertFalse($outcome->isNull()); }
<?php use qtism\runtime\common\State; use qtism\data\storage\xml\XmlDocument; use qtism\runtime\rendering\markup\xhtml\XhtmlRenderingEngine; use qtism\runtime\rendering\markup\AbstractMarkupRenderingEngine; use qtism\runtime\common\OutcomeVariable; use qtism\common\enums\BaseType; use qtism\common\enums\Cardinality; use qtism\common\datatypes\Identifier; require_once dirname(__FILE__) . '/../../vendor/autoload.php'; $doc = new XmlDocument(); $doc->load(dirname(__FILE__) . '/../samples/rendering/itemfeedback_1.xml'); $outcome1 = new OutcomeVariable('FEEDBACK', Cardinality::SINGLE, BaseType::IDENTIFIER, new Identifier('')); $renderer = new XhtmlRenderingEngine(); if (isset($argv[1]) && $argv[1] === 'CONTEXT_AWARE') { $renderer->setFeedbackShowHidePolicy(AbstractMarkupRenderingEngine::CONTEXT_AWARE); if (isset($argv[2])) { $outcome1->setValue(new Identifier($argv[2])); } } $renderer->setState(new State(array($outcome1))); $rendering = $renderer->render($doc->getDocumentComponent()); $rendering->formatOutput = true; echo $rendering->saveXML();
<?php use qtism\runtime\rendering\markup\AbstractMarkupRenderingEngine; use qtism\runtime\common\State; use qtism\common\enums\BaseType; use qtism\common\enums\Cardinality; use qtism\common\datatypes\Identifier; use qtism\runtime\common\OutcomeVariable; use qtism\data\storage\xml\XmlDocument; use qtism\runtime\rendering\markup\xhtml\XhtmlRenderingEngine; require_once dirname(__FILE__) . '/../../vendor/autoload.php'; $doc = new XmlDocument(); $doc->load(dirname(__FILE__) . '/../samples/rendering/itembodywithfeedback_1.xml'); $outcome1 = new OutcomeVariable('outcome1', Cardinality::SINGLE, BaseType::IDENTIFIER, new Identifier('')); $outcome2 = new OutcomeVariable('outcome2', Cardinality::SINGLE, BaseType::IDENTIFIER, new Identifier('')); $renderer = new XhtmlRenderingEngine(); if (isset($argv[1]) && $argv[1] === 'CONTEXT_AWARE') { $renderer->setFeedbackShowHidePolicy(AbstractMarkupRenderingEngine::CONTEXT_AWARE); if (isset($argv[2])) { $outcome1->setValue(new Identifier($argv[2])); } if (isset($argv[3])) { $outcome2->setValue(new Identifier($argv[3])); } } $renderer->setState(new State(array($outcome1, $outcome2))); $rendering = $renderer->render($doc->getDocumentComponent()); $rendering->formatOutput = true; echo $rendering->saveXML();
<?php use qtism\runtime\rendering\markup\AbstractMarkupRenderingEngine; use qtism\runtime\common\State; use qtism\common\enums\BaseType; use qtism\common\enums\Cardinality; use qtism\runtime\common\OutcomeVariable; use qtism\data\storage\xml\XmlDocument; use qtism\runtime\rendering\markup\xhtml\XhtmlRenderingEngine; require_once dirname(__FILE__) . '/../../qtism/qtism.php'; $doc = new XmlDocument(); $doc->load('../samples/rendering/itembodywithfeedback_1.xml'); $outcome1 = new OutcomeVariable('outcome1', Cardinality::SINGLE, BaseType::IDENTIFIER, ''); $outcome2 = new OutcomeVariable('outcome2', Cardinality::SINGLE, BaseType::IDENTIFIER, ''); $renderer = new XhtmlRenderingEngine(); if (isset($argv[1]) && $argv[1] === 'CONTEXT_AWARE') { $renderer->setFeedbackShowHidePolicy(AbstractMarkupRenderingEngine::CONTEXT_AWARE); if (isset($argv[2])) { $outcome1->setValue($argv[2]); } if (isset($argv[3])) { $outcome2->setValue($argv[3]); } } $renderer->setState(new State(array($outcome1, $outcome2))); $rendering = $renderer->render($doc->getDocumentComponent()); $rendering->formatOutput = true; echo $rendering->saveXML();
<?php use qtism\runtime\common\State; use qtism\data\storage\xml\XmlDocument; use qtism\runtime\rendering\markup\xhtml\XhtmlRenderingEngine; use qtism\runtime\rendering\markup\AbstractMarkupRenderingEngine; use qtism\runtime\common\OutcomeVariable; use qtism\common\enums\BaseType; use qtism\common\enums\Cardinality; require_once dirname(__FILE__) . '/../../qtism/qtism.php'; $doc = new XmlDocument(); $doc->load('../samples/rendering/itemfeedback_1.xml'); $outcome1 = new OutcomeVariable('FEEDBACK', Cardinality::SINGLE, BaseType::IDENTIFIER, ''); $renderer = new XhtmlRenderingEngine(); if (isset($argv[1]) && $argv[1] === 'CONTEXT_AWARE') { $renderer->setFeedbackShowHidePolicy(AbstractMarkupRenderingEngine::CONTEXT_AWARE); if (isset($argv[2])) { $outcome1->setValue($argv[2]); } } $renderer->setState(new State(array($outcome1))); $rendering = $renderer->render($doc->getDocumentComponent()); $rendering->formatOutput = true; echo $rendering->saveXML();