diff --git a/main/exercise/exercise.class.php b/main/exercise/exercise.class.php index 64e1fb7e97..2f39c16608 100755 --- a/main/exercise/exercise.class.php +++ b/main/exercise/exercise.class.php @@ -3133,6 +3133,28 @@ class Exercise return $id; } + /** + * Get number of questions in exercise by user attempt. + * + * @return int + */ + private function countQuestionsInExercise() + { + $lpId = isset($_REQUEST['learnpath_id']) ? (int) $_REQUEST['learnpath_id'] : 0; + $lpItemId = isset($_REQUEST['learnpath_item_id']) ? (int) $_REQUEST['learnpath_item_id'] : 0; + $lpItemViewId = isset($_REQUEST['learnpath_item_view_id']) ? (int) $_REQUEST['learnpath_item_view_id'] : 0; + + $trackInfo = $this->get_stat_track_exercise_info($lpId, $lpItemId, $lpItemViewId); + + if (!empty($trackInfo)) { + $questionIds = explode(',', $trackInfo['data_tracking']); + + return count($questionIds); + } + + return $this->getQuestionCount(); + } + /** * @param int $question_id * @param int $questionNum @@ -3150,7 +3172,7 @@ class Exercise $myRemindList = [] ) { global $safe_lp_id, $safe_lp_item_id, $safe_lp_item_view_id; - $nbrQuestions = $this->getQuestionCount(); + $nbrQuestions = $this->countQuestionsInExercise(); $buttonList = []; $html = $label = ''; $hotspot_get = isset($_POST['hotspot']) ? Security::remove_XSS($_POST['hotspot']) : null;