33 include_once
'./webservice/soap/classes/class.ilSoapAdministration.php';
47 $permission_ok =
false;
48 $result = $ilDB->queryF(
"SELECT tst_tests.obj_fi FROM tst_active, tst_tests WHERE tst_active.active_id = %s AND tst_active.test_fi = tst_tests.test_id",
52 $row = $ilDB->fetchAssoc($result);
55 $obj_id =
$row[
'obj_fi'];
58 if ($ilAccess->checkAccess(
"write",
"", $ref_id))
60 $permission_ok =
true;
65 return $permission_ok;
77 $result = $ilDB->queryF(
"SELECT * FROM tst_times WHERE active_fi = %s ORDER BY started DESC",
81 if ($result->numRows())
83 $row = $ilDB->fetchAssoc($result);
84 if (preg_match(
"/(\\d{4})-(\\d{2})-(\\d{2}) (\\d{2}):(\\d{2}):(\\d{2})/",
$row[
"started"], $matches))
86 $time = mktime($matches[4], $matches[5], $matches[6], $matches[2], $matches[3], $matches[1]);
90 global $ilClientIniFile;
91 $expires = $ilClientIniFile->readVariable(
'session',
'expire');
92 if (
$diff <= $expires)
113 $result = $ilDB->queryF(
"SELECT user_fi FROM tst_active WHERE active_id = %s",
117 $row = $ilDB->fetchAssoc($result);
118 if (
$row[
'user_fi'] == $ilUser->getId())
140 return $this->
__raiseError(
"The required user information is only available for active users.",
"");
143 if (is_array($solution) && (array_key_exists(
"item", $solution))) $solution = $solution[
"item"];
146 if (($active_id > 0) && ($question_id > 0) && (strlen(
$pass) > 0))
148 $affectedRows =
$ilDB->manipulateF(
"DELETE FROM tst_solutions WHERE active_fi = %s AND question_fi = %s AND pass = %s",
149 array(
'integer',
'integer',
'integer'),
150 array($active_id, $question_id,
$pass)
154 for($i = 0; $i < count($solution); $i += 3)
156 $next_id =
$ilDB->nextId(
'tst_solutions');
157 $affectedRows =
$ilDB->insert(
"tst_solutions", array(
158 "solution_id" => array(
"integer", $next_id),
159 "active_fi" => array(
"integer", $active_id),
160 "question_fi" => array(
"integer", $question_id),
161 "value1" => array(
"clob", $solution[$i]),
162 "value2" => array(
"clob", $solution[$i+1]),
163 "points" => array(
"float", $solution[$i+2]),
164 "pass" => array(
"integer",
$pass),
165 "tstamp" => array(
"integer", time())
167 $totalrows += $affectedRows;
171 return $this->
__raiseError(
"Wrong solution data. ILIAS did not execute any database queries: Solution data: " . print_r($solution,
true));
175 include_once
"./Modules/TestQuestionPool/classes/class.assQuestion.php";
177 $question->calculateResultsFromSolution($active_id,
$pass);
204 return $this->
__raiseError(
"The required user information is only available for active users.",
"");
207 $solutions = array();
208 if (preg_match(
"/<values>(.*?)<\/values>/is", $solution, $matches))
210 if (preg_match_all(
"/<value>(.*?)<\/value><value>(.*?)<\/value><points>(.*?)<\/points>/is", $solution, $matches, PREG_SET_ORDER))
212 foreach ($matches as $match)
214 if (count($match) == 4)
216 for ($i = 1; $i < count($match); $i++)
218 array_push($solutions, trim($match[$i]));
225 if (count($solutions) == 0)
227 return $this->
__raiseError(
"Wrong solution data. ILIAS did not find one or more solution triplets: $solution",
"");
232 if (($active_id > 0) && ($question_id > 0) && (strlen(
$pass) > 0))
234 $affectedRows =
$ilDB->manipulateF(
"DELETE FROM tst_solutions WHERE active_fi = %s AND question_fi = %s AND pass = %s",
235 array(
'integer',
'integer',
'integer'),
236 array($active_id, $question_id,
$pass)
240 for($i = 0; $i < count($solutions); $i += 3)
242 $next_id =
$ilDB->nextId(
'tst_solutions');
243 $affectedRows =
$ilDB->insert(
"tst_solutions", array(
244 "solution_id" => array(
"integer", $next_id),
245 "active_fi" => array(
"integer", $active_id),
246 "question_fi" => array(
"integer", $question_id),
247 "value1" => array(
"clob", $solutions[$i]),
248 "value2" => array(
"clob", $solutions[$i+1]),
249 "points" => array(
"float", $solutions[$i+2]),
250 "pass" => array(
"integer",
$pass),
251 "tstamp" => array(
"integer", time())
253 $totalrows += $affectedRows;
255 if (count($totalrows) == 0)
257 return $this->
__raiseError(
"Wrong solution data. ILIAS did not execute any database queries");
261 include_once
"./Modules/TestQuestionPool/classes/class.assQuestion.php";
263 $question->calculateResultsFromSolution($active_id,
$pass);
289 return $this->
__raiseError(
"The required user information is only available for active users.",
"");
295 $use_previous_answers = 1;
297 $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",
301 if ($result->numRows())
303 $row = $ilDB->fetchAssoc($result);
304 $use_previous_answers =
$row[
"use_previous_answers"];
307 if ($use_previous_answers)
309 $result = $ilDB->queryF(
"SELECT MAX(pass) maxpass FROM tst_test_result WHERE active_fi = %s AND question_fi = %s",
310 array(
'integer',
'integer'),
311 array($active_id, $question_id)
313 if ($result->numRows() == 1)
315 $row = $ilDB->fetchAssoc($result);
316 $lastpass =
$row[
"maxpass"];
324 if (($active_id > 0) && ($question_id > 0) && (strlen($lastpass) > 0))
326 $result = $ilDB->queryF(
"SELECT * FROM tst_solutions WHERE active_fi = %s AND question_fi = %s AND pass = %s",
327 array(
'integer',
'integer',
'integer'),
328 array($active_id, $question_id, $lastpass)
330 if ($result->numRows())
332 while (
$row = $ilDB->fetchAssoc($result))
334 array_push($solution,
$row[
"value1"]);
335 array_push($solution,
$row[
"value2"]);
336 array_push($solution,
$row[
"points"]);
362 return $this->
__raiseError(
"The required user information is only available for active users.",
"");
367 $result = $ilDB->queryF(
"SELECT user_fi, test_fi FROM tst_active WHERE active_id = %s",
371 $row = $ilDB->fetchAssoc($result);
372 $user_id =
$row[
"user_fi"];
373 $test_id =
$row[
"test_fi"];
375 $result = $ilDB->queryF(
"SELECT anonymity FROM tst_tests WHERE test_id = %s",
379 $row = $ilDB->fetchAssoc($result);
380 $anonymity =
$row[
"anonymity"];
382 $result = $ilDB->queryF(
"SELECT firstname, lastname, title, login FROM usr_data WHERE usr_id = %s",
388 if ($result->numRows() == 0)
390 $userdata[
"fullname"] = $lng->txt(
"deleted_user");
391 $userdata[
"title"] =
"";
392 $userdata[
"firstname"] =
"";
393 $userdata[
"lastname"] = $lng->txt(
"anonymous");
394 $userdata[
"login"] =
"";
398 $data = $ilDB->fetchAssoc($result);
399 if (($user_id == ANONYMOUS_USER_ID) || ($anonymity))
401 $userdata[
"fullname"] = $lng->txt(
"anonymous");
402 $userdata[
"title"] =
"";
403 $userdata[
"firstname"] =
"";
404 $userdata[
"lastname"] = $lng->txt(
"anonymous");
405 $userdata[
"login"] =
"";
409 $userdata[
"fullname"] = trim(
$data[
"title"] .
" " .
$data[
"firstname"] .
" " .
$data[
"lastname"]);
410 $userdata[
"title"] = $data[
"title"];
411 $userdata[
"firstname"] = $data[
"firstname"];
412 $userdata[
"lastname"] = $data[
"lastname"];
413 $userdata[
"login"] = $data[
"login"];
416 return array_values($userdata);
440 return $this->
__raiseError(
"The required user information is only available for active users.",
"");
445 $result = $ilDB->queryF(
"SELECT tst_tests.random_test FROM tst_active, tst_tests WHERE tst_active.active_id = %s AND tst_tests.test_id = tst_active.test_fi",
449 if ($result->numRows() != 1)
return -1;
450 $row = $ilDB->fetchAssoc($result);
451 $is_random =
$row[
"random_test"];
453 include_once
"./Modules/Test/classes/class.ilTestSequence.php";
455 return $sequence->getSequenceForQuestion($question_id);
479 return $this->
__raiseError(
"The required user information is only available for active users.",
"");
484 $result = $ilDB->queryF(
"SELECT tst_tests.random_test FROM tst_active, tst_tests WHERE tst_active.active_id = %s AND tst_tests.test_id = tst_active.test_fi",
488 if ($result->numRows() != 1)
return -1;
489 $row = $ilDB->fetchAssoc($result);
490 $is_random =
$row[
"random_test"];
492 include_once
"./Modules/Test/classes/class.ilTestSequence.php";
494 $result = $ilDB->queryF(
"SELECT question_fi, points FROM tst_test_result WHERE active_fi = %s AND pass = %s",
495 array(
'integer',
'integer'),
496 array($active_id,
$pass)
498 $reachedpoints = array();
499 while (
$row = $ilDB->fetchAssoc($result))
501 $reachedpoints[
$row[
"question_fi"]] = $row[
"points"];
504 $pointsforposition = array();
505 foreach ($sequence->getUserSequence() as $seq)
509 $qid = $sequence->getQuestionForSequence($seq);
510 if ($qid == $question_id)
516 array_push($pointsforposition, $reachedpoints[$qid]);
520 return $pointsforposition;
543 return $this->
__raiseError(
"The required user information is only available for active users.",
"");
548 $result = $ilDB->queryF(
"SELECT tst_tests.random_test FROM tst_active, tst_tests WHERE tst_active.active_id = %s AND tst_tests.test_id = tst_active.test_fi",
552 if ($result->numRows() != 1)
return 0;
553 $row = $ilDB->fetchAssoc($result);
554 $is_random =
$row[
"random_test"];
556 include_once
"./Modules/Test/classes/class.ilTestSequence.php";
558 return $sequence->getUserQuestionCount();
582 if(!strlen($test_ref_id))
584 return $this->
__raiseError(
'No test id given. Aborting!',
587 global $rbacsystem, $tree,
$ilLog;
591 return $this->
__raiseError(
'Test is trashed. Aborting!',
598 return $this->
__raiseError(
'No test found for id: '.$test_ref_id,
604 $permission_ok =
false;
607 if($rbacsystem->checkAccess(
'write',$ref_id))
609 $permission_ok =
true;
615 return $this->
__raiseError(
'No permission to edit the object with id: '.$test_ref_id,
619 include_once
'./webservice/soap/classes/class.ilXMLResultSet.php';
620 include_once
'./webservice/soap/classes/class.ilXMLResultSetWriter.php';
623 $xmlResultSet->addColumn(
"user_id");
624 $xmlResultSet->addColumn(
"login");
625 $xmlResultSet->addColumn(
"firstname");
626 $xmlResultSet->addColumn(
"lastname");
627 $xmlResultSet->addColumn(
"matriculation");
629 include_once
'./Modules/Test/classes/class.ilObjTest.php';
630 $test_obj =
new ilObjTest($obj_id,
false);
631 $participants = $test_obj->getTestParticipants();
636 $data = $test_obj->getAllTestResults($participants,
false);
638 $xmlResultSet->addColumn(
"maximum_points");
639 $xmlResultSet->addColumn(
"received_points");
641 $titles = array_shift(
$data);
644 $xmlRow->setValue(0, $row[
"user_id"]);
645 $xmlRow->setValue(1, $row[
"login"]);
646 $xmlRow->setValue(2, $row[
"firstname"]);
647 $xmlRow->setValue(3, $row[
"lastname"]);
648 $xmlRow->setValue(4, $row[
"matriculation"]);
649 $xmlRow->setValue(5, $row[
"max_points"]);
650 $xmlRow->setValue(6, $row[
"reached_points"]);
651 $xmlResultSet->addRow($xmlRow);
654 $data = $test_obj->getDetailedTestResults($participants);
656 $xmlResultSet->addColumn(
"question_id");
657 $xmlResultSet->addColumn(
"question_title");
658 $xmlResultSet->addColumn(
"maximum_points");
659 $xmlResultSet->addColumn(
"received_points");
662 $xmlRow->setValue(0, $row[
"user_id"]);
663 $xmlRow->setValue(1, $row[
"login"]);
664 $xmlRow->setValue(2, $row[
"firstname"]);
665 $xmlRow->setValue(3, $row[
"lastname"]);
666 $xmlRow->setValue(4, $row[
"matriculation"]);
667 $xmlRow->setValue(5, $row[
"question_id"]);
668 $xmlRow->setValue(6, $row[
"question_title"]);
669 $xmlRow->setValue(7, $row[
"max_points"]);
670 $xmlRow->setValue(8, $row[
"reached_points"]);
671 $xmlResultSet->addRow($xmlRow);
677 return $xmlWriter->getXML();
698 if(!strlen($test_obj_id))
700 return $this->
__raiseError(
'No test object id given. Aborting!',
704 include_once
'./Modules/Test/classes/class.ilObjTest.php';
705 $test_obj =
new ilObjTest($test_obj_id,
false);
706 $test_obj->loadFromDb();
707 $test_id = $test_obj->getTestId();
709 return $test_id ? $test_id :
"0";
733 return $this->
__raiseError(
'No test object id given. Aborting!',
737 include_once
'./Modules/Test/classes/class.ilObjTest.php';
738 $test_obj =
new ilObjTest($obj_id,
false);
739 $test_obj->loadFromDb();
741 return $test_obj->getRunDates();
766 return $this->
__raiseError(
'No test object id given. Aborting!',
770 include_once
'./Modules/Test/classes/class.ilObjTest.php';
771 $test_obj =
new ilObjTest($obj_id,
false);
772 $test_obj->loadFromDb();
774 return $test_obj->packageRun($date);
799 return $this->
__raiseError(
'No test object id given. Aborting!',
803 include_once
'./Modules/Test/classes/class.ilObjTest.php';
804 $test_obj =
new ilObjTest($obj_id,
false);
805 $test_obj->loadFromDb();
807 return $test_obj->getRunPackageDates();
831 return $this->
__raiseError(
'No test object id given. Aborting!',
835 include_once
'./Modules/Test/classes/class.ilObjTest.php';
836 $test_obj =
new ilObjTest($obj_id,
false);
837 $test_obj->loadFromDb();
839 $filename = $test_obj->getRunPackageFilename($date);
842 return $this->
__raiseError(
'Test with ID $obj_id has no packaged run for $date. Aborting!',
848 $content = base64_encode($content);
874 return $this->
__raiseError(
'No test object id given. Aborting!',
878 include_once
'./Modules/Test/classes/class.ilObjTest.php';
879 $test_obj =
new ilObjTest($obj_id,
false);
880 $test_obj->loadFromDb();
882 return $test_obj->deleteRunPackage($date);
906 return $this->
__raiseError(
'No test object id given. Aborting!',
910 include_once
'./Modules/Test/classes/class.ilObjTest.php';
911 $test_obj =
new ilObjTest($obj_id,
false);
912 $test_obj->loadFromDb();
914 return $test_obj->obliterateRun($date);