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",
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",
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",
118 if (
$row[
'user_fi'] == $ilUser->getId())
134 if(!$this->__checkSession($sid))
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"];
147 require_once
'Modules/TestQuestionPool/classes/class.ilAssQuestionProcessLockerFactory.php';
149 $processLockerFactory->setQuestionId($question_id);
150 $processLockerFactory->setUserId($ilUser->getId());
151 include_once (
"./Modules/Test/classes/class.ilObjAssessmentFolder.php");
153 $processLocker = $processLockerFactory->getLocker();
155 $processLocker->requestPersistWorkingStateLock();
156 $processLocker->requestUserSolutionUpdateLock();
159 if (($active_id > 0) && ($question_id > 0) && (strlen(
$pass) > 0))
161 $affectedRows = $ilDB->manipulateF(
"DELETE FROM tst_solutions WHERE active_fi = %s AND question_fi = %s AND pass = %s",
162 array(
'integer',
'integer',
'integer'),
163 array($active_id, $question_id,
$pass)
167 for($i = 0; $i < count($solution); $i += 3)
169 $next_id = $ilDB->nextId(
'tst_solutions');
170 $affectedRows = $ilDB->insert(
"tst_solutions", array(
171 "solution_id" => array(
"integer", $next_id),
172 "active_fi" => array(
"integer", $active_id),
173 "question_fi" => array(
"integer", $question_id),
174 "value1" => array(
"clob", $solution[$i]),
175 "value2" => array(
"clob", $solution[$i+1]),
176 "points" => array(
"float", $solution[$i+2]),
177 "pass" => array(
"integer",
$pass),
178 "tstamp" => array(
"integer", time())
180 $totalrows += $affectedRows;
183 $processLocker->releaseUserSolutionUpdateLock();
187 $processLocker->releasePersistWorkingStateLock();
189 "Wrong solution data. ILIAS did not execute any database queries: Solution data: " . print_r($solution,
true),
195 include_once
"./Modules/TestQuestionPool/classes/class.assQuestion.php";
197 $question->setProcessLocker($processLocker);
198 $question->calculateResultsFromSolution($active_id,
$pass);
200 $processLocker->releasePersistWorkingStateLock();
221 if(!$this->__checkSession($sid))
227 return $this->
__raiseError(
"The required user information is only available for active users.",
"");
230 $solutions = array();
231 if (preg_match(
"/<values>(.*?)<\/values>/is", $solution, $matches))
233 if (preg_match_all(
"/<value>(.*?)<\/value><value>(.*?)<\/value><points>(.*?)<\/points>/is", $solution, $matches, PREG_SET_ORDER))
235 foreach ($matches as $match)
237 if (count($match) == 4)
239 for ($i = 1; $i < count($match); $i++)
241 array_push($solutions, trim($match[$i]));
248 if (count($solutions) == 0)
250 return $this->
__raiseError(
"Wrong solution data. ILIAS did not find one or more solution triplets: $solution",
"");
255 if (($active_id > 0) && ($question_id > 0) && (strlen(
$pass) > 0))
257 $affectedRows =
$ilDB->manipulateF(
"DELETE FROM tst_solutions WHERE active_fi = %s AND question_fi = %s AND pass = %s",
258 array(
'integer',
'integer',
'integer'),
259 array($active_id, $question_id,
$pass)
263 for($i = 0; $i < count($solutions); $i += 3)
265 $next_id =
$ilDB->nextId(
'tst_solutions');
266 $affectedRows =
$ilDB->insert(
"tst_solutions", array(
267 "solution_id" => array(
"integer", $next_id),
268 "active_fi" => array(
"integer", $active_id),
269 "question_fi" => array(
"integer", $question_id),
270 "value1" => array(
"clob", $solutions[$i]),
271 "value2" => array(
"clob", $solutions[$i+1]),
272 "points" => array(
"float", $solutions[$i+2]),
273 "pass" => array(
"integer",
$pass),
274 "tstamp" => array(
"integer", time())
276 $totalrows += $affectedRows;
278 if (count($totalrows) == 0)
280 return $this->
__raiseError(
"Wrong solution data. ILIAS did not execute any database queries");
284 include_once
"./Modules/TestQuestionPool/classes/class.assQuestion.php";
286 $question->calculateResultsFromSolution($active_id,
$pass);
306 if(!$this->__checkSession($sid))
312 return $this->
__raiseError(
"The required user information is only available for active users.",
"");
318 $use_previous_answers = 1;
320 $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",
327 $use_previous_answers =
$row[
"use_previous_answers"];
330 if ($use_previous_answers)
332 $result = $ilDB->queryF(
"SELECT MAX(pass) maxpass FROM tst_test_result WHERE active_fi = %s AND question_fi = %s",
333 array(
'integer',
'integer'),
334 array($active_id, $question_id)
339 $lastpass =
$row[
"maxpass"];
347 if (($active_id > 0) && ($question_id > 0) && (strlen($lastpass) > 0))
349 $result = $ilDB->queryF(
"SELECT * FROM tst_solutions WHERE active_fi = %s AND question_fi = %s AND pass = %s",
350 array(
'integer',
'integer',
'integer'),
351 array($active_id, $question_id, $lastpass)
357 array_push($solution,
$row[
"value1"]);
358 array_push($solution,
$row[
"value2"]);
359 array_push($solution,
$row[
"points"]);
379 if(!$this->__checkSession($sid))
385 return $this->
__raiseError(
"The required user information is only available for active users.",
"");
390 $result = $ilDB->queryF(
"SELECT user_fi, test_fi FROM tst_active WHERE active_id = %s",
395 $user_id =
$row[
"user_fi"];
396 $test_id =
$row[
"test_fi"];
398 $result = $ilDB->queryF(
"SELECT anonymity FROM tst_tests WHERE test_id = %s",
403 $anonymity =
$row[
"anonymity"];
405 $result = $ilDB->queryF(
"SELECT firstname, lastname, title, login FROM usr_data WHERE usr_id = %s",
413 $userdata[
"fullname"] = $lng->txt(
"deleted_user");
414 $userdata[
"title"] =
"";
415 $userdata[
"firstname"] =
"";
416 $userdata[
"lastname"] = $lng->txt(
"anonymous");
417 $userdata[
"login"] =
"";
421 $data = $ilDB->fetchAssoc(
$result);
422 if (($user_id == ANONYMOUS_USER_ID) || ($anonymity))
424 $userdata[
"fullname"] = $lng->txt(
"anonymous");
425 $userdata[
"title"] =
"";
426 $userdata[
"firstname"] =
"";
427 $userdata[
"lastname"] = $lng->txt(
"anonymous");
428 $userdata[
"login"] =
"";
432 $userdata[
"fullname"] = trim($data[
"title"] .
" " . $data[
"firstname"] .
" " . $data[
"lastname"]);
433 $userdata[
"title"] = $data[
"title"];
434 $userdata[
"firstname"] = $data[
"firstname"];
435 $userdata[
"lastname"] = $data[
"lastname"];
436 $userdata[
"login"] = $data[
"login"];
439 return array_values($userdata);
457 if(!$this->__checkSession($sid))
463 return $this->
__raiseError(
"The required user information is only available for active users.",
"");
468 $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",
472 if (
$result->numRows() != 1)
return -1;
474 $is_random =
$row[
"random_test"];
476 include_once
"./Modules/Test/classes/class.ilTestSequence.php";
478 return $sequence->getSequenceForQuestion($question_id);
496 if(!$this->__checkSession($sid))
502 return $this->
__raiseError(
"The required user information is only available for active users.",
"");
507 $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",
511 if (
$result->numRows() != 1)
return -1;
513 $is_random =
$row[
"random_test"];
515 include_once
"./Modules/Test/classes/class.ilTestSequence.php";
517 $result = $ilDB->queryF(
"SELECT question_fi, points FROM tst_test_result WHERE active_fi = %s AND pass = %s",
518 array(
'integer',
'integer'),
519 array($active_id,
$pass)
521 $reachedpoints = array();
524 $reachedpoints[
$row[
"question_fi"]] = $row[
"points"];
527 $pointsforposition = array();
528 foreach ($sequence->getUserSequence() as $seq)
532 $qid = $sequence->getQuestionForSequence($seq);
533 if ($qid == $question_id)
539 array_push($pointsforposition, $reachedpoints[$qid]);
543 return $pointsforposition;
560 if(!$this->__checkSession($sid))
566 return $this->
__raiseError(
"The required user information is only available for active users.",
"");
571 $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",
575 if (
$result->numRows() != 1)
return 0;
577 $is_random =
$row[
"random_test"];
579 include_once
"./Modules/Test/classes/class.ilTestSequence.php";
581 return $sequence->getUserQuestionCount();
596 if(!$this->__checkSession($sid))
600 if(!strlen($test_ref_id))
602 return $this->
__raiseError(
'No test id given. Aborting!',
605 global $rbacsystem, $tree,
$ilLog;
609 return $this->
__raiseError(
'Test is trashed. Aborting!',
615 return $this->
__raiseError(
'No test found for id: '.$test_ref_id,
'Client');
617 if($tst->getType() !=
'tst')
619 return $this->
__raiseError(
'Object with ref_id '.$test_ref_id.
' is not of type test. Aborting',
'Client');
623 if(isset($a_user_ids[
'item']))
625 $a_user_ids = $a_user_ids[
'item'];
628 foreach((array) $a_user_ids as $user_id)
630 $tst->removeTestResultsForUser($user_id);
652 if(!$this->__checkSession($sid))
656 if(!strlen($test_ref_id))
658 return $this->
__raiseError(
'No test id given. Aborting!',
661 global $rbacsystem, $tree,
$ilLog;
665 return $this->
__raiseError(
'Test is trashed. Aborting!',
672 return $this->
__raiseError(
'No test found for id: '.$test_ref_id,
678 $permission_ok =
false;
681 if($rbacsystem->checkAccess(
'write',$ref_id))
683 $permission_ok =
true;
689 return $this->
__raiseError(
'No permission to edit the object with id: '.$test_ref_id,
693 include_once
'./webservice/soap/classes/class.ilXMLResultSet.php';
694 include_once
'./webservice/soap/classes/class.ilXMLResultSetWriter.php';
697 $xmlResultSet->addColumn(
"user_id");
698 $xmlResultSet->addColumn(
"login");
699 $xmlResultSet->addColumn(
"firstname");
700 $xmlResultSet->addColumn(
"lastname");
701 $xmlResultSet->addColumn(
"matriculation");
703 include_once
'./Modules/Test/classes/class.ilObjTest.php';
704 $test_obj =
new ilObjTest($obj_id,
false);
705 $participants = $test_obj->getTestParticipants();
710 $data = $test_obj->getAllTestResults($participants,
false);
712 $xmlResultSet->addColumn(
"maximum_points");
713 $xmlResultSet->addColumn(
"received_points");
715 $titles = array_shift($data);
716 foreach ($data as
$row) {
718 $xmlRow->setValue(0, $row[
"user_id"]);
719 $xmlRow->setValue(1, $row[
"login"]);
720 $xmlRow->setValue(2, $row[
"firstname"]);
721 $xmlRow->setValue(3, $row[
"lastname"]);
722 $xmlRow->setValue(4, $row[
"matriculation"]);
723 $xmlRow->setValue(5, $row[
"max_points"]);
724 $xmlRow->setValue(6, $row[
"reached_points"]);
725 $xmlResultSet->addRow($xmlRow);
728 $data = $test_obj->getDetailedTestResults($participants);
730 $xmlResultSet->addColumn(
"question_id");
731 $xmlResultSet->addColumn(
"question_title");
732 $xmlResultSet->addColumn(
"maximum_points");
733 $xmlResultSet->addColumn(
"received_points");
734 foreach ($data as
$row) {
736 $xmlRow->setValue(0, $row[
"user_id"]);
737 $xmlRow->setValue(1, $row[
"login"]);
738 $xmlRow->setValue(2, $row[
"firstname"]);
739 $xmlRow->setValue(3, $row[
"lastname"]);
740 $xmlRow->setValue(4, $row[
"matriculation"]);
741 $xmlRow->setValue(5, $row[
"question_id"]);
742 $xmlRow->setValue(6, $row[
"question_title"]);
743 $xmlRow->setValue(7, $row[
"max_points"]);
744 $xmlRow->setValue(8, $row[
"reached_points"]);
745 $xmlResultSet->addRow($xmlRow);
751 return $xmlWriter->getXML();