4 include_once
"./Services/Object/classes/class.ilObjectAccess.php";
5 include_once
"./Modules/Test/classes/inc.AssessmentConstants.php";
36 function _checkAccess($a_cmd, $a_permission, $a_ref_id, $a_obj_id, $a_user_id =
"")
42 $a_user_id = $ilUser->getId();
45 $is_admin = $rbacsystem->checkAccessOfUser($a_user_id,
'write',$a_ref_id);
48 if(!self::_isOnline($a_obj_id) && !$is_admin)
54 switch ($a_permission)
97 $result = $ilDB->queryF(
"SELECT SUM(qpl_questions.points) maxpoints FROM tst_test_rnd_qst, qpl_questions, tst_active WHERE tst_active.active_id = tst_test_rnd_qst.active_fi AND tst_test_rnd_qst.question_fi = qpl_questions.question_id AND tst_active.test_fi = %s AND tst_test_rnd_qst.pass = %s AND tst_active.user_fi = %s",
98 array(
'integer',
'integer',
'integer'),
99 array($test_id,
$pass, $user_id)
104 $max =
$row[
"maxpoints"];
109 $result = $ilDB->queryF(
"SELECT SUM(qpl_questions.points) maxpoints FROM tst_test_question, qpl_questions WHERE tst_test_question.question_fi = qpl_questions.question_id AND tst_test_question.test_fi = %s",
116 $max =
$row[
"maxpoints"];
133 $result = $ilDB->queryF(
"SELECT tst_result_cache.* FROM tst_result_cache, tst_active, tst_tests WHERE tst_active.test_fi = tst_tests.test_id AND tst_active.user_fi = %s AND tst_tests.obj_fi = %s AND tst_result_cache.active_fi = tst_active.active_id",
134 array(
'integer',
'integer'),
135 array($user_id, $a_obj_id)
139 $result = $ilDB->queryF(
"SELECT tst_active.active_id FROM tst_active, tst_tests WHERE tst_active.test_fi = tst_tests.test_id AND tst_active.user_fi = %s AND tst_tests.obj_fi = %s",
140 array(
'integer',
'integer'),
141 array($user_id, $a_obj_id)
144 if (
$row[
'active_id'] > 0)
146 include_once
"./Modules/TestQuestionPool/classes/class.assQuestion.php";
154 $result = $ilDB->queryF(
"SELECT tst_result_cache.* FROM tst_result_cache, tst_active, tst_tests WHERE tst_active.test_fi = tst_tests.test_id AND tst_active.user_fi = %s AND tst_tests.obj_fi = %s AND tst_result_cache.active_fi = tst_active.active_id",
155 array(
'integer',
'integer'),
156 array($user_id, $a_obj_id)
160 $result = $ilDB->queryF(
"SELECT tst_pass_result.*, tst_tests.pass_scoring, tst_tests.random_test, tst_tests.test_id FROM tst_pass_result, tst_active, tst_tests WHERE tst_active.test_fi = tst_tests.test_id AND tst_active.user_fi = %s AND tst_tests.obj_fi = %s AND tst_pass_result.active_fi = tst_active.active_id ORDER BY tst_pass_result.pass",
161 array(
'integer',
'integer'),
162 array($user_id, $a_obj_id)
167 array_push($points,
$row);
171 if ($points[0][
"pass_scoring"] == 0)
173 $reached = $points[count($points)-1][
"points"];
174 $max = $points[count($points)-1][
"maxpoints"];
177 $active_id = $points[count($points)-1][
"active_fi"];
178 $pass = $points[count($points)-1][
"pass"];
179 if (strlen($active_id) && strlen(
$pass))
181 include_once
"./Modules/TestQuestionPool/classes/class.assQuestion.php";
182 $res = assQuestion::_updateTestPassResults($active_id,
$pass);
183 $max =
$res[
'maxpoints'];
184 $reached =
$res[
'points'];
190 foreach ($points as
$row)
192 if ($row[
"points"] > $reached)
194 $reached = $row[
"points"];
195 $max = $row[
"maxpoints"];
198 $active_id = $row[
"active_fi"];
199 $pass = $row[
"pass"];
200 if (strlen($active_id) && strlen(
$pass))
202 include_once
"./Modules/TestQuestionPool/classes/class.assQuestion.php";
203 $res = assQuestion::_updateTestPassResults($active_id,
$pass);
204 $max =
$res[
'maxpoints'];
205 $reached =
$res[
'points'];
211 include_once
"./Modules/Test/classes/class.assMarkSchema.php";
212 $percentage = (!$max) ? 0 : ($reached / $max) * 100.0;
214 return ($mark[
"passed"]) ? TRUE : FALSE;
219 return (
$row[
'passed']) ?
true :
false;
232 $a_usr_id = $a_usr_id ? $a_usr_id : $ilUser->getId();
268 array(
"permission" =>
"write",
"cmd" =>
"questionsTabGateway",
"lang_var" =>
"tst_edit_questions"),
269 array(
"permission" =>
"write",
"cmd" =>
"ilObjTestSettingsGeneralGUI::showForm",
"lang_var" =>
"settings"),
270 array(
"permission" =>
"read",
"cmd" =>
"infoScreen",
"lang_var" =>
"tst_run",
273 array(
"permission" =>
"tst_statistics",
"cmd" =>
"outEvaluation",
"lang_var" =>
"tst_statistical_evaluation"),
290 $result = $ilDB->queryF(
"SELECT complete FROM tst_tests WHERE obj_fi=%s",
299 return (
$row[
'complete']) ?
true :
false;
318 if( !isset(self::$hasFinishedCache[
"{$a_user_id}:{$a_obj_id}"]) )
320 require_once
'Modules/Test/classes/class.ilTestParticipantData.php';
321 require_once
'Modules/Test/classes/class.ilTestSessionFactory.php';
322 require_once
'Modules/Test/classes/class.ilTestPassesSelector.php';
329 $partData->setUserIds(array($a_user_id));
330 $partData->load($testOBJ->getTestId());
332 $activeId = $partData->getActiveIdByUserId($a_user_id);
335 $testSession = $testSessionFactory->getSession($activeId);
338 $testPassesSelector->setActiveId($activeId);
339 $testPassesSelector->setLastFinishedPass($testSession->getLastFinishedPass());
341 self::$hasFinishedCache[
"{$a_user_id}:{$a_obj_id}"] = count($testPassesSelector->getClosedPasses());
344 return self::$hasFinishedCache[
"{$a_user_id}:{$a_obj_id}"];
358 $result = $ilDB->queryF(
"SELECT test_id FROM tst_tests WHERE obj_fi = %s",
365 $test_id =
$row[
"test_id"];
376 $questions = array();
379 $result = $ilDB->queryF(
"SELECT test_fi FROM tst_active WHERE active_id = %s",
387 $test_id =
$row[
"test_fi"];
393 $result = $ilDB->queryF(
"SELECT qpl_questions.question_id, qpl_questions.points FROM qpl_questions, tst_test_question WHERE tst_test_question.question_fi = qpl_questions.question_id AND tst_test_question.test_fi = %s ORDER BY tst_test_question.sequence",
402 array_push($questions,
$row);
408 $result = $ilDB->queryF(
"SELECT qpl_questions.question_id, qpl_questions.points 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 ORDER BY tst_test_rnd_qst.sequence",
409 array(
'integer',
'integer'),
410 array($active_id,
$pass)
416 array_push($questions,
$row);
434 SELECT tst_tests.complete
437 ON tst_tests.obj_fi = object_data.obj_id
438 WHERE object_data.obj_id = %s
441 $res = $ilDB->queryF(
$query, array(
'integer'), array($a_obj_id));
443 while(
$row = $ilDB->fetchAssoc(
$res) )
445 return (
bool)
$row[
'complete'];
461 $result = $ilDB->queryF(
"SELECT * FROM tst_tests WHERE test_id = %s",
469 return $ilDB->fetchAssoc(
$result);
482 $result = $ilDB->queryF(
"SELECT obj_fi FROM tst_tests WHERE test_id = %s",
488 return $row[
"obj_fi"];
503 SELECT DISTINCT t.obj_fi
505 INNER JOIN tst_rnd_quest_set_qpls r
506 ON t.test_id = r.test_fi
510 $result = $ilDB->queryF(
$query, array(
'integer'), array($qpl_id));
532 $result = $ilDB->queryF(
"SELECT tst_tests.* FROM tst_tests WHERE tst_tests.obj_fi = %s",
539 if (
$row[
"fixed_participants"])
541 $result = $ilDB->queryF(
"SELECT * FROM tst_invited_user WHERE test_fi = %s AND user_fi = %s",
542 array(
'integer',
'integer'),
543 array(
$row[
"test_id"], $a_user_id)
548 if (trim(
$row[
'clientip']) !=
"")
550 $row[
'clientip'] = preg_replace(
"/[^0-9.?*,:]+/",
"",
$row[
'clientip']);
551 $row[
'clientip'] = str_replace(
".",
"\\.",
$row[
'clientip']);
552 $row[
'clientip'] = str_replace(Array(
"?",
"*",
","), Array(
"[0-9]",
"[0-9]*",
"|"),
$row[
'clientip']);
553 if (!preg_match(
"/^".
$row[
'clientip'].
"$/", $_SERVER[
"REMOTE_ADDR"]))
555 return $lng->txt(
"tst_user_wrong_clientip");
569 return $lng->txt(
"tst_user_not_invited");
594 $result = $ilDB->queryF(
"SELECT * FROM tst_active WHERE active_id = %s",
599 $user_id =
$row[
"user_fi"];
600 $test_id =
$row[
"test_fi"];
601 $importname =
$row[
'importname'];
603 $result = $ilDB->queryF(
"SELECT obj_fi FROM tst_tests WHERE test_id = %s",
608 $obj_id =
$row[
"obj_fi"];
610 include_once
"./Modules/Test/classes/class.ilObjTest.php";
613 include_once
'./Services/User/classes/class.ilObjUser.php';
617 if (strlen($importname))
619 $name = $importname .
' (' . $lng->txt(
'imported') .
')';
621 else if (strlen($uname[
"firstname"].$uname[
"lastname"]) == 0)
623 $name = $lng->txt(
"deleted_user");
627 if ($user_id == ANONYMOUS_USER_ID)
633 $name = trim($uname[
"lastname"] .
", " . $uname[
"firstname"] .
" " . $uname[
"title"]);
637 $name = $lng->txt(
"anonymous");
653 $result = $ilDB->queryF(
"SELECT user_fi FROM tst_active WHERE active_id = %s",
658 return $row[
"user_fi"];
680 $passed_users = array();
682 $userresult = $ilDB->queryF(
"
683 SELECT tst_active.active_id, COUNT(tst_sequence.active_fi) sequences
685 INNER JOIN tst_active
686 ON tst_active.test_fi = tst_tests.test_id
687 LEFT JOIN tst_sequence
688 ON tst_sequence.active_fi = tst_active.active_id
689 WHERE tst_tests.obj_fi = %s
690 GROUP BY tst_active.active_id
692 array(
'integer'), array($a_obj_id)
694 $all_participants = array();
695 $notAttempted = array();
696 while (
$row = $ilDB->fetchAssoc($userresult))
698 if(
$row[
'sequences'] == 0)
700 $notAttempted[
$row[
'active_id']] = $row[
'active_id'];
703 $all_participants[
$row[
'active_id']] = $row[
'active_id'];
706 $result = $ilDB->query(
"SELECT tst_result_cache.*, tst_active.user_fi FROM tst_result_cache, tst_active WHERE tst_active.active_id = tst_result_cache.active_fi AND " . $ilDB->in(
'active_fi', $all_participants,
false,
'integer'));
707 $found_all = (
$result->numRows() == count($all_participants)) ?
true :
false;
711 $found_participants = array();
712 while ($data = $ilDB->fetchAssoc(
$result))
714 array_push($found_participants, $data[
'active_fi']);
716 foreach ($all_participants as $active_id)
718 if (!in_array($active_id, $found_participants))
720 include_once
"./Modules/TestQuestionPool/classes/class.assQuestion.php";
724 $result = $ilDB->query(
"SELECT tst_result_cache.*, tst_active.user_fi FROM tst_result_cache, tst_active WHERE tst_active.active_id = tst_result_cache.active_fi AND " . $ilDB->in(
'active_fi', $all_participants,
false,
'integer'));
726 while ($data = $ilDB->fetchAssoc(
$result))
728 if( isset($notAttempted[$data[
'active_fi']]) )
734 $data[
'user_id'] = $data[
'user_fi'];
735 array_push($passed_users, $data);
737 return $passed_users;
747 $t_arr = explode(
"_", $a_target);
749 if ($t_arr[0] !=
"tst" || ((
int) $t_arr[1]) <= 0)
754 if ($ilAccess->checkAccess(
"read",
"", $t_arr[1]))
791 AND online_status = 1
794 $result = $ilDB->queryF(
$query, array(
'integer'), array($a_obj_id) );
796 return $result->numRows() == 1;