Adding trackExercise variable in order to load the data_tracking as the question list.

skala
Julio Montoya 12 years ago
parent 297bdbac41
commit cddffa1512
  1. 11
      main/exercice/exercise.class.php
  2. 6
      main/exercice/exercise_submit.php

@ -103,6 +103,7 @@ class Exercise
public $globalCategoryId = null;
public $distributionId = 0;
public $loadDistributions = false;
public $trackExercise = array();
/**
* Constructor of the class
@ -238,6 +239,9 @@ class Exercise
// Control time
$this->expired_time = $object->expired_time;
// 5. Getting user exercise info (if the user took the exam before) - generating exe_id
$this->trackExercise = $this->getStatTrackExerciseInfo();
if ($parseQuestionList) {
$this->setQuestionList($this->loadDistributions);
}
@ -5600,6 +5604,12 @@ class Exercise
$sessionId = api_get_session_id();
if (!empty($sessionId)) {
$dataExists = !empty($this->trackExercise) && isset($this->trackExercise['data_tracking']) && !empty($this->trackExercise['data_tracking']) ? true : false;
if ($dataExists) {
$questionList = explode(',', $this->trackExercise['data_tracking']);
} else {
// Counting how many attempts from session are in the DB
$trackExercises = Database::get_main_table(TABLE_STATISTIC_TRACK_E_EXERCICES);
$sql = "SELECT count(exe_id) as count FROM $trackExercises WHERE session_id = $sessionId";
@ -5664,6 +5674,7 @@ class Exercise
}
}
}
}
$this->setMediaList($questionList, $this->course_id);

@ -349,6 +349,7 @@ if (!isset($exerciseInSession) || isset($exerciseInSession) && ($exerciseInSessi
// Construction of Exercise
/** @var \Exercise $objExercise */
$objExercise = new Exercise();
if ($debug) {
error_log('1. Setting the $objExercise variable');
}
@ -514,8 +515,12 @@ if ($objExercise->selectAttempts() > 0) {
}
}
if (empty($objExercise->trackExercise)) {
// 5. Getting user exercise info (if the user took the exam before) - generating exe_id
$exercise_stat_info = $objExercise->getStatTrackExerciseInfo($learnpath_id, $learnpath_item_id, $learnpath_item_view_id);
} else {
$exercise_stat_info = $objExercise->trackExercise;
}
//if (1) {
$questionListInSession = Session::read('questionList');
@ -528,6 +533,7 @@ if (!isset($questionListInSession)) {
// Getting order from random
if ($media_is_activated == false && $objExercise->isRandom() && isset($exercise_stat_info) && !empty($exercise_stat_info['data_tracking'])) {
//if ($media_is_activated == false && isset($exercise_stat_info) && !empty($exercise_stat_info['data_tracking'])) {
$questionList = explode(',', $exercise_stat_info['data_tracking']);
}
Session::write('questionList', $questionList);

Loading…
Cancel
Save