33 include_once
'./webservice/soap/classes/class.ilSoapAdministration.php';
46 $result = $ilDB->queryF(
"SELECT * FROM tst_times WHERE active_fi = %s ORDER BY started DESC",
53 if (preg_match(
"/(\\d{4})-(\\d{2})-(\\d{2}) (\\d{2}):(\\d{2}):(\\d{2})/",
$row[
"started"], $matches))
55 $time = mktime($matches[4], $matches[5], $matches[6], $matches[2], $matches[3], $matches[1]);
59 global $ilClientIniFile;
60 $expires = $ilClientIniFile->readVariable(
'session',
'expire');
61 if (
$diff <= $expires)
92 return $this->
__raiseError(
"The required user information is only available for active users.",
"");
95 if (is_array($solution) && (array_key_exists(
"item", $solution))) $solution = $solution[
"item"];
98 if (($active_id > 0) && ($question_id > 0) && (strlen(
$pass) > 0))
100 $affectedRows =
$ilDB->manipulateF(
"DELETE FROM tst_solutions WHERE active_fi = %s AND question_fi = %s AND pass = %s",
101 array(
'integer',
'integer',
'integer'),
102 array($active_id, $question_id,
$pass)
106 for($i = 0; $i < count($solution); $i += 3)
108 $next_id =
$ilDB->nextId(
'tst_solutions');
109 $affectedRows =
$ilDB->insert(
"tst_solutions", array(
110 "solution_id" => array(
"integer", $next_id),
111 "active_fi" => array(
"integer", $active_id),
112 "question_fi" => array(
"integer", $question_id),
113 "value1" => array(
"clob", $solution[$i]),
114 "value2" => array(
"clob", $solution[$i+1]),
115 "points" => array(
"float", $solution[$i+2]),
116 "pass" => array(
"integer",
$pass),
117 "tstamp" => array(
"integer", time())
119 $totalrows += $affectedRows;
123 return $this->
__raiseError(
"Wrong solution data. ILIAS did not execute any database queries: Solution data: " . print_r($solution,
true));
127 include_once
"./Modules/TestQuestionPool/classes/class.assQuestion.php";
129 $question->calculateResultsFromSolution($active_id,
$pass);
156 return $this->
__raiseError(
"The required user information is only available for active users.",
"");
159 $solutions = array();
160 if (preg_match(
"/<values>(.*?)<\/values>/is", $solution, $matches))
162 if (preg_match_all(
"/<value>(.*?)<\/value><value>(.*?)<\/value><points>(.*?)<\/points>/is", $solution, $matches, PREG_SET_ORDER))
164 foreach ($matches as $match)
166 if (count($match) == 4)
168 for ($i = 1; $i < count($match); $i++)
170 array_push($solutions, trim($match[$i]));
177 if (count($solutions) == 0)
179 return $this->
__raiseError(
"Wrong solution data. ILIAS did not find one or more solution triplets: $solution",
"");
184 if (($active_id > 0) && ($question_id > 0) && (strlen(
$pass) > 0))
186 $affectedRows =
$ilDB->manipulateF(
"DELETE FROM tst_solutions WHERE active_fi = %s AND question_fi = %s AND pass = %s",
187 array(
'integer',
'integer',
'integer'),
188 array($active_id, $question_id,
$pass)
192 for($i = 0; $i < count($solutions); $i += 3)
194 $next_id =
$ilDB->nextId(
'tst_solutions');
195 $affectedRows =
$ilDB->insert(
"tst_solutions", array(
196 "solution_id" => array(
"integer", $next_id),
197 "active_fi" => array(
"integer", $active_id),
198 "question_fi" => array(
"integer", $question_id),
199 "value1" => array(
"clob", $solutions[$i]),
200 "value2" => array(
"clob", $solutions[$i+1]),
201 "points" => array(
"float", $solutions[$i+2]),
202 "pass" => array(
"integer",
$pass),
203 "tstamp" => array(
"integer", time())
205 $totalrows += $affectedRows;
207 if (count($totalrows) == 0)
209 return $this->
__raiseError(
"Wrong solution data. ILIAS did not execute any database queries");
213 include_once
"./Modules/TestQuestionPool/classes/class.assQuestion.php";
215 $question->calculateResultsFromSolution($active_id,
$pass);
241 return $this->
__raiseError(
"The required user information is only available for active users.",
"");
247 $use_previous_answers = 1;
249 $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",
256 $use_previous_answers =
$row[
"use_previous_answers"];
259 if ($use_previous_answers)
261 $result = $ilDB->queryF(
"SELECT MAX(pass) maxpass FROM tst_test_result WHERE active_fi = %s AND question_fi = %s",
262 array(
'integer',
'integer'),
263 array($active_id, $question_id)
268 $lastpass =
$row[
"maxpass"];
276 if (($active_id > 0) && ($question_id > 0) && (strlen($lastpass) > 0))
278 $result = $ilDB->queryF(
"SELECT * FROM tst_solutions WHERE active_fi = %s AND question_fi = %s AND pass = %s",
279 array(
'integer',
'integer',
'integer'),
280 array($active_id, $question_id, $lastpass)
286 array_push($solution,
$row[
"value1"]);
287 array_push($solution,
$row[
"value2"]);
288 array_push($solution,
$row[
"points"]);
314 return $this->
__raiseError(
"The required user information is only available for active users.",
"");
319 $result = $ilDB->queryF(
"SELECT user_fi, test_fi FROM tst_active WHERE active_id = %s",
324 $user_id =
$row[
"user_fi"];
325 $test_id =
$row[
"test_fi"];
327 $result = $ilDB->queryF(
"SELECT anonymity FROM tst_tests WHERE test_id = %s",
332 $anonymity =
$row[
"anonymity"];
334 $result = $ilDB->queryF(
"SELECT firstname, lastname, title, login FROM usr_data WHERE usr_id = %s",
342 $userdata[
"fullname"] = $lng->txt(
"deleted_user");
343 $userdata[
"title"] =
"";
344 $userdata[
"firstname"] =
"";
345 $userdata[
"lastname"] = $lng->txt(
"anonymous");
346 $userdata[
"login"] =
"";
351 if (($user_id == ANONYMOUS_USER_ID) || ($anonymity))
353 $userdata[
"fullname"] = $lng->txt(
"anonymous");
354 $userdata[
"title"] =
"";
355 $userdata[
"firstname"] =
"";
356 $userdata[
"lastname"] = $lng->txt(
"anonymous");
357 $userdata[
"login"] =
"";
361 $userdata[
"fullname"] = trim(
$data[
"title"] .
" " .
$data[
"firstname"] .
" " .
$data[
"lastname"]);
362 $userdata[
"title"] = $data[
"title"];
363 $userdata[
"firstname"] = $data[
"firstname"];
364 $userdata[
"lastname"] = $data[
"lastname"];
365 $userdata[
"login"] = $data[
"login"];
368 return array_values($userdata);
392 return $this->
__raiseError(
"The required user information is only available for active users.",
"");
397 $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",
401 if (
$result->numRows() != 1)
return -1;
403 $is_random =
$row[
"random_test"];
405 include_once
"./Modules/Test/classes/class.ilTestSequence.php";
407 return $sequence->getSequenceForQuestion($question_id);
431 return $this->
__raiseError(
"The required user information is only available for active users.",
"");
436 $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",
440 if (
$result->numRows() != 1)
return -1;
442 $is_random =
$row[
"random_test"];
444 include_once
"./Modules/Test/classes/class.ilTestSequence.php";
446 $result = $ilDB->queryF(
"SELECT question_fi, points FROM tst_test_result WHERE active_fi = %s AND pass = %s",
447 array(
'integer',
'integer'),
448 array($active_id,
$pass)
450 $reachedpoints = array();
453 $reachedpoints[
$row[
"question_fi"]] = $row[
"points"];
456 $pointsforposition = array();
457 foreach ($sequence->getUserSequence() as $seq)
461 $qid = $sequence->getQuestionForSequence($seq);
462 if ($qid == $question_id)
468 array_push($pointsforposition, $reachedpoints[$qid]);
472 return $pointsforposition;
495 return $this->
__raiseError(
"The required user information is only available for active users.",
"");
500 $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",
504 if (
$result->numRows() != 1)
return 0;
506 $is_random =
$row[
"random_test"];
508 include_once
"./Modules/Test/classes/class.ilTestSequence.php";
510 return $sequence->getUserQuestionCount();
534 if(!strlen($test_ref_id))
536 return $this->
__raiseError(
'No test id given. Aborting!',
539 global $rbacsystem, $tree,
$ilLog;
543 return $this->
__raiseError(
'Test is trashed. Aborting!',
550 return $this->
__raiseError(
'No test found for id: '.$test_ref_id,
556 $permission_ok =
false;
559 if($rbacsystem->checkAccess(
'write',$ref_id))
561 $permission_ok =
true;
567 return $this->
__raiseError(
'No permission to edit the object with id: '.$test_ref_id,
571 include_once
'./webservice/soap/classes/class.ilXMLResultSet.php';
572 include_once
'./webservice/soap/classes/class.ilXMLResultSetWriter.php';
575 $xmlResultSet->addColumn(
"user_id");
576 $xmlResultSet->addColumn(
"login");
577 $xmlResultSet->addColumn(
"firstname");
578 $xmlResultSet->addColumn(
"lastname");
579 $xmlResultSet->addColumn(
"matriculation");
581 include_once
'./Modules/Test/classes/class.ilObjTest.php';
582 $test_obj =
new ilObjTest($obj_id,
false);
583 $participants = $test_obj->getTestParticipants();
588 $data = $test_obj->getAllTestResults($participants,
false);
590 $xmlResultSet->addColumn(
"maximum_points");
591 $xmlResultSet->addColumn(
"received_points");
593 $titles = array_shift(
$data);
596 $xmlRow->setValue(0, $row[
"user_id"]);
597 $xmlRow->setValue(1, $row[
"login"]);
598 $xmlRow->setValue(2, $row[
"firstname"]);
599 $xmlRow->setValue(3, $row[
"lastname"]);
600 $xmlRow->setValue(4, $row[
"matriculation"]);
601 $xmlRow->setValue(5, $row[
"max_points"]);
602 $xmlRow->setValue(6, $row[
"reached_points"]);
603 $xmlResultSet->addRow($xmlRow);
606 $data = $test_obj->getDetailedTestResults($participants);
608 $xmlResultSet->addColumn(
"question_id");
609 $xmlResultSet->addColumn(
"question_title");
610 $xmlResultSet->addColumn(
"maximum_points");
611 $xmlResultSet->addColumn(
"received_points");
614 $xmlRow->setValue(0, $row[
"user_id"]);
615 $xmlRow->setValue(1, $row[
"login"]);
616 $xmlRow->setValue(2, $row[
"firstname"]);
617 $xmlRow->setValue(3, $row[
"lastname"]);
618 $xmlRow->setValue(4, $row[
"matriculation"]);
619 $xmlRow->setValue(5, $row[
"question_id"]);
620 $xmlRow->setValue(6, $row[
"question_title"]);
621 $xmlRow->setValue(7, $row[
"max_points"]);
622 $xmlRow->setValue(8, $row[
"reached_points"]);
623 $xmlResultSet->addRow($xmlRow);
629 return $xmlWriter->getXML();