5 include_once 
"./Services/Object/classes/class.ilObject.php";
 
    6 include_once 
"./Modules/Test/classes/inc.AssessmentConstants.php";
 
  455         function ilObjTest($a_id = 0,$a_call_by_reference = 
true)
 
  459                 include_once 
"./Modules/Test/classes/class.assMarkSchema.php";
 
  462                 $this->author = $ilUser->fullname;
 
  463                 $this->introduction = 
"";
 
  464                 $this->questions = array();
 
  467                 $this->instant_verification = 0;
 
  468                 $this->answer_feedback_points = 0;
 
  469                 $this->reporting_date = 
"";
 
  470                 $this->nr_of_tries = 0;
 
  472                 $this->use_previous_answers = 1;
 
  473                 $this->title_output = 0;
 
  474                 $this->starting_time = 
"";
 
  475                 $this->ending_time = 
"";
 
  476                 $this->processing_time = 
"00:00:00";
 
  477                 $this->enable_processing_time = 
"0";
 
  478                 $this->reset_processing_time = 0;
 
  479                 $this->ects_output = 0;
 
  480                 $this->ects_fx = NULL;
 
  481                 $this->random_test = 0;
 
  482                 $this->shuffle_questions = FALSE;
 
  483                 $this->mailnottype = 0;
 
  484                 $this->exportsettings = 0;
 
  485                 $this->show_summary = 8;
 
  486                 $this->random_question_count = 
"";
 
  491                 $this->answer_feedback = 0;
 
  492                 $this->password = 
"";
 
  493                 $this->certificate_visibility = 0;
 
  494                 $this->allowedUsers = 
"";
 
  495                 $this->_showfinalstatement = FALSE;
 
  496                 $this->_finalstatement = 
"";
 
  497                 $this->_showinfo = TRUE;
 
  498                 $this->_forcejs = FALSE;
 
  499                 $this->_customStyle = 
"";
 
  500                 $this->allowedUsersTimeGap = 
"";
 
  501                 $this->anonymity = 0;
 
  502                 $this->show_cancel = 0;
 
  503                 $this->show_marker = 0;
 
  504                 $this->fixed_participants = 0;
 
  509                 $this->testSession = FALSE;
 
  510                 $this->testSequence = FALSE;
 
  511                 $this->mailnotification = 0;
 
  512                 $this->poolUsage = 1;
 
  514                 $lng->loadLanguageModule(
"assessment");
 
  515                 $this->mark_schema->createSimpleSchema($lng->txt(
"failed_short"), $lng->txt(
"failed_official"), 0, 0, $lng->txt(
"passed_short"), $lng->txt(
"passed_official"), 50, 1);
 
  516                 $this->ects_grades = array(
 
  523                 $this->autosave = FALSE;
 
  524                 $this->autosave_ival = 30000;
 
  526                 $this->express_mode = 
false;
 
  527                 $this->template_id = 
'';
 
  528                 $this->
ilObject($a_id, $a_call_by_reference);
 
  554                 if (!parent::update())
 
  569         function read($a_force_db = 
false)
 
  585                 if (!parent::delete())
 
  612                 $result = $ilDB->queryF(
"SELECT active_id FROM tst_active WHERE test_fi = %s",
 
  616                 $active_array = array();
 
  619                         array_push($active_array, 
$row[
"active_id"]);
 
  622                 $affectedRows = $ilDB->manipulateF(
"DELETE FROM tst_active WHERE test_fi = %s",
 
  627                 if (count($active_array))
 
  629                         foreach ($active_array as $active_id)
 
  631                                 $affectedRows = $ilDB->manipulateF(
"DELETE FROM tst_times WHERE active_fi = %s",
 
  636                                 $affectedRows = $ilDB->manipulateF(
"DELETE FROM tst_sequence WHERE active_fi = %s",
 
  643                 $affectedRows = $ilDB->manipulateF(
"DELETE FROM tst_mark WHERE test_fi = %s",
 
  648                 $result = $ilDB->queryF(
"SELECT question_fi FROM tst_test_question WHERE test_fi = %s",
 
  657                 $affectedRows = $ilDB->manipulateF(
"DELETE FROM tst_tests WHERE test_id = %s",
 
  662                 $affectedRows = $ilDB->manipulateF(
"DELETE FROM tst_test_random WHERE test_fi = %s",
 
  677                 $affectedRows = $ilDB->manipulateF(
"DELETE FROM tst_test_question WHERE test_fi = %s",
 
  689                 include_once 
"./Services/Utilities/classes/class.ilUtil.php";
 
  691                 $directory = $tst_data_dir.
"/tst_".$this->
getId();
 
  692                 if (is_dir($directory))
 
  694                         include_once 
"./Services/Utilities/classes/class.ilUtil.php";
 
  697                 include_once(
"./Services/MediaObjects/classes/class.ilObjMediaObject.php");
 
  703                 foreach(
$mobs as $mob)
 
  742         function notify($a_event,$a_ref_id,$a_parent_non_rbac_id,$a_node_id,$a_params = 0)
 
  782                 if ($a_node_id==
$_GET[
"ref_id"])
 
  784                         $parent_obj =& $this->ilias->obj_factory->getInstanceByRefId($a_node_id);
 
  785                         $parent_type = $parent_obj->getType();
 
  786                         if ($parent_type == $this->
getType())
 
  788                                 $a_node_id = (int) $tree->getParentId($a_node_id);
 
  792                 parent::notify($a_event,$a_ref_id,$a_parent_non_rbac_id,$a_node_id,$a_params);
 
  802                 include_once 
"./Services/Utilities/classes/class.ilUtil.php";
 
  805                 if (!is_writable($tst_data_dir))
 
  807                         $this->ilias->raiseError(
"Test Data Directory (".$tst_data_dir
 
  808                                 .
") not writeable.",$this->ilias->error_obj->MESSAGE);
 
  812                 $tst_dir = $tst_data_dir.
"/tst_".$this->
getId();
 
  814                 if (!@is_dir($tst_dir))
 
  816                         $this->ilias->raiseError(
"Creation of Test Directory failed.",$this->ilias->error_obj->MESSAGE);
 
  819                 $export_dir = $tst_dir.
"/export";
 
  821                 if (!@is_dir($export_dir))
 
  823                         $this->ilias->raiseError(
"Creation of Export Directory failed.",$this->ilias->error_obj->MESSAGE);
 
  834                 include_once 
"./Services/Utilities/classes/class.ilUtil.php";
 
  848                 if (!@is_dir($dir) or
 
  861                 while ($entry = $dir->read())
 
  863                         if ($entry != 
"." and
 
  866                                 ereg(
"^[0-9]{10}_{2}[0-9]+_{2}(tst(__results)?_)*[0-9]+\.[a-z]{1,3}\$", $entry))
 
  887                 if (strlen($a_import_dir))
 
  889                         $_SESSION[
"tst_import_dir"] = $a_import_dir;
 
  924                 include_once 
"./Services/Utilities/classes/class.ilUtil.php";
 
  928                 if (!is_writable($tst_data_dir))
 
  930                         $this->ilias->raiseError(
"Test Data Directory (".$tst_data_dir
 
  931                                 .
") not writeable.",$this->ilias->error_obj->FATAL);
 
  935                 $tst_dir = $tst_data_dir.
"/tst_import";
 
  937                 if (!@is_dir($tst_dir))
 
  939                         $ilias->raiseError(
"Creation of test import directory failed.",
$ilias->error_obj->FATAL);
 
  954                 $result = $ilDB->queryF(
"SELECT DISTINCT(qpl_qst_type.type_tag) foundtypes FROM qpl_questions, tst_test_result, qpl_qst_type, tst_active WHERE tst_test_result.question_fi = qpl_questions.question_id AND qpl_questions.question_type_fi = qpl_qst_type.question_type_id AND tst_test_result.active_fi = tst_active.active_id AND tst_active.test_fi = %s",
 
  961                         if (strcmp(
$row[
'foundtypes'], 
'assSingleChoice') == 0)
 
  979                 $result = $ilDB->queryF(
"SELECT DISTINCT(qpl_qst_type.type_tag) foundtypes FROM qpl_questions, tst_test_result, qpl_qst_type, tst_active WHERE tst_test_result.question_fi = qpl_questions.question_id AND qpl_questions.question_type_fi = qpl_qst_type.question_type_id AND tst_test_result.active_fi = tst_active.active_id AND tst_active.test_fi = %s",
 
  986                         if (strcmp(
$row[
'foundtypes'], 
'assSingleChoice') == 0)
 
 1011                                 SELECT  DISTINCT(qpl_qst_sc.shuffle) foundshuffles 
 1017                                 WHERE   tst_test_result.question_fi = qpl_questions.question_id 
 1018                                 AND             qpl_questions.question_type_fi = qpl_qst_type.question_type_id 
 1019                                 AND             tst_test_result.active_fi = tst_active.active_id 
 1020                                 AND             qpl_questions.question_id = qpl_qst_sc.question_fi 
 1021                                 AND             tst_active.test_fi = %s 
 1022                                 AND             qpl_qst_type.type_tag = %s 
 1024                         array(
'integer', 
'text'),
 
 1025                         array($this->
getTestId(), 
'assSingleChoice')
 
 1030                         return (
$row[
'foundshuffles'] == 0);
 
 1043                 if ((count($this->mark_schema->mark_steps)) and (count($this->questions)))
 
 1057                                 foreach ($arr as $array)
 
 1059                                         $count += $array[
"count"];
 
 1080                 $test->loadFromDb();
 
 1081                 return $test->isComplete();
 
 1092                 if ($this->test_id > 0) 
 
 1094                         $fx_support = preg_replace(
"/,/", 
".", $fx_support);
 
 1095                         if (preg_match(
"/\d+/", $fx_support))
 
 1097                                 $fx_support = $fx_support;
 
 1103                         $affectedRows = $ilDB->manipulateF(
"UPDATE tst_tests SET ects_output = %s, ects_a = %s, ects_b = %s, ects_c = %s, ects_d = %s, ects_e = %s, ects_fx = %s WHERE test_id = %s",
 
 1104                                 array(
'text',
'float',
'float',
'float',
'float',
'float',
'float',
'integer'),
 
 1108                         $this->ects_fx = $fx_support;
 
 1126                 if ($this->test_id > 0)
 
 1128                         $affectedRows = $ilDB->manipulateF(
"UPDATE tst_tests SET complete = %s WHERE test_id = %s",
 
 1129                                 array(
'text',
'integer'),
 
 1130                                 array($complete, $this->test_id)
 
 1155                 include_once(
"./Services/RTE/classes/class.ilRTE.php");
 
 1156                 $completecontent = 
"";
 
 1159                         $completecontent .= $content;
 
 1181                 include_once (
"./Modules/Test/classes/class.ilObjAssessmentFolder.php");
 
 1182                 if ($this->test_id == -1)
 
 1185                         $next_id = $ilDB->nextId(
'tst_tests');
 
 1187                         $ilDB->insert(
'tst_tests', array(
 
 1188                                 'test_id' => array(
'integer', $next_id),
 
 1189                                 'obj_fi' => array(
'integer', $this->
getId()),
 
 1190                                 'author' => array(
'text', $this->
getAuthor()),
 
 1193                                 'showinfo' => array(
'integer', $this->
getShowInfo()),
 
 1194                                 'forcejs' => array(
'integer', $this->
getForceJS()),
 
 1206                                 'nr_of_tries' => array(
'integer', $this->
getNrOfTries()),
 
 1207                                 'kiosk' => array(
'integer', $this->
getKiosk()),
 
 1216                                 'complete' => array(
'text', $this->
isComplete()),
 
 1218                                 'ects_a' => array(
'float', strlen($this->ects_grades[
"A"]) ? $this->ects_grades[
"A"] : NULL),
 
 1219                                 'ects_b' => array(
'float', strlen($this->ects_grades[
"B"]) ? $this->ects_grades[
"B"] : NULL),
 
 1220                                 'ects_c' => array(
'float', strlen($this->ects_grades[
"C"]) ? $this->ects_grades[
"C"] : NULL),
 
 1221                                 'ects_d' => array(
'float', strlen($this->ects_grades[
"D"]) ? $this->ects_grades[
"D"] : NULL),
 
 1222                                 'ects_e' => array(
'float', strlen($this->ects_grades[
"E"]) ? $this->ects_grades[
"E"] : NULL),
 
 1223                                 'ects_fx' => array(
'float', $this->
getECTSFX()),
 
 1233                                 'password' => array(
'text', $this->
getPassword()),
 
 1240                                 'created' => array(
'integer', time()),
 
 1241                                 'tstamp' => array(
'integer', time()),
 
 1243                                 'template_id' => array(
'integer', $this->
getTemplate()),
 
 1244                                 'pool_usage' => array(
'integer', $this->
getPoolUsage()),
 
 1258                                 'online_status' => array(
'integer', (
int) $this->
isOnline()),
 
 1260                                 'autosave' => array(
'integer', (
int)$this->
getAutosave()),
 
 1265                         $this->test_id = $next_id;
 
 1278                                 $result = $ilDB->queryF(
"SELECT * FROM tst_tests WHERE test_id = %s",
 
 1280                                         array($this->test_id)
 
 1284                                         $oldrow = $ilDB->fetchAssoc(
$result);
 
 1288                         $affectedRows = $ilDB->manipulateF(
"UPDATE tst_tests SET author = %s, introduction = %s, " .
 
 1289                                 "finalstatement = %s, showinfo = %s, forcejs = %s, customstyle = %s, showfinalstatement = %s, sequence_settings = %s, " .
 
 1290                                 "score_reporting = %s, instant_verification = %s, answer_feedback_points = %s, answer_feedback = %s, anonymity = %s, show_cancel = %s, show_marker = %s, " .
 
 1291                                 "fixed_participants = %s, nr_of_tries = %s, kiosk = %s, use_previous_answers = %s, title_output = %s, processing_time = %s, enable_processing_time = %s, " . 
 
 1292                                 "reset_processing_time = %s, reporting_date = %s, starting_time = %s, ending_time = %s, complete = %s, ects_output = %s, ects_a = %s, ects_b = %s, ects_c = %s, ects_d = %s, " .
 
 1293                                 "ects_e = %s, ects_fx = %s, random_test = %s, random_question_count = %s, count_system = %s, mc_scoring = %s, score_cutting = %s, pass_scoring = %s, " . 
 
 1294                                 "shuffle_questions = %s, results_presentation = %s, show_summary = %s, password = %s, allowedusers = %s, mailnottype = %s, exportsettings = %s, " .
 
 1295                                 "print_bs_with_res = %s,".
 
 1296                                 "alloweduserstimegap = %s, certificate_visibility = %s, mailnotification = %s, tstamp = %s, enabled_view_mode = %s, template_id = %s, pool_usage = %s, " .
 
 1297                                 "offer_question_hints = %s, highscore_enabled = %s, highscore_anon = %s, highscore_achieved_ts = %s, " . 
 
 1298                                 "highscore_score = %s, highscore_percentage = %s, ".
 
 1299                                 "highscore_hints = %s, highscore_wtime = %s, highscore_own_table = %s, highscore_top_table = %s, highscore_top_num = %s, " .
 
 1300                                 "online_status = %s, specific_feedback = %s, obligations_enabled = %s, autosave = %s, autosave_ival = %s, pass_deletion_allowed = %s ".
 
 1301                                 "WHERE test_id = %s",
 
 1304                                         'text', 
'integer', 
'integer', 
'text', 
'integer', 
'integer',
 
 1305                                         'integer', 
'text', 
'text', 
'text', 
'text', 
'text', 
'integer',
 
 1306                                         'text', 
'integer', 
'integer', 
'text', 
'text', 
'text', 
'text',
 
 1307                                         'integer', 
'text', 
'text', 
'text', 
'text', 
'text', 
'float', 
'float', 
'float', 
'float',
 
 1308                                         'float', 
'float', 
'text', 
'integer', 
'text', 
'text', 
'text', 
'text',
 
 1309                                         'text', 
'integer', 
'integer', 
'text', 
'integer',
'integer', 
'integer',
 
 1311                                         'integer', 
'text', 
'integer', 
'integer', 
'text', 
'text', 
'integer', 
 
 1312                                         'integer', 
'integer', 
'integer', 
'integer', 
 
 1313                                         'integer', 
'integer', 
 
 1314                                         'integer', 
'integer', 
'integer', 
'integer', 
'integer', 
 
 1315                                         'integer', 
'integer',
'integer', 
'integer', 
'integer', 
'integer',
 
 1347                                         strlen($this->ects_grades[
"A"]) ? $this->ects_grades[
"A"] : NULL, 
 
 1348                                         strlen($this->ects_grades[
"B"]) ? $this->ects_grades[
"B"] : NULL, 
 
 1349                                         strlen($this->ects_grades[
"C"]) ? $this->ects_grades[
"C"] : NULL, 
 
 1350                                         strlen($this->ects_grades[
"D"]) ? $this->ects_grades[
"D"] : NULL, 
 
 1351                                         strlen($this->ects_grades[
"E"]) ? $this->ects_grades[
"E"] : NULL, 
 
 1395                         include_once (
"./Modules/Test/classes/class.ilObjAssessmentFolder.php");
 
 1398                                 $logresult = $ilDB->queryF(
"SELECT * FROM tst_tests WHERE test_id = %s",
 
 1403                                 if ($logresult->numRows() == 1)
 
 1405                                         $newrow = $ilDB->fetchAssoc($logresult);
 
 1407                                 $changed_fields = array();
 
 1408                                 foreach ($oldrow as $key => $value)
 
 1410                                         if (strcmp($oldrow[$key], $newrow[$key]) != 0)
 
 1412                                                 array_push($changed_fields, 
"$key: " . $oldrow[$key] . 
" => " . $newrow[$key]);
 
 1415                                 $changes = join($changed_fields, 
", ");
 
 1416                                 if (count($changed_fields) > 0)
 
 1427                                         $aresult = $ilDB->queryF(
"SELECT active_id FROM tst_active WHERE test_fi = %s AND tries >= %s AND submitted = %s",
 
 1428                                                 array(
'integer', 
'integer', 
'integer'),
 
 1431                                         while (
$row = $ilDB->fetchAssoc($aresult))
 
 1433                                                 $affectedRows = $ilDB->manipulateF(
"UPDATE tst_active SET submitted = %s, submittimestamp = %s WHERE active_id = %s",
 
 1434                                                         array(
'integer', 
'timestamp', 
'integer'),
 
 1435                                                         array(1, date(
'Y-m-d H:i:s'), 
$row[
"active_id"])
 
 1440                                         $aresult = $ilDB->queryF(
"SELECT active_id FROM tst_active WHERE test_fi = %s AND tries < %s AND submitted = %s",
 
 1441                                                 array(
'integer', 
'integer', 
'integer'),
 
 1444                                         while (
$row = $ilDB->fetchAssoc($aresult))
 
 1446                                                 $affectedRows = $ilDB->manipulateF(
"UPDATE tst_active SET submitted = %s, submittimestamp = %s WHERE active_id = %s",
 
 1447                                                         array(
'integer', 
'timestamp', 
'integer'),
 
 1448                                                         array(0, NULL, 
$row[
"active_id"])
 
 1455                                         $aresult = $ilDB->queryF(
"SELECT active_id FROM tst_active WHERE test_fi = %s AND submitted = %s",
 
 1456                                                 array(
'integer', 
'integer'),
 
 1459                                         while (
$row = $ilDB->fetchAssoc($aresult))
 
 1461                                                 $affectedRows = $ilDB->manipulateF(
"UPDATE tst_active SET submitted = %s, submittimestamp = %s WHERE active_id = %s",
 
 1462                                                         array(
'integer', 
'timestamp', 
'integer'),
 
 1463                                                         array(0, NULL, 
$row[
"active_id"])
 
 1473                         include_once 
"./Services/Object/classes/class.ilObjectActivation.php";          
 
 1489                         $item->update($this->ref_id);           
 
 1496                 if (!$properties_only)
 
 1501                                 $ilias->raiseError(
$result->getMessage());
 
 1509                                 $this->mark_schema->saveToDb($this->test_id);
 
 1524                 $oldquestions = array();
 
 1525                 include_once 
"./Modules/Test/classes/class.ilObjAssessmentFolder.php";
 
 1528                         $result = $ilDB->queryF(
"SELECT question_fi FROM tst_test_question WHERE test_fi = %s ORDER BY sequence",
 
 1536                                         array_push($oldquestions, 
$row[
"question_fi"]);
 
 1542                 $currentQuestionsObligationsQuery = 
'SELECT question_fi, obligatory FROM tst_test_question WHERE test_fi = %s';
 
 1543                 $rset = $ilDB->queryF($currentQuestionsObligationsQuery, array(
'integer'), array($this->
getTestId()));
 
 1544                 while (
$row = $ilDB->fetchAssoc($rset)) {
 
 1545                         $obligatoryQuestionState[
$row[
'question_fi']] = $row[
'obligatory'];
 
 1548                 $affectedRows = $ilDB->manipulateF(
"DELETE FROM tst_test_question WHERE test_fi = %s",
 
 1553                 foreach ($this->questions as $key => $value) 
 
 1556                         if( !isset($obligatoryQuestionState[$value]) || is_null($obligatoryQuestionState[$value]) )
 
 1558                                 $obligatoryQuestionState[$value] = 0;
 
 1562                         $next_id = $ilDB->nextId(
'tst_test_question');
 
 1563                         $ilDB->insert(
'tst_test_question', array(
 
 1564                                 'test_question_id' => array(
'integer', $next_id),
 
 1565                                 'test_fi' => array(
'integer', $this->
getTestId()),
 
 1566                                 'question_fi' => array(
'integer', $value),
 
 1567                                 'sequence' => array(
'integer', $key),
 
 1568                                 'obligatory' => array(
'integer', $obligatoryQuestionState[$value]),
 
 1569                                 'tstamp' => array(
'integer', time())
 
 1572                 include_once (
"./Modules/Test/classes/class.ilObjAssessmentFolder.php");
 
 1575                         $result = $ilDB->queryF(
"SELECT question_fi FROM tst_test_question WHERE test_fi = %s ORDER BY sequence",
 
 1579                         $newquestions = array();
 
 1584                                         array_push($newquestions, 
$row[
"question_fi"]);
 
 1587                         foreach ($oldquestions as $index => $question_id)
 
 1589                                 if (strcmp($newquestions[$index], $question_id) != 0)
 
 1591                                         $pos = array_search($question_id, $newquestions);
 
 1602                         foreach ($newquestions as $index => $question_id)
 
 1604                                 if (array_search($question_id, $oldquestions) === FALSE)
 
 1618                 $result = $ilDB->queryF(
'SELECT copy_id FROM tst_rnd_cpy WHERE tst_fi = %s',
 
 1622                 return $result->numRows() > 0;
 
 1637                 $result = $ilDB->queryF(
"SELECT test_random_question_id FROM tst_test_rnd_qst WHERE active_fi = %s AND pass = %s",
 
 1638                         array(
'integer',
'integer'),
 
 1639                         array($active_id, 
$pass)
 
 1641                 if (
$result->numRows() < $maxcount)
 
 1643                         $duplicate_id = $question_id;
 
 1647                                 if ($duplicate_id === FALSE)
 
 1652                         $next_id = $ilDB->nextId(
'tst_test_rnd_qst');
 
 1653                         $result = $ilDB->manipulateF(
"INSERT INTO tst_test_rnd_qst (test_random_question_id, active_fi, question_fi, sequence, pass, tstamp) VALUES (%s, %s, %s, %s, %s, %s)",
 
 1654                                 array(
'integer',
'integer',
'integer',
'integer',
'integer',
'integer'),
 
 1655                                 array($next_id,$active_id, $duplicate_id, 
$result->numRows()+1, 
$pass, time())
 
 1673                 $result = $ilDB->queryF(
"SELECT qpl_questions.question_id FROM qpl_questions, tst_test_rnd_qst WHERE qpl_questions.original_id = %s AND tst_test_rnd_qst.question_fi = qpl_questions.question_id AND tst_test_rnd_qst.active_fi = %s",
 
 1674                         array(
'integer', 
'integer'),
 
 1675                         array($question_id, $active_id)
 
 1681                         return $row[
"question_id"];
 
 1698                 $result = $ilDB->queryF(
"SELECT test_result_id FROM tst_test_result WHERE active_fi = %s AND pass = %s",
 
 1699                         array(
'integer',
'integer'),
 
 1700                         array($active_id, 
$pass)
 
 1716                 $result = $ilDB->queryF(
"SELECT test_random_question_id FROM tst_test_rnd_qst WHERE active_fi = %s AND pass = %s",
 
 1717                         array(
'integer',
'integer'),
 
 1718                         array($active_id, 
$pass)
 
 1720                 return (
$result->numRows() > 0) ? 
true : 
false;
 
 1742                         if (
false && 
$pass > 0) 
 
 1757                         $ilias->raiseError(sprintf($this->lng->txt(
"error_random_question_generation"), $ilUser->getId(), $this->
getTestId()), $ilErr->FATAL);
 
 1765                         $allquestions = array();
 
 1766                         foreach ($rndquestions as $question_id)
 
 1768                                 array_push($allquestions, $question_id);
 
 1772                                 srand ((
float)microtime()*1000000);
 
 1773                                 shuffle($allquestions);
 
 1777                         foreach ($qpls as 
$data)
 
 1779                                 $maxcount += $data[
"contains"];
 
 1781                         if ($num > $maxcount) $num = $maxcount;
 
 1782                         foreach ($allquestions as $question_id)
 
 1790                         $allquestions = array();
 
 1792                         foreach ($qpls as $key => $value)
 
 1794                                 if ($value[
"count"] > 0)
 
 1797                                         foreach ($rndquestions as $question_id)
 
 1799                                                 array_push($allquestions, $question_id);
 
 1802                                 $add = ($value[
"count"] <= $value[
"contains"]) ? $value[
"count"] : $value[
"contains"];
 
 1807                                 srand ((
float)microtime()*1000000);
 
 1808                                 shuffle($allquestions);
 
 1810                         foreach ($allquestions as $question_id)
 
 1827                 if (strlen($total_questions))
 
 1831                 $affectedRows = $ilDB->manipulateF(
"UPDATE tst_tests SET random_question_count = %s, tstamp = %s WHERE test_id = %s",
 
 1832                         array(
'integer', 
'integer', 
'integer'),
 
 1835                 include_once (
"./Modules/Test/classes/class.ilObjAssessmentFolder.php");
 
 1855                 $result = $ilDB->queryF(
"SELECT tst_test_random.*, qpl_questionpool.questioncount FROM tst_test_random, qpl_questionpool WHERE tst_test_random.test_fi = %s AND tst_test_random.questionpool_fi = qpl_questionpool.obj_fi ORDER BY sequence, test_random_id",
 
 1863                                 $qpls[$counter] = array(
 
 1864                                         "index" => $counter,
 
 1865                                         "count" => 
$row[
"num_of_q"],
 
 1866                                         "qpl"   => 
$row[
"questionpool_fi"],
 
 1867                                         "contains" => 
$row[
"questioncount"]
 
 1882                 include_once (
"./Modules/Test/classes/class.ilObjAssessmentFolder.php");
 
 1884                 $affectedRows = $ilDB->manipulateF(
"DELETE FROM tst_test_random WHERE test_fi = %s",
 
 1896                 foreach ($this->random_questionpool_data as $idx => 
$data) 
 
 1901                                 $next_id = $ilDB->nextId(
'tst_test_random');
 
 1902                                 $result = $ilDB->manipulateF(
"INSERT INTO tst_test_random (test_random_id, test_fi, questionpool_fi, num_of_q, tstamp, sequence) VALUES (%s, %s, %s, %s, %s, %s)",
 
 1903                                         array(
'integer',
'integer', 
'integer', 
'integer', 
'integer', 
'integer'),
 
 1923                 $result = $ilDB->queryF(
'SELECT * FROM tst_rnd_cpy WHERE tst_fi = %s',
 
 1930                         $question->delete(
$row[
'qst_fi']);
 
 1933                 $affectedRows = $ilDB->manipulateF(
'DELETE FROM tst_rnd_cpy WHERE tst_fi = %s',
 
 1938                 $affectedRows = $ilDB->manipulateF(
'DELETE FROM tst_rnd_qpl_title WHERE tst_fi = %s',
 
 1952                         $result = $ilDB->queryF(
'SELECT tst_rnd_cpy.*, tst_test_random.num_of_q FROM tst_rnd_cpy, tst_test_random WHERE tst_rnd_cpy.tst_fi = %s AND tst_rnd_cpy.tst_fi = tst_test_random.test_fi AND tst_rnd_cpy.qpl_fi = tst_test_random.questionpool_fi',
 
 1959                                 if (is_array($pools[
$row[
'qpl_fi']]))
 
 1961                                         $pools[$row[
'qpl_fi']][
'count']++;
 
 1965                                         $pools[$row[
'qpl_fi']][
'count'] = 1;
 
 1967                                 $pools[$row[
'qpl_fi']][
'num_of_q'] = $row[
'num_of_q'];
 
 1969                         $result = $ilDB->queryF(
'SELECT * FROM tst_rnd_qpl_title WHERE tst_fi = %s',
 
 1976                                 $pools[
$row[
'qpl_fi']][
'title'] = $row[
'qpl_title'];
 
 1982                         $result = $ilDB->queryF(
'SELECT tst_test_random.* FROM tst_test_random WHERE tst_test_random.test_fi = %s ORDER BY sequence, test_random_id',
 
 1989                                 $pools[
$row[
'questionpool_fi']][
'count'] = $row[
'num_of_q'];
 
 1990                                 $pools[$row[
'questionpool_fi']][
'num_of_q'] = $row[
'num_of_q'];
 
 1992                         $result = $ilDB->queryF(
'SELECT * FROM tst_rnd_qpl_title WHERE tst_fi = %s',
 
 1999                                 $pools[
$row[
'qpl_fi']][
'title'] = $row[
'qpl_title'];
 
 2011                 $result = $ilDB->queryF(
'SELECT question_id FROM qpl_questions WHERE obj_fi = %s AND complete = %s AND original_id IS NULL',
 
 2012                         array(
'integer', 
'text'),
 
 2013                         array($questionpool_id, 1)
 
 2015                 $saved_titles = array();
 
 2019                         $duplicate_id = $question->duplicate(
true, null, null, null, $this->
getId());
 
 2020                         if ($duplicate_id > 0)
 
 2022                                 $next_id = $ilDB->nextId(
'tst_rnd_cpy');
 
 2023                                 $ilDB->manipulateF(
'INSERT INTO tst_rnd_cpy (copy_id, tst_fi, qst_fi, qpl_fi) VALUES (%s, %s, %s, %s)',
 
 2024                                         array(
'integer', 
'integer', 
'integer', 
'integer'),
 
 2025                                         array($next_id, $this->
getTestId(), $duplicate_id, $questionpool_id)
 
 2027                                 if (!array_key_exists($questionpool_id, $saved_titles))
 
 2029                                         $next_id = $ilDB->nextId(
'tst_rnd_qpl_title');
 
 2030                                         $ilDB->manipulateF(
'INSERT INTO tst_rnd_qpl_title (title_id, tst_fi, qpl_fi, qpl_title) VALUES (%s, %s, %s, %s)',
 
 2031                                                 array(
'integer', 
'integer', 
'integer', 
'text'),
 
 2034                                         $saved_titles[$questionpool_id] = 1;
 
 2042                 include_once 
"./Modules/Test/classes/class.ilRandomTestData.php";
 
 2043                 if (array_key_exists($position, $this->random_questionpool_data))
 
 2045                         $newitems = array();
 
 2046                         for ($i = 0; $i < $position; $i++)
 
 2048                                 array_push($newitems, $this->random_questionpool_data[$i]);
 
 2051                         for ($i = $position; $i < count($this->random_questionpool_data); $i++)
 
 2053                                 array_push($newitems, $this->random_questionpool_data[$i]);
 
 2055                         $this->random_questionpool_data = $newitems;
 
 2059                         array_push($this->random_questionpool_data, 
new ilRandomTestData($count, $qpl));
 
 2065                 if (array_key_exists($position, $this->random_questionpool_data))
 
 2067                         unset($this->random_questionpool_data[$position]);
 
 2073                 $this->random_questionpool_data = $a_data;
 
 2091                 $result = $ilDB->queryF(
"SELECT tst_test_random.*, qpl_questionpool.questioncount FROM tst_test_random, qpl_questionpool WHERE tst_test_random.test_fi = %s AND tst_test_random.questionpool_fi = qpl_questionpool.obj_fi ORDER BY sequence, test_random_id",
 
 2095                 include_once 
"./Modules/Test/classes/class.ilRandomTestData.php";
 
 2117                 $result = $ilDB->queryF(
"SELECT * FROM tst_tests WHERE obj_fi = %s",
 
 2119                         array($this->
getId())
 
 2130                         include_once(
"./Services/RTE/classes/class.ilRTE.php");
 
 2162                                         "A" => 
$data->ects_a,
 
 2163                                         "B" => 
$data->ects_b,
 
 2164                                         "C" => 
$data->ects_c,
 
 2165                                         "D" => 
$data->ects_d,
 
 2166                                         "E" => 
$data->ects_e
 
 2172                         $this->mark_schema->flush();
 
 2173                         $this->mark_schema->loadFromDb($this->
getTestId());
 
 2212                         include_once 
"./Services/Object/classes/class.ilObjectActivation.php";
 
 2214                         switch($activation[
"timing_type"])
 
 2241         $this->questions = array();
 
 2242         if (strcmp($active_id, 
"") == 0)
 
 2252                 $result = $ilDB->queryF(
"SELECT tst_test_rnd_qst.* FROM tst_test_rnd_qst, qpl_questions WHERE tst_test_rnd_qst.active_fi = %s AND qpl_questions.question_id = tst_test_rnd_qst.question_fi AND tst_test_rnd_qst.pass = %s ORDER BY sequence",
 
 2253                         array(
'integer', 
'integer'),
 
 2254                         array($active_id, 
$pass)
 
 2262                         $result = $ilDB->queryF(
"SELECT tst_test_rnd_qst.* FROM tst_test_rnd_qst, qpl_questions WHERE tst_test_rnd_qst.active_fi = %s AND qpl_questions.question_id = tst_test_rnd_qst.question_fi AND tst_test_rnd_qst.pass = 0 ORDER BY sequence",
 
 2270                 $result = $ilDB->queryF(
"SELECT tst_test_question.* FROM tst_test_question, qpl_questions WHERE tst_test_question.test_fi = %s AND qpl_questions.question_id = tst_test_question.question_fi ORDER BY sequence",
 
 2272                         array($this->test_id)
 
 2278                 $this->questions[$index++] = 
$data[
"question_fi"];
 
 2303                 $this->_finalstatement = $a_statement;
 
 2315                 $this->_showinfo = ($a_info) ? 1 : 0;
 
 2327                 $this->_forcejs = ($a_js) ? 1 : 0;
 
 2339                 $this->_customStyle = $a_customStyle;
 
 2351                 return (strlen($this->_customStyle)) ? $this->_customStyle : NULL;
 
 2364                 $css_path = str_replace(
"ta.css", 
"customstyles", $css_path) . 
"/";
 
 2365                 $customstyles = array();
 
 2366                 if (is_dir($css_path))
 
 2369                         include_once 
"./Services/Utilities/classes/class.ilFileUtils.php";
 
 2375                                         if (strpos($filename, 
".css"))
 
 2377                                                 array_push($customstyles, $filename);
 
 2382                 return $customstyles;
 
 2397                         $custom = str_replace(
"ta.css", 
"customstyles/" . $this->
getCustomStyle(), $default);
 
 2398                         if (file_exists($custom))
 
 2401                                 $custom = str_replace(
"ta.css", 
"customstyles/" . $this->
getCustomStyle(), $custom);
 
 2424                 $this->_showfinalstatement = ($show) ? 1 : 0;
 
 2437                 return ($this->random_test) ? 1 : 0;
 
 2450                 $query = 
"SELECT random_test FROM tst_tests ".
 
 2451                         "WHERE obj_fi = ".$ilDB->quote($a_obj_id,
'integer');
 
 2455                         return $row->random_test ? 
true : 
false;
 
 2469                 return ($this->random_question_count) ? $this->random_question_count : 0;
 
 2480                 return (strlen($this->introduction)) ? $this->introduction : NULL;
 
 2491                 return (strlen($this->_finalstatement)) ? $this->_finalstatement : NULL;
 
 2503                 return ($this->_showinfo) ? 1 : 0;
 
 2515                 return ($this->_forcejs) ? 1 : 0;
 
 2527                 return ($this->_showfinalstatement) ? 1 : 0;
 
 2551                 return ($this->ects_output) ? 1 : 0;
 
 2563                 $this->ects_output = $a_ects_output ? 1 : 0;
 
 2575                 return (strlen($this->ects_fx)) ? $this->ects_fx : NULL;
 
 2587                 $this->ects_fx = $a_ects_fx;
 
 2611                 if (is_array($a_ects_grades))
 
 2613                         $this->ects_grades = $a_ects_grades;
 
 2650                 switch ($instant_feedback)
 
 2653                                 $this->instant_verification = 1;
 
 2656                                 $this->instant_verification = 0;
 
 2673                         $this->answer_feedback = 1;
 
 2676                         $this->answer_feedback = 0;
 
 2689         switch ($generic_answer_feedback)
 
 2692                         $this->answer_feedback = 1;
 
 2695                         $this->answer_feedback = 0;
 
 2712                                 $this->answer_feedback_points = 1;
 
 2715                                 $this->answer_feedback_points = 0;
 
 2729                 $this->random_test = $a_random_test;
 
 2741                 $this->random_question_count = $a_random_question_count;
 
 2755                         $this->reporting_date = 
"";
 
 2756                         $this->ects_output = 0;
 
 2773                 return ($this->sequence_settings) ? $this->sequence_settings : 0;
 
 2785                 return ($this->score_reporting) ? $this->score_reporting : 0;
 
 2797                 return ($this->instant_verification) ? $this->instant_verification : 0;
 
 2810                 return ($this->answer_feedback) ? $this->answer_feedback : 0;
 
 2823                 return ($this->answer_feedback) ? $this->answer_feedback : 0;
 
 2835         return ($this->answer_feedback_points) ? $this->answer_feedback_points : 0;
 
 2847                 return ($this->count_system) ? $this->count_system : 0;
 
 2860                 $result = $ilDB->queryF(
"SELECT tst_tests.count_system FROM tst_tests, tst_active WHERE tst_active.active_id = %s AND tst_active.test_fi = tst_tests.test_id",
 
 2867                         return $row[
"count_system"];
 
 2881                 return ($this->mc_scoring) ? $this->mc_scoring : 0;
 
 2893                 return ($this->score_cutting) ? $this->score_cutting : 0;
 
 2905                 return (strlen($this->password)) ? $this->password : NULL;
 
 2917                 return ($this->pass_scoring) ? $this->pass_scoring : 0;
 
 2930                 $result = $ilDB->queryF(
"SELECT tst_tests.pass_scoring FROM tst_tests, tst_active WHERE tst_tests.test_id = tst_active.test_fi AND tst_active.active_id = %s",
 
 2937                         return $row[
"pass_scoring"];
 
 2952                 $result = $ilDB->queryF(
"SELECT tst_tests.mc_scoring FROM tst_tests, tst_active WHERE tst_active.active_id = %s AND tst_active.test_fi = tst_tests.test_id",
 
 2959                         return $row[
"mc_scoring"];
 
 2974                 $result = $ilDB->queryF(
"SELECT tst_tests.score_cutting FROM tst_tests, tst_active WHERE tst_active.active_id = %s AND tst_tests.test_id = tst_active.test_fi",
 
 2981                         return $row[
"score_cutting"];
 
 2995                 return (strlen($this->reporting_date)) ? $this->reporting_date : NULL;
 
 3007                 return ($this->nr_of_tries) ? $this->nr_of_tries : 0;
 
 3019                 return ($this->_kiosk) ? $this->_kiosk : 0;
 
 3032                 $this->_kiosk = $kiosk;
 
 3044                 if (($this->_kiosk & 1) > 0)
 
 3065                         $this->_kiosk = $this->_kiosk | 1;
 
 3071                                 $this->_kiosk = $this->_kiosk ^ 1;
 
 3085                 if (($this->_kiosk & 2) > 0)
 
 3105                         $this->_kiosk = $this->_kiosk | 2;
 
 3111                                 $this->_kiosk = $this->_kiosk ^ 2;
 
 3125                 if (($this->_kiosk & 4) > 0)
 
 3145                         $this->_kiosk = $this->_kiosk | 4;
 
 3151                                 $this->_kiosk = $this->_kiosk ^ 4;
 
 3165                 return ($this->use_previous_answers) ? $this->use_previous_answers : 0;
 
 3177                 return ($this->title_output) ? $this->title_output : 0;
 
 3192                 $result = $ilDB->queryF(
"SELECT tst_tests.title_output FROM tst_tests, tst_active WHERE tst_tests.test_id = tst_active.test_fi AND tst_active.active_id = %s",
 
 3199                         return $row[
"title_output"];
 
 3220                 $result = $ilDB->queryF(
"SELECT tst_tests.use_previous_answers FROM tst_tests, tst_active WHERE tst_tests.test_id = tst_active.test_fi AND tst_active.active_id = %s",
 
 3232                         if ($user_active_user_setting)
 
 3234                                 $res = $ilUser->getPref(
"tst_use_previous_answers");
 
 3253                 return (strlen($this->processing_time)) ? $this->processing_time : NULL;
 
 3264                 if (strlen($this->processing_time))
 
 3266                         if (preg_match(
"/(\d{2}):(\d{2}):(\d{2})/is", $this->processing_time, $matches))
 
 3268                                 if ((
int)$matches[1]+(
int)$matches[2]+(
int)$matches[3] == 0)
 
 3275                                                 'hh' => $matches[1],
 
 3276                                                 'mm' => $matches[2],
 
 3277                                                 'ss' => $matches[3],
 
 3294                 if (preg_match(
"/(\d{2}):(\d{2}):(\d{2})/", $this->
getProcessingTime(), $matches))
 
 3296                         return ($matches[1] * 3600) + ($matches[2] * 60) + $matches[3];
 
 3313                         if (preg_match(
"/(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})/", $this->
getEndingTime(), $matches))
 
 3315                                 $ending = mktime($matches[4], $matches[5], $matches[6], $matches[2], $matches[3], $matches[1]);
 
 3317                                 return $ending - $now;
 
 3334                 return ($this->enable_processing_time) ? $this->enable_processing_time : 0;
 
 3346                 return ($this->reset_processing_time) ? $this->reset_processing_time : 0;
 
 3358                 return (strlen($this->starting_time)) ? $this->starting_time : NULL;
 
 3370                 return (strlen($this->ending_time)) ? $this->ending_time : NULL;
 
 3396                         $this->use_previous_answers = 1;
 
 3400                         $this->use_previous_answers = 0;
 
 3416                                 $this->title_output = 1;
 
 3419                                 $this->title_output = 2;
 
 3422                                 $this->title_output = 0;
 
 3449                         $this->enable_processing_time = 
"1";
 
 3451                         $this->enable_processing_time = 
"0";
 
 3466                         $this->reset_processing_time = 1;
 
 3470                         $this->reset_processing_time = 0;
 
 3507                 $this->count_system = $a_count_system;
 
 3519                 $this->password = $a_password;
 
 3531                 $this->score_cutting = $a_score_cutting;
 
 3543                 $this->mc_scoring = $a_mc_scoring;
 
 3555                 switch ($a_pass_scoring)
 
 3576                 include_once (
"./Modules/Test/classes/class.ilObjAssessmentFolder.php");
 
 3581                 $question->delete($question_id);
 
 3601                         $affectedRows = $ilDB->manipulateF(
"DELETE FROM tst_solutions WHERE tst_solutions.active_fi IN (SELECT active_id FROM tst_active WHERE test_fi = %s) AND tst_solutions.question_fi = %s",
 
 3602                                 array(
'integer',
'integer'),
 
 3605                         $affectedRows = $ilDB->manipulateF(
"DELETE FROM tst_qst_solved WHERE tst_qst_solved.active_fi IN (SELECT active_id FROM tst_active WHERE test_fi = %s) AND tst_qst_solved.question_fi = %s",
 
 3606                                 array(
'integer',
'integer'),
 
 3609                         $affectedRows = $ilDB->manipulateF(
"DELETE FROM tst_test_result WHERE tst_test_result.active_fi IN (SELECT active_id FROM tst_active WHERE test_fi = %s) AND tst_test_result.question_fi = %s",
 
 3610                                 array(
'integer',
'integer'),
 
 3613                         $affectedRows = $ilDB->manipulateF(
"DELETE FROM tst_pass_result WHERE tst_pass_result.active_fi IN (SELECT active_id FROM tst_active WHERE test_fi = %s)",
 
 3618                         require_once 
'Modules/TestQuestionPool/classes/class.ilAssQuestionHintTracking.php';
 
 3623                         $affectedRows = $ilDB->manipulateF(
"DELETE FROM tst_solutions WHERE tst_solutions.active_fi IN  (SELECT active_id FROM tst_active WHERE test_fi = %s)",
 
 3627                         $affectedRows = $ilDB->manipulateF(
"DELETE FROM tst_qst_solved WHERE tst_qst_solved.active_fi IN  (SELECT active_id FROM tst_active WHERE test_fi = %s)",
 
 3631                         $affectedRows = $ilDB->manipulateF(
"DELETE FROM tst_test_result WHERE tst_test_result.active_fi IN  (SELECT active_id FROM tst_active WHERE test_fi = %s)",
 
 3635                         $affectedRows = $ilDB->manipulateF(
"DELETE FROM tst_pass_result WHERE tst_pass_result.active_fi IN  (SELECT active_id FROM tst_active WHERE test_fi = %s)",
 
 3640                         $query = 
"SELECT active_id FROM tst_active WHERE test_fi = %s";
 
 3642                         $activeIds = array();
 
 3643                         while( 
$row = $ilDB->fetchAssoc(
$res) )
 
 3645                                 $activeIds[] = 
$row[
'active_id'];
 
 3648                         require_once 
'Modules/TestQuestionPool/classes/class.ilAssQuestionHintTracking.php';
 
 3651                         include_once (
"./Modules/Test/classes/class.ilObjAssessmentFolder.php");
 
 3657                 $affectedRows = $ilDB->manipulateF(
"DELETE FROM tst_sequence WHERE tst_sequence.active_fi IN  (SELECT active_id FROM tst_active WHERE test_fi = %s)",
 
 3664                         $affectedRows = $ilDB->manipulateF(
"DELETE FROM tst_test_rnd_qst WHERE tst_test_rnd_qst.active_fi IN  (SELECT active_id FROM tst_active WHERE test_fi = %s)",
 
 3671                 $affectedRows = $ilDB->manipulateF(
"DELETE FROM tst_active WHERE test_fi = %s",
 
 3677                 $affectedRows = $ilDB->manipulateF(
"DELETE FROM usr_pref WHERE keyword = %s",
 
 3679                         array(
"tst_password_".$this->
getTestId())
 
 3684                 if (@is_dir(CLIENT_WEB_DIR . 
"/assessment/tst_" . $this->
getTestId()))
 
 3694                 $IN_activeIds = $ilDB->in(
'active_fi', $participantData->
getActiveIds(), 
false, 
'integer');
 
 3696                 $ilDB->manipulate(
"DELETE FROM tst_solutions WHERE $IN_activeIds");
 
 3697                 $ilDB->manipulate(
"DELETE FROM tst_qst_solved WHERE $IN_activeIds");
 
 3698                 $ilDB->manipulate(
"DELETE FROM tst_test_result WHERE $IN_activeIds");
 
 3699                 $ilDB->manipulate(
"DELETE FROM tst_pass_result WHERE $IN_activeIds");
 
 3700                 $ilDB->manipulate(
"DELETE FROM tst_result_cache WHERE $IN_activeIds");
 
 3701                 $ilDB->manipulate(
"DELETE FROM tst_sequence WHERE $IN_activeIds");
 
 3705                         $ilDB->manipulate(
"DELETE FROM tst_test_rnd_qst WHERE $IN_activeIds");
 
 3708                 $IN_userIds = $ilDB->in(
'usr_id', $participantData->
getUserIds(), 
false, 
'integer');
 
 3710                         "DELETE FROM usr_pref WHERE $IN_userIds AND keyword = %s",
 
 3711                         array(
'text'), array(
"tst_password_".$this->
getTestId())
 
 3714                 include_once (
"./Modules/Test/classes/class.ilObjAssessmentFolder.php");
 
 3716                 foreach ($participantData->
getActiveIds() as $active_id)
 
 3720                         if (@is_dir(CLIENT_WEB_DIR . 
"/assessment/tst_" . $this->
getTestId() . 
"/$active_id"))
 
 3731                 require_once 
'Modules/TestQuestionPool/classes/class.ilAssQuestionHintTracking.php';
 
 3739                 $IN_activeIds = $ilDB->in(
'active_id', $activeIds, 
false, 
'integer');
 
 3740                 $ilDB->manipulate(
"DELETE FROM tst_active WHERE $IN_activeIds");
 
 3750                 $affectedRows = $ilDB->manipulateF(
"DELETE FROM tst_solutions WHERE active_fi = %s",
 
 3754                 $affectedRows = $ilDB->manipulateF(
"DELETE FROM tst_qst_solved WHERE active_fi = %s",
 
 3758                 $affectedRows = $ilDB->manipulateF(
"DELETE FROM tst_test_result WHERE active_fi = %s",
 
 3762                 $affectedRows = $ilDB->manipulateF(
"DELETE FROM tst_pass_result WHERE active_fi = %s",
 
 3769                         $affectedRows = $ilDB->manipulateF(
"DELETE FROM tst_test_rnd_qst WHERE active_fi = %s",
 
 3775                 include_once (
"./Modules/Test/classes/class.ilObjAssessmentFolder.php");
 
 3781                 $affectedRows = $ilDB->manipulateF(
"DELETE FROM tst_sequence WHERE active_fi = %s",
 
 3787                 $affectedRows = $ilDB->manipulateF(
"DELETE FROM tst_active WHERE active_id = %s",
 
 3795                         $affectedRows = $ilDB->manipulateF(
"DELETE FROM usr_pref WHERE usr_id = %s AND keyword = %s",
 
 3796                                 array(
'integer', 
'text'),
 
 3797                                 array($user_id, 
"tst_password_".$this->
getTestId())
 
 3803                 if (@is_dir(CLIENT_WEB_DIR . 
"/assessment/tst_" . $this->
getTestId() . 
"/$active_id"))
 
 3808                 require_once 
'Modules/TestQuestionPool/classes/class.ilAssQuestionHintTracking.php';
 
 3824                 $result = $ilDB->queryF(
"SELECT * FROM tst_test_question WHERE test_fi=%s AND question_fi=%s",
 
 3825                         array(
'integer', 
'integer'),
 
 3829                 if (
$data->sequence > 1) 
 
 3832                         $result = $ilDB->queryF(
"SELECT * FROM tst_test_question WHERE test_fi=%s AND sequence=%s",
 
 3833                                 array(
'integer',
'integer'),
 
 3836                         $data_previous = $ilDB->fetchObject(
$result);
 
 3838                         $affectedRows = $ilDB->manipulateF(
"UPDATE tst_test_question SET sequence=%s WHERE test_question_id=%s",
 
 3839                                 array(
'integer',
'integer'),
 
 3840                                 array(
$data->sequence, $data_previous->test_question_id)
 
 3843                         $affectedRows = $ilDB->manipulateF(
"UPDATE tst_test_question SET sequence=%s WHERE test_question_id=%s",
 
 3844                                 array(
'integer',
'integer'),
 
 3845                                 array(
$data->sequence - 1, 
$data->test_question_id)
 
 3847                         include_once (
"./Modules/Test/classes/class.ilObjAssessmentFolder.php");
 
 3868                 $result = $ilDB->queryF(
"SELECT * FROM tst_test_question WHERE test_fi=%s AND question_fi=%s",
 
 3869                         array(
'integer',
'integer'),
 
 3873                 $result = $ilDB->queryF(
"SELECT * FROM tst_test_question WHERE test_fi=%s AND sequence=%s",
 
 3874                         array(
'integer',
'integer'),
 
 3880                         $data_next = $ilDB->fetchObject(
$result);
 
 3882                         $affectedRows = $ilDB->manipulateF(
"UPDATE tst_test_question SET sequence=%s WHERE test_question_id=%s",
 
 3883                                 array(
'integer',
'integer'),
 
 3884                                 array(
$data->sequence, $data_next->test_question_id)
 
 3887                         $affectedRows = $ilDB->manipulateF(
"UPDATE tst_test_question SET sequence=%s WHERE test_question_id=%s",
 
 3888                                 array(
'integer',
'integer'),
 
 3889                                 array(
$data->sequence + 1, 
$data->test_question_id)
 
 3891                         include_once (
"./Modules/Test/classes/class.ilObjAssessmentFolder.php");
 
 3911                 $duplicate_id = $question->duplicate(
true, null, null, null, $this->
getId());
 
 3913                 return $duplicate_id;
 
 3925 #var_dump($question_id); 
 3928                         $duplicate_id = $question_id;
 
 3936                 $result = $ilDB->queryF(
"SELECT MAX(sequence) seq FROM tst_test_question WHERE test_fi=%s",
 
 3945                         $sequence = 
$data->seq + 1;
 
 3948                 $next_id = $ilDB->nextId(
'tst_test_question');
 
 3949                 $affectedRows = $ilDB->manipulateF(
"INSERT INTO tst_test_question (test_question_id, test_fi, question_fi, sequence, tstamp) VALUES (%s, %s, %s, %s, %s)",
 
 3950                         array(
'integer', 
'integer',
'integer',
'integer',
'integer'),
 
 3951                         array($next_id, $this->
getTestId(), $duplicate_id, $sequence, time())
 
 3953                 if ($affectedRows == 1) 
 
 3955                         include_once (
"./Modules/Test/classes/class.ilObjAssessmentFolder.php");
 
 3962                 $affectedRows = $ilDB->manipulateF(
"DELETE FROM tst_active WHERE test_fi = %s",
 
 3968                 return $duplicate_id;
 
 3984                         $result = $ilDB->queryF(
"SELECT qpl_questions.title FROM tst_test_question, qpl_questions WHERE tst_test_question.test_fi = %s AND tst_test_question.question_fi = qpl_questions.question_id ORDER BY tst_test_question.sequence",
 
 3990                                 array_push($titles, 
$row[
"title"]);
 
 4009                         $result = $ilDB->queryF(
"SELECT qpl_questions.title, qpl_questions.question_id FROM tst_test_question, qpl_questions WHERE tst_test_question.test_fi = %s AND tst_test_question.question_fi = qpl_questions.question_id ORDER BY tst_test_question.sequence",
 
 4015                                 $titles[
$row[
'question_id']] = $row[
"title"];
 
 4033                         return $this->lng->txt(
"ass_question");
 
 4053                 $result = $ilDB->queryF(
"SELECT qpl_questions.*, qpl_qst_type.type_tag FROM qpl_questions, qpl_qst_type WHERE qpl_questions.question_id = %s AND qpl_questions.question_type_fi = qpl_qst_type.question_type_id",
 
 4065         public function &getExistingQuestions(
$pass = NULL)
 
 4073                 $existing_questions = array();
 
 4079                                 "SELECT qpl_questions.original_id 
 4080                                 FROM qpl_questions, tst_test_rnd_qst 
 4081                                 WHERE tst_test_rnd_qst.active_fi = %s 
 4082                                 AND tst_test_rnd_qst.question_fi = qpl_questions.question_id 
 4083                                 AND tst_test_rnd_qst.pass = %s 
 4084                                 AND qpl_questions.original_id IS NOT NULL",
 
 4085                                 array(
'integer', 
'integer'),
 
 4086                                 array($active_id, 
$pass)
 
 4092                                 "SELECT qpl_questions.original_id 
 4093                                 FROM qpl_questions, tst_test_question 
 4094                                 WHERE tst_test_question.test_fi = %s 
 4095                                 AND tst_test_question.question_fi = qpl_questions.question_id 
 4096                                 AND qpl_questions.original_id IS NOT NULL",
 
 4103                         array_push($existing_questions, 
$data->original_id);
 
 4105                 return $existing_questions;
 
 4119                 if ($question_id < 1) 
return -1;
 
 4120                 $result = $ilDB->queryF(
"SELECT type_tag FROM qpl_questions, qpl_qst_type WHERE qpl_questions.question_id = %s AND qpl_questions.question_type_fi = qpl_qst_type.question_type_id",
 
 4127                         return $data->type_tag;
 
 4145                 $next_id = $ilDB->nextId(
'tst_times');
 
 4146                 $affectedRows = $ilDB->manipulateF(
"INSERT INTO tst_times (times_id, active_fi, started, finished, pass, tstamp) VALUES (%s, %s, %s, %s, %s, %s)",
 
 4147                         array(
'integer', 
'integer', 
'timestamp', 
'timestamp', 
'integer', 
'integer'),
 
 4148                         array($next_id, $active_id, strftime(
"%Y-%m-%d %H:%M:%S"), strftime(
"%Y-%m-%d %H:%M:%S"), 
$pass, time())
 
 4163                 $affectedRows = $ilDB->manipulateF(
"UPDATE tst_times SET finished = %s, tstamp = %s WHERE times_id = %s",
 
 4164                         array(
'timestamp', 
'integer', 
'integer'),
 
 4165                         array(strftime(
"%Y-%m-%d %H:%M:%S"), time(), $times_id)
 
 4182                         $result = $ilDB->queryF(
"SELECT question_fi FROM tst_solutions WHERE active_fi = %s AND pass = %s GROUP BY question_fi",
 
 4183                                 array(
'integer',
'integer'),
 
 4184                                 array($active_id, 0)
 
 4189                         $result = $ilDB->queryF(
"SELECT question_fi FROM tst_solutions WHERE active_fi = %s AND pass = %s GROUP BY question_fi",
 
 4190                                 array(
'integer',
'integer'),
 
 4191                                 array($active_id, 
$pass)
 
 4194                 $result_array = array();
 
 4197                         array_push($result_array, 
$row[
"question_fi"]);
 
 4199                 return $result_array;
 
 4213                 return ((($currentpass > 0) && ($num == 0)) || $this->
isTestFinished($active_id)) ? 
true : 
false;
 
 4227                 $result_array = array();
 
 4232                         if (count($this->questions) == 0) 
return $result_array;
 
 4237                         $result = $ilDB->queryF(
"SELECT qpl_questions.* FROM qpl_questions, tst_test_rnd_qst WHERE tst_test_rnd_qst.question_fi = qpl_questions.question_id AND tst_test_rnd_qst.active_fi = %s AND tst_test_rnd_qst.pass = %s AND " . $ilDB->in(
'qpl_questions.question_id', $this->questions, 
false, 
'integer'),
 
 4238                                 array(
'integer',
'integer'),
 
 4239                                 array($active_id, 
$pass)
 
 4244                         if (count($this->questions) == 0) 
return $result_array;
 
 4245                         $result = $ilDB->query(
"SELECT qpl_questions.* FROM qpl_questions, tst_test_question WHERE tst_test_question.question_fi = qpl_questions.question_id AND " . $ilDB->in(
'qpl_questions.question_id', $this->questions, 
false, 
'integer'));
 
 4249                         $result_array[
$row[
"question_id"]] = 
$row;
 
 4251                 return $result_array;
 
 4267                         if (!$user_id) $user_id = $ilUser->getId();
 
 4270                                 $result = $ilDB->queryF(
"SELECT active_id FROM tst_active WHERE user_fi = %s AND test_fi = %s AND anonymous_id = %s",
 
 4271                                         array(
'integer',
'integer',
'text'),
 
 4275                         else if (strlen($anonymous_id))
 
 4277                                 $result = $ilDB->queryF(
"SELECT active_id FROM tst_active WHERE user_fi = %s AND test_fi = %s AND anonymous_id = %s",
 
 4278                                         array(
'integer',
'integer',
'text'),
 
 4279                                         array($user_id, $this->test_id, $anonymous_id)
 
 4284                                 if (
$_SESSION[
"AccountId"] == ANONYMOUS_USER_ID)
 
 4288                                 $result = $ilDB->queryF(
"SELECT active_id FROM tst_active WHERE user_fi = %s AND test_fi = %s",
 
 4289                                         array(
'integer',
'integer'),
 
 4290                                         array($user_id, $this->test_id)
 
 4296                                 return $row[
"active_id"];
 
 4318                         $user_id = $ilUser->id;
 
 4324                 $result = $ilDB->queryF(
"SELECT tst_active.active_id FROM tst_active WHERE user_fi = %s AND test_fi = %s",
 
 4325                         array(
'integer', 
'integer'),
 
 4331                         return $row[
"active_id"];
 
 4347                 $keys = array_keys($array);
 
 4350                 foreach ($keys as $key)
 
 4370                 if( is_null(
$pass) )
 
 4375                 include_once 
"./Modules/Test/classes/class.ilTestSequence.php";
 
 4379                 $sequence = array();
 
 4381                 if( $ordered_sequence )
 
 4390                 $arrResults = array();
 
 4393                         SELECT          tst_test_result.question_fi, 
 4394                                                 tst_test_result.points reached, 
 4395                                                 tst_test_result.hint_count requested_hints, 
 4396                                                 tst_test_result.hint_points hint_points, 
 4397                                                 tst_test_result.answered answered 
 4399                         FROM            tst_test_result 
 4401                         LEFT JOIN       tst_solutions 
 4402                         ON                      tst_solutions.active_fi = tst_test_result.active_fi 
 4403                         AND                     tst_solutions.question_fi = tst_test_result.question_fi 
 4405                         WHERE           tst_test_result.active_fi = %s 
 4406                         AND                     tst_test_result.pass = %s 
 4409                 $solutionresult = $ilDB->queryF(
 
 4410                         $query, array(
'integer', 
'integer'), array($active_id, 
$pass)
 
 4413                 while( 
$row = $ilDB->fetchAssoc($solutionresult) )
 
 4415                         $arrResults[ 
$row[
'question_fi'] ] = 
$row;
 
 4418                 $numWorkedThrough = count($arrResults);
 
 4420                 require_once 
"./Modules/TestQuestionPool/classes/class.assQuestion.php";
 
 4422                 $IN_question_ids = $ilDB->in(
'qpl_questions.question_id', $sequence, 
false, 
'integer');
 
 4425                         SELECT          qpl_questions.*, 
 4426                                                 qpl_qst_type.type_tag, 
 4427                                                 qpl_sol_sug.question_fi has_sug_sol 
 4432                         LEFT JOIN       qpl_sol_sug 
 4433                         ON                      qpl_sol_sug.question_fi = qpl_questions.question_id 
 4435                         WHERE           qpl_qst_type.question_type_id = qpl_questions.question_type_fi 
 4436                         AND                     $IN_question_ids 
 4441                 $unordered = array();
 
 4445                 $obligationsAnswered = 
true;
 
 4450                                 $row[
'points'] ? $arrResults[ 
$row[
'question_id'] ][
'reached'] / 
$row[
'points'] : 0
 
 4453                         if( $percentvalue < 0 ) $percentvalue = 0.0;
 
 4458                                 "max" => round(
$row[
'points'], 2),
 
 4459                                 "reached" => round($arrResults[
$row[
'question_id']][
'reached'],2),
 
 4460                                 'requested_hints' => $arrResults[$row[
'question_id']][
'requested_hints'],
 
 4461                                 'hint_points' => $arrResults[$row[
'question_id']][
'hint_points'],
 
 4462                                 "percent" => sprintf(
"%2.2f ", ($percentvalue) * 100) . 
"%",
 
 4464                                 "type" => $row[
"type_tag"],
 
 4465                                 "qid" => $row[
'question_id'],
 
 4466                                 "original_id" => $row[
"original_id"],
 
 4467                                 "workedthrough" => isset($arrResults[$row[
'question_id']]) ? 1 : 0,
 
 4468                                 'answered' => $arrResults[$row[
'question_id']][
'answered']
 
 4471                         if( !$arrResults[ $row[
'question_id'] ][
'answered'] )
 
 4473                                 $obligationsAnswered = 
false;
 
 4476                         $unordered[ $row[
'question_id'] ] = 
$data;
 
 4483                 $pass_requested_hints = 0;
 
 4484                 $pass_hint_points = 0;
 
 4489                 foreach( $sequence as $qid )
 
 4493                         $pass_max += round($unordered[$qid][
'max'], 2);
 
 4494                         $pass_reached += round($unordered[$qid][
'reached'], 2);
 
 4495                         $pass_requested_hints += $unordered[$qid][
'requested_hints'];
 
 4496                         $pass_hint_points += $unordered[$qid][
'hint_points'];
 
 4500                         $unordered[$qid][
'nr'] = $key;
 
 4501                         array_push($found, $unordered[$qid]);
 
 4511                         if( 
$results[
'reached_points'] < 0 )
 
 4516                         if( $pass_reached < 0 ) $pass_reached = 0;
 
 4519                 $found[
'pass'][
'total_max_points'] = $pass_max;
 
 4520                 $found[
'pass'][
'total_reached_points'] = $pass_reached;
 
 4521                 $found[
'pass'][
'total_requested_hints'] = $pass_requested_hints;
 
 4522                 $found[
'pass'][
'total_hint_points'] = $pass_hint_points;
 
 4523                 $found[
'pass'][
'percent'] = ($pass_max > 0) ? $pass_reached / $pass_max : 0;
 
 4524                 $found[
'pass'][
'obligationsAnswered'] = $obligationsAnswered;
 
 4525                 $found[
'pass'][
'num_workedthrough'] = $numWorkedThrough;
 
 4527                 $found[
"test"][
"total_max_points"] = 
$results[
'max_points'];
 
 4528                 $found[
"test"][
"total_reached_points"] = 
$results[
'reached_points'];
 
 4529                 $found[
"test"][
"total_requested_hints"] = 
$results[
'hint_count'];
 
 4530                 $found[
"test"][
"total_hint_points"] = 
$results[
'hint_points'];
 
 4531                 $found[
"test"][
"result_pass"] = 
$results[
'pass'];
 
 4532                 $found[
'test'][
'obligations_answered'] = 
$results[
'obligations_answered'];
 
 4534                 if( (!$total_reached_points) or (!$total_max_points) )
 
 4540                         $percentage = ($total_reached_points / $total_max_points) * 100.0;
 
 4542                         if( $percentage < 0 ) $percentage = 0.0;
 
 4545                 $found[
"test"][
"passed"] = 
$results[
'passed'];
 
 4560                 $result = $ilDB->queryF(
"SELECT COUNT(active_id) total FROM tst_active WHERE test_fi = %s",
 
 4565                 return $row[
"total"];
 
 4578                 $result = $ilDB->queryF(
"SELECT tst_times.* FROM tst_active, tst_times WHERE tst_active.test_fi = %s AND tst_active.active_id = tst_times.active_fi AND tst_active.user_fi = %s",
 
 4579                         array(
'integer',
'integer'),
 
 4585                         preg_match(
"/(\d{4})-(\d{2})-(\d{2}) (\d{2}):(\d{2}):(\d{2})/", 
$row[
"started"], $matches);
 
 4586                         $epoch_1 = mktime($matches[4], $matches[5], $matches[6], $matches[2], $matches[3], $matches[1]);
 
 4587                         preg_match(
"/(\d{4})-(\d{2})-(\d{2}) (\d{2}):(\d{2}):(\d{2})/", 
$row[
"finished"], $matches);
 
 4588                         $epoch_2 = mktime($matches[4], $matches[5], $matches[6], $matches[2], $matches[3], $matches[1]);
 
 4589                         $time += ($epoch_2 - $epoch_1);
 
 4616                 $result = $ilDB->queryF(
"SELECT tst_times.* FROM tst_active, tst_times WHERE tst_active.test_fi = %s AND tst_active.active_id = tst_times.active_fi ORDER BY tst_times.active_fi, tst_times.started",
 
 4624                         if (!array_key_exists(
$row[
"active_fi"], $times))
 
 4626                                 $times[
$row[
"active_fi"]] = 0;
 
 4628                         preg_match(
"/(\d{4})-(\d{2})-(\d{2}) (\d{2}):(\d{2}):(\d{2})/", 
$row[
"started"], $matches);
 
 4629                         $epoch_1 = mktime($matches[4], $matches[5], $matches[6], $matches[2], $matches[3], $matches[1]);
 
 4630                         preg_match(
"/(\d{4})-(\d{2})-(\d{2}) (\d{2}):(\d{2}):(\d{2})/", 
$row[
"finished"], $matches);
 
 4631                         $epoch_2 = mktime($matches[4], $matches[5], $matches[6], $matches[2], $matches[3], $matches[1]);
 
 4632                         $times[
$row[
"active_fi"]] += ($epoch_2 - $epoch_1);
 
 4647                 $result = $ilDB->queryF(
"SELECT tst_times.* FROM tst_active, tst_times WHERE tst_active.test_fi = %s AND tst_active.active_id = tst_times.active_fi AND tst_active.active_id = %s ORDER BY tst_times.active_fi, tst_times.started",
 
 4648                         array(
'integer',
'integer'),
 
 4654                         preg_match(
"/(\d{4})-(\d{2})-(\d{2}) (\d{2}):(\d{2}):(\d{2})/", 
$row[
"started"], $matches);
 
 4655                         $epoch_1 = mktime($matches[4], $matches[5], $matches[6], $matches[2], $matches[3], $matches[1]);
 
 4656                         preg_match(
"/(\d{4})-(\d{2})-(\d{2}) (\d{2}):(\d{2}):(\d{2})/", 
$row[
"finished"], $matches);
 
 4657                         $epoch_2 = mktime($matches[4], $matches[5], $matches[6], $matches[2], $matches[3], $matches[1]);
 
 4658                         $time += ($epoch_2 - $epoch_1);
 
 4673                 $result = $ilDB->queryF(
"SELECT * FROM tst_times WHERE active_fi = %s AND pass = %s ORDER BY started",
 
 4674                         array(
'integer',
'integer'),
 
 4675                         array($active_id, 
$pass)
 
 4680                         preg_match(
"/(\d{4})-(\d{2})-(\d{2}) (\d{2}):(\d{2}):(\d{2})/", 
$row[
"started"], $matches);
 
 4681                         $epoch_1 = mktime($matches[4], $matches[5], $matches[6], $matches[2], $matches[3], $matches[1]);
 
 4682                         preg_match(
"/(\d{4})-(\d{2})-(\d{2}) (\d{2}):(\d{2}):(\d{2})/", 
$row[
"finished"], $matches);
 
 4683                         $epoch_2 = mktime($matches[4], $matches[5], $matches[6], $matches[2], $matches[3], $matches[1]);
 
 4684                         $time += ($epoch_2 - $epoch_1);
 
 4713                 $result = $ilDB->queryF(
"SELECT tst_times.* FROM tst_active, tst_times WHERE tst_active.test_fi = %s AND tst_active.active_id = tst_times.active_fi AND tst_active.active_id = %s ORDER BY tst_times.started",
 
 4714                         array(
'integer',
'integer'),
 
 4721                         preg_match(
"/(\d{4})-(\d{2})-(\d{2}) (\d{2}):(\d{2}):(\d{2})/", 
$row[
"started"], $matches);
 
 4722                         $epoch_1 = mktime($matches[4], $matches[5], $matches[6], $matches[2], $matches[3], $matches[1]);
 
 4723                         if ($firstvisit == 0 || $epoch_1 < $firstvisit) $firstvisit = $epoch_1;
 
 4724                         preg_match(
"/(\d{4})-(\d{2})-(\d{2}) (\d{2}):(\d{2}):(\d{2})/", 
$row[
"finished"], $matches);
 
 4725                         $epoch_2 = mktime($matches[4], $matches[5], $matches[6], $matches[2], $matches[3], $matches[1]);
 
 4726                         if ($epoch_2 > $lastvisit) $lastvisit = $epoch_2;
 
 4728                 return array(
"firstvisit" => $firstvisit, 
"lastvisit" => $lastvisit);
 
 4743                 $result = $ilDB->queryF(
"SELECT tst_times.* FROM tst_active, tst_times WHERE tst_active.active_id = %s AND tst_active.active_id = tst_times.active_fi",
 
 4752                         preg_match(
"/(\d{4})-(\d{2})-(\d{2}) (\d{2}):(\d{2}):(\d{2})/", 
$row->started, $matches);
 
 4753                         $epoch_1 = mktime($matches[4], $matches[5], $matches[6], $matches[2], $matches[3], $matches[1]);
 
 4754                         if (!$first_visit) {
 
 4755                                 $first_visit = $epoch_1;
 
 4757                         if ($epoch_1 < $first_visit) {
 
 4758                                 $first_visit = $epoch_1;
 
 4760                         preg_match(
"/(\d{4})-(\d{2})-(\d{2}) (\d{2}):(\d{2}):(\d{2})/", 
$row->finished, $matches);
 
 4761                         $epoch_2 = mktime($matches[4], $matches[5], $matches[6], $matches[2], $matches[3], $matches[1]);
 
 4763                                 $last_visit = $epoch_2;
 
 4765                         if ($epoch_2 > $last_visit) {
 
 4766                                 $last_visit = $epoch_2;
 
 4768                         $times[
$row->active_fi] += ($epoch_2 - $epoch_1);
 
 4771                 foreach ($times as $key => $value) {
 
 4772                         $max_time += $value;
 
 4774                 if ((!$test_result[
"test"][
"total_reached_points"]) or (!$test_result[
"test"][
"total_max_points"]))
 
 4780                         $percentage = ($test_result[
"test"][
"total_reached_points"] / $test_result[
"test"][
"total_max_points"]) * 100.0;
 
 4781                         if ($percentage < 0) $percentage = 0.0;
 
 4783                 $mark_obj = $this->mark_schema->getMatchingMark($percentage);
 
 4784                 $first_date = getdate($first_visit);
 
 4785                 $last_date = getdate($last_visit);
 
 4786                 $qworkedthrough = 0;
 
 4787                 foreach ($test_result as $key => $value)
 
 4789                         if (preg_match(
"/\d+/", $key))
 
 4791                                 $qworkedthrough += $value[
"workedthrough"];
 
 4794                 if (!$qworkedthrough)
 
 4800                         $atimeofwork = $max_time / $qworkedthrough;
 
 4803                 $obligationsAnswered = $test_result[
"test"][
"obligations_answered"];
 
 4810                         $result_mark = $mark_obj->getShortName();
 
 4812                         if( $mark_obj->getPassed() && $obligationsAnswered )
 
 4821                 $percent_worked_through = 0;
 
 4822                 if (count($this->questions))
 
 4824                         $percent_worked_through = $qworkedthrough / count($this->questions);
 
 4826                 $result_array = array(
 
 4827                         "qworkedthrough" => $qworkedthrough,
 
 4828                         "qmax" => count($this->questions),
 
 4829                         "pworkedthrough" => $percent_worked_through,
 
 4830                         "timeofwork" => $max_time,
 
 4831                         "atimeofwork" => $atimeofwork,
 
 4832                         "firstvisit" => $first_date,
 
 4833                         "lastvisit" => $last_date,
 
 4834                         "resultspoints" => $test_result[
"test"][
"total_reached_points"],
 
 4835                         "maxpoints" => $test_result[
"test"][
"total_max_points"],
 
 4836                         "resultsmarks" => $result_mark,
 
 4837                         "passed" => $passed,
 
 4838                         "distancemedian" => 
"0" 
 4840                 foreach ($test_result as $key => $value)
 
 4842                         if (preg_match(
"/\d+/", $key))
 
 4844                                 $result_array[$key] = $value;
 
 4847                 return $result_array;
 
 4859                 $totalpoints_array = array();
 
 4861                 foreach ($all_users as $active_id => $user_name)
 
 4864                         $reached = $test_result[
"test"][
"total_reached_points"];
 
 4865                         $total = $test_result[
"test"][
"total_max_points"];
 
 4867                         $mark = $this->mark_schema->getMatchingMark($percentage*100.0);
 
 4869                         $obligationsAnswered = $test_result[
"test"][
"obligations_answered"];
 
 4873                                 if( $mark->getPassed() && $obligationsAnswered )
 
 4875                                         array_push($totalpoints_array, $test_result[
"test"][
"total_reached_points"]);
 
 4879                 return $totalpoints_array;
 
 4891                 $result = $ilDB->queryF(
"SELECT tst_active.active_id, usr_data.usr_id, usr_data.firstname, usr_data.lastname, usr_data.title, usr_data.login FROM tst_active LEFT JOIN usr_data ON tst_active.user_fi = usr_data.usr_id WHERE tst_active.test_fi = %s ORDER BY usr_data.lastname ASC",
 
 4895                 $persons_array = array();
 
 4898                         $name = $this->lng->txt(
"unknown");
 
 4899                         $fullname = $this->lng->txt(
"unknown");
 
 4903                                 if (strlen(
$row[
"firstname"].
$row[
"lastname"].
$row[
"title"]) == 0)
 
 4905                                         $name = $this->lng->txt(
"deleted_user");
 
 4906                                         $fullname = $this->lng->txt(
"deleted_user");
 
 4907                                         $login = $this->lng->txt(
"unknown");
 
 4911                                         $login = $row[
"login"];
 
 4912                                         if ($row[
"user_fi"] == ANONYMOUS_USER_ID)
 
 4914                                                 $name = $this->lng->txt(
"unknown");
 
 4915                                                 $fullname = $this->lng->txt(
"unknown");
 
 4919                                                 $name = trim($row[
"lastname"] . 
", " . $row[
"firstname"] . 
" " .  $row[
"title"]);
 
 4920                                                 $fullname = trim($row[
"title"] . 
" " . $row[
"firstname"] . 
" " .  $row[
"lastname"]);
 
 4924                         $persons_array[
$row[
"active_id"]] = array(
 
 4926                                 "fullname" => $fullname,
 
 4930                 return $persons_array;
 
 4942                 $result = $ilDB->queryF(
"SELECT tst_active.active_id, usr_data.firstname, usr_data.lastname, usr_data.title FROM tst_active LEFT JOIN usr_data ON tst_active.user_fi = usr_data.usr_id WHERE tst_active.test_fi = %s ORDER BY usr_data.lastname " . strtoupper($name_sort_order),
 
 4946                 $persons_array = array();
 
 4951                                 $persons_array[
$row[
"active_id"]] = $this->lng->txt(
"unknown");
 
 4955                                 if (strlen(
$row[
"firstname"].
$row[
"lastname"].
$row[
"title"]) == 0)
 
 4957                                         $persons_array[$row[
"active_id"]] = $this->lng->txt(
"deleted_user");
 
 4961                                         if ($row[
"user_fi"] == ANONYMOUS_USER_ID)
 
 4963                                                 $persons_array[$row[
"active_id"]] = $row[
"lastname"];
 
 4967                                                 $persons_array[$row[
"active_id"]] = trim($row[
"lastname"] . 
", " . $row[
"firstname"] . 
" " .  $row[
"title"]);
 
 4972                 return $persons_array;
 
 4984                 $result = $ilDB->queryF(
"SELECT tst_active.active_id, usr_data.login, usr_data.firstname, usr_data.lastname, usr_data.title FROM tst_active LEFT JOIN usr_data ON tst_active.user_fi = usr_data.usr_id WHERE tst_active.test_fi = %s ORDER BY usr_data.lastname " . strtoupper($name_sort_order),
 
 4988                 $persons_array = array();
 
 4993                                 $persons_array[
$row[
"active_id"]] = array(
"name" => $this->lng->txt(
"unknown"));
 
 4997                                 if (strlen(
$row[
"firstname"].
$row[
"lastname"].
$row[
"title"]) == 0)
 
 4999                                         $persons_array[$row[
"active_id"]] = array(
"name" => $this->lng->txt(
"deleted_user"));
 
 5003                                         if ($row[
"user_fi"] == ANONYMOUS_USER_ID)
 
 5005                                                 $persons_array[$row[
"active_id"]] = array(
"name" => $row[
"lastname"]);
 
 5009                                                 $persons_array[$row[
"active_id"]] = array(
"name" => trim($row[
"lastname"] . 
", " . $row[
"firstname"] . 
" " .  $row[
"title"]), 
"login" => $row[
"login"]);
 
 5014                 return $persons_array;
 
 5027                 $result = $ilDB->queryF(
"SELECT COUNT(active_id) total FROM tst_active WHERE test_fi = %s AND submitted = %s",
 
 5028                         array(
'integer', 
'integer'),
 
 5032                 return $row[
"total"];
 
 5047                         $result = $ilDB->queryF(
"SELECT tst_test_rnd_qst.sequence, tst_test_rnd_qst.question_fi, " .
 
 5048                                 "tst_test_rnd_qst.pass, qpl_questions.points " .
 
 5049                                 "FROM tst_test_rnd_qst, qpl_questions " .
 
 5050                                 "WHERE tst_test_rnd_qst.question_fi = qpl_questions.question_id " .
 
 5051                                 "AND tst_test_rnd_qst.active_fi = %s ORDER BY tst_test_rnd_qst.sequence",
 
 5058                         $result = $ilDB->queryF(
"SELECT tst_test_question.sequence, tst_test_question.question_fi, " .
 
 5059                                 "qpl_questions.points " .
 
 5060                                 "FROM tst_test_question, tst_active, qpl_questions " .
 
 5061                                 "WHERE tst_test_question.question_fi = qpl_questions.question_id " .
 
 5062                                 "AND tst_active.active_id = %s AND tst_active.test_fi = tst_test_question.test_fi",
 
 5072                                 array_push($qtest, 
$row);
 
 5090                         $result = $ilDB->queryF(
"SELECT tst_test_rnd_qst.sequence, tst_test_rnd_qst.question_fi, " .
 
 5091                                 "qpl_questions.points " .
 
 5092                                 "FROM tst_test_rnd_qst, qpl_questions " .
 
 5093                                 "WHERE tst_test_rnd_qst.question_fi = qpl_questions.question_id " .
 
 5094                                 "AND tst_test_rnd_qst.active_fi = %s AND tst_test_rnd_qst.pass = %s " .
 
 5095                                 "ORDER BY tst_test_rnd_qst.sequence",
 
 5096                                 array(
'integer', 
'integer'),
 
 5097                                 array($active_id, 
$pass)
 
 5102                         $result = $ilDB->queryF(
"SELECT tst_test_question.sequence, tst_test_question.question_fi, " .
 
 5103                                 "qpl_questions.points " .
 
 5104                                 "FROM tst_test_question, tst_active, qpl_questions " .
 
 5105                                 "WHERE tst_test_question.question_fi = qpl_questions.question_id " .
 
 5106                                 "AND tst_active.active_id = %s AND tst_active.test_fi = tst_test_question.test_fi",
 
 5116                                 array_push($qpass, 
$row);
 
 5126                 include_once 
"./Modules/Test/classes/class.ilTestEvaluationPassData.php";
 
 5127                 include_once 
"./Modules/Test/classes/class.ilTestEvaluationUserData.php";
 
 5128                 include_once 
"./Modules/Test/classes/class.ilTestEvaluationData.php";
 
 5133                         SELECT          tst_test_result.*, 
 5134                                                 qpl_questions.original_id, 
 5135                                                 qpl_questions.title questiontitle, 
 5136                                                 qpl_questions.points maxpoints 
 5138                         FROM            tst_test_result, qpl_questions, tst_active 
 5140                         WHERE           tst_active.active_id = tst_test_result.active_fi 
 5141                         AND                     qpl_questions.question_id = tst_test_result.question_fi 
 5142                         AND                     tst_active.test_fi = %s 
 5144                         ORDER BY        tst_active.active_id, tst_test_result.pass, tst_test_result.tstamp 
 5157                         $participantObject = 
$data->getParticipant(
$row[
"active_fi"]);
 
 5164                         $passObject = $participantObject->getPass(
$row[
"pass"]);
 
 5171                         $passObject->addAnsweredQuestion(
 
 5176                 foreach( array_keys(
$data->getParticipants()) as $active_id )
 
 5180                                 for( $testpass = 0; $testpass <= 
$data->getParticipant($active_id)->getLastPass(); $testpass++ )
 
 5183                                         $result = $ilDB->queryF(
"SELECT tst_test_rnd_qst.sequence, tst_test_rnd_qst.question_fi, qpl_questions.original_id, " .
 
 5184                                                 "tst_test_rnd_qst.pass, qpl_questions.points, qpl_questions.title " .
 
 5185                                                 "FROM tst_test_rnd_qst, qpl_questions " .
 
 5186                                                 "WHERE tst_test_rnd_qst.question_fi = qpl_questions.question_id " .
 
 5187                                                 "AND tst_test_rnd_qst.pass = %s " .
 
 5188                                                 "AND tst_test_rnd_qst.active_fi = %s ORDER BY tst_test_rnd_qst.sequence",
 
 5189                                                 array(
'integer',
'integer'),
 
 5190                                                 array($testpass, $active_id)
 
 5196                                                         $tpass = array_key_exists(
"pass", 
$row) ? 
$row[
"pass"] : 0;
 
 5197                                                         $data->getParticipant($active_id)->addQuestion(
$row[
"original_id"], 
$row[
"question_fi"], 
$row[
"points"], 
$row[
"sequence"], $tpass);
 
 5198                                                         $data->addQuestionTitle(
$row[
"question_fi"], 
$row[
"title"]);
 
 5205                                 $result = $ilDB->queryF(
"SELECT tst_test_question.sequence, tst_test_question.question_fi, " .
 
 5206                                         "qpl_questions.points, qpl_questions.title, qpl_questions.original_id " .
 
 5207                                         "FROM tst_test_question, tst_active, qpl_questions " .
 
 5208                                         "WHERE tst_test_question.question_fi = qpl_questions.question_id " .
 
 5209                                         "AND tst_active.active_id = %s AND tst_active.test_fi = tst_test_question.test_fi ORDER BY tst_test_question.sequence",
 
 5215                                         $questionsbysequence = array();
 
 5219                                                 $questionsbysequence[
$row[
"sequence"]] = 
$row;
 
 5222                                         $seqresult = $ilDB->queryF(
"SELECT * FROM tst_sequence WHERE active_fi = %s",
 
 5227                                         while ($seqrow = $ilDB->fetchAssoc($seqresult))
 
 5229                                                 $questionsequence = unserialize($seqrow[
"sequence"]);
 
 5230                                                 foreach ($questionsequence as $sidx => $seq)
 
 5232                                                         $data->getParticipant($active_id)->addQuestion($questionsbysequence[$seq][
"original_id"], $questionsbysequence[$seq][
"question_fi"], $questionsbysequence[$seq][
"points"], $sidx + 1, $seqrow[
"pass"]);
 
 5233                                                         $data->addQuestionTitle($questionsbysequence[$seq][
"question_fi"], $questionsbysequence[$seq][
"title"]);
 
 5240                 if ($this->ects_output)
 
 5245                 foreach( array_keys(
$data->getParticipants()) as $active_id )
 
 5247                         $tstUserData = 
$data->getParticipant($active_id);
 
 5249                         $percentage = $tstUserData->getReachedPointsInPercent();
 
 5251                         $obligationsAnswered = $tstUserData->areObligationsAnswered();
 
 5253                         $mark = $this->mark_schema->getMatchingMark($percentage);
 
 5255                         if (is_object($mark))
 
 5257                                 $tstUserData->setMark($mark->getShortName());
 
 5258                                 $tstUserData->setMarkOfficial($mark->getOfficialName());
 
 5260                                 $tstUserData->setPassed(
 
 5261                                         $mark->getPassed() && $tstUserData->areObligationsAnswered()
 
 5265                         if ($this->ects_output)
 
 5268                                                 $passed_array, $tstUserData->getReached(), $tstUserData->getMaxPoints()
 
 5271                                 $tstUserData->setECTSMark($ects_mark);
 
 5276                         $tstUserData->setFirstVisit($visitingTime[
"firstvisit"]);
 
 5277                         $tstUserData->setLastVisit($visitingTime[
"lastvisit"]);
 
 5289                         $result = $ilDB->queryF(
"SELECT tst_test_rnd_qst.pass, COUNT(tst_test_rnd_qst.question_fi) qcount, " .
 
 5290                                 "SUM(qpl_questions.points) qsum FROM tst_test_rnd_qst, qpl_questions " .
 
 5291                                 "WHERE tst_test_rnd_qst.question_fi = qpl_questions.question_id AND " .
 
 5292                                 "tst_test_rnd_qst.active_fi = %s and pass = %s GROUP BY tst_test_rnd_qst.active_fi, " .
 
 5293                                 "tst_test_rnd_qst.pass",
 
 5294                                 array(
'integer', 
'integer'),
 
 5295                                 array($active_id, 
$pass)
 
 5300                         $result = $ilDB->queryF(
"SELECT COUNT(tst_test_question.question_fi) qcount, " .
 
 5301                                 "SUM(qpl_questions.points) qsum FROM tst_test_question, qpl_questions, tst_active " .
 
 5302                                 "WHERE tst_test_question.question_fi = qpl_questions.question_id AND tst_test_question.test_fi = tst_active.test_fi AND " .
 
 5303                                 "tst_active.active_id = %s GROUP BY tst_test_question.test_fi",
 
 5311                         return array(
"count" => 
$row[
"qcount"], 
"points" => 
$row[
"qsum"]);
 
 5315                         return array(
"count" => 0, 
"points" => 0);
 
 5321                 include_once 
"./Modules/Test/classes/class.ilTestEvaluationData.php";
 
 5322                 include_once 
"./Modules/Test/classes/class.ilTestEvaluationPassData.php";
 
 5323                 include_once 
"./Modules/Test/classes/class.ilTestEvaluationUserData.php";
 
 5325                 if ($withStatistics)
 
 5327                         $data->calculateStatistics();
 
 5329                 $data->setFilter($filterby, $filtertext);
 
 5354                 $result = $ilDB->queryF(
"SELECT usr_data.usr_id, usr_data.firstname, usr_data.lastname, usr_data.title, usr_data.login, " .
 
 5355                         "tst_test_result.*, qpl_questions.original_id, qpl_questions.title questiontitle, " .
 
 5356                         "qpl_questions.points maxpoints " .
 
 5357                         "FROM tst_test_result, qpl_questions, tst_active " .
 
 5358                         "LEFT JOIN usr_data ON tst_active.user_fi = usr_data.usr_id " .
 
 5359                         "WHERE tst_active.active_id = tst_test_result.active_fi " .
 
 5360                         "AND qpl_questions.question_id = tst_test_result.question_fi " .
 
 5361                         "AND tst_active.test_fi = %s " .
 
 5362                         "ORDER BY tst_active.active_id, tst_test_result.pass, tst_test_result.tstamp",
 
 5366                 $overview = array();
 
 5369                         if (!array_key_exists(
$row[
"active_fi"], $overview))
 
 5371                                 $overview[
$row[
"active_fi"]] = array();
 
 5372                                 $overview[$row[
"active_fi"]][
"firstname"] = $row[
"firstname"];
 
 5373                                 $overview[$row[
"active_fi"]][
"lastname"] = $row[
"lastname"];
 
 5374                                 $overview[$row[
"active_fi"]][
"title"] = $row[
"title"];
 
 5375                                 $overview[$row[
"active_fi"]][
"login"] = $row[
"login"];
 
 5376                                 $overview[$row[
"active_fi"]][
"usr_id"] = $row[
"usr_id"];
 
 5377                                 $overview[$row[
"active_fi"]][
"started"] = $row[
"started"];
 
 5378                                 $overview[$row[
"active_fi"]][
"finished"] = $row[
"finished"];
 
 5380                         if (!array_key_exists(
$row[
"pass"], $overview[
$row[
"active_fi"]]))
 
 5382                                 $overview[$row[
"active_fi"]][$row[
"pass"]] = array();
 
 5383                                 $overview[$row[
"active_fi"]][$row[
"pass"]][
"reached"] = 0;
 
 5384                                 $overview[$row[
"active_fi"]][$row[
"pass"]][
"maxpoints"] = $row[
"maxpoints"];
 
 5386                         array_push($overview[$row[
"active_fi"]][$row[
"pass"]], $row);
 
 5387                         $overview[$row[
"active_fi"]][$row[
"pass"]][
"reached"] += $row[
"points"];
 
 5403                 $result = $ilDB->queryF(
"SELECT usr_data.usr_id, usr_data.firstname, usr_data.lastname, usr_data.title, usr_data.login, " .
 
 5404                         "tst_test_result.*, qpl_questions.original_id, qpl_questions.title questiontitle, " .
 
 5405                         "qpl_questions.points maxpoints " .
 
 5406                         "FROM tst_test_result, qpl_questions, tst_active " .
 
 5407                         "LEFT JOIN usr_data ON tst_active.user_fi = usr_data.usr_id " .
 
 5408                         "WHERE tst_active.active_id = tst_test_result.active_fi " .
 
 5409                         "AND qpl_questions.question_id = tst_test_result.question_fi " .
 
 5410                         "AND tst_active.test_fi = %s AND tst_active.active_id = %s" .
 
 5411                         "ORDER BY tst_active.active_id, tst_test_result.pass, tst_test_result.tstamp",
 
 5412                         array(
'integer', 
'integer'),
 
 5415                 $overview = array();
 
 5418                         if (!array_key_exists(
$row[
"active_fi"], $overview))
 
 5420                                 $overview[
$row[
"active_fi"]] = array();
 
 5421                                 $overview[$row[
"active_fi"]][
"firstname"] = $row[
"firstname"];
 
 5422                                 $overview[$row[
"active_fi"]][
"lastname"] = $row[
"lastname"];
 
 5423                                 $overview[$row[
"active_fi"]][
"title"] = $row[
"title"];
 
 5424                                 $overview[$row[
"active_fi"]][
"login"] = $row[
"login"];
 
 5425                                 $overview[$row[
"active_fi"]][
"usr_id"] = $row[
"usr_id"];
 
 5426                                 $overview[$row[
"active_fi"]][
"started"] = $row[
"started"];
 
 5427                                 $overview[$row[
"active_fi"]][
"finished"] = $row[
"finished"];
 
 5429                         if (!array_key_exists(
$row[
"pass"], $overview[
$row[
"active_fi"]]))
 
 5431                                 $overview[$row[
"active_fi"]][$row[
"pass"]] = array();
 
 5432                                 $overview[$row[
"active_fi"]][$row[
"pass"]][
"reached"] = 0;
 
 5433                                 $overview[$row[
"active_fi"]][$row[
"pass"]][
"maxpoints"] = $row[
"maxpoints"];
 
 5435                         array_push($overview[$row[
"active_fi"]][$row[
"pass"]], $row);
 
 5436                         $overview[$row[
"active_fi"]][$row[
"pass"]][
"reached"] += $row[
"points"];
 
 5455                 if (strlen($firstname.$lastname.$title) == 0)
 
 5457                         $name = $this->lng->txt(
"deleted_user");
 
 5461                         if ($user_id == ANONYMOUS_USER_ID)
 
 5467                                 $name = trim($lastname . 
", " . $firstname . 
" " .  
$title);
 
 5471                                 $name = $this->lng->txt(
"anonymous");
 
 5493                 if (strlen($firstname.$lastname.$title) == 0)
 
 5495                         $name = $lng->txt(
"deleted_user");
 
 5499                         if ($user_id == ANONYMOUS_USER_ID)
 
 5505                                 $name = trim($lastname . 
", " . $firstname . 
" " .  
$title);
 
 5509                                 $name = $lng->txt(
"anonymous");
 
 5525                 $result = $ilDB->queryF(
"SELECT tst_times.* FROM tst_active, tst_times WHERE tst_active.test_fi = %s AND tst_active.active_id = tst_times.active_fi",
 
 5532                         preg_match(
"/(\d{4})-(\d{2})-(\d{2}) (\d{2}):(\d{2}):(\d{2})/", 
$row->started, $matches);
 
 5533                         $epoch_1 = mktime($matches[4], $matches[5], $matches[6], $matches[2], $matches[3], $matches[1]);
 
 5534                         preg_match(
"/(\d{4})-(\d{2})-(\d{2}) (\d{2}):(\d{2}):(\d{2})/", 
$row->finished, $matches);
 
 5535                         $epoch_2 = mktime($matches[4], $matches[5], $matches[6], $matches[2], $matches[3], $matches[1]);
 
 5536                         $times[
$row->active_fi] += ($epoch_2 - $epoch_1);
 
 5540                 foreach ($times as $key => $value)
 
 5542                         $max_time += $value;
 
 5547                         $average_time = round($max_time / $counter);
 
 5553                 return $average_time;
 
 5562         function &
getAvailableQuestionpools($use_object_id = 
false, $equal_points = 
false, $could_be_offline = 
false, $show_path = FALSE, $with_questioncount = FALSE, $permission = 
"read")
 
 5564                 include_once 
"./Modules/TestQuestionPool/classes/class.ilObjQuestionPool.php";
 
 5576                 $time_in_seconds = 0;
 
 5577                 foreach ($this->questions as $question_id)
 
 5580                         $est_time = $question->getEstimatedWorkingTime();
 
 5581                         $time_in_seconds += $est_time[
"h"] * 3600 + $est_time[
"m"] * 60 + $est_time[
"s"];
 
 5583                 $hours = (int)($time_in_seconds / 3600) ;
 
 5584                 $time_in_seconds = $time_in_seconds - ($hours * 3600);
 
 5585                 $minutes = (int)($time_in_seconds / 60);
 
 5586                 $time_in_seconds = $time_in_seconds - ($minutes * 60);
 
 5587                 $result = array(
"hh" => $hours, 
"mm" => $minutes, 
"ss" => $time_in_seconds);
 
 5603                 foreach ($qpls as $arr) array_push($qplids, $arr[
'qpl']);
 
 5604                 $result = $ilDB->queryF(
'SELECT * FROM tst_rnd_cpy WHERE tst_fi = %s AND ' . $ilDB->in(
'qpl_fi', $qplids, 
false, 
'integer'),
 
 5611                         while (
$row = $ilDB->fetchAssoc(
$result)) array_push($ids, 
$row[
'qst_fi']);
 
 5612                         $nr = ($nr > count($ids)) ? count($ids) : $nr;
 
 5613                         if ($nr == 0) 
return array();
 
 5614                         $rand_keys = array_rand($ids, $nr);
 
 5615                         $selection = array();
 
 5616                         if (is_array($rand_keys))
 
 5618                                 foreach ($rand_keys as $key)
 
 5620                                         $selection[$ids[$key]] = $ids[$key];
 
 5625                                 $selection[$ids[$rand_keys]] = $ids[$rand_keys];
 
 5655                 $result = $ilDB->queryF(
"SELECT qpl_questions.original_id FROM qpl_questions, tst_test_question WHERE qpl_questions.question_id = tst_test_question.question_fi AND qpl_questions.tstamp > 0 AND tst_test_question.test_fi = %s",
 
 5659                 $original_ids = array();
 
 5660                 $paramtypes = array();
 
 5661                 $paramvalues = array();
 
 5664                         array_push($original_ids, 
$row[
'original_id']);
 
 5669                 if (($questionpool == 0) && (!is_array($qpls)))
 
 5671                         include_once 
"./Modules/TestQuestionPool/classes/class.ilObjQuestionPool.php";
 
 5673                         if (count($available_pools))
 
 5675                                 $available = 
" AND " . $ilDB->in(
'obj_fi', $available_pools, 
false, 
'integer');
 
 5683                 $constraint_qpls = 
"";
 
 5684                 $result_array = array();
 
 5685                 if ($questionpool == 0)
 
 5687                         if (is_array($qpls))
 
 5689                                 if (count($qpls) > 0)
 
 5691                                         $constraint_qpls = 
" AND " . $ilDB->in(
'obj_fi', $qpls, 
false, 
'integer');
 
 5696                 $original_clause = 
"";
 
 5697                 if (count($original_ids))
 
 5699                         $original_clause = 
" AND " . $ilDB->in(
'question_id', $original_ids, 
true, 
'integer');
 
 5702                 if ($questionpool == 0)
 
 5704                         $result = $ilDB->queryF(
"SELECT question_id FROM qpl_questions WHERE original_id IS NULL $available $constraint_qpls AND owner > %s AND complete = %s $original_clause",
 
 5705                                 array(
'integer', 
'text'),
 
 5711                         $result = $ilDB->queryF(
"SELECT question_id FROM qpl_questions WHERE original_id IS NULL AND obj_fi = %s AND owner > %s AND complete = %s $original_clause",
 
 5712                                 array(
'integer',
'integer', 
'text'),
 
 5713                                 array($questionpool, 0, 
"1")
 
 5716                 $found_ids = array();
 
 5719                         array_push($found_ids, 
$row[
'question_id']);
 
 5721                 $nr_of_questions = ($nr_of_questions > count($found_ids)) ? count($found_ids) : $nr_of_questions;
 
 5722                 if ($nr_of_questions == 0) 
return array();
 
 5723                 $rand_keys = array_rand($found_ids, $nr_of_questions);
 
 5725                 if (is_array($rand_keys))
 
 5727                         foreach ($rand_keys as $key)
 
 5729                                 $result[$found_ids[$key]] = $found_ids[$key];
 
 5734                         $result[$found_ids[$rand_keys]] = $found_ids[$rand_keys];
 
 5747                 return CLIENT_WEB_DIR . 
"/assessment/" . $this->
getId() . 
"/images/";
 
 5758                 include_once 
"./Services/Utilities/classes/class.ilUtil.php";
 
 5773                 if ((!$question_type) and ($question_id > 0))
 
 5778                 if (!strlen($question_type)) 
return null;
 
 5780                 include_once 
"./Modules/TestQuestionPool/classes/class.assQuestion.php";
 
 5783                 $question_type_gui = $question_type . 
"GUI";
 
 5784                 $question = 
new $question_type_gui();
 
 5788                 if ($question_id > 0)
 
 5790                         $question->object->loadFromDb($question_id);
 
 5805                 if (strcmp($question_id, 
"") != 0)
 
 5807                         include_once 
"./Modules/TestQuestionPool/classes/class.assQuestion.php";
 
 5822                 $this->questions = array_values($this->questions);
 
 5823                 $array_pos = array_search($target_index, $this->questions);
 
 5824                 if ($insert_mode == 0)
 
 5826                         $part1 = array_slice($this->questions, 0, $array_pos);
 
 5827                         $part2 = array_slice($this->questions, $array_pos);
 
 5829                 else if ($insert_mode == 1)
 
 5831                         $part1 = array_slice($this->questions, 0, $array_pos + 1);
 
 5832                         $part2 = array_slice($this->questions, $array_pos + 1);
 
 5834                 foreach ($move_questions as $question_id)
 
 5836                         if (!(array_search($question_id, $part1) === FALSE))
 
 5838                                 unset($part1[array_search($question_id, $part1)]);
 
 5840                         if (!(array_search($question_id, $part2) === FALSE))
 
 5842                                 unset($part2[array_search($question_id, $part2)]);
 
 5845                 $part1 = array_values($part1);
 
 5846                 $part2 = array_values($part2);
 
 5847                 $new_array = array_values(array_merge($part1, $move_questions, $part2));
 
 5848                 $this->questions = array();
 
 5850                 foreach ($new_array as $question_id)
 
 5852                         $this->questions[$counter] = $question_id;
 
 5870                         if (preg_match(
"/(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})/", $this->
getStartingTime(), $matches))
 
 5872                                 $epoch_time = mktime($matches[4], $matches[5], $matches[6], $matches[2], $matches[3], $matches[1]);
 
 5874                                 if ($now < $epoch_time)
 
 5895                         if (preg_match(
"/(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})/", $this->
getEndingTime(), $matches))
 
 5897                                 $epoch_time = mktime($matches[4], $matches[5], $matches[6], $matches[2], $matches[3], $matches[1]);
 
 5899                                 if ($now > $epoch_time)
 
 5919                 include_once 
"./Modules/TestQuestionPool/classes/class.ilObjQuestionPool.php";
 
 5922                 if (count($available_pools))
 
 5924                         $available = 
" AND " . $ilDB->in(
'qpl_questions.obj_fi', $available_pools, 
false, 
'integer');
 
 5932                         $available .= 
" AND qpl_questions.complete = " . $ilDB->quote(
"1", 
'text');
 
 5936                 if (is_array($arrFilter))
 
 5938                         if (array_key_exists(
'title', $arrFilter) && strlen($arrFilter[
'title']))
 
 5940                                 $where .= 
" AND " . $ilDB->like(
'qpl_questions.title', 
'text', 
"%%" . $arrFilter[
'title'] . 
"%%");
 
 5942                         if (array_key_exists(
'description', $arrFilter) && strlen($arrFilter[
'description']))
 
 5944                                 $where .= 
" AND " . $ilDB->like(
'qpl_questions.description', 
'text', 
"%%" . $arrFilter[
'description'] . 
"%%");
 
 5946                         if (array_key_exists(
'author', $arrFilter) && strlen($arrFilter[
'author']))
 
 5948                                 $where .= 
" AND " . $ilDB->like(
'qpl_questions.author', 
'text', 
"%%" . $arrFilter[
'author'] . 
"%%");
 
 5950                         if (array_key_exists(
'type', $arrFilter) && strlen($arrFilter[
'type']))
 
 5952                                 $where .= 
" AND qpl_qst_type.type_tag = " . $ilDB->quote($arrFilter[
'type'], 
'text');
 
 5954                         if (array_key_exists(
'qpl', $arrFilter) && strlen($arrFilter[
'qpl']))
 
 5956                                 $where .= 
" AND " . $ilDB->like(
'object_data.title', 
'text', 
"%%" . $arrFilter[
'qpl'] . 
"%%");
 
 5960                 $original_ids =& $this->getExistingQuestions();
 
 5961                 $original_clause = 
" qpl_questions.original_id IS NULL";
 
 5962                 if (count($original_ids))
 
 5964                         $original_clause = 
" qpl_questions.original_id IS NULL AND " . $ilDB->in(
'qpl_questions.question_id',  $original_ids, 
true, 
'integer');
 
 5967                 $query_result = $ilDB->query(
 
 5968                         "SELECT qpl_questions.*, qpl_questions.tstamp, qpl_qst_type.type_tag, qpl_qst_type.plugin, object_data.title qpl " .
 
 5969                         "FROM qpl_questions, qpl_qst_type, object_data WHERE $original_clause $available AND " .
 
 5970                         "object_data.obj_id = qpl_questions.obj_fi AND qpl_questions.tstamp > 0 AND " .
 
 5971                         "qpl_questions.question_type_fi = qpl_qst_type.question_type_id$where");
 
 5974                 if ($query_result->numRows())
 
 5976                         while (
$row = $ilDB->fetchAssoc($query_result))
 
 5978                                 $row[
'ttype'] = $types[
$row[
'type_tag']];
 
 5983                                                 array_push($rows, $row);
 
 5988                                         array_push($rows, $row);
 
 6000                 global $ilPluginAdmin;
 
 6002                 $lng->loadLanguageModule(
"assessment");
 
 6003                 $result = $ilDB->query(
"SELECT * FROM qpl_qst_type");
 
 6007                         if (
$row[
"plugin"] == 0)
 
 6009                                 $types[
$row[
'type_tag']] = $lng->txt($row[
"type_tag"]);
 
 6013                                 $pl_names = $ilPluginAdmin->getActivePluginsForSlot(
IL_COMP_MODULE, 
"TestQuestionPool", 
"qst");
 
 6014                                 foreach ($pl_names as $pl_name)
 
 6017                                         if (strcmp($pl->getQuestionType(), 
$row[
"type_tag"]) == 0)
 
 6019                                                 $types[
$row[
'type_tag']] = $pl->getQuestionTypeTranslation();
 
 6039                 foreach ($assessment->objectives as $objectives)
 
 6041                         foreach ($objectives->materials as $material)
 
 6056                 foreach ($assessment->assessmentcontrol as $assessmentcontrol)
 
 6058                         switch ($assessmentcontrol->getSolutionswitch())
 
 6069                 foreach ($assessment->qtimetadata as 
$metadata)
 
 6071                         switch ($metadata[
"label"])
 
 6075                                         $type = $metadata[
"entry"];
 
 6096                                 case "sequence_settings":
 
 6106                                         $this->
setKiosk($metadata[
"entry"]);
 
 6108                                 case "showfinalstatement":
 
 6121                                 case "highscore_enabled":
 
 6125                                 case "highscore_anon":
 
 6129                                 case "highscore_achieved_ts":
 
 6133                                 case "highscore_score":
 
 6137                                 case "highscore_percentage":
 
 6141                                 case "highscore_hints":
 
 6145                                 case "highscore_wtime":
 
 6149                                 case "highscore_own_table":
 
 6153                                 case "highscore_top_table":
 
 6157                                 case "highscore_top_num":
 
 6161                                 case "hide_previous_results":
 
 6162                                         if ($metadata[
"entry"] == 0)
 
 6171                                 case "use_previous_answers":
 
 6174                                 case "answer_feedback":
 
 6177                                 case "hide_title_points":
 
 6180                                 case "title_output":
 
 6186                                 case "random_question_count":
 
 6189                                 case "results_presentation":
 
 6192                                 case "reset_processing_time":
 
 6195                                 case "instant_verification":
 
 6198                                 case "answer_feedback_points":
 
 6210                                 case "fixed_participants":
 
 6213                                 case "score_reporting":
 
 6216                                 case "shuffle_questions":
 
 6219                                 case "count_system":
 
 6225                                 case "mailnotification":
 
 6231                                 case "exportsettings":
 
 6234                                 case "score_cutting":
 
 6240                                 case "allowedUsers":
 
 6243                                 case "allowedUsersTimeGap":
 
 6246                                 case "pass_scoring":
 
 6249                                 case "show_summary":
 
 6252                                 case "reporting_date":
 
 6253                                         $iso8601period = $metadata[
"entry"];
 
 6254                                         if (preg_match(
"/P(\d+)Y(\d+)M(\d+)DT(\d+)H(\d+)M(\d+)S/", $iso8601period, $matches))
 
 6256                                                 $this->
setReportingDate(sprintf(
"%02d%02d%02d%02d%02d%02d", $matches[1], $matches[2], $matches[3], $matches[4], $matches[5], $matches[6]));
 
 6259                                 case 'enable_processing_time': 
 
 6262                                 case "processing_time": 
 
 6265                                 case "starting_time":
 
 6266                                         $iso8601period = $metadata[
"entry"];
 
 6267                                         if (preg_match(
"/P(\d+)Y(\d+)M(\d+)DT(\d+)H(\d+)M(\d+)S/", $iso8601period, $matches))
 
 6269                                                 $this->
setStartingTime(sprintf(
"%02d%02d%02d%02d%02d%02d", $matches[1], $matches[2], $matches[3], $matches[4], $matches[5], $matches[6]));
 
 6273                                         $iso8601period = $metadata[
"entry"];
 
 6274                                         if (preg_match(
"/P(\d+)Y(\d+)M(\d+)DT(\d+)H(\d+)M(\d+)S/", $iso8601period, $matches))
 
 6276                                                 $this->
setEndingTime(sprintf(
"%02d%02d%02d%02d%02d%02d", $matches[1], $matches[2], $matches[3], $matches[4], $matches[5], $matches[6]));
 
 6279                                 case 'activation_limited':
 
 6282                                 case 'activation_start_time':
 
 6285                                 case 'activation_end_time':
 
 6288                                 case 'activation_visibility':
 
 6294                                 case 'autosave_ival':
 
 6297                                 case 'offer_question_hints':
 
 6300                                 case 'instant_feedback_specific':
 
 6303                                 case 'obligations_enabled':
 
 6307                         if (preg_match(
"/mark_step_\d+/", $metadata[
"label"]))
 
 6309                                 $xmlmark = $metadata[
"entry"];
 
 6310                                 preg_match(
"/<short>(.*?)<\/short>/", $xmlmark, $matches);
 
 6311                                 $mark_short = $matches[1];
 
 6312                                 preg_match(
"/<official>(.*?)<\/official>/", $xmlmark, $matches);
 
 6313                                 $mark_official = $matches[1];
 
 6314                                 preg_match(
"/<percentage>(.*?)<\/percentage>/", $xmlmark, $matches);
 
 6315                                 $mark_percentage = $matches[1];
 
 6316                                 preg_match(
"/<passed>(.*?)<\/passed>/", $xmlmark, $matches);
 
 6317                                 $mark_passed = $matches[1];
 
 6318                                 $this->mark_schema->addMarkStep($mark_short, $mark_official, $mark_percentage, $mark_passed);
 
 6322                 if (is_array(
$_SESSION[
"import_mob_xhtml"]))
 
 6324                         include_once 
"./Services/MediaObjects/classes/class.ilObjMediaObject.php";
 
 6325                         include_once 
"./Services/RTE/classes/class.ilRTE.php";
 
 6326                         include_once 
"./Modules/TestQuestionPool/classes/class.ilObjQuestionPool.php";
 
 6327                         foreach (
$_SESSION[
"import_mob_xhtml"] as $mob)
 
 6330                                 if (file_exists($importfile))
 
 6340                                         $ilLog->write(
"Error: Could not open XHTML mob file for test introduction during test import. File $importfile does not exist!");
 
 6355                 include_once(
"./Services/Xml/classes/class.ilXmlWriter.php");
 
 6359                 $a_xml_writer->xmlSetDtdDef(
"<!DOCTYPE questestinterop SYSTEM \"ims_qtiasiv1p2p1.dtd\">");
 
 6360                 $a_xml_writer->xmlStartTag(
"questestinterop");
 
 6363                         "ident" => 
"il_".IL_INST_ID.
"_tst_".$this->getTestId(),
 
 6366                 $a_xml_writer->xmlStartTag(
"assessment", $attrs);
 
 6368                 $a_xml_writer->xmlElement(
"qticomment", NULL, $this->
getDescription());
 
 6371                 if ($this->enable_processing_time)
 
 6373                         preg_match(
"/(\d+):(\d+):(\d+)/", $this->processing_time, $matches);
 
 6374                         $a_xml_writer->xmlElement(
"duration", NULL, sprintf(
"P0Y0M0DT%dH%dM%dS", $matches[1], $matches[2], $matches[3]));
 
 6378                 $a_xml_writer->xmlStartTag(
"qtimetadata");
 
 6379                 $a_xml_writer->xmlStartTag(
"qtimetadatafield");
 
 6380                 $a_xml_writer->xmlElement(
"fieldlabel", NULL, 
"ILIAS_VERSION");
 
 6381                 $a_xml_writer->xmlElement(
"fieldentry", NULL, $this->ilias->getSetting(
"ilias_version"));
 
 6382                 $a_xml_writer->xmlEndTag(
"qtimetadatafield");
 
 6385                 $a_xml_writer->xmlStartTag(
"qtimetadatafield");
 
 6386                 $a_xml_writer->xmlElement(
"fieldlabel", NULL, 
"anonymity");
 
 6387                 $a_xml_writer->xmlElement(
"fieldentry", NULL, sprintf(
"%d", $this->
getAnonymity()));
 
 6388                 $a_xml_writer->xmlEndTag(
"qtimetadatafield");
 
 6391                 $a_xml_writer->xmlStartTag(
"qtimetadatafield");
 
 6392                 $a_xml_writer->xmlElement(
"fieldlabel", NULL, 
"random_test");
 
 6393                 $a_xml_writer->xmlElement(
"fieldentry", NULL, sprintf(
"%d", $this->
isRandomTest()));
 
 6394                 $a_xml_writer->xmlEndTag(
"qtimetadatafield");
 
 6397                 $a_xml_writer->xmlStartTag(
"qtimetadatafield");
 
 6398                 $a_xml_writer->xmlElement(
"fieldlabel", NULL, 
"sequence_settings");
 
 6400                 $a_xml_writer->xmlEndTag(
"qtimetadatafield");
 
 6403                 $a_xml_writer->xmlStartTag(
"qtimetadatafield");
 
 6404                 $a_xml_writer->xmlElement(
"fieldlabel", NULL, 
"author");
 
 6405                 $a_xml_writer->xmlElement(
"fieldentry", NULL, $this->
getAuthor());
 
 6406                 $a_xml_writer->xmlEndTag(
"qtimetadatafield");
 
 6409                 $a_xml_writer->xmlStartTag(
"qtimetadatafield");
 
 6410                 $a_xml_writer->xmlElement(
"fieldlabel", NULL, 
"reset_processing_time");
 
 6412                 $a_xml_writer->xmlEndTag(
"qtimetadatafield");
 
 6415                 $a_xml_writer->xmlStartTag(
"qtimetadatafield");
 
 6416                 $a_xml_writer->xmlElement(
"fieldlabel", NULL, 
"count_system");
 
 6417                 $a_xml_writer->xmlElement(
"fieldentry", NULL, $this->
getCountSystem());
 
 6418                 $a_xml_writer->xmlEndTag(
"qtimetadatafield");
 
 6421                 $a_xml_writer->xmlStartTag(
"qtimetadatafield");
 
 6422                 $a_xml_writer->xmlElement(
"fieldlabel", NULL, 
"mc_scoring");
 
 6423                 $a_xml_writer->xmlElement(
"fieldentry", NULL, $this->
getMCScoring());
 
 6424                 $a_xml_writer->xmlEndTag(
"qtimetadatafield");
 
 6427                 $a_xml_writer->xmlStartTag(
"qtimetadatafield");
 
 6428                 $a_xml_writer->xmlElement(
"fieldlabel", NULL, 
"score_cutting");
 
 6429                 $a_xml_writer->xmlElement(
"fieldentry", NULL, $this->
getScoreCutting());
 
 6430                 $a_xml_writer->xmlEndTag(
"qtimetadatafield");
 
 6433                 $a_xml_writer->xmlStartTag(
"qtimetadatafield");
 
 6434                 $a_xml_writer->xmlElement(
"fieldlabel", NULL, 
"password");
 
 6435                 $a_xml_writer->xmlElement(
"fieldentry", NULL, $this->
getPassword());
 
 6436                 $a_xml_writer->xmlEndTag(
"qtimetadatafield");
 
 6439                 $a_xml_writer->xmlStartTag(
"qtimetadatafield");
 
 6440                 $a_xml_writer->xmlElement(
"fieldlabel", NULL, 
"allowedUsers");
 
 6441                 $a_xml_writer->xmlElement(
"fieldentry", NULL, $this->
getAllowedUsers());
 
 6442                 $a_xml_writer->xmlEndTag(
"qtimetadatafield");
 
 6445                 $a_xml_writer->xmlStartTag(
"qtimetadatafield");
 
 6446                 $a_xml_writer->xmlElement(
"fieldlabel", NULL, 
"allowedUsersTimeGap");
 
 6448                 $a_xml_writer->xmlEndTag(
"qtimetadatafield");
 
 6451                 $a_xml_writer->xmlStartTag(
"qtimetadatafield");
 
 6452                 $a_xml_writer->xmlElement(
"fieldlabel", NULL, 
"pass_scoring");
 
 6453                 $a_xml_writer->xmlElement(
"fieldentry", NULL, $this->
getPassScoring());
 
 6454                 $a_xml_writer->xmlEndTag(
"qtimetadatafield");
 
 6459                         $a_xml_writer->xmlStartTag(
"qtimetadatafield");
 
 6460                         $a_xml_writer->xmlElement(
"fieldlabel", NULL, 
"reporting_date");
 
 6461                         preg_match(
"/(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})/", $this->reporting_date, $matches);
 
 6462                         $a_xml_writer->xmlElement(
"fieldentry", NULL, sprintf(
"P%dY%dM%dDT%dH%dM%dS", $matches[1], $matches[2], $matches[3], $matches[4], $matches[5], $matches[6]));
 
 6463                         $a_xml_writer->xmlEndTag(
"qtimetadatafield");
 
 6466                 $a_xml_writer->xmlStartTag(
"qtimetadatafield");
 
 6467                 $a_xml_writer->xmlElement(
"fieldlabel", NULL, 
"nr_of_tries");
 
 6468                 $a_xml_writer->xmlElement(
"fieldentry", NULL, sprintf(
"%d", $this->
getNrOfTries()));
 
 6469                 $a_xml_writer->xmlEndTag(
"qtimetadatafield");
 
 6472                 $a_xml_writer->xmlStartTag(
"qtimetadatafield");
 
 6473                 $a_xml_writer->xmlElement(
"fieldlabel", NULL, 
"kiosk");
 
 6474                 $a_xml_writer->xmlElement(
"fieldentry", NULL, sprintf(
"%d", $this->
getKiosk()));
 
 6475                 $a_xml_writer->xmlEndTag(
"qtimetadatafield");
 
 6478                 $a_xml_writer->xmlStartTag(
"qtimetadatafield");
 
 6479                 $a_xml_writer->xmlElement(
"fieldlabel", NULL, 
"use_previous_answers");
 
 6481                 $a_xml_writer->xmlEndTag(
"qtimetadatafield");
 
 6484                 $a_xml_writer->xmlStartTag(
"qtimetadatafield");
 
 6485                 $a_xml_writer->xmlElement(
"fieldlabel", NULL, 
"title_output");
 
 6486                 $a_xml_writer->xmlElement(
"fieldentry", NULL, sprintf(
"%d", $this->
getTitleOutput()));
 
 6487                 $a_xml_writer->xmlEndTag(
"qtimetadatafield");
 
 6490                 $a_xml_writer->xmlStartTag(
"qtimetadatafield");
 
 6491                 $a_xml_writer->xmlElement(
"fieldlabel", NULL, 
"random_question_count");
 
 6493                 $a_xml_writer->xmlEndTag(
"qtimetadatafield");
 
 6496                 $a_xml_writer->xmlStartTag(
"qtimetadatafield");
 
 6497                 $a_xml_writer->xmlElement(
"fieldlabel", NULL, 
"results_presentation");
 
 6499                 $a_xml_writer->xmlEndTag(
"qtimetadatafield");
 
 6502                 $a_xml_writer->xmlStartTag(
"qtimetadatafield");
 
 6503                 $a_xml_writer->xmlElement(
"fieldlabel", NULL, 
"show_summary");
 
 6505                 $a_xml_writer->xmlEndTag(
"qtimetadatafield");
 
 6508                 $a_xml_writer->xmlStartTag(
"qtimetadatafield");
 
 6509                 $a_xml_writer->xmlElement(
"fieldlabel", NULL, 
"score_reporting");
 
 6510                 $a_xml_writer->xmlElement(
"fieldentry", NULL, sprintf(
"%d", $this->
getScoreReporting()));
 
 6511                 $a_xml_writer->xmlEndTag(
"qtimetadatafield");
 
 6514                 $a_xml_writer->xmlStartTag(
"qtimetadatafield");
 
 6515                 $a_xml_writer->xmlElement(
"fieldlabel", NULL, 
"instant_verification");
 
 6517                 $a_xml_writer->xmlEndTag(
"qtimetadatafield");
 
 6520                 $a_xml_writer->xmlStartTag(
"qtimetadatafield");
 
 6521                 $a_xml_writer->xmlElement(
"fieldlabel", NULL, 
"answer_feedback");
 
 6522                 $a_xml_writer->xmlElement(
"fieldentry", NULL, sprintf(
"%d", $this->
getAnswerFeedback()));
 
 6523                 $a_xml_writer->xmlEndTag(
"qtimetadatafield");
 
 6526                 $a_xml_writer->xmlStartTag(
"qtimetadatafield");
 
 6527                 $a_xml_writer->xmlElement(
"fieldlabel", NULL, 
"answer_feedback_points");
 
 6529                 $a_xml_writer->xmlEndTag(
"qtimetadatafield");
 
 6532                 $highscore_metadata = array(
 
 6544                 foreach($highscore_metadata as $label => 
$data)
 
 6546                         $a_xml_writer->xmlStartTag(
"qtimetadatafield");
 
 6547                         $a_xml_writer->xmlElement(
"fieldlabel", NULL, $label);
 
 6548                         $a_xml_writer->xmlElement(
"fieldentry", NULL, sprintf(
"%d", 
$data[
'value']));
 
 6549                         $a_xml_writer->xmlEndTag(
"qtimetadatafield");
 
 6553                 $a_xml_writer->xmlStartTag(
"qtimetadatafield");
 
 6554                 $a_xml_writer->xmlElement(
"fieldlabel", NULL, 
"show_cancel");
 
 6555                 $a_xml_writer->xmlElement(
"fieldentry", NULL, sprintf(
"%d", $this->
getShowCancel()));
 
 6556                 $a_xml_writer->xmlEndTag(
"qtimetadatafield");
 
 6559                 $a_xml_writer->xmlStartTag(
"qtimetadatafield");
 
 6560                 $a_xml_writer->xmlElement(
"fieldlabel", NULL, 
"show_marker");
 
 6561                 $a_xml_writer->xmlElement(
"fieldentry", NULL, sprintf(
"%d", $this->
getShowMarker()));
 
 6562                 $a_xml_writer->xmlEndTag(
"qtimetadatafield");
 
 6565                 $a_xml_writer->xmlStartTag(
"qtimetadatafield");
 
 6566                 $a_xml_writer->xmlElement(
"fieldlabel", NULL, 
"fixed_participants");
 
 6568                 $a_xml_writer->xmlEndTag(
"qtimetadatafield");
 
 6571                 $a_xml_writer->xmlStartTag(
"qtimetadatafield");
 
 6572                 $a_xml_writer->xmlElement(
"fieldlabel", NULL, 
"showfinalstatement");
 
 6573                 $a_xml_writer->xmlElement(
"fieldentry", NULL, sprintf(
"%d", (($this->
getShowFinalStatement()) ? 
"1" : 
"0")));
 
 6574                 $a_xml_writer->xmlEndTag(
"qtimetadatafield");
 
 6577                 $a_xml_writer->xmlStartTag(
"qtimetadatafield");
 
 6578                 $a_xml_writer->xmlElement(
"fieldlabel", NULL, 
"showinfo");
 
 6579                 $a_xml_writer->xmlElement(
"fieldentry", NULL, sprintf(
"%d", (($this->
getShowInfo()) ? 
"1" : 
"0")));
 
 6580                 $a_xml_writer->xmlEndTag(
"qtimetadatafield");
 
 6583                 $a_xml_writer->xmlStartTag(
"qtimetadatafield");
 
 6584                 $a_xml_writer->xmlElement(
"fieldlabel", NULL, 
"mailnotification");
 
 6586                 $a_xml_writer->xmlEndTag(
"qtimetadatafield");
 
 6589                 $a_xml_writer->xmlStartTag(
"qtimetadatafield");
 
 6590                 $a_xml_writer->xmlElement(
"fieldlabel", NULL, 
"mailnottype");
 
 6592                 $a_xml_writer->xmlEndTag(
"qtimetadatafield");
 
 6595                 $a_xml_writer->xmlStartTag(
"qtimetadatafield");
 
 6596                 $a_xml_writer->xmlElement(
"fieldlabel", NULL, 
"exportsettings");
 
 6598                 $a_xml_writer->xmlEndTag(
"qtimetadatafield");
 
 6601                 $a_xml_writer->xmlStartTag(
"qtimetadatafield");
 
 6602                 $a_xml_writer->xmlElement(
"fieldlabel", NULL, 
"forcejs");
 
 6603                 $a_xml_writer->xmlElement(
"fieldentry", NULL, sprintf(
"%d", (($this->
getForceJS()) ? 
"1" : 
"0")));
 
 6604                 $a_xml_writer->xmlEndTag(
"qtimetadatafield");
 
 6607                 $a_xml_writer->xmlStartTag(
"qtimetadatafield");
 
 6608                 $a_xml_writer->xmlElement(
"fieldlabel", NULL, 
"customstyle");
 
 6609                 $a_xml_writer->xmlElement(
"fieldentry", NULL, $this->
getCustomStyle());
 
 6610                 $a_xml_writer->xmlEndTag(
"qtimetadatafield");
 
 6613                 $a_xml_writer->xmlStartTag(
"qtimetadatafield");
 
 6614                 $a_xml_writer->xmlElement(
"fieldlabel", NULL, 
"shuffle_questions");
 
 6615                 $a_xml_writer->xmlElement(
"fieldentry", NULL, sprintf(
"%d", $this->
getShuffleQuestions()));
 
 6616                 $a_xml_writer->xmlEndTag(
"qtimetadatafield");
 
 6619                 $a_xml_writer->xmlStartTag(
"qtimetadatafield");
 
 6620                 $a_xml_writer->xmlElement(
"fieldlabel", NULL, 
"processing_time");
 
 6622                 $a_xml_writer->xmlEndTag(
"qtimetadatafield");
 
 6627                         $a_xml_writer->xmlStartTag(
"qtimetadatafield");
 
 6628                         $a_xml_writer->xmlElement(
"fieldlabel", NULL, 
"starting_time");
 
 6629                         preg_match(
"/(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})/", $this->starting_time, $matches);
 
 6630                         $a_xml_writer->xmlElement(
"fieldentry", NULL, sprintf(
"P%dY%dM%dDT%dH%dM%dS", $matches[1], $matches[2], $matches[3], $matches[4], $matches[5], $matches[6]));
 
 6631                         $a_xml_writer->xmlEndTag(
"qtimetadatafield");
 
 6636                         $a_xml_writer->xmlStartTag(
"qtimetadatafield");
 
 6637                         $a_xml_writer->xmlElement(
"fieldlabel", NULL, 
"ending_time");
 
 6638                         preg_match(
"/(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})/", $this->ending_time, $matches);
 
 6639                         $a_xml_writer->xmlElement(
"fieldentry", NULL, sprintf(
"P%dY%dM%dDT%dH%dM%dS", $matches[1], $matches[2], $matches[3], $matches[4], $matches[5], $matches[6]));
 
 6640                         $a_xml_writer->xmlEndTag(
"qtimetadatafield");
 
 6645                 $a_xml_writer->xmlStartTag(
"qtimetadatafield");
 
 6646                 $a_xml_writer->xmlElement(
"fieldlabel", NULL, 
"activation_limited");
 
 6648                 $a_xml_writer->xmlEndTag(
"qtimetadatafield");
 
 6651                 $a_xml_writer->xmlStartTag(
"qtimetadatafield");
 
 6652                 $a_xml_writer->xmlElement(
"fieldlabel", NULL, 
"activation_start_time");
 
 6654                 $a_xml_writer->xmlEndTag(
"qtimetadatafield");
 
 6657                 $a_xml_writer->xmlStartTag(
"qtimetadatafield");
 
 6658                 $a_xml_writer->xmlElement(
"fieldlabel", NULL, 
"activation_end_time");
 
 6660                 $a_xml_writer->xmlEndTag(
"qtimetadatafield");
 
 6663                 $a_xml_writer->xmlStartTag(
"qtimetadatafield");
 
 6664                 $a_xml_writer->xmlElement(
"fieldlabel", NULL, 
"activation_visibility");
 
 6666                 $a_xml_writer->xmlEndTag(
"qtimetadatafield");
 
 6669                 $a_xml_writer->xmlStartTag(
"qtimetadatafield");
 
 6670                 $a_xml_writer->xmlElement(
"fieldlabel", NULL, 
"autosave");
 
 6671                 $a_xml_writer->xmlElement(
"fieldentry", NULL, (
int)$this->
getAutosave());
 
 6672                 $a_xml_writer->xmlEndTag(
"qtimetadatafield");
 
 6675                 $a_xml_writer->xmlStartTag(
"qtimetadatafield");
 
 6676                 $a_xml_writer->xmlElement(
"fieldlabel", NULL, 
"autosave_ival");
 
 6677                 $a_xml_writer->xmlElement(
"fieldentry", NULL, (
int)$this->
getAutosaveIval());
 
 6678                 $a_xml_writer->xmlEndTag(
"qtimetadatafield");
 
 6681                 $a_xml_writer->xmlStartTag(
"qtimetadatafield");
 
 6682                 $a_xml_writer->xmlElement(
"fieldlabel", NULL, 
"offer_question_hints");
 
 6684                 $a_xml_writer->xmlEndTag(
"qtimetadatafield");
 
 6687                 $a_xml_writer->xmlStartTag(
"qtimetadatafield");
 
 6688                 $a_xml_writer->xmlElement(
"fieldlabel", NULL, 
"instant_feedback_specific");
 
 6690                 $a_xml_writer->xmlEndTag(
"qtimetadatafield");
 
 6693                 $a_xml_writer->xmlStartTag(
"qtimetadatafield");
 
 6694                 $a_xml_writer->xmlElement(
"fieldlabel", NULL, 
"obligations_enabled");
 
 6696                 $a_xml_writer->xmlEndTag(
"qtimetadatafield");
 
 6699                 $a_xml_writer->xmlStartTag(
"qtimetadatafield");
 
 6700                 $a_xml_writer->xmlElement(
"fieldlabel", NULL, 
"enable_processing_time");
 
 6702                 $a_xml_writer->xmlEndTag(
"qtimetadatafield");
 
 6704                 foreach ($this->mark_schema->mark_steps as $index => $mark)
 
 6707                         $a_xml_writer->xmlStartTag(
"qtimetadatafield");
 
 6708                         $a_xml_writer->xmlElement(
"fieldlabel", NULL, 
"mark_step_$index");
 
 6709                         $a_xml_writer->xmlElement(
"fieldentry", NULL, sprintf(
 
 6710                                 "<short>%s</short><official>%s</official><percentage>%.2f</percentage><passed>%d</passed>",
 
 6711                                 $mark->getShortName(), $mark->getOfficialName(), $mark->getMinimumLevel(), $mark->getPassed()
 
 6713                         $a_xml_writer->xmlEndTag(
"qtimetadatafield");
 
 6715                 $a_xml_writer->xmlEndTag(
"qtimetadata");
 
 6718                 $a_xml_writer->xmlStartTag(
"objectives");
 
 6720                 $a_xml_writer->xmlEndTag(
"objectives");
 
 6726                                 "solutionswitch" => 
"Yes" 
 6733                 $a_xml_writer->xmlElement(
"assessmentcontrol", $attrs, NULL);
 
 6738                         $a_xml_writer->xmlStartTag(
"presentation_material");
 
 6739                         $a_xml_writer->xmlStartTag(
"flow_mat");
 
 6741                         $a_xml_writer->xmlEndTag(
"flow_mat");
 
 6742                         $a_xml_writer->xmlEndTag(
"presentation_material");
 
 6748                 $a_xml_writer->xmlElement(
"section", $attrs, NULL);
 
 6749                 $a_xml_writer->xmlEndTag(
"assessment");
 
 6750                 $a_xml_writer->xmlEndTag(
"questestinterop");
 
 6752                 $xml = $a_xml_writer->xmlDumpMem(FALSE);
 
 6754                 foreach ($this->questions as $question_id)
 
 6757                         $qti_question = $question->toXML(
false);
 
 6758                         $qti_question = preg_replace(
"/<questestinterop>/", 
"", $qti_question);
 
 6759                         $qti_question = preg_replace(
"/<\/questestinterop>/", 
"", $qti_question);
 
 6760                         if (strpos($xml, 
"</section>") !== 
false)
 
 6762                                 $xml = str_replace(
"</section>", 
"$qti_question</section>", $xml);
 
 6766                                 $xml = str_replace(
"<section ident=\"1\"/>", 
"<section ident=\"1\">\n$qti_question</section>", $xml);
 
 6782                 $this->mob_ids = array();
 
 6783                 $this->file_ids = array();
 
 6786                 $attrs[
"Type"] = 
"Test";
 
 6787                 $a_xml_writer->xmlStartTag(
"ContentObject", $attrs);
 
 6793                 $expLog->write(date(
"[y-m-d H:i:s] ").
"Start Export Page Objects");
 
 6794                 $ilBench->start(
"ContentObjectExport", 
"exportPageObjects");
 
 6796                 $ilBench->stop(
"ContentObjectExport", 
"exportPageObjects");
 
 6797                 $expLog->write(date(
"[y-m-d H:i:s] ").
"Finished Export Page Objects");
 
 6800                 $expLog->write(date(
"[y-m-d H:i:s] ").
"Start Export Media Objects");
 
 6801                 $ilBench->start(
"ContentObjectExport", 
"exportMediaObjects");
 
 6803                 $ilBench->stop(
"ContentObjectExport", 
"exportMediaObjects");
 
 6804                 $expLog->write(date(
"[y-m-d H:i:s] ").
"Finished Export Media Objects");
 
 6807                 $expLog->write(date(
"[y-m-d H:i:s] ").
"Start Export File Items");
 
 6808                 $ilBench->start(
"ContentObjectExport", 
"exportFileItems");
 
 6810                 $ilBench->stop(
"ContentObjectExport", 
"exportFileItems");
 
 6811                 $expLog->write(date(
"[y-m-d H:i:s] ").
"Finished Export File Items");
 
 6813                 $a_xml_writer->xmlEndTag(
"ContentObject");
 
 6824                 include_once 
"./Services/MetaData/classes/class.ilMD2XML.php";
 
 6826                 $md2xml->setExportMode(
true);
 
 6827                 $md2xml->startExport();
 
 6828                 $a_xml_writer->appendXML($md2xml->getXML());
 
 6838                 if ($a_tag == 
"Identifier" && $a_param == 
"Entry")
 
 6840                         include_once 
"./Services/Utilities/classes/class.ilUtil.php";
 
 6858                 include_once 
"./Modules/LearningModule/classes/class.ilLMPageObject.php";
 
 6860                 foreach ($this->questions as $question_id)
 
 6862                         $ilBench->start(
"ContentObjectExport", 
"exportPageObject");
 
 6863                         $expLog->write(date(
"[y-m-d H:i:s] ").
"Page Object ".$question_id);
 
 6866                         $a_xml_writer->xmlStartTag(
"PageObject", $attrs);
 
 6870                         $ilBench->start(
"ContentObjectExport", 
"exportPageObject_XML");
 
 6872                         $page_object->buildDom();
 
 6873                         $page_object->insertInstIntoIDs($a_inst);
 
 6874                         $mob_ids = $page_object->collectMediaObjects(
false);
 
 6875                         $file_ids = $page_object->collectFileItems();
 
 6876                         $xml = $page_object->getXMLFromDom(
false, 
false, 
false, 
"", 
true);
 
 6877                         $xml = str_replace(
"&",
"&", $xml);
 
 6878                         $a_xml_writer->appendXML($xml);
 
 6879                         $page_object->freeDom();
 
 6880                         unset ($page_object);
 
 6882                         $ilBench->stop(
"ContentObjectExport", 
"exportPageObject_XML");
 
 6885                         $ilBench->start(
"ContentObjectExport", 
"exportPageObject_CollectMedia");
 
 6887                         foreach($mob_ids as $mob_id)
 
 6889                                 $this->mob_ids[$mob_id] = $mob_id;
 
 6891                         $ilBench->stop(
"ContentObjectExport", 
"exportPageObject_CollectMedia");
 
 6894                         $ilBench->start(
"ContentObjectExport", 
"exportPageObject_CollectFileItems");
 
 6896                         foreach($file_ids as $file_id)
 
 6898                                 $this->file_ids[$file_id] = $file_id;
 
 6900                         $ilBench->stop(
"ContentObjectExport", 
"exportPageObject_CollectFileItems");
 
 6902                         $a_xml_writer->xmlEndTag(
"PageObject");
 
 6905                         $ilBench->stop(
"ContentObjectExport", 
"exportPageObject");
 
 6919                 include_once 
"./Services/MediaObjects/classes/class.ilObjMediaObject.php";
 
 6921                 foreach ($this->mob_ids as $mob_id)
 
 6923                         $expLog->write(date(
"[y-m-d H:i:s] ").
"Media Object ".$mob_id);
 
 6927                                 $media_obj->exportXML($a_xml_writer, $a_inst);
 
 6928                                 $media_obj->exportFiles($a_target_dir);
 
 6940                 include_once 
"./Modules/File/classes/class.ilObjFile.php";
 
 6942                 foreach ($this->file_ids as $file_id)
 
 6944                         $expLog->write(date(
"[y-m-d H:i:s] ").
"File Item ".$file_id);
 
 6945                         $file_obj = 
new ilObjFile($file_id, 
false);
 
 6946                         $file_obj->export($a_target_dir);
 
 6957                 if (!is_array($this->import_mapping))
 
 6963                         return $this->import_mapping;
 
 6978                 return ilObjTest::_getECTSGrade($passed_array, $reached_points, $max_points, $this->ects_grades[
"A"], $this->ects_grades[
"B"], $this->ects_grades[
"C"], $this->ects_grades[
"D"], $this->ects_grades[
"E"], $this->ects_fx);
 
 6989         function _getECTSGrade($points_passed, $reached_points, $max_points, $a, $b, $c, 
$d, $e, $fx)
 
 6991                 include_once 
"./Modules/Test/classes/class.ilStatistics.php";
 
 6994                 $passed_statistics->setData($points_passed);
 
 6995                 $ects_percentiles = array
 
 6997                         "A" => $passed_statistics->quantile($a),
 
 6998                         "B" => $passed_statistics->quantile($b),
 
 6999                         "C" => $passed_statistics->quantile($c),
 
 7000                         "D" => $passed_statistics->quantile(
$d),
 
 7001                         "E" => $passed_statistics->quantile($e)
 
 7003                 if (count($points_passed) && ($reached_points >= $ects_percentiles[
"A"]))
 
 7007                 else if (count($points_passed) && ($reached_points >= $ects_percentiles[
"B"]))
 
 7011                 else if (count($points_passed) && ($reached_points >= $ects_percentiles[
"C"]))
 
 7015                 else if (count($points_passed) && ($reached_points >= $ects_percentiles[
"D"]))
 
 7019                 else if (count($points_passed) && ($reached_points >= $ects_percentiles[
"E"]))
 
 7023                 else if (strcmp($fx, 
"") != 0)
 
 7025                         if ($max_points > 0)
 
 7027                                 $percentage = ($reached_points / $max_points) * 100.0;
 
 7028                                 if ($percentage < 0) $percentage = 0.0;
 
 7034                         if ($percentage >= $fx)
 
 7051                 return $this->mark_schema->checkMarks();
 
 7083                 $md_life =& $md->getLifecycle();
 
 7086                         if (strlen($a_author) == 0)
 
 7089                                 $a_author = $ilUser->getFullname();
 
 7092                         $md_life =& $md->addLifecycle();
 
 7094                         $con =& $md_life->addContribute();
 
 7095                         $con->setRole(
"Author");
 
 7097                         $ent =& $con->addEntity();
 
 7098                         $ent->setEntity($a_author);
 
 7124                 include_once 
"./Services/MetaData/classes/class.ilMD.php";
 
 7126                 $md_life =& $md->getLifecycle();
 
 7129                         $ids =& $md_life->getContributeIds();
 
 7130                         foreach ($ids as 
$id)
 
 7132                                 $md_cont =& $md_life->getContribute($id);
 
 7133                                 if (strcmp($md_cont->getRole(), 
"Author") == 0)
 
 7135                                         $entids =& $md_cont->getEntityIds();
 
 7136                                         foreach ($entids as $entid)
 
 7138                                                 $md_ent =& $md_cont->getEntity($entid);
 
 7139                                                 array_push(
$author, $md_ent->getEntity());
 
 7157                 include_once 
"./Services/MetaData/classes/class.ilMD.php";
 
 7158                 $md =& 
new ilMD($obj_id, 0, 
"tst");
 
 7159                 $md_life =& $md->getLifecycle();
 
 7162                         $ids =& $md_life->getContributeIds();
 
 7163                         foreach ($ids as 
$id)
 
 7165                                 $md_cont =& $md_life->getContribute($id);
 
 7166                                 if (strcmp($md_cont->getRole(), 
"Author") == 0)
 
 7168                                         $entids =& $md_cont->getEntityIds();
 
 7169                                         foreach ($entids as $entid)
 
 7171                                                 $md_ent =& $md_cont->getEntity($entid);
 
 7172                                                 array_push(
$author, $md_ent->getEntity());
 
 7191                 $result_array = array();
 
 7201                                         $result_array[$obj_id] = $titles[
$ref_id];
 
 7209                 return $result_array;
 
 7224                         $result = $ilDB->queryF(
"SELECT * FROM tst_test_random WHERE test_fi = %s ORDER BY sequence, test_random_id",
 
 7232                                         $next_id = $ilDB->nextId(
'tst_test_random');
 
 7233                                         $affectedRows = $ilDB->manipulateF(
"INSERT INTO tst_test_random (test_random_id, test_fi, questionpool_fi, num_of_q, tstamp, sequence) VALUES (%s, %s, %s, %s, %s, %s)",
 
 7234                                                 array(
'integer', 
'integer', 
'integer', 
'integer', 
'integer', 
'integer'),
 
 7235                                                 array($next_id, $new_id, 
$row[
"questionpool_fi"], 
$row[
"num_of_q"], time(), 
$row[
'sequence'])
 
 7279                 $newObj->setKiosk($this->
getKiosk());
 
 7309                 $newObj->saveToDb();
 
 7312                 include_once 
"./Services/Certificate/classes/class.ilCertificate.php";
 
 7313                 include_once 
"./Modules/Test/classes/class.ilTestCertificateAdapter.php";
 
 7316                 $cert->cloneCertificate($newcert);
 
 7320                         $newObj->saveRandomQuestionCount($newObj->getRandomQuestionCount());
 
 7325                         include_once(
"./Services/CopyWizard/classes/class.ilCopyWizardOptions.php");
 
 7329                         include_once 
"./Modules/TestQuestionPool/classes/class.assQuestion.php";
 
 7330                         foreach ($this->questions as $key => $question_id)
 
 7333                                 $newObj->questions[$key] = $question->duplicate(
true, null, null, null, $newObj->getId());
 
 7336                                 $question->saveToDb($original_id);
 
 7340                                 $cwo->appendMapping($this->
getRefId().
'_'.$question_id,$newObj->getRefId().
'_'.$newObj->questions[$key]);
 
 7341                                 $ilLog->write(__METHOD__.
': Added mapping '.$this->getRefId().
'_'.$question_id.
' <-> ' .
 
 7342                                                 $newObj->getRefId().
'_'.$newObj->questions[$key]);
 
 7345                 $newObj->saveToDb();
 
 7366                                 foreach ($qpls as 
$data)
 
 7368                                         $maxcount += $data[
"contains"];
 
 7370                                 if ($num > $maxcount) $num = $maxcount;
 
 7375                                 foreach ($qpls as 
$data)
 
 7377                                         $add = ($data[
"count"] <= $data[
"contains"]) ? $data[
"count"] : $data[
"contains"];
 
 7384                         $num = count($this->questions);
 
 7402                 $result = $ilDB->queryF(
"SELECT * FROM tst_tests WHERE test_id = %s",
 
 7412                 if (
$test[
"random_test"] == 1)
 
 7416                         $result = $ilDB->queryF(
"SELECT * FROM tst_test_random WHERE test_fi = %s ORDER BY sequence, test_random_id",
 
 7424                                         $countresult = $ilDB->queryF(
"SELECT question_id FROM qpl_questions WHERE obj_fi =  %s AND qpl_questions.tstamp > 0 AND original_id IS NULL",
 
 7426                                                 $row[
"questionpool_fi"]
 
 7428                                         $contains = $countresult->numRows();
 
 7429                                         $qpls[$counter] = array(
 
 7430                                                 "index" => $counter,
 
 7431                                                 "count" => 
$row[
"num_of_q"],
 
 7432                                                 "qpl"   => 
$row[
"questionpool_fi"],
 
 7433                                                 "contains" => $contains
 
 7438                         if (
$test[
"random_question_count"] > 0)
 
 7440                                 $num = 
$test[
"random_question_count"];
 
 7442                                 foreach ($qpls as 
$data)
 
 7444                                         $maxcount += $data[
"contains"];
 
 7446                                 if ($num > $maxcount) $num = $maxcount;
 
 7451                                 foreach ($qpls as 
$data)
 
 7453                                         $add = ($data[
"count"] <= $data[
"contains"]) ? $data[
"count"] : $data[
"contains"];
 
 7460                         $result = $ilDB->queryF(
"SELECT test_question_id FROM tst_test_question WHERE test_fi = %s",
 
 7480                 $affectedRows = $ilDB->manipulateF(
"DELETE FROM tst_test_question WHERE test_fi = %s",
 
 7484                 $this->questions = array();
 
 7498                 $affectedRows = $ilDB->manipulateF(
"DELETE FROM tst_test_random WHERE test_fi = %s",
 
 7502                 $this->questions = array();
 
 7518                 if (strcmp($question_id, 
"") != 0)
 
 7520                         include_once 
"./Modules/TestQuestionPool/classes/class.assQuestion.php";
 
 7523                 include_once 
"./Modules/Test/classes/class.ilObjAssessmentFolder.php";
 
 7538                 $result = $ilDB->queryF(
"SELECT obj_fi FROM tst_tests WHERE test_id = %s",
 
 7545                         $object_id = 
$row[
"obj_fi"];
 
 7561                 $result = $ilDB->queryF(
"SELECT tst_tests.obj_fi FROM tst_tests, tst_active WHERE tst_tests.test_id = tst_active.test_fi AND tst_active.active_id = %s",
 
 7568                         $object_id = 
$row[
"obj_fi"];
 
 7584                 $result = $ilDB->queryF(
"SELECT test_id FROM tst_tests WHERE obj_fi = %s",
 
 7609                 if (($active_id) && ($question_id))
 
 7613                                 include_once 
"./Modules/TestQuestionPool/classes/class.assQuestion.php";
 
 7616                         $result = $ilDB->queryF(
"SELECT value1 FROM tst_solutions WHERE active_fi = %s AND question_fi = %s AND pass = %s",
 
 7617                                 array(
'integer', 
'integer', 
'integer'),
 
 7618                                 array($active_id, $question_id, 
$pass)
 
 7643                         $result = $ilDB->queryF(
"SELECT question_text FROM qpl_questions WHERE question_id = %s",
 
 7666                 $result_array = array();
 
 7670                         if (is_numeric($user_id))
 
 7672                                 $result = $ilDB->queryF(
"SELECT tst_active.active_id, tst_active.tries, usr_id, %s login, %s lastname, %s firstname, tst_invited_user.clientip, " .
 
 7673                                         "tst_active.submitted test_finished, matriculation FROM usr_data, tst_invited_user " .
 
 7674                                         "LEFT JOIN tst_active ON tst_active.user_fi = tst_invited_user.user_fi AND tst_active.test_fi = tst_invited_user.test_fi " .
 
 7675                                         "WHERE tst_invited_user.test_fi = %s and tst_invited_user.user_fi=usr_data.usr_id AND usr_data.usr_id=%s " .
 
 7677                                         array(
'text', 
'text', 
'text', 
'integer', 
'integer'),
 
 7678                                         array(
"", $this->lng->txt(
"unknown"), 
"", $this->
getTestId(), $user_id)
 
 7683                                 $result = $ilDB->queryF(
"SELECT tst_active.active_id, usr_id, %s login, %s lastname, %s firstname, tst_invited_user.clientip, " .
 
 7684                                         "tst_active.submitted test_finished, matriculation FROM usr_data, tst_invited_user " .
 
 7685                                         "LEFT JOIN tst_active ON tst_active.user_fi = tst_invited_user.user_fi AND tst_active.test_fi = tst_invited_user.test_fi " .
 
 7686                                         "WHERE tst_invited_user.test_fi = %s and tst_invited_user.user_fi=usr_data.usr_id " .
 
 7688                                         array(
'text', 
'text', 
'text', 
'integer'),
 
 7689                                         array(
"", $this->lng->txt(
"unknown"), 
"", $this->
getTestId())
 
 7695                         if (is_numeric($user_id))
 
 7697                                 $result = $ilDB->queryF(
"SELECT tst_active.active_id, tst_active.tries, usr_id, login, lastname, firstname, tst_invited_user.clientip, " .
 
 7698                                         "tst_active.submitted test_finished, matriculation FROM usr_data, tst_invited_user " .
 
 7699                                         "LEFT JOIN tst_active ON tst_active.user_fi = tst_invited_user.user_fi AND tst_active.test_fi = tst_invited_user.test_fi " .
 
 7700                                         "WHERE tst_invited_user.test_fi = %s and tst_invited_user.user_fi=usr_data.usr_id AND usr_data.usr_id=%s " .
 
 7702                                         array(
'integer', 
'integer'),
 
 7708                                 $result = $ilDB->queryF(
"SELECT tst_active.active_id, tst_active.tries, usr_id, login, lastname, firstname, tst_invited_user.clientip, " .
 
 7709                                         "tst_active.submitted test_finished, matriculation FROM usr_data, tst_invited_user " .
 
 7710                                         "LEFT JOIN tst_active ON tst_active.user_fi = tst_invited_user.user_fi AND tst_active.test_fi = tst_invited_user.test_fi " .
 
 7711                                         "WHERE tst_invited_user.test_fi = %s and tst_invited_user.user_fi=usr_data.usr_id " .
 
 7718                 $result_array = array();
 
 7721                         $result_array[
$row[
'usr_id']]= 
$row;
 
 7723                 return $result_array;
 
 7738                         $result = $ilDB->queryF(
"SELECT tst_active.active_id, tst_active.tries, tst_active.user_fi usr_id, %s login, %s lastname, %s firstname, tst_active.submitted test_finished, usr_data.matriculation, usr_data.active ".
 
 7739                                 "FROM tst_active LEFT JOIN usr_data ON tst_active.user_fi = usr_data.usr_id WHERE tst_active.test_fi = %s ORDER BY usr_data.lastname " . strtoupper($name_sort_order),
 
 7740                                 array(
'text', 
'text', 
'text', 
'integer'),
 
 7741                                 array(
"", $this->lng->txt(
"unknown"), 
"", $this->
getTestId())
 
 7746                         $result = $ilDB->queryF(
"SELECT tst_active.active_id, tst_active.tries, tst_active.user_fi usr_id, usr_data.login, usr_data.lastname, usr_data.firstname, tst_active.submitted test_finished, usr_data.matriculation, usr_data.active ".
 
 7747                                 "FROM tst_active LEFT JOIN usr_data ON tst_active.user_fi = usr_data.usr_id WHERE tst_active.test_fi = %s ORDER BY usr_data.lastname " . strtoupper($name_sort_order),
 
 7757                 foreach (
$data as $index => $participant)
 
 7759                         if (strlen(trim($participant[
"firstname"].$participant[
"lastname"])) == 0)
 
 7761                                 $data[$index][
"lastname"] = $this->lng->txt(
"deleted_user");
 
 7771                 include_once 
"./Modules/Test/classes/class.ilObjAssessmentFolder.php";
 
 7773                 if (count($scoring) == 0) 
return array();
 
 7776                 $filtered_participants = array();
 
 7777                 foreach ($participants as $active_id => $participant)
 
 7779                         $qstType_IN_manScoreableQstTypes = $ilDB->in(
'qpl_questions.question_type_fi', $scoring, 
false, 
'integer');
 
 7782                                 SELECT          tst_test_result.manual 
 7784                                 FROM            tst_test_result 
 7786                                 INNER JOIN      qpl_questions 
 7787                                 ON                      tst_test_result.question_fi = qpl_questions.question_id 
 7789                                 WHERE           tst_test_result.active_fi = %s 
 7790                                 AND                     $qstType_IN_manScoreableQstTypes 
 7794                                         $queryString, array(
"integer"), array($active_id)
 
 7804                                                 if ($participant->active) $filtered_participants[$active_id] = $participant;
 
 7807                                                 if (!$participant->active) $filtered_participants[$active_id] = $participant;
 
 7810                                                 $filtered_participants[$active_id] = $participant;
 
 7825                                                         $assessmentSetting = 
new ilSetting(
"assessment");
 
 7826                                                         $manscoring_done = $assessmentSetting->get(
"manscoring_done_" . $active_id);
 
 7827                                                         if ($manscoring_done) $filtered_participants[$active_id] = $participant;
 
 7839                                                         $assessmentSetting = 
new ilSetting(
"assessment");
 
 7840                                                         $manscoring_done = $assessmentSetting->get(
"manscoring_done_" . $active_id);
 
 7841                                                         if (!$manscoring_done) $filtered_participants[$active_id] = $participant;
 
 7849                                                         if (
$row[
"manual"]) $found++;
 
 7851                                                 if (($found > 0) && ($found < $count)) $filtered_participants[$active_id] = $participant;
 
 7854                                                 $filtered_participants[$active_id] = $participant;
 
 7859                 return $filtered_participants;
 
 7873                 if (!is_array($ids) || count($ids) ==0) 
return array();
 
 7877                         $result = $ilDB->queryF(
"SELECT usr_id, %s login, %s lastname, %s firstname, client_ip clientip FROM usr_data WHERE " . $ilDB->in(
'usr_id', $ids, 
false, 
'integer') . 
" ORDER BY login",
 
 7878                                 array(
'text', 
'text', 
'text'),
 
 7879                                 array(
"", $this->lng->txt(
"unknown"), 
"")
 
 7884                         $result = $ilDB->query(
"SELECT usr_id, login, lastname, firstname, client_ip clientip FROM usr_data WHERE " . $ilDB->in(
'usr_id', $ids, 
false, 
'integer') . 
" ORDER BY login");
 
 7887                 $result_array = array();
 
 7890                         $result_array[
$row[
"usr_id"]]= 
$row;
 
 7892                 return $result_array;
 
 7897                 if (!is_array($ids) || count($ids) ==0) 
return array();
 
 7909                 if (!is_array($ids) || count($ids) ==0) 
return array();
 
 7911                 foreach ($ids as $obj_id)
 
 7927                 include_once 
"./Modules/Group/classes/class.ilObjGroup.php";
 
 7929                 $members = $group->getGroupMemberIds();
 
 7930                 include_once 
'./Services/User/classes/class.ilObjUser.php';
 
 7931                 foreach ($members as $user_id)
 
 7946                 $members =  $rbacreview->assignedUsers($role_id,
"usr_id");
 
 7947                 include_once 
'./Services/User/classes/class.ilObjUser.php';
 
 7948                 foreach ($members as $user_id)
 
 7966                 $affectedRows = $ilDB->manipulateF(
"DELETE FROM tst_invited_user WHERE test_fi = %s AND user_fi = %s",
 
 7967                         array(
'integer', 
'integer'),
 
 7982                 $affectedRows = $ilDB->manipulateF(
"DELETE FROM tst_invited_user WHERE test_fi = %s AND user_fi = %s",
 
 7983                         array(
'integer', 
'integer'),
 
 7986                 $affectedRows = $ilDB->manipulateF(
"INSERT INTO tst_invited_user (test_fi, user_fi, clientip, tstamp) VALUES (%s, %s, %s, %s)",
 
 7987                         array(
'integer', 
'integer', 
'text', 
'integer'),
 
 7988                         array($this->
getTestId(), $user_id, (strlen($client_ip)) ? $client_ip : NULL, time())
 
 7997                 $affectedRows = $ilDB->manipulateF(
"UPDATE tst_invited_user SET clientip = %s, tstamp = %s WHERE test_fi=%s and user_fi=%s",
 
 7998                         array(
'text', 
'integer', 
'integer', 
'integer'),
 
 7999                         array((strlen($client_ip)) ? $client_ip : NULL, time(), $this->
getTestId(), $user_id)
 
 8011                 if (is_numeric($question_fi))
 
 8013                         $result = $ilDB->queryF(
"SELECT question_fi, solved FROM tst_qst_solved WHERE active_fi = %s AND question_fi=%s",
 
 8014                                 array(
'integer', 
'integer'),
 
 8015                                 array($active_id, $question_fi)
 
 8020                         $result = $ilDB->queryF(
"SELECT question_fi, solved FROM tst_qst_solved WHERE active_fi = %s",
 
 8025                 $result_array = array();
 
 8028                         $result_array[
$row[
"question_fi"]]= 
$row;
 
 8030                 return $result_array;
 
 8042                 $affectedRows = $ilDB->manipulateF(
"DELETE FROM tst_qst_solved WHERE active_fi = %s AND question_fi = %s",
 
 8043                         array(
'integer', 
'integer'),
 
 8044                         array($active_id, $question_id)
 
 8046                 $affectedRows = $ilDB->manipulateF(
"INSERT INTO tst_qst_solved (solved, question_fi, active_fi) VALUES (%s, %s, %s)",
 
 8047                         array(
'integer', 
'integer', 
'integer'),
 
 8048                         array($value, $question_id, $active_id)
 
 8060                 $affectedRows = $ilDB->manipulateF(
"UPDATE tst_active SET submitted = %s, submittimestamp = %s, tstamp = %s WHERE test_fi = %s AND user_fi = %s",
 
 8061                         array(
'integer', 
'timestamp', 
'integer', 
'integer', 
'integer'),
 
 8062                         array(1, date(
'Y-m-d H:i:s'), time(), $this->
getTestId(), $user_id)
 
 8064                 $this->testSession = NULL;
 
 8074                 $result = $ilDB->queryF(
"SELECT submitted FROM tst_active WHERE active_id=%s AND submitted=%s",
 
 8075                         array(
'integer', 
'integer'),
 
 8076                         array($active_id, 1)
 
 8078                 return $result->numRows() == 1;
 
 8089                 if (!is_numeric($user_id))
 
 8090                         $user_id = $ilUser->getId();
 
 8092                 $result = $ilDB->queryF(
"SELECT submitted FROM tst_active WHERE test_fi=%s AND user_fi=%s AND submitted=%s",
 
 8093                         array(
'integer', 
'integer', 
'integer'),
 
 8096                 return $result->numRows() == 1;
 
 8130                         "user_id" => $this->lng->txt(
"user_id"),
 
 8131                         "matriculation" =>  $this->lng->txt(
"matriculation"),
 
 8132                         "lastname" =>  $this->lng->txt(
"lastname"),
 
 8133                         "firstname" => $this->lng->txt(
"firstname"),
 
 8134                         "login" =>$this->lng->txt(
"login"),
 
 8135                         "reached_points" => $this->lng->txt(
"tst_reached_points"),
 
 8136                         "max_points" => $this->lng->txt(
"tst_maximum_points"),
 
 8137                         "percent_value" => $this->lng->txt(
"tst_percent_solved"),
 
 8138                         "mark" => $this->lng->txt(
"tst_mark"),
 
 8139                         "ects" => $this->lng->txt(
"ects_grade")
 
 8142                 if (count($participants))
 
 8144                         if ($this->ects_output)
 
 8148                         foreach ($participants as $active_id => $user_rec)
 
 8151                                 $reached_points = 0;
 
 8153                                 foreach ($this->questions as $value)
 
 8156                                         if (is_object($question))
 
 8158                                                 $max_points += $question->getMaximumPoints();
 
 8159                                                 $reached_points += $question->getReachedPoints($active_id);
 
 8162                                 if ($max_points > 0)
 
 8164                                         $percentvalue = $reached_points / $max_points;
 
 8165                                         if ($percentvalue < 0) $percentvalue = 0.0;
 
 8171                                 $mark_obj = $this->mark_schema->getMatchingMark($percentvalue * 100);
 
 8175                                         $mark = $mark_obj->getOfficialName();
 
 8176                                         $ects_mark = $this->
getECTSGrade($passed_array, $reached_points, $max_points);
 
 8180                                         $user_rec[
'firstname'] = 
"";
 
 8181                                         $user_rec[
'lastname'] = $this->lng->txt(
"unknown");
 
 8184                                         "user_id"=>$user_rec[
'usr_id'],
 
 8185                                         "matriculation" =>  $user_rec[
'matriculation'],
 
 8186                                         "lastname" =>  $user_rec[
'lastname'],
 
 8187                                         "firstname" => $user_rec[
'firstname'],
 
 8188                                         "login"=>$user_rec[
'login'],
 
 8189                                         "reached_points" => $reached_points,
 
 8190                                         "max_points" => $max_points,
 
 8191                                         "percent_value" => $percentvalue,
 
 8193                                         "ects" => $ects_mark
 
 8213                 $resultarray = array();
 
 8214                 foreach (
$row as $rowindex => $entry)
 
 8221                         if (strpos($entry, 
"\"") !== FALSE)
 
 8223                                 $entry = str_replace(
"\"", 
"\"\"", $entry);
 
 8231                         $entry = str_replace(chr(13).chr(10), chr(10), $entry);
 
 8235                             $entry = 
"\"" . $entry . 
"\"";
 
 8238                         $resultarray[$rowindex] = $entry;
 
 8240                 return $resultarray;
 
 8254                 $result = $ilDB->queryF(
"SELECT tries FROM tst_active WHERE active_id = %s",
 
 8261                         return $row[
"tries"];
 
 8281                         $result = $ilDB->queryF(
"SELECT MAX(pass) maxpass FROM tst_test_result WHERE active_fi = %s",
 
 8288                                 $max = 
$row[
"maxpass"];
 
 8311                 $result = $ilDB->queryF(
"SELECT * FROM tst_pass_result WHERE active_fi = %s",
 
 8321                                 if(
$row[
"maxpoints"] > 0)
 
 8323                                         $factor = 
$row[
"points"] / 
$row[
"maxpoints"];
 
 8330                                 if($factor > $bestfactor)
 
 8333                                         $bestfactor = $factor;
 
 8336                         if (is_array($bestrow))
 
 8338                                 return $bestrow[
"pass"];
 
 8361                 $counted_pass = NULL;
 
 8370                 return $counted_pass;
 
 8388                 include_once 
"./Modules/TestQuestionPool/classes/class.assQuestion.php";
 
 8390                 foreach ($this->questions as $value)
 
 8394                                 $workedthrough += 1;
 
 8397                 return $workedthrough;
 
 8413                 $result = $ilDB->queryF(
"SELECT tst_test_result.tstamp FROM tst_test_result WHERE active_fi = %s AND pass = %s ORDER BY tst_test_result.tstamp DESC",
 
 8414                         array(
'integer', 
'integer'),
 
 8415                         array($active_id, 
$pass)
 
 8420                         return $row[
"tstamp"];
 
 8438                         "executable" => 
true,
 
 8439                         "errormessage" => 
"" 
 8443                         $result[
"executable"] = 
false;
 
 8449                         $result[
"executable"] = 
false;
 
 8478                                                         $result[
"executable"] = 
false;
 
 8479                                                         $result[
"errormessage"] = $this->lng->txt(
"detail_max_processing_time_reached");
 
 8489                         $result[
"executable"] = 
false;
 
 8490                         $result[
"errormessage"] = $this->lng->txt(
"maximum_nr_of_tries_reached");
 
 8509                         if (preg_match(
"/(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})/", $this->
getReportingDate(), $matches))
 
 8511                                 $epoch_time = mktime($matches[4], $matches[5], $matches[6], $matches[2], $matches[3], $matches[1]);
 
 8513                                 if ($now < $epoch_time)
 
 8529                 $notimeleft = FALSE;
 
 8554                                 if (preg_match(
"/(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})/", $this->
getReportingDate(), $matches))
 
 8556                                         $epoch_time = mktime($matches[4], $matches[5], $matches[6], $matches[2], $matches[3], $matches[1]);
 
 8558                                         if ($now < $epoch_time)
 
 8583                 if ($active_id < 1) 
return FALSE;
 
 8585                 $result = $ilDB->queryF(
"SELECT tst_times.started FROM tst_times WHERE tst_times.active_fi = %s AND tst_times.pass = %s ORDER BY tst_times.started",
 
 8586                         array(
'integer', 
'integer'),
 
 8587                         array($active_id, 
$pass)
 
 8592                         if (preg_match(
"/(\d{4})-(\d{2})-(\d{2}) (\d{2}):(\d{2}):(\d{2})/", 
$row[
"started"], $matches))
 
 8594                                 return mktime($matches[4], $matches[5], $matches[6], $matches[2], $matches[3], $matches[1]);
 
 8642                                                 questtypes.type_tag, 
 8644                                                 tstquest.obligatory, 
 8645                                                 origquest.obj_fi orig_obj_fi 
 8647                         FROM            qpl_questions questions 
 8649                         INNER JOIN      qpl_qst_type questtypes 
 8650                         ON                      questtypes.question_type_id = questions.question_type_fi 
 8652                         INNER JOIN      tst_test_question tstquest 
 8653                         ON                      tstquest.question_fi = questions.question_id 
 8655                         LEFT JOIN       qpl_questions origquest 
 8656                         ON                      origquest.question_id = questions.original_id 
 8658                         WHERE           tstquest.test_fi = %s 
 8660                         ORDER BY        tstquest.sequence 
 8663                 $query_result = $ilDB->queryF(
 
 8669                 while (
$row = $ilDB->fetchAssoc($query_result))
 
 8689                 return ($this->shuffle_questions) ? 1 : 0;
 
 8700                 $this->shuffle_questions = ($a_shuffle) ? 1 : 0;
 
 8717                 return ($this->show_summary) ? $this->show_summary : 0;
 
 8734                 $this->show_summary = $a_value;
 
 8745                 if (($this->show_summary & 1) > 0)
 
 8765                         $this->show_summary = 1;
 
 8769                         $this->show_summary = 0;
 
 8781                 if (($this->show_summary & 2) > 0)
 
 8801                         $this->show_summary = $this->show_summary | 2;
 
 8807                                 $this->show_summary = $this->show_summary ^ 2;
 
 8820                 if (($this->show_summary & 4) > 0)
 
 8840                         $this->show_summary = $this->show_summary | 4;
 
 8846                                 $this->show_summary = $this->show_summary ^ 4;
 
 8859                         if (($this->show_summary & 8) > 0)
 
 8879                                 $this->show_summary = $this->show_summary | 8;
 
 8885                                         $this->show_summary = $this->show_summary ^ 8;
 
 8898                 return ($this->results_presentation) ? $this->results_presentation : 0;
 
 8909                 if (($this->results_presentation & 1) > 0)
 
 8927                 if (($this->results_presentation & 2) > 0)
 
 8945                 if (($this->results_presentation & 4) > 0)
 
 8963                 if (($this->results_presentation & 8) > 0)
 
 8981                         if (($this->results_presentation & 16) > 0)
 
 8999                         if (($this->results_presentation & 32) > 0)
 
 9015                 if (($this->results_presentation & 64) > 0)
 
 9033                 $this->results_presentation = $a_results_presentation;
 
 9048                         $this->results_presentation = $this->results_presentation | 1;
 
 9054                                 $this->results_presentation = $this->results_presentation ^ 1;
 
 9069                         $this->results_presentation = $this->results_presentation | 2;
 
 9075                                 $this->results_presentation = $this->results_presentation ^ 2;
 
 9101                         $this->results_presentation = $this->results_presentation | 4;
 
 9107                                 $this->results_presentation = $this->results_presentation ^ 4;
 
 9122                         $this->results_presentation = $this->results_presentation | 8;
 
 9128                                 $this->results_presentation = $this->results_presentation ^ 8;
 
 9143                                 $this->results_presentation = $this->results_presentation | 16;
 
 9149                                         $this->results_presentation = $this->results_presentation ^ 16;
 
 9164                                 $this->results_presentation = $this->results_presentation | 32;
 
 9170                                         $this->results_presentation = $this->results_presentation ^ 32;
 
 9185                         $this->results_presentation = $this->results_presentation | 64;
 
 9191                                 $this->results_presentation = $this->results_presentation ^ 64;
 
 9204                 $codestring = 
"0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
 
 9207                 for ($i = 1; $i <=5; $i++)
 
 9209                         $index = mt_rand(0, strlen($codestring)-1);
 
 9210                         $code .= substr($codestring, $index, 1);
 
 9228                 $result = $ilDB->queryF(
"SELECT anonymous_id FROM tst_active WHERE test_fi = %s AND anonymous_id = %s",
 
 9229                         array(
'integer', 
'text'),
 
 9232                 return (
$result->numRows() > 0) ? 
true : 
false;
 
 9238                 $result = $ilDB->queryF(
"SELECT user_fi FROM tst_active WHERE active_id = %s",
 
 9245                         return $row[
"user_fi"];
 
 9256                 if (!is_array(
$_SESSION[
"tst_access_code"]))
 
 9262                         return $_SESSION[
"tst_access_code"][
"$id"];
 
 9269                 if (!is_array(
$_SESSION[
"tst_access_code"]))
 
 9273                 $_SESSION[
"tst_access_code"][
"$id"] = $access_code;
 
 9279                 unset(
$_SESSION[
"tst_access_code"][
"$id"]);
 
 9284                 return ($this->allowedUsers) ? $this->allowedUsers : 0;
 
 9289                 $this->allowedUsers = $a_allowed_users;
 
 9294                 return ($this->allowedUsersTimeGap) ? $this->allowedUsersTimeGap : 0;
 
 9299                 $this->allowedUsersTimeGap = $a_allowed_users_time_gap;
 
 9308                 if (($nr_of_users > 0) && ($time_gap > 0))
 
 9311                         $time_border = $now - $time_gap;
 
 9312                         $str_time_border = strftime(
"%Y%m%d%H%M%S", $time_border);
 
 9313                         $result = $ilDB->queryF(
"SELECT DISTINCT tst_times.active_fi FROM tst_times, tst_active WHERE tst_times.tstamp > %s AND tst_times.active_fi = tst_active.active_id AND tst_active.test_fi = %s",
 
 9314                                 array(
'integer', 
'integer'),
 
 9317                         if (
$result->numRows() >= $nr_of_users)
 
 9319                                 include_once 
"./Modules/Test/classes/class.ilObjAssessmentFolder.php";
 
 9338                 $result = $ilDB->queryF(
"SELECT finished FROM tst_times WHERE active_fi = %s ORDER BY finished DESC",
 
 9345                         return $row[
"finished"];
 
 9359                 if (preg_match(
"/<[^>]*?>/", $a_text))
 
 9379                 for ($i = 0; $i < $a_material->getMaterialCount(); $i++)
 
 9381                         $material = $a_material->getMaterial($i);
 
 9382                         if (strcmp($material[
"type"], 
"mattext") == 0)
 
 9384                                 $result .= $material[
"material"]->getContent();
 
 9386                         if (strcmp($material[
"type"], 
"matimage") == 0)
 
 9388                                 $matimage = $material[
"material"];
 
 9389                                 if (preg_match(
"/(il_([0-9]+)_mob_([0-9]+))/", $matimage->getLabel(), $matches))
 
 9392                                         if (!is_array(
$_SESSION[
"import_mob_xhtml"])) 
$_SESSION[
"import_mob_xhtml"] = array();
 
 9393                                         array_push(
$_SESSION[
"import_mob_xhtml"], array(
"mob" => $matimage->getLabel(), 
"uri" => $matimage->getUri()));
 
 9398                 $ilLog->write(print_r(
$_SESSION[
"import_mob_xhtml"], 
true));
 
 9412                 include_once 
"./Services/RTE/classes/class.ilRTE.php";
 
 9413                 include_once(
"./Services/MediaObjects/classes/class.ilObjMediaObject.php");
 
 9415                 $a_xml_writer->xmlStartTag(
"material");
 
 9417                         "texttype" => 
"text/plain" 
 9419                 if ($this->
isHTML($a_material))
 
 9421                         $attrs[
"texttype"] = 
"text/xhtml";
 
 9426                 foreach (
$mobs as $mob)
 
 9428                         $moblabel = 
"il_" . IL_INST_ID . 
"_mob_" . $mob;
 
 9429                         if (strpos($a_material, 
"mm_$mob") !== FALSE)
 
 9435                                                 "label" => $moblabel,
 
 9436                                                 "uri" => 
"objects/" . 
"il_" . IL_INST_ID . 
"_mob_" . $mob . 
"/" . $mob_obj->getTitle()
 
 9439                                 $a_xml_writer->xmlElement(
"matimage", $imgattrs, NULL);
 
 9442                 $a_xml_writer->xmlEndTag(
"material");
 
 9453                 include_once 
"./Services/Utilities/classes/class.ilUtil.php";
 
 9467                 $affectedRows = $ilDB->manipulateF(
"UPDATE tst_tests SET certificate_visibility = %s, tstamp = %s WHERE test_id = %s",
 
 9468                         array(
'text', 
'integer', 
'integer'),
 
 9469                         array($a_value, time(), $this->
getTestId())
 
 9481                 return (strlen($this->certificate_visibility)) ? $this->certificate_visibility : 0;
 
 9492                 $this->certificate_visibility = $a_value;
 
 9503                 return ($this->anonymity) ? 1 : 0;
 
 9517                                 $this->anonymity = 1;
 
 9520                                 $this->anonymity = 0;
 
 9533                 return ($this->show_cancel) ? 1 : 0;
 
 9547                                 $this->show_cancel = 1;
 
 9550                                 $this->show_cancel = 0;
 
 9563                 return ($this->show_marker) ? 1 : 0;
 
 9577                                 $this->show_marker = 1;
 
 9580                                 $this->show_marker = 0;
 
 9593                 return ($this->fixed_participants) ? 1 : 0;
 
 9607                                 $this->fixed_participants = 1;
 
 9610                                 $this->fixed_participants = 0;
 
 9626                 $result = $ilDB->queryF(
"SELECT anonymity FROM tst_tests WHERE obj_fi = %s",
 
 9632                         return $row[
'anonymity'];
 
 9648                 $result = $ilDB->queryF(
"SELECT tst_tests.random_test FROM tst_tests, tst_active WHERE tst_active.active_id = %s AND tst_active.test_fi = tst_tests.test_id",
 
 9654                         return $row[
'random_test'];
 
 9671                         return $this->lng->txt(
"unknown") . $suffix;
 
 9675                         include_once 
'./Services/User/classes/class.ilObjUser.php';
 
 9677                         if (strlen($uname[
"firstname"].$uname[
"lastname"]) == 0) $uname[
"firstname"] = $this->lng->txt(
"deleted_user");
 
 9680                                 return trim($uname[
"lastname"] . 
", " . $uname[
"firstname"]) .  $suffix;
 
 9684                                 return trim($uname[
"firstname"] . 
" " . $uname[
"lastname"]) .  $suffix;
 
 9700                         return $this->lng->txt(
"tst_start_test");
 
 9702                 $active_pass = $this->
_getPass($active_id);
 
 9706                         if ($active_pass == 0)
 
 9708                                 return $this->lng->txt(
"tst_start_test");
 
 9712                                 return $this->lng->txt(
"tst_start_new_test_pass");
 
 9717                         return $this->lng->txt(
"tst_resume_test");
 
 9734                 $result = $ilDB->queryF(
"SELECT * FROM tst_test_defaults WHERE user_fi = %s ORDER BY $sortby $sortorder",
 
 9736                         array($ilUser->getId())
 
 9738                 $defaults = array();
 
 9741                         $defaults[
$row[
"test_defaults_id"]] = 
$row;
 
 9762                 $result = $ilDB->queryF(
"SELECT * FROM tst_test_defaults WHERE test_defaults_id = %s",
 
 9764                         array($test_defaults_id)
 
 9786                 $affectedRows = $ilDB->manipulateF(
"DELETE FROM tst_test_defaults WHERE test_defaults_id = %s",
 
 9788                         array($test_default_id)
 
 9802                 $testsettings = array(
 
 9865                 $next_id = $ilDB->nextId(
'tst_test_defaults');
 
 9866                 $affectedRows = $ilDB->manipulateF(
"INSERT INTO tst_test_defaults (test_defaults_id, name, user_fi, defaults, marks, tstamp) VALUES (%s, %s, %s, %s, %s, %s)",
 
 9867                         array(
'integer', 
'text', 
'integer', 
'text', 
'text', 
'integer'),
 
 9868                         array($next_id, $a_name, $ilUser->getId(), serialize($testsettings), serialize($this->mark_schema), time())
 
 9881                 $testsettings = unserialize($test_defaults[
"defaults"]);
 
 9882                 include_once 
"./Modules/Test/classes/class.assMarkSchema.php";
 
 9883                 $this->mark_schema = unserialize($test_defaults[
"marks"]);
 
 9913                 $this->
setKiosk($testsettings[
"Kiosk"]);
 
 9916                 $this->
setECTSFX($testsettings[
"ECTSFX"]);
 
 9960                 if (extension_loaded(
"tidy"))
 
 9964                                 "output-xml"     => 
true,
 
 9965                                 "numeric-entities" => 
true 
 9968                         $tidy->parseString($print_output, $config, 
'utf8');
 
 9969                         $tidy->cleanRepair();
 
 9970                         $print_output = tidy_get_output($tidy);
 
 9971                         $print_output = preg_replace(
"/^.*?(<html)/", 
"\\1", $print_output);
 
 9975                         $print_output = str_replace(
" ", 
" ", $print_output);
 
 9976                         $print_output = str_replace(
"⊗", 
"X", $print_output);
 
 9978                 $xsl = file_get_contents(
"./Modules/Test/xml/question2fo.xsl");
 
 9982                                 'font-family="Helvetica, unifont"',
 
 9983                                 'font-family="'.
$GLOBALS[
'ilSetting']->
get(
'rpc_pdf_font',
'Helvetica, unifont').
'"',
 
 9987                 $args = array( 
'/_xml' => $print_output, 
'/_xsl' => $xsl );
 
 9990                 $output = 
xslt_process($xh, 
"arg:/_xml", 
"arg:/_xsl", NULL, $args, $params);
 
10004                 $content = preg_replace(
"/href=\".*?\"/", 
"", $content);
 
10005                 $printbody = 
new ilTemplate(
"tpl.il_as_tst_print_body.html", TRUE, TRUE, 
"Modules/Test");
 
10007                 $printbody->setVariable(
"ADM_CONTENT", $content);
 
10008                 $printbody->setCurrentBlock(
"css_file");
 
10010                 $printbody->parseCurrentBlock();
 
10011                 $printbody->setCurrentBlock(
"css_file");
 
10013                 $printbody->parseCurrentBlock();
 
10014                 $printoutput = $printbody->get();
 
10015                 $html = str_replace(
"href=\"./", 
"href=\"" . ILIAS_HTTP_PATH . 
"/", $printoutput);
 
10016                 $html = preg_replace(
"/<div id=\"dontprint\">.*?<\\/div>/ims", 
"", $html);
 
10017                 if (extension_loaded(
"tidy"))
 
10021                                 "output-xml"     => 
true,
 
10022                                 "numeric-entities" => 
true 
10024                         $tidy = 
new tidy();
 
10025                         $tidy->parseString($html, $config, 
'utf8');
 
10026                         $tidy->cleanRepair();
 
10027                         $html = tidy_get_output($tidy);
 
10028                         $html = preg_replace(
"/^.*?(<html)/", 
"\\1", $html);
 
10032                         $html = str_replace(
" ", 
" ", $html);
 
10033                         $html = str_replace(
"⊗", 
"X", $html);
 
10035                 $html = preg_replace(
"/src=\".\\//ims", 
"src=\"" . ILIAS_HTTP_PATH . 
"/", $html);
 
10037                 $html = preg_replace(
'/&(?!([\w]+?;|#[\d]+?;))/', 
'&', $html);
 
10039                 if( $fo === 
false )
 
10042                         $ilLog->write(__METHOD__.
': could not process HTML to FO: '.$html);
 
10043                         $ilias->raiseError(__METHOD__.
': could not process HTML to FO: '.htmlentities($html));
 
10058                 include_once 
"./Services/Utilities/classes/class.ilUtil.php";
 
10060                 $fp = fopen($fo_file, 
"w"); fwrite($fp, $fo); fclose($fp);
 
10062                 include_once 
'./Services/WebServices/RPC/classes/class.ilRpcClientFactory.php';
 
10072                         $ilLog->write(__METHOD__.
': '.$e->getMessage());
 
10077                         $ilLog->write(__METHOD__.
': '.$e->getMessage());
 
10104                 $result = $ilDB->queryF(
"SELECT feedback FROM tst_manual_fb WHERE active_fi = %s AND question_fi = %s AND pass = %s",
 
10105                         array(
'integer', 
'integer', 
'integer'),
 
10106                         array($active_id, $question_id, 
$pass)
 
10111                         include_once(
"./Services/RTE/classes/class.ilRTE.php");
 
10127         function saveManualFeedback($active_id, $question_id, 
$pass, $feedback)
 
10131                 $affectedRows = $ilDB->manipulateF(
"DELETE FROM tst_manual_fb WHERE active_fi = %s AND question_fi = %s AND pass = %s",
 
10132                         array(
'integer', 
'integer', 
'integer'),
 
10133                         array($active_id, $question_id, 
$pass)
 
10136                 if (strlen($feedback))
 
10138                         $next_id = $ilDB->nextId(
'tst_manual_fb');
 
10141                         $result = $ilDB->insert(
'tst_manual_fb', array(
 
10142                                                                                                            'manual_feedback_id'         => array( 
'integer',    $next_id ),
 
10143                                                                                                            'active_fi'                          => array( 
'integer',    $active_id ),
 
10144                                                                                                            'question_fi'                        => array( 
'integer',    $question_id ),
 
10145                                                                                                            'pass'                                       => array( 
'integer',    
$pass),
 
10147                                                                                                            'tstamp'                                     => array( 
'integer',    time() ),
 
10151                         include_once (
"./Modules/Test/classes/class.ilObjAssessmentFolder.php");
 
10155                                 include_once 
"./Modules/Test/classes/class.ilObjTestAccess.php";
 
10157                                 include_once 
"./Modules/TestQuestionPool/classes/class.assQuestion.php";
 
10164                         $ilias->raiseError(
$result->getMessage());
 
10182                 if (strcmp(
$_GET[
"tst_javascript"], 
"0") == 0) 
return FALSE;
 
10184                 $assessmentSetting = 
new ilSetting(
"assessment");
 
10185                 return ($ilUser->getPref(
"tst_javascript") === FALSE) ? $assessmentSetting->get(
"use_javascript") : $ilUser->getPref(
"tst_javascript");
 
10198                 include_once 
"./Modules/Test/classes/class.ilTestSession.php";
 
10217                 $this->test_id = $a_id;
 
10229                 if (is_object($this->testSession) && ($this->testSession->getActiveId() > 0)) 
return $this->testSession;
 
10233                 include_once 
"./Modules/Test/classes/class.ilTestSession.php";
 
10235                 if ($active_id > 0)
 
10258                 if (is_object($this->testSession) && ($this->testSession->getActiveId() > 0)) 
return $this->testSession;
 
10264                 include_once 
"./Modules/Test/classes/class.ilTestSequence.php";
 
10266                 if (!$this->testSequence->hasSequence())
 
10268                         $this->testSequence->createNewSequence($this->
getQuestionCount(), $shuffle);
 
10269                         $this->testSequence->saveToDb();
 
10280                 if (is_object($this->testSequence) && ($this->testSequence->getActiveId() > 0)) 
return $this->testSequence;
 
10282                 include_once 
"./Modules/Test/classes/class.ilTestSequence.php";
 
10283                 if (($active_id > 0) && (strlen(
$pass)))
 
10299                         foreach (
$result as $sequence => $question)
 
10301                                 if (is_numeric($sequence))
 
10303                                         if ($question[
"reached"] == $question[
"max"])
 
10324                 if (count($participants))
 
10326                         foreach ($participants as $active_id => $user_rec)
 
10329                                 $reached_points = 0;
 
10331                                 foreach ($this->questions as $value)
 
10334                                         if (is_object($question))
 
10336                                                 $max_points += $question->getMaximumPoints();
 
10337                                                 $reached_points += $question->getReachedPoints($active_id);
 
10338                                                 if ($max_points > 0)
 
10340                                                         $percentvalue = $reached_points / $max_points;
 
10341                                                         if ($percentvalue < 0) $percentvalue = 0.0;
 
10349                                                         $user_rec[
'firstname'] = 
"";
 
10350                                                         $user_rec[
'lastname'] = $this->lng->txt(
"unknown");
 
10353                                                         "user_id"=>$user_rec[
'usr_id'],
 
10354                                                         "matriculation" =>  $user_rec[
'matriculation'],
 
10355                                                         "lastname" =>  $user_rec[
'lastname'],
 
10356                                                         "firstname" => $user_rec[
'firstname'],
 
10357                                                         "login"=>$user_rec[
'login'],
 
10358                                                         "question_id" => $question->getId(),
 
10359                                                         "question_title" => $question->getTitle(),
 
10360                                                         "reached_points" => $reached_points,
 
10361                                                         "max_points" => $max_points
 
10378                 $result = $ilDB->queryF(
"SELECT t.obj_fi obj_id FROM tst_test_question q, tst_tests t WHERE q.test_fi = t.test_id AND q.question_fi = %s",
 
10382                 $rec = $ilDB->fetchAssoc(
$result);
 
10383                 return $rec[
"obj_id"];
 
10394                 global $ilPluginAdmin;
 
10395                 if ($ilPluginAdmin->isActive(
IL_COMP_MODULE, 
"TestQuestionPool", 
"qst", $a_pname))
 
10409                 $result = $ilDB->queryF(
"SELECT passed FROM tst_result_cache WHERE active_fi = %s",
 
10416                         return $row[
'passed'];
 
10421                         $result_array =& $this->
getTestResult($active_id, $counted_pass);
 
10422                         return $result_array[
"test"][
"passed"];
 
10435                         include_once 
"./Services/Certificate/classes/class.ilCertificate.php";
 
10436                         include_once 
"./Modules/Test/classes/class.ilTestCertificateAdapter.php";
 
10438                         if ($cert->isComplete())
 
10486                         SELECT tst_test_result.active_fi, tst_test_result.question_fi, tst_test_result.pass  
10487                         FROM tst_test_result, tst_active, qpl_questions  
10488                         WHERE tst_active.active_id = tst_test_result.active_fi  
10489                         AND tst_active.test_fi = %s  
10490                         AND tst_test_result.question_fi = qpl_questions.question_id  
10491                         AND tst_test_result.question_fi = %s";
 
10494                         array(
'integer', 
'integer'),
 
10497                 $foundusers = array();
 
10500                         if (!array_key_exists(
$row[
"active_fi"], $foundusers))
 
10502                                 $foundusers[
$row[
"active_fi"]] = array();
 
10504                         array_push($foundusers[
$row[
"active_fi"]], array(
"pass" => $row[
"pass"], 
"qid" => $row[
"question_fi"]));
 
10506                 return $foundusers;
 
10518                 include_once 
'./Services/WebServices/RPC/classes/class.ilRPCServerSettings.php';
 
10537                 $foundParticipants =& 
$data->getParticipants();
 
10538                 $results = array(
"overview" => array(), 
"questions" => array());
 
10539                 if (count($foundParticipants)) 
 
10541                         $results[
"overview"][$this->lng->txt(
"tst_eval_total_persons")] = count($foundParticipants);
 
10543                         $results[
"overview"][$this->lng->txt(
"tst_eval_total_finished")] = $total_finished;
 
10545                         $diff_seconds = $average_time;
 
10546                         $diff_hours    = floor($diff_seconds/3600);
 
10547                         $diff_seconds -= $diff_hours   * 3600;
 
10548                         $diff_minutes  = floor($diff_seconds/60);
 
10549                         $diff_seconds -= $diff_minutes * 60;
 
10550                         $results[
"overview"][$this->lng->txt(
"tst_eval_total_finished_average_time")] = sprintf(
"%02d:%02d:%02d", $diff_hours, $diff_minutes, $diff_seconds);
 
10552                         $total_passed_reached = 0;
 
10553                         $total_passed_max = 0;
 
10554                         $total_passed_time = 0;
 
10555                         foreach ($foundParticipants as $userdata)
 
10557                                 if ($userdata->getPassed()) 
 
10560                                         $total_passed_reached += $userdata->getReached();
 
10561                                         $total_passed_max += $userdata->getMaxpoints();
 
10562                                         $total_passed_time += $userdata->getTimeOfWork();
 
10565                         $average_passed_reached = $total_passed ? $total_passed_reached / $total_passed : 0;
 
10566                         $average_passed_max = $total_passed ? $total_passed_max / $total_passed : 0;
 
10567                         $average_passed_time = $total_passed ? $total_passed_time / $total_passed : 0;
 
10568                         $results[
"overview"][$this->lng->txt(
"tst_eval_total_passed")] = $total_passed;
 
10569                         $results[
"overview"][$this->lng->txt(
"tst_eval_total_passed_average_points")] = sprintf(
"%2.2f", $average_passed_reached) . 
" " . strtolower($this->lng->txt(
"of")) . 
" " . sprintf(
"%2.2f", $average_passed_max);
 
10570                         $average_time = $average_passed_time;
 
10571                         $diff_seconds = $average_time;
 
10572                         $diff_hours    = floor($diff_seconds/3600);
 
10573                         $diff_seconds -= $diff_hours   * 3600;
 
10574                         $diff_minutes  = floor($diff_seconds/60);
 
10575                         $diff_seconds -= $diff_minutes * 60;
 
10576                         $results[
"overview"][$this->lng->txt(
"tst_eval_total_passed_average_time")] = sprintf(
"%02d:%02d:%02d", $diff_hours, $diff_minutes, $diff_seconds);
 
10579                 foreach (
$data->getQuestionTitles() as $question_id => $question_title)
 
10584                         foreach ($foundParticipants as $userdata)
 
10586                                 for ($i = 0; $i <= $userdata->getLastPass(); $i++)
 
10588                                         if (is_object($userdata->getPass($i)))
 
10590                                                 $question =& $userdata->getPass($i)->getAnsweredQuestionByQuestionId($question_id);
 
10591                                                 if (is_array($question))
 
10594                                                         $reached += $question[
"reached"];
 
10595                                                         $max += $question[
"points"];
 
10600                         $percent = $max ? $reached/$max * 100.0 : 0;
 
10602                         $results[
"questions"][$question_id] = array(
 
10604                                 sprintf(
"%.2f", $answered ? $reached / $answered : 0) . 
" " . strtolower($this->lng->txt(
"of")) . 
" " . sprintf(
"%.2f", $answered ? $max / $answered : 0),
 
10605                                 sprintf(
"%.2f", $percent) . 
"%",
 
10607                                 sprintf(
"%.2f", $answered ? $reached / $answered : 0),
 
10608                                 sprintf(
"%.2f", $answered ? $max / $answered : 0),
 
10620                 include_once(
"./Modules/Test/classes/class.ilTestExport.php");
 
10622                 return $test_exp->buildExportFile();
 
10640                 $this->mailnotification = $a_notification;
 
10645                 include_once 
"./Modules/Test/classes/class.ilTestMailNotification.php";
 
10650                 $mail->sendSimpleNotification($owner_id, $this->
getTitle(), $usr_data);
 
10660                 include_once 
"./Modules/Test/classes/class.ilObjTestGUI.php";
 
10661                 include_once 
"./Modules/Test/classes/tables/class.ilEvaluationAllTableGUI.php";
 
10663                 return $table_gui->getSelectedColumns();
 
10668                 include_once 
"./Modules/Test/classes/class.ilTestMailNotification.php";
 
10674                 include_once 
"./Modules/Test/classes/class.ilTestExport.php";
 
10676                 $file = $exportObj->exportToExcel($deliver = FALSE, 
'active_id', $active_id, $passedonly = FALSE);
 
10677                 include_once 
"./Services/Mail/classes/class.ilFileDataMail.php";
 
10679                 $fd->copyAttachmentFile(
$file, 
"result_" . $active_id . 
".xls");
 
10680                 $file_names[] = 
"result_" . $active_id . 
".xls";
 
10682                 $mail->sendAdvancedNotification($owner_id, $this->
getTitle(), $usr_data, $file_names);
 
10684                 if(count($file_names))
 
10686                         $fd->unlinkFiles($file_names);
 
10697                 $query = 
"SELECT usr_id FROM usr_data";
 
10701                         $activequery = sprintf(
"SELECT user_fi FROM tst_active WHERE test_fi = %s AND user_fi = %s",
 
10702                                 $ilDB->quote($this->getTestId()),
 
10703                                 $ilDB->quote(
$data[
'usr_id'])
 
10705                         $activeresult = $ilDB->query($activequery);
 
10706                         if ($activeresult->numRows() == 0)
 
10708                                 $user_id = 
$data[
'usr_id'];
 
10709                                 if ($user_id != 13)
 
10711                                         include_once 
"./Modules/Test/classes/class.ilTestSession.php";
 
10719                                         $nr_of_passes = rand(1, $passes);
 
10723                                                 include_once 
"./Modules/Test/classes/class.ilTestSequence.php";
 
10730                                                 for ($seq = 1; $seq <= count($this->questions); $seq++)
 
10732                                                         $question_id = 
$testSequence->getQuestionForSequence($seq);
 
10736                                                 if (
$pass < $nr_of_passes - 1)
 
10748                                         if ($number == 0) 
return;
 
10760                         FROM            tst_result_cache 
10761                         WHERE           active_fi = %s 
10765                         $query, array(
'integer'), array($active_id)
 
10770                         include_once 
"./Modules/TestQuestionPool/classes/class.assQuestion.php";
 
10776                                 FROM            tst_result_cache 
10777                                 WHERE           active_fi = %s 
10781                                 $query, array(
'integer'), array($active_id)
 
10793                 if ($this->mailnottype == 1)
 
10807                         $this->mailnottype = 1;
 
10811                         $this->mailnottype = 0;
 
10817                 if ($this->exportsettings)
 
10831                         $this->exportsettings = $a_settings;
 
10835                         $this->exportsettings = 0;
 
10841                 if (($this->exportsettings & 1) > 0)
 
10855                         $this->exportsettings = $this->exportsettings | 1;
 
10861                                 $this->exportsettings = $this->exportsettings ^ 1;
 
10867             return $this->enabled_view_mode;
 
10871             $this->enabled_view_mode = $mode;
 
10883             $new_array = array();
 
10886             $query = 
'SELECT question_fi  FROM tst_test_question WHERE test_fi = %s';
 
10887             $types = array(
'integer');
 
10890             $new_question_id += 1;
 
10894             $res = $ilDB->queryF(
$query, $types, $values);
 
10895             while(
$row = $ilDB->fetchAssoc(
$res)) {
 
10897                 $qid = 
$row[
'question_fi'];
 
10899                 if ($qid == $new_question_id) {
 
10902                 else if ($qid == $previous_question_id) {
 
10903                     $new_array[$position++] = $qid;
 
10904                     $new_array[$position++] =  $new_question_id;
 
10908                     $new_array[$position++] = $qid;
 
10912             $update_query = 
'UPDATE tst_test_question SET sequence = %s WHERE test_fi = %s AND question_fi = %s';
 
10913             $update_types = array(
'integer', 
'integer', 
'integer');
 
10915             foreach($new_array as $position => $qid) {
 
10916                 $ilDB->manipulateF(
 
10929                         if (is_array($options))
 
10945                 'pass_details' => 
'setShowPassDetails',
 
10946                 'solution_details' => 
'setShowSolutionDetails',
 
10947                 'solution_printview' => 
'setShowSolutionPrintview',
 
10948                 'solution_feedback' => 
'setShowSolutionFeedback',
 
10949                 'solution_answers_only' => 
'setShowSolutionAnswersOnly',
 
10950                 'solution_signature' => 
'setShowSolutionSignature',
 
10951                 'solution_suggested' => 
'setShowSolutionSuggested',
 
10953             foreach($setter as $key => $setter) {
 
10954                 if (in_array($key, $options)) {
 
10968             $this->poolUsage = (boolean)$usage;
 
10979             foreach($orders as 
$id => $position)
 
10984                                 isset($obligations[
$id]) && $obligations[
$id] ? 1 : 0
 
10988                                 UPDATE          tst_test_question 
10991                                 WHERE           question_fi = %s 
10994                         $ilDB->manipulateF(
 
10995                                 $query, array(
'integer', 
'integer', 
'integer'), array($i, $obligatory, $id)
 
11005             if ($question_before) {
 
11006                 $query = 
'SELECT sequence, test_fi FROM tst_test_question WHERE question_fi = %s';
 
11007                 $types = array(
'integer');
 
11008                 $values = array($question_before);
 
11009                 $rset = $ilDB->queryF(
$query, $types, $values);
 
11012             if (!$question_before || ($rset && !(
$row = $ilDB->fetchAssoc($rset)))) {
 
11019             $update = 
'UPDATE tst_test_question SET sequence = sequence + 1 WHERE sequence > %s AND test_fi = %s';
 
11020             $types = array(
'integer', 
'integer');
 
11021             $values = array(
$row[
'sequence'], 
$row[
'test_fi']);
 
11022             $ilDB->manipulateF($update, $types, $values);
 
11024             $update = 
'UPDATE tst_test_question SET sequence = %s WHERE question_fi = %s';
 
11025             $types = array(
'integer', 
'integer');
 
11026             $values = array(
$row[
'sequence'] + 1, $question_to_move);
 
11027             $ilDB->manipulateF($update, $types, $values);
 
11034             $query = 
'SELECT count(question_id) cnt FROM qpl_questions'.
 
11035                         ' INNER JOIN object_data on obj_fi = obj_id'.
 
11036                         ' WHERE type <> '.$ilDB->quote(
'qpl', 
'text').
 
11037                         ' AND '.$ilDB->in(
'question_id', array_keys(
$questions), 
false, 
'integer');
 
11039             $rset = $ilDB->query(
$query);
 
11041             if (
$row = $ilDB->fetchAssoc($rset)) {
 
11042                 return $row[
'cnt'] > 0;
 
11057                 $result = $ilDB->queryF(
"SELECT test_fi,MAX(pass) AS pass FROM tst_active".
 
11058                         " JOIN tst_pass_result ON (tst_pass_result.active_fi = tst_active.active_id)".
 
11059                         " WHERE user_fi=%s".
 
11060                         " GROUP BY test_fi",
 
11061                         array(
'integer', 
'integer'),
 
11062                         array($a_user_id, 1)
 
11068                         $all[$obj_id] = (bool)
$row[
"pass"];
 
11084                 $this->online = (bool)$a_online;
 
11089                 $this->print_best_solution_with_result = (bool) $status;
 
11119                 $this->activation_visibility = (bool) $a_value;
 
11129            return (
bool)$this->activation_limited;
 
11134            $this->activation_limited = (bool)$a_value;
 
11146                 $this->_highscore_enabled = (bool)$a_enabled;
 
11156                 return (
bool) $this->_highscore_enabled;
 
11168                 $this->_highscore_anon = (bool)$a_anon;
 
11182                 return (
bool) $this->_highscore_anon;
 
11212                 $this->_highscore_achieved_ts = (bool)$a_achieved_ts;
 
11222                 return (
bool) $this->_highscore_achieved_ts;
 
11232                 $this->_highscore_score = (bool)$a_score;
 
11242                 return (
bool) $this->_highscore_score;
 
11252                 $this->_highscore_percentage = (bool)$a_percentage;
 
11262                 return (
bool) $this->_highscore_percentage;
 
11272                 $this->_highscore_hints = (bool)$a_hints;
 
11282                 return (
bool) $this->_highscore_hints;
 
11292                 $this->_highscore_wtime = (bool)$a_wtime;
 
11302                 return (
bool) $this->_highscore_wtime;
 
11312                 $this->_highscore_own_table = (bool)$a_own_table;
 
11322                 return (
bool) $this->_highscore_own_table;
 
11332                 $this->_highscore_top_table = (bool)$a_top_table;
 
11342                 return (
bool) $this->_highscore_top_table;
 
11353                 $this->_highscore_top_num = (int)$a_top_num;
 
11366                 $retval = $a_retval;
 
11367                 if ( (
int) $this->_highscore_top_num != 0)
 
11369                         $retval = $this->_highscore_top_num;
 
11378                 switch ($specific_answer_feedback)
 
11381                                 $this->specific_answer_feedback = 1;
 
11384                                 $this->specific_answer_feedback = 0;
 
11391                 switch ($this->specific_answer_feedback)
 
11428                 require_once(
'Modules/TestQuestionPool/classes/class.assQuestion.php');
 
11436                 $obligationPossible = call_user_func(array($classConcreteQuestion, 
'isObligationPossible'), $questionId);
 
11438                 return $obligationPossible;
 
11451             $rset = $ilDB->queryF(
'SELECT obligatory FROM tst_test_question WHERE question_fi = %s', array(
'integer'), array($question_id));
 
11453                 if( 
$row = $ilDB->fetchAssoc($rset) )
 
11455                         return (
bool) 
$row[
'obligatory'];
 
11477             $rset = $ilDB->queryF(
 
11478                     'SELECT obligations_answered FROM tst_pass_result WHERE active_fi = %s AND pass = %s',
 
11479                     array(
'integer', 
'integer'),
 
11480                     array($active_id, 
$pass)
 
11483             if( 
$row = $ilDB->fetchAssoc($rset) )
 
11485                         return (
bool)
$row[
'obligations_answered'];
 
11503                 $rset = $ilDB->queryF(
 
11504                         'SELECT count(*) cnt FROM tst_test_question WHERE test_fi = %s AND obligatory = 1',
 
11508                 $row = $ilDB->fetchAssoc($rset);
 
11510                 return (
bool)
$row[
'cnt'] > 0;
 
11589                 return (strlen($this->activation_starting_time)) ? $this->activation_starting_time : NULL;
 
11594                 return (strlen($this->activation_ending_time)) ? $this->activation_ending_time : NULL;