Skip to content

Commit

Permalink
Merge pull request #37 from oat-sa/feature/association-response-const…
Browse files Browse the repository at this point in the history
…raints

New AssociationValidityConstraint class.
  • Loading branch information
Jérôme Bogaerts authored Jul 19, 2016
2 parents d671b61 + a2ae7c4 commit 69567e4
Show file tree
Hide file tree
Showing 25 changed files with 1,250 additions and 100 deletions.
4 changes: 3 additions & 1 deletion src/qtism/data/AssessmentItem.php
Original file line number Diff line number Diff line change
Expand Up @@ -751,7 +751,9 @@ public function getResponseValidityConstraints()
'selectPointInteraction',
'graphicOrderInteraction',
'graphicAssociateInteraction',
'positionObjectInteraction'
'positionObjectInteraction',
'gapMatchInteraction',
'graphicGapMatchInteraction'
);

$responseValidityConstraints = new ResponseValidityConstraintCollection();
Expand Down
17 changes: 16 additions & 1 deletion src/qtism/data/content/interactions/AssociateInteraction.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@

use qtism\data\QtiComponentCollection;
use qtism\data\state\ResponseValidityConstraint;
use qtism\data\state\AssociationValidityConstraint;
use qtism\data\state\AssociationValidityConstraintCollection;
use \InvalidArgumentException;

/**
Expand Down Expand Up @@ -247,11 +249,24 @@ public function getSimpleAssociableChoices()
*/
public function getResponseValidityConstraint()
{
return new ResponseValidityConstraint(
$responseValidityConstraint = new ResponseValidityConstraint(
$this->getResponseIdentifier(),
$this->getMinAssociations(),
$this->getMaxAssociations()
);

$simpleAssociableChoices = $this->getComponentsByClassName('simpleAssociableChoice');
foreach ($simpleAssociableChoices as $simpleAssociableChoice) {
$responseValidityConstraint->addAssociationValidityConstraint(
new AssociationValidityConstraint(
$simpleAssociableChoice->getIdentifier(),
$simpleAssociableChoice->getMatchMin(),
$simpleAssociableChoice->getMatchMax()
)
);
}

return $responseValidityConstraint;
}

/**
Expand Down
29 changes: 27 additions & 2 deletions src/qtism/data/content/interactions/GapMatchInteraction.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* Copyright (c) 2013-2014 (original work) Open Assessment Technologies SA (under the project TAO-PRODUCT);
* Copyright (c) 2013-2016 (original work) Open Assessment Technologies SA (under the project TAO-PRODUCT);
*
* @author Jérôme Bogaerts <[email protected]>
* @license GPLv2
Expand All @@ -23,7 +23,8 @@
namespace qtism\data\content\interactions;

use qtism\data\QtiComponentCollection;

use qtism\data\state\ResponseValidityConstraint;
use qtism\data\state\AssociationValidityConstraint;
use qtism\data\content\BlockStaticCollection;
use \InvalidArgumentException;

Expand Down Expand Up @@ -180,6 +181,30 @@ public function getContent()
{
return $this->content;
}

/**
* @see qtism\data\content\interactions\Interaction::getResponseValidityConstraint()
*/
public function getResponseValidityConstraint()
{
$responseValidityConstraint = new ResponseValidityConstraint(
$this->getResponseIdentifier(),
0,
0
);

foreach ($this->getComponentsByClassName(array('gapImg', 'gapText')) as $gapChoice) {
$responseValidityConstraint->addAssociationValidityConstraint(
new AssociationValidityConstraint(
$gapChoice->getIdentifier(),
$gapChoice->getMatchMin(),
$gapChoice->getMatchMax()
)
);
}

return $responseValidityConstraint;
}

/**
* @see \qtism\data\content\interactions\BlockInteraction::getComponents()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
use qtism\data\content\xhtml\Object;
use qtism\data\QtiComponentCollection;
use qtism\data\state\ResponseValidityConstraint;
use qtism\data\state\AssociationValidityConstraint;
use \InvalidArgumentException;

/**
Expand Down Expand Up @@ -194,11 +195,23 @@ public function getMinAssociations()
*/
public function getResponseValidityConstraint()
{
return new ResponseValidityConstraint(
$responseValidityConstraint = new ResponseValidityConstraint(
$this->getResponseIdentifier(),
$this->getMinAssociations(),
$this->getMaxAssociations()
);

foreach ($this->getComponentsByClassName('associableHotspot') as $associableHotspot) {
$responseValidityConstraint->addAssociationValidityConstraint(
new AssociationValidityConstraint(
$associableHotspot->getIdentifier(),
$associableHotspot->getMatchMin(),
$associableHotspot->getMatchMax()
)
);
}

return $responseValidityConstraint;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* Copyright (c) 2013-2014 (original work) Open Assessment Technologies SA (under the project TAO-PRODUCT);
* Copyright (c) 2013-2016 (original work) Open Assessment Technologies SA (under the project TAO-PRODUCT);
*
* @author Jérôme Bogaerts <[email protected]>
* @license GPLv2
Expand All @@ -23,6 +23,8 @@
namespace qtism\data\content\interactions;

use qtism\data\QtiComponentCollection;
use qtism\data\state\ResponseValidityConstraint;
use qtism\data\state\AssociationValidityConstraint;
use \InvalidArgumentException;

/**
Expand Down Expand Up @@ -145,6 +147,30 @@ public function getAssociableHotspots()
{
return $this->associableHotspots;
}

/**
* @see qtism\data\content\interactions\Interaction::getResponseValidityConstraint()
*/
public function getResponseValidityConstraint()
{
$responseValidityConstraint = new ResponseValidityConstraint(
$this->getResponseIdentifier(),
0,
0
);

foreach ($this->getComponentsByClassName(array('gapImg', 'gapText')) as $gapChoice) {
$responseValidityConstraint->addAssociationValidityConstraint(
new AssociationValidityConstraint(
$gapChoice->getIdentifier(),
$gapChoice->getMatchMin(),
$gapChoice->getMatchMax()
)
);
}

return $responseValidityConstraint;
}

/**
* @see \qtism\data\content\interactions\BlockInteraction::getComponents()
Expand Down
15 changes: 14 additions & 1 deletion src/qtism/data/content/interactions/MatchInteraction.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@

use qtism\data\QtiComponentCollection;
use qtism\data\state\ResponseValidityConstraint;
use qtism\data\state\AssociationValidityConstraint;
use \InvalidArgumentException;

/**
Expand Down Expand Up @@ -249,11 +250,23 @@ public function getTargetChoices()
*/
public function getResponseValidityConstraint()
{
return new ResponseValidityConstraint(
$responseValidityConstraint = new ResponseValidityConstraint(
$this->getResponseIdentifier(),
$this->getMinAssociations(),
$this->getMaxAssociations()
);

foreach ($this->getComponentsByClassName('simpleAssociableChoice') as $simpleAssociableChoice) {
$responseValidityConstraint->addAssociationValidityConstraint(
new AssociationValidityConstraint(
$simpleAssociableChoice->getIdentifier(),
$simpleAssociableChoice->getMatchMin(),
$simpleAssociableChoice->getMatchMax()
)
);
}

return $responseValidityConstraint;
}

/**
Expand Down
Loading

0 comments on commit 69567e4

Please sign in to comment.