* */ class taoQtiTest_helpers_TestCompilerUtils { /** * Get an associative array representing some meta-data about the * given $test. * * The following keys can be accessed: * * 'branchRules': whether or not the test definition contains branchRule components in force. * 'preConditions': whether or not the test definition contains preCondition components in force. * * @param AssessmentTest $test * @return array An associative array. */ public static function testMeta(AssessmentTest $test) { $meta = []; $meta['branchRules'] = self::testContainsBranchRules($test); $meta['preConditions'] = self::testContainsPreConditions($test); return $meta; } /** * Whether or not a given $test contains branchRules subject to be * in force during its execution. * * @param AssessmentTest $test * @return boolean */ private static function testContainsBranchRules(AssessmentTest $test) { $testParts = $test->getComponentsByClassName('testPart'); $containsBranchRules = false; foreach ($testParts as $testPart) { // Remember that branchRules are ignored when the navigation mode // is non linear. if ($testPart->getNavigationMode() !== NavigationMode::NONLINEAR) { $branchings = $testPart->getComponentsByClassName('branchRule'); if (count($branchings) > 0) { $containsBranchRules = true; break; } } } return $containsBranchRules; } /** * Whether or not a given $test contains preConditions subject to be in force * during its execution. * * @param AssessmentTest $test * @return boolean */ private static function testContainsPreConditions(AssessmentTest $test) { $testParts = $test->getComponentsByClassName('testPart'); $containsPreConditions = false; foreach ($testParts as $testPart) { // PreConditions are only taken into account // in linear navigation mode. if ($testPart->getNavigationMode() !== NavigationMode::NONLINEAR) { $preConditions = $testPart->getComponentsByClassName('preCondition'); if (count($preConditions) > 0) { $containsPreConditions = true; break; } } } return $containsPreConditions; } }