Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
= committed Sep 23, 2016
2 parents cb9f33c + 114ed5d commit f9fd58e
Show file tree
Hide file tree
Showing 7 changed files with 406 additions and 33 deletions.
10 changes: 9 additions & 1 deletion src/qtism/data/ItemSessionControl.php
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,8 @@ public function setAllowComment($allowComment)

/**
* Is the candidate allowed to skip items?
*
* Know whether or not the Delivery Engine allow the candidate to skip items.
*
* @return boolean true if allowed, false if not.
*/
Expand All @@ -297,6 +299,8 @@ public function doesAllowSkipping()

/**
* Set if the candidate is allowed to skip items.
*
* Set whether or not the Delivery Engine allows the candidate to skip items.
*
* @param boolean $allowSkipping true if allowed, false otherwise.
* @throws \InvalidArgumentException If $allowSkipping is not a valid boolean.
Expand All @@ -312,7 +316,7 @@ public function setAllowSkipping($allowSkipping)
}

/**
* Must validate responses ?
* Must validate responses?
*
* @return boolean true if responses must be validated, false if not.
*/
Expand All @@ -322,6 +326,8 @@ public function mustValidateResponses()
}

/**
* Is a default Item Session Control?
*
* Whether the values held by the ItemSessionControl are the default ones.
*
* @return boolean
Expand All @@ -339,6 +345,8 @@ public function isDefault()

/**
* Set if the responses must be validated.
*
* Set whether or not responses must be validated by the Delivery Engine.
*
* @param boolean $validateResponses true if responses must be validated, false if not.
* @throws \InvalidArgumentException If $validateResponses is not a boolean.
Expand Down
5 changes: 3 additions & 2 deletions src/qtism/data/storage/php/PhpStreamAccess.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 @@ -28,6 +28,7 @@
use qtism\common\storage\AbstractStreamAccess;
use qtism\common\storage\StreamException;
use \InvalidArgumentException;
use \Exception;

/**
*
Expand Down Expand Up @@ -415,7 +416,7 @@ public function writeInstantiation($classname, PhpArgumentCollection $arguments
}

$this->writeClosingParenthesis();
} catch (StreamException $e) {
} catch (Exception $e) {
$msg = "An error occured while writing an object instantiation.";
throw new StreamAccessException($msg, $this, 0, $e);
}
Expand Down
53 changes: 24 additions & 29 deletions src/qtism/runtime/storage/binary/QtiBinaryStreamAccess.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@
use qtism\common\storage\BinaryStreamAccessException;
use \InvalidArgumentException;
use \Exception;
use \OutOfBoundsException;

/**
* The QtiBinaryStreamAccess aims at providing access to QTI data stored
Expand Down Expand Up @@ -845,35 +846,29 @@ public function writeAssessmentItemSession(AssessmentTestSeeker $seeker, Assessm
$varNature = 2;
}

try {
$this->writeShort($varNature);
$this->writeShort($seeker->seekPosition($variableDeclaration));

// If defaultValue or correct response is different from what's inside
// the variable declaration, just write it.
$hasDefaultValue = !Utils::equals($variable->getDefaultValue(), $var->getDefaultValue());
$hasCorrectResponse = false;

if ($varNature === 1 && !Utils::equals($variable->getCorrectResponse(), $var->getCorrectResponse())) {
$hasCorrectResponse = true;
}

$this->writeBoolean($hasDefaultValue);
$this->writeBoolean($hasCorrectResponse);

$this->writeVariableValue($var, self::RW_VALUE);

if ($hasDefaultValue === true) {
$this->writeVariableValue($var, self::RW_DEFAULTVALUE);
}

if ($hasCorrectResponse === true) {
$this->writeVariableValue($var, self::RW_CORRECTRESPONSE);
}

} catch (OutOfBoundsException $e) {
$msg = "No variable found in the assessmentTest tree structure.";
throw new QtiBinaryStreamAccessException($msg, $this, QtiBinaryStreamAccessException::ITEM_SESSION, $e);
$this->writeShort($varNature);
$this->writeShort($seeker->seekPosition($variableDeclaration));

// If defaultValue or correct response is different from what's inside
// the variable declaration, just write it.
$hasDefaultValue = !Utils::equals($variable->getDefaultValue(), $var->getDefaultValue());
$hasCorrectResponse = false;

if ($varNature === 1 && !Utils::equals($variable->getCorrectResponse(), $var->getCorrectResponse())) {
$hasCorrectResponse = true;
}

$this->writeBoolean($hasDefaultValue);
$this->writeBoolean($hasCorrectResponse);

$this->writeVariableValue($var, self::RW_VALUE);

if ($hasDefaultValue === true) {
$this->writeVariableValue($var, self::RW_DEFAULTVALUE);
}

if ($hasCorrectResponse === true) {
$this->writeVariableValue($var, self::RW_CORRECTRESPONSE);
}
}
}
Expand Down
Loading

0 comments on commit f9fd58e

Please sign in to comment.