/** * Checks if the current test allows the progress bar to be displayed * @param AssessmentTestSession $session * @param array $testMeta * @param array $config * @return bool */ public static function considerProgress(AssessmentTestSession $session, array $testMeta, array $config = array()) { $considerProgress = true; if (!empty($config['progress-indicator-forced'])) { // Caution: this piece of code can introduce a heavy load on very large tests // The local optimisation made here concerns: // - only check the part branchRules if the progress indicator must be forced for all tests // - branchRules check is ignored when the navigation mode is non linear. // // TODO: Perform this check at compilation time and store a map of parts options. // This can be also done for navigation map (see getNavigatorMap and getJumpsMap) $testPart = $session->getCurrentTestPart(); if ($testPart->getNavigationMode() !== NavigationMode::NONLINEAR) { $branchings = $testPart->getComponentsByClassName('branchRule'); if (count($branchings) > 0) { $considerProgress = false; } } } else { if ($testMeta['preConditions'] === true) { $considerProgress = false; } else { if ($testMeta['branchRules'] === true) { $considerProgress = false; } } } return $considerProgress; }