|
|
|
@ -103,6 +103,7 @@ class Exercise |
|
|
|
public $globalCategoryId = null; |
|
|
|
public $globalCategoryId = null; |
|
|
|
public $distributionId = 0; |
|
|
|
public $distributionId = 0; |
|
|
|
public $loadDistributions = false; |
|
|
|
public $loadDistributions = false; |
|
|
|
|
|
|
|
public $trackExercise = array(); |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Constructor of the class |
|
|
|
* Constructor of the class |
|
|
|
@ -238,6 +239,9 @@ class Exercise |
|
|
|
// Control time |
|
|
|
// Control time |
|
|
|
$this->expired_time = $object->expired_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) { |
|
|
|
if ($parseQuestionList) { |
|
|
|
$this->setQuestionList($this->loadDistributions); |
|
|
|
$this->setQuestionList($this->loadDistributions); |
|
|
|
} |
|
|
|
} |
|
|
|
@ -5600,66 +5604,73 @@ class Exercise |
|
|
|
$sessionId = api_get_session_id(); |
|
|
|
$sessionId = api_get_session_id(); |
|
|
|
if (!empty($sessionId)) { |
|
|
|
if (!empty($sessionId)) { |
|
|
|
|
|
|
|
|
|
|
|
// Counting how many attempts from session are in the DB |
|
|
|
$dataExists = !empty($this->trackExercise) && isset($this->trackExercise['data_tracking']) && !empty($this->trackExercise['data_tracking']) ? true : false; |
|
|
|
$trackExercises = Database::get_main_table(TABLE_STATISTIC_TRACK_E_EXERCICES); |
|
|
|
|
|
|
|
$sql = "SELECT count(exe_id) as count FROM $trackExercises WHERE session_id = $sessionId"; |
|
|
|
|
|
|
|
$result = Database::query($sql); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$count = 0; |
|
|
|
if ($dataExists) { |
|
|
|
if (Database::num_rows($result)) { |
|
|
|
$questionList = explode(',', $this->trackExercise['data_tracking']); |
|
|
|
$result = Database::fetch_array($result); |
|
|
|
} else { |
|
|
|
$count = $result['count']; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
global $app; |
|
|
|
// Counting how many attempts from session are in the DB |
|
|
|
/** @var \Doctrine\manager $em */ |
|
|
|
$trackExercises = Database::get_main_table(TABLE_STATISTIC_TRACK_E_EXERCICES); |
|
|
|
$em = $app['orm.em']; |
|
|
|
$sql = "SELECT count(exe_id) as count FROM $trackExercises WHERE session_id = $sessionId"; |
|
|
|
|
|
|
|
$result = Database::query($sql); |
|
|
|
|
|
|
|
|
|
|
|
$params = array( |
|
|
|
$count = 0; |
|
|
|
'exerciseId' => $this->id, |
|
|
|
if (Database::num_rows($result)) { |
|
|
|
'sessionId' => $sessionId, |
|
|
|
$result = Database::fetch_array($result); |
|
|
|
'cId' => $this->course_id |
|
|
|
$count = $result['count']; |
|
|
|
); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// Searching for forms in this session. |
|
|
|
global $app; |
|
|
|
$quizDistributionRelSessions = $em->getRepository("Entity\CQuizDistributionRelSession")->findBy($params); |
|
|
|
/** @var \Doctrine\manager $em */ |
|
|
|
|
|
|
|
$em = $app['orm.em']; |
|
|
|
if (!empty($quizDistributionRelSessions)) { |
|
|
|
|
|
|
|
// Getting a distribution. It depends of the count of attempts and count of distributions. |
|
|
|
|
|
|
|
$formToUse = $count % (count($quizDistributionRelSessions)); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** @var \Entity\CQuizDistributionRelSession $quizDistributionRelSession */ |
|
|
|
|
|
|
|
if (isset($quizDistributionRelSessions[$formToUse])) { |
|
|
|
|
|
|
|
// We found a distribution! |
|
|
|
|
|
|
|
$quizDistributionRelSession = $quizDistributionRelSessions[$formToUse]; |
|
|
|
|
|
|
|
$this->distributionId = $quizDistributionRelSession->getQuizDistributionId(); |
|
|
|
|
|
|
|
$distribution = $quizDistributionRelSession->getDistribution(); |
|
|
|
|
|
|
|
$dataTracking = array(); |
|
|
|
|
|
|
|
if (!empty($distribution)) { |
|
|
|
|
|
|
|
$dataTracking = $distribution->getDataTracking(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
// Form question list found! |
|
|
|
|
|
|
|
if (!empty($dataTracking)) { |
|
|
|
|
|
|
|
$questionList = explode(',', $dataTracking); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// We make a little shuffle now. |
|
|
|
|
|
|
|
$questionByCategory = Testcategory::getCategoriesFromQuestionList( |
|
|
|
|
|
|
|
$questionList, |
|
|
|
|
|
|
|
$this->course_id |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$cat = new Testcategory(); |
|
|
|
$params = array( |
|
|
|
$categoriesAddedInExercise = $cat->getCategoryExerciseTree( |
|
|
|
'exerciseId' => $this->id, |
|
|
|
$this->id, |
|
|
|
'sessionId' => $sessionId, |
|
|
|
null, |
|
|
|
'cId' => $this->course_id |
|
|
|
null, |
|
|
|
); |
|
|
|
false, |
|
|
|
|
|
|
|
false, |
|
|
|
// Searching for forms in this session. |
|
|
|
false |
|
|
|
$quizDistributionRelSessions = $em->getRepository("Entity\CQuizDistributionRelSession")->findBy($params); |
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
if (!empty($quizDistributionRelSessions)) { |
|
|
|
|
|
|
|
// Getting a distribution. It depends of the count of attempts and count of distributions. |
|
|
|
|
|
|
|
$formToUse = $count % (count($quizDistributionRelSessions)); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** @var \Entity\CQuizDistributionRelSession $quizDistributionRelSession */ |
|
|
|
|
|
|
|
if (isset($quizDistributionRelSessions[$formToUse])) { |
|
|
|
|
|
|
|
// We found a distribution! |
|
|
|
|
|
|
|
$quizDistributionRelSession = $quizDistributionRelSessions[$formToUse]; |
|
|
|
|
|
|
|
$this->distributionId = $quizDistributionRelSession->getQuizDistributionId(); |
|
|
|
|
|
|
|
$distribution = $quizDistributionRelSession->getDistribution(); |
|
|
|
|
|
|
|
$dataTracking = array(); |
|
|
|
|
|
|
|
if (!empty($distribution)) { |
|
|
|
|
|
|
|
$dataTracking = $distribution->getDataTracking(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
// Form question list found! |
|
|
|
|
|
|
|
if (!empty($dataTracking)) { |
|
|
|
|
|
|
|
$questionList = explode(',', $dataTracking); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// We make a little shuffle now. |
|
|
|
|
|
|
|
$questionByCategory = Testcategory::getCategoriesFromQuestionList( |
|
|
|
|
|
|
|
$questionList, |
|
|
|
|
|
|
|
$this->course_id |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
$questionList = self::shuffleQuestionListPerCategory($questionByCategory, $categoriesAddedInExercise); |
|
|
|
$cat = new Testcategory(); |
|
|
|
$questionList = ArrayClass::array_flatten($questionList); |
|
|
|
$categoriesAddedInExercise = $cat->getCategoryExerciseTree( |
|
|
|
|
|
|
|
$this->id, |
|
|
|
|
|
|
|
null, |
|
|
|
|
|
|
|
null, |
|
|
|
|
|
|
|
false, |
|
|
|
|
|
|
|
false, |
|
|
|
|
|
|
|
false |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$questionList = self::shuffleQuestionListPerCategory($questionByCategory, $categoriesAddedInExercise); |
|
|
|
|
|
|
|
$questionList = ArrayClass::array_flatten($questionList); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|