Quiz: Get number of questions by user attempt - refs BT#17042

pull/3183/head
Angel Fernando Quiroz Campos 5 years ago
parent 3c6e068cb5
commit e4d25f0248
  1. 24
      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;

Loading…
Cancel
Save