-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #409 from oat-sa/fix/AUT-3994/ResponseValidityCons…
…traint Fix/aut 3994/response validity constraint
- Loading branch information
Showing
40 changed files
with
2,092 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,7 +15,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-2020 (original work) Open Assessment Technologies SA (under the project TAO-PRODUCT); | ||
* Copyright (c) 2013-2024 (original work) Open Assessment Technologies SA (under the project TAO-PRODUCT); | ||
* | ||
* @author Jérôme Bogaerts <[email protected]> | ||
* @license GPLv2 | ||
|
@@ -30,6 +30,8 @@ | |
use qtism\data\state\OutcomeDeclarationCollection; | ||
use qtism\data\state\ResponseDeclaration; | ||
use qtism\data\state\ResponseDeclarationCollection; | ||
use qtism\data\state\ResponseValidityConstraint; | ||
use qtism\data\state\ResponseValidityConstraintCollection; | ||
|
||
/** | ||
* The ExtendedAssessmentItemRef class is an extended representation of the QTI assessmentItemRef class. | ||
|
@@ -79,6 +81,12 @@ class ExtendedAssessmentItemRef extends AssessmentItemRef implements IAssessment | |
*/ | ||
private $timeDependent = false; | ||
|
||
/** | ||
* @var ResponseValidityConstraintCollection | ||
* @qtism-bean-property | ||
*/ | ||
private $responseValidityConstraints; | ||
|
||
/** | ||
* Create a new instance of CompactAssessmentItem | ||
* | ||
|
@@ -93,6 +101,7 @@ public function __construct($identifier, $href, IdentifierCollection $categories | |
|
||
$this->setOutcomeDeclarations(new OutcomeDeclarationCollection()); | ||
$this->setResponseDeclarations(new ResponseDeclarationCollection()); | ||
$this->setResponseValidityConstraints(new ResponseValidityConstraintCollection()); | ||
} | ||
|
||
/** | ||
|
@@ -298,4 +307,38 @@ public function getComponents() | |
|
||
return new QtiComponentCollection($components); | ||
} | ||
|
||
/** | ||
* Get the response validity constraints related to the item content. | ||
*/ | ||
public function getResponseValidityConstraints() | ||
{ | ||
return $this->responseValidityConstraints; | ||
} | ||
|
||
/** | ||
* Add a response validity constraint related to item content. | ||
*/ | ||
public function addResponseValidityConstraint(ResponseValidityConstraint $responseValidityConstraint): void | ||
{ | ||
$this->getResponseValidityConstraints()->attach($responseValidityConstraint); | ||
} | ||
|
||
/** | ||
* Remove a response validity constraint related to item content. | ||
*/ | ||
public function removeResponseValidityConstraint(ResponseValidityConstraint $responseValidityConstraint): void | ||
{ | ||
$this->getResponseValidityConstraints()->detach($responseValidityConstraint); | ||
} | ||
|
||
/** | ||
* Set the response validity constraints related to the item content. | ||
*/ | ||
public function setResponseValidityConstraints(ResponseValidityConstraintCollection $responseValidityConstraints): void | ||
{ | ||
$this->responseValidityConstraints = $responseValidityConstraints; | ||
} | ||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,130 @@ | ||
<?php | ||
|
||
/** | ||
* This program is free software; you can redistribute it and/or | ||
* modify it under the terms of the GNU General Public License | ||
* as published by the Free Software Foundation; under version 2 | ||
* of the License (non-upgradable). | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* 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-2024 (original work) Open Assessment Technologies SA (under the project TAO-PRODUCT); | ||
* | ||
* @author Jérôme Bogaerts <[email protected]> | ||
* @license GPLv2 | ||
*/ | ||
|
||
namespace qtism\data; | ||
|
||
/** | ||
* The ExtendedAssessmentTest class is an extended representation of the QTI | ||
* AssessmentTest class. It gathers together the AssessmentTest + additional references | ||
* to testFeedback components. | ||
*/ | ||
class ExtendedAssessmentTest extends AssessmentTest | ||
{ | ||
/** | ||
* A collection of TestFeedbackRef objects. | ||
* | ||
* @var TestFeedbackRefCollection | ||
* @qtism-bean-property | ||
*/ | ||
private $testFeedbackRefs; | ||
|
||
/** | ||
* Create a new ExtendedAssessmentTest object. | ||
* | ||
* @param string $identifier A QTI identifier. | ||
* @param string $title A title. | ||
* @param TestPartCollection $testParts A collection of ExtendedTestPart objects. | ||
*/ | ||
public function __construct($identifier, $title, TestPartCollection $testParts = null) | ||
{ | ||
parent::__construct($identifier, $title, $testParts); | ||
$this->setTestFeedbackRefs(new TestFeedbackRefCollection()); | ||
} | ||
|
||
/** | ||
* Set the collection of TestFeedbackRef objects. | ||
* | ||
* @param TestFeedbackRefCollection $testFeedbackRefs | ||
*/ | ||
public function setTestFeedbackRefs(TestFeedbackRefCollection $testFeedbackRefs): void | ||
{ | ||
$this->testFeedbackRefs = $testFeedbackRefs; | ||
} | ||
|
||
/** | ||
* Get the collection of TestFeedbackRef objects. | ||
* | ||
* @return TestFeedbackRefCollection | ||
*/ | ||
public function getTestFeedbackRefs(): TestFeedbackRefCollection | ||
{ | ||
return $this->testFeedbackRefs; | ||
} | ||
|
||
/** | ||
* Add a TestFeedbackRef object. | ||
* | ||
* @param TestFeedbackRef $testFeedbackRef | ||
*/ | ||
public function addTestFeedbackRef(TestFeedbackRef $testFeedbackRef): void | ||
{ | ||
$this->getTestFeedbackRefs()->attach($testFeedbackRef); | ||
} | ||
|
||
/** | ||
* Remove a TestFeedbackRef object. | ||
* | ||
* @param TestFeedbackRef $testFeedbackRef | ||
*/ | ||
public function removeTestFeedbackRef(TestFeedbackRef $testFeedbackRef): void | ||
{ | ||
$this->getTestFeedbackRefs()->detach($testFeedbackRef); | ||
} | ||
|
||
/** | ||
* Create an ExtendedAssessmentTest object from an AssessmentTest object. | ||
* | ||
* @param AssessmentTest $assessmentTest | ||
* @return ExtendedAssessmentTest | ||
*/ | ||
public static function createFromAssessmentTest(AssessmentTest $assessmentTest): ExtendedAssessmentTest | ||
{ | ||
$ref = new ExtendedAssessmentTest( | ||
$assessmentTest->getIdentifier(), | ||
$assessmentTest->getTitle(), | ||
$assessmentTest->getTestParts() | ||
); | ||
|
||
$ref->setTimeLimits($assessmentTest->getTimeLimits()); | ||
$ref->setOutcomeDeclarations($assessmentTest->getOutcomeDeclarations()); | ||
$ref->setOutcomeProcessing($assessmentTest->getOutcomeProcessing()); | ||
$ref->setTestFeedbacks($assessmentTest->getTestFeedbacks()); | ||
$ref->setToolName($assessmentTest->getToolName()); | ||
$ref->setToolVersion($assessmentTest->getToolVersion()); | ||
|
||
return $ref; | ||
} | ||
|
||
/** | ||
* @return QtiComponentCollection | ||
*/ | ||
public function getComponents(): QtiComponentCollection | ||
{ | ||
$components = array_merge( | ||
parent::getComponents()->getArrayCopy(), | ||
$this->getTestFeedbackRefs()->getArrayCopy() | ||
); | ||
|
||
return new QtiComponentCollection($components); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,135 @@ | ||
<?php | ||
|
||
/** | ||
* This program is free software; you can redistribute it and/or | ||
* modify it under the terms of the GNU General Public License | ||
* as published by the Free Software Foundation; under version 2 | ||
* of the License (non-upgradable). | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* 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-2024 (original work) Open Assessment Technologies SA (under the project TAO-PRODUCT); | ||
* | ||
* @author Jérôme Bogaerts <[email protected]> | ||
* @license GPLv2 | ||
*/ | ||
|
||
namespace qtism\data; | ||
|
||
use InvalidArgumentException; | ||
|
||
/** | ||
* The ExtendedTestPart class is an extended representation of the QTI | ||
* testPart class. It gathers together the testPart + additional references | ||
* to testFeedback components. | ||
*/ | ||
class ExtendedTestPart extends TestPart | ||
{ | ||
/** | ||
* Create a new ExtendedTestPart object. | ||
* | ||
* @param string $identifier An identifier. | ||
* @param SectionPartCollection $assessmentSections A collection of AssessmentSection and/or AssessmentSectionRef objects. | ||
* @param int $navigationMode A value from the NavigationMode enumeration. | ||
* @param int $submissionMode A value from the SubmissionMode enumeration. | ||
* @throws InvalidArgumentException If any of the arguments is invalid. | ||
*/ | ||
public function __construct($identifier, SectionPartCollection $assessmentSections, $navigationMode = NavigationMode::LINEAR, $submissionMode = SubmissionMode::INDIVIDUAL) | ||
{ | ||
parent::__construct($identifier, $assessmentSections, $navigationMode, $submissionMode); | ||
$this->setTestFeedbackRefs(new TestFeedbackRefCollection()); | ||
} | ||
|
||
/** | ||
* A collection of TestFeedbackRef objects. | ||
* | ||
* @var TestFeedbackRefCollection | ||
* @qtism-bean-property | ||
*/ | ||
private $testFeedbackRefs; | ||
|
||
/** | ||
* Set the collection of TestFeedbackRef objects. | ||
* | ||
* @param TestFeedbackRefCollection $testFeedbackRefs | ||
*/ | ||
public function setTestFeedbackRefs(TestFeedbackRefCollection $testFeedbackRefs): void | ||
{ | ||
$this->testFeedbackRefs = $testFeedbackRefs; | ||
} | ||
|
||
/** | ||
* Get the collection of TestFeedbackRef objects. | ||
* | ||
* @return TestFeedbackRefCollection | ||
*/ | ||
public function getTestFeedbackRefs(): TestFeedbackRefCollection | ||
{ | ||
return $this->testFeedbackRefs; | ||
} | ||
|
||
/** | ||
* Add a TestFeedbackRef to the ExtendedTestPart. | ||
* | ||
* @param TestFeedbackRef $testFeedbackRef | ||
*/ | ||
public function addTestFeedbackRef(TestFeedbackRef $testFeedbackRef): void | ||
{ | ||
$this->getTestFeedbackRefs()->attach($testFeedbackRef); | ||
} | ||
|
||
/** | ||
* Remove a TestFeedbackRef from the ExtendedTestPart. | ||
* | ||
* @param TestFeedbackRef $testFeedbackRef | ||
*/ | ||
public function removeTestFeedbackRef(TestFeedbackRef $testFeedbackRef): void | ||
{ | ||
$this->getTestFeedbackRefs()->detach($testFeedbackRef); | ||
} | ||
|
||
/** | ||
* Create a new ExtendedTestPart object from another TestPart object. | ||
* | ||
* @param TestPart $testPart | ||
* @return ExtendedTestPart | ||
*/ | ||
public static function createFromTestPart(TestPart $testPart): ExtendedTestPart | ||
{ | ||
$ref = new self( | ||
$testPart->getIdentifier(), | ||
$testPart->getAssessmentSections(), | ||
$testPart->getNavigationMode(), | ||
$testPart->getSubmissionMode() | ||
); | ||
|
||
$ref->setAssessmentSections($testPart->getAssessmentSections()); | ||
$ref->setTimeLimits($testPart->getTimeLimits()); | ||
$ref->setPreConditions($testPart->getPreConditions()); | ||
$ref->setBranchRules($testPart->getBranchRules()); | ||
$ref->setItemSessionControl($testPart->getItemSessionControl()); | ||
$ref->setTestFeedbacks($testPart->getTestFeedbacks()); | ||
|
||
return $ref; | ||
} | ||
|
||
/** | ||
* @return QtiComponentCollection | ||
*/ | ||
public function getComponents(): QtiComponentCollection | ||
{ | ||
$components = array_merge( | ||
parent::getComponents()->getArrayCopy(), | ||
$this->getTestFeedbackRefs()->getArrayCopy() | ||
); | ||
|
||
return new QtiComponentCollection($components); | ||
} | ||
} |
Oops, something went wrong.