Skip to content

Commit

Permalink
Fix modal feedback/choice templating rendering when using
Browse files Browse the repository at this point in the history
outcomeDeclarations with multiple cardinalities.
  • Loading branch information
bugalot committed Jul 10, 2015
1 parent 1d1a8e2 commit 13ed421
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,12 @@

namespace qtism\runtime\rendering\markup;

use qtism\common\collections\Container;

use qtism\common\datatypes\Identifier;

use qtism\common\datatypes\Scalar;

use qtism\runtime\rendering\RenderingException;
use qtism\runtime\rendering\Renderable;
use qtism\data\content\ModalFeedback;
Expand Down Expand Up @@ -595,11 +601,21 @@ protected function mustIgnoreComponent(QtiComponent $component)
protected function identifierMatches(QtiComponent $component)
{
$variableIdentifier = ($component instanceof FeedbackElement || $component instanceof ModalFeedback) ? $component->getOutcomeIdentifier() : $component->getTemplateIdentifier();
$identifier = $component->getIdentifier();
$identifier = new Identifier($component->getIdentifier());
$showHide = $component->getShowHide();
$state = $this->getState();

return (($val = $state[$variableIdentifier]) !== null && $val->equals($identifier));

$matches = false;

if (($val = $state[$variableIdentifier]) !== null) {
if ($val instanceof Scalar) {
$matches = $val->equals($identifier);
} elseif ($val instanceof Container) {
$matches = $val->contains($identifier);
}
}

return $matches;
}

/**
Expand Down
9 changes: 9 additions & 0 deletions test/qtismtest/common/collections/ContainerTest.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
<?php
namespace qtismtest\common\collections;

use qtism\common\datatypes\Identifier;

use qtismtest\QtiSmTestCase;
use qtism\common\datatypes\Boolean;
use qtism\common\datatypes\String;
Expand Down Expand Up @@ -216,6 +218,13 @@ public function testContains() {
$this->assertTrue($container->contains(new Pair('A', 'B')));
}

public function testContains2() {
$identifier = new Identifier('test');
$container = $this->getContainer();
$container[] = $identifier;
$this->assertTrue($container->contains(new Identifier('test')));
}

/**
* @dataProvider toStringProvider
*
Expand Down

0 comments on commit 13ed421

Please sign in to comment.