38 if( PHP_SAPI ==
'cli' )
40 include_once(
'include/inc.ilias_version.php');
44 die(
"Usage: php fixTestQuestionOrderingGaps.php username password client [show|fix]\n");
49 include_once
'./Services/Cron/classes/class.ilCronStartUp.php';
56 $cron->authenticate();
60 echo
'Unknown trouble during ilInit. Exception: ' . $e->getMessage();
66 include_once
"Services/Context/classes/class.ilContext.php";
69 include_once
'Services/Authentication/classes/class.ilAuthFactory.php';
78 require_once
'include/inc.header.php';
82 echo
'Unknown trouble during ilInit. Exception: '.$e->getMessage();
100 To fix your database call this script with the additional parameter 'fix' (!) 102 Usage: php fixTestQuestionOrderingGaps.php username password client [show|fix] 108 if( isset(
$_GET[
'fix']) )
114 <a href='http://{$_SERVER['HTTP_HOST']}{$_SERVER['SCRIPT_NAME']}?fix'>HTTP</a> 116 <a href='https://{$_SERVER['HTTP_HOST']}{$_SERVER['SCRIPT_NAME']}?fix'>HTTPS</a> 121 To fix your database use the link below (!) 126 require_once
'include/inc.header.php';
129 if(!$rbacsystem->checkAccess(
'visible,read', SYSTEM_FOLDER_ID))
131 echo
'Sorry, this script requires administrative privileges!';
137 if(
$task ==
'show' )
140 SELECT COUNT(DISTINCT test_fi) num_tst, COUNT(test_question_id) num_qst 141 FROM tst_test_question WHERE test_fi IN( 142 SELECT test_fi FROM tst_test_question 143 GROUP BY test_fi HAVING COUNT(test_fi) < MAX(sequence) 152 $numTests =
$row[
'num_tst'];
153 $numQuestions =
$row[
'num_qst'];
156 DEAR ADMINISTRATOR !! 158 Please read the following instructions CAREFULLY! 160 -> Due to a bug in almost all earlier versions of ILIAS question orderings 161 from the assessment component are broken but repairable. 163 -> This fixing script can exhaust any php enviroment settings like 164 max_execution_time or memory_limit for example. 166 -> In the case of any php fatal error the script causes that is about exhausting 167 any ressource or time restriction you just need to refresh the page by using F5 for example. 169 Mantis Bug Report: https://ilias.de/mantis/view.php?id=20382 171 In your database there were > {$numTests} tests < detected having > {$numQuestions} questions < overall, 172 that are stored with gaps in the ordering index. 181 elseif(
$task ==
'fix' )
184 SELECT test_fi, test_question_id 185 FROM tst_test_question WHERE test_fi IN( 186 SELECT test_fi FROM tst_test_question 187 GROUP BY test_fi HAVING COUNT(test_fi) < MAX(sequence) 188 ) ORDER BY test_fi ASC, sequence ASC 197 $tests[ $row[
'test_fi'] ] = array();
200 $tests[ $row[
'test_fi'] ][] = $row[
'test_question_id'];
203 foreach(
$tests as $testFi => $testQuestions)
205 for($i = 0, $m = count($testQuestions); $i <= $m; $i++)
207 $testQuestionId = $testQuestions[$i];
211 $ilDB->update(
'tst_test_question',
212 array(
'sequence' => array(
'integer', $position) ),
213 array(
'test_question_id' => array(
'integer', $testQuestionId) )
218 echo
"fixing TestQuestionOrderingGaps successfully finished :-)\n";
if((!isset($_SERVER['DOCUMENT_ROOT'])) OR(empty($_SERVER['DOCUMENT_ROOT']))) $_SERVER['DOCUMENT_ROOT']
const ILIAS_VERSION_NUMERIC
static setContext($a_context)
set context
static init($a_type)
Init context by type.
$task
GENERAL INFORMATION: