33 include_once
'./webservice/soap/classes/class.ilSoapAdministration.php';
42 $permission_ok =
false;
43 $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",
50 $obj_id =
$row[
'obj_fi'];
53 if ($ilAccess->checkAccess(
"write",
"", $ref_id))
55 $permission_ok =
true;
60 return $permission_ok;
72 $result = $ilDB->queryF(
"SELECT * FROM tst_times WHERE active_fi = %s ORDER BY started DESC",
79 if (preg_match(
"/(\\d{4})-(\\d{2})-(\\d{2}) (\\d{2}):(\\d{2}):(\\d{2})/",
$row[
"started"], $matches))
81 $time = mktime($matches[4], $matches[5], $matches[6], $matches[2], $matches[3], $matches[1]);
85 global $ilClientIniFile;
86 $expires = $ilClientIniFile->readVariable(
'session',
'expire');
87 if ($diff <= $expires)
108 $result = $ilDB->queryF(
"SELECT user_fi FROM tst_active WHERE active_id = %s",
113 if (
$row[
'user_fi'] == $ilUser->getId())
129 if(!$this->__checkSession($sid))
135 return $this->
__raiseError(
"The required user information is only available for active users.",
"");
138 if (is_array($solution) && (array_key_exists(
"item", $solution))) $solution = $solution[
"item"];
142 require_once
'Modules/TestQuestionPool/classes/class.ilAssQuestionProcessLockerFactory.php';
144 $processLockerFactory->setQuestionId($question_id);
145 $processLockerFactory->setUserId($ilUser->getId());
146 include_once (
"./Modules/Test/classes/class.ilObjAssessmentFolder.php");
148 $processLocker = $processLockerFactory->getLocker();
152 $processLocker->executePersistWorkingStateLockOperation(
function() use (&$totalrows, $processLocker, $active_id, $question_id,
$pass, $solution) {
154 $processLocker->executeUserSolutionUpdateLockOperation(
function() use (&$totalrows, $active_id, $question_id,
$pass, $solution) {
157 if (($active_id > 0) && ($question_id > 0) && (strlen(
$pass) > 0))
159 $affectedRows = $ilDB->manipulateF(
"DELETE FROM tst_solutions WHERE active_fi = %s AND question_fi = %s AND pass = %s",
160 array(
'integer',
'integer',
'integer'),
164 for($i = 0; $i < count($solution); $i += 3)
166 $next_id = $ilDB->nextId(
'tst_solutions');
167 $affectedRows = $ilDB->insert(
"tst_solutions",
array(
168 "solution_id" =>
array(
"integer", $next_id),
169 "active_fi" =>
array(
"integer", $active_id),
170 "question_fi" =>
array(
"integer", $question_id),
171 "value1" =>
array(
"clob", $solution[$i]),
172 "value2" =>
array(
"clob", $solution[$i+1]),
173 "points" =>
array(
"float", $solution[$i+2]),
177 $totalrows += $affectedRows;
183 include_once
"./Modules/TestQuestionPool/classes/class.assQuestion.php";
185 $question->setProcessLocker($processLocker);
186 $question->calculateResultsFromSolution($active_id,
$pass);
194 "Wrong solution data. ILIAS did not execute any database queries: Solution data: " . print_r($solution,
true),
218 if(!$this->__checkSession($sid))
224 return $this->
__raiseError(
"The required user information is only available for active users.",
"");
227 $solutions =
array();
228 if (preg_match(
"/<values>(.*?)<\/values>/is", $solution, $matches))
230 if (preg_match_all(
"/<value>(.*?)<\/value><value>(.*?)<\/value><points>(.*?)<\/points>/is", $solution, $matches, PREG_SET_ORDER))
232 foreach ($matches as $match)
234 if (count($match) == 4)
236 for ($i = 1; $i < count($match); $i++)
238 array_push($solutions, trim($match[$i]));
245 if (count($solutions) == 0)
247 return $this->
__raiseError(
"Wrong solution data. ILIAS did not find one or more solution triplets: $solution",
"");
252 if (($active_id > 0) && ($question_id > 0) && (strlen(
$pass) > 0))
254 $affectedRows =
$ilDB->manipulateF(
"DELETE FROM tst_solutions WHERE active_fi = %s AND question_fi = %s AND pass = %s",
255 array(
'integer',
'integer',
'integer'),
260 for($i = 0; $i < count($solutions); $i += 3)
262 $next_id =
$ilDB->nextId(
'tst_solutions');
263 $affectedRows =
$ilDB->insert(
"tst_solutions",
array(
264 "solution_id" =>
array(
"integer", $next_id),
265 "active_fi" =>
array(
"integer", $active_id),
266 "question_fi" =>
array(
"integer", $question_id),
267 "value1" =>
array(
"clob", $solutions[$i]),
268 "value2" =>
array(
"clob", $solutions[$i+1]),
269 "points" =>
array(
"float", $solutions[$i+2]),
273 $totalrows += $affectedRows;
275 if (count($totalrows) == 0)
277 return $this->
__raiseError(
"Wrong solution data. ILIAS did not execute any database queries");
281 include_once
"./Modules/TestQuestionPool/classes/class.assQuestion.php";
283 $question->calculateResultsFromSolution($active_id,
$pass);
303 if(!$this->__checkSession($sid))
309 return $this->
__raiseError(
"The required user information is only available for active users.",
"");
315 $use_previous_answers = 1;
317 $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",
324 $use_previous_answers =
$row[
"use_previous_answers"];
327 if ($use_previous_answers)
329 $result = $ilDB->queryF(
"SELECT MAX(pass) maxpass FROM tst_test_result WHERE active_fi = %s AND question_fi = %s",
330 array(
'integer',
'integer'),
331 array($active_id, $question_id)
336 $lastpass =
$row[
"maxpass"];
344 if (($active_id > 0) && ($question_id > 0) && (strlen($lastpass) > 0))
346 $result = $ilDB->queryF(
"SELECT * FROM tst_solutions WHERE active_fi = %s AND question_fi = %s AND pass = %s",
347 array(
'integer',
'integer',
'integer'),
348 array($active_id, $question_id, $lastpass)
354 array_push($solution,
$row[
"value1"]);
355 array_push($solution,
$row[
"value2"]);
356 array_push($solution,
$row[
"points"]);
376 if(!$this->__checkSession($sid))
382 return $this->
__raiseError(
"The required user information is only available for active users.",
"");
387 $result = $ilDB->queryF(
"SELECT user_fi, test_fi FROM tst_active WHERE active_id = %s",
392 $user_id =
$row[
"user_fi"];
393 $test_id =
$row[
"test_fi"];
395 $result = $ilDB->queryF(
"SELECT anonymity FROM tst_tests WHERE test_id = %s",
400 $anonymity =
$row[
"anonymity"];
402 $result = $ilDB->queryF(
"SELECT firstname, lastname, title, login FROM usr_data WHERE usr_id = %s",
410 $userdata[
"fullname"] = $lng->txt(
"deleted_user");
411 $userdata[
"title"] =
"";
412 $userdata[
"firstname"] =
"";
413 $userdata[
"lastname"] = $lng->txt(
"anonymous");
414 $userdata[
"login"] =
"";
419 if (($user_id == ANONYMOUS_USER_ID) || ($anonymity))
421 $userdata[
"fullname"] = $lng->txt(
"anonymous");
422 $userdata[
"title"] =
"";
423 $userdata[
"firstname"] =
"";
424 $userdata[
"lastname"] = $lng->txt(
"anonymous");
425 $userdata[
"login"] =
"";
429 $userdata[
"fullname"] = trim(
$data[
"title"] .
" " .
$data[
"firstname"] .
" " .
$data[
"lastname"]);
430 $userdata[
"title"] = $data[
"title"];
431 $userdata[
"firstname"] = $data[
"firstname"];
432 $userdata[
"lastname"] = $data[
"lastname"];
433 $userdata[
"login"] = $data[
"login"];
436 return array_values($userdata);
454 if(!$this->__checkSession($sid))
460 return $this->
__raiseError(
"The required user information is only available for active users.",
"");
465 $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",
469 if (
$result->numRows() != 1)
return -1;
471 $is_random =
$row[
"random_test"];
473 include_once
"./Modules/Test/classes/class.ilTestSequence.php";
475 return $sequence->getSequenceForQuestion($question_id);
493 if(!$this->__checkSession($sid))
499 return $this->
__raiseError(
"The required user information is only available for active users.",
"");
504 $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",
508 if (
$result->numRows() != 1)
return -1;
510 $is_random =
$row[
"random_test"];
512 include_once
"./Modules/Test/classes/class.ilTestSequence.php";
514 $result = $ilDB->queryF(
"SELECT question_fi, points FROM tst_test_result WHERE active_fi = %s AND pass = %s",
515 array(
'integer',
'integer'),
518 $reachedpoints =
array();
521 $reachedpoints[
$row[
"question_fi"]] = $row[
"points"];
524 $pointsforposition =
array();
525 foreach ($sequence->getUserSequence() as $seq)
529 $qid = $sequence->getQuestionForSequence($seq);
530 if ($qid == $question_id)
536 array_push($pointsforposition, $reachedpoints[$qid]);
540 return $pointsforposition;
557 if(!$this->__checkSession($sid))
563 return $this->
__raiseError(
"The required user information is only available for active users.",
"");
568 $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",
572 if (
$result->numRows() != 1)
return 0;
574 $is_random =
$row[
"random_test"];
576 include_once
"./Modules/Test/classes/class.ilTestSequence.php";
578 return $sequence->getUserQuestionCount();
593 if(!$this->__checkSession($sid))
597 if(!strlen($test_ref_id))
599 return $this->
__raiseError(
'No test id given. Aborting!',
602 global $rbacsystem, $tree,
$ilLog;
605 if( !$ilAccess->checkAccess(
'write',
'', $test_ref_id) )
607 return $this->
__raiseError(
'no permission. Aborting!',
'Client');
612 return $this->
__raiseError(
'Test is trashed. Aborting!',
618 return $this->
__raiseError(
'No test found for id: '.$test_ref_id,
'Client');
620 if($tst->getType() !=
'tst')
622 return $this->
__raiseError(
'Object with ref_id '.$test_ref_id.
' is not of type test. Aborting',
'Client');
626 if(isset($a_user_ids[
'item']))
628 $a_user_ids = $a_user_ids[
'item'];
631 include_once
'./Modules/Test/classes/class.ilObjTest.php';
632 include_once
'./Modules/Test/classes/class.ilTestParticipantData.php';
634 $part->setUserIds((
array) $a_user_ids);
635 $part->load($tst->getTestId());
636 $tst->removeTestResults($part);
658 if(!$this->__checkSession($sid))
662 if(!strlen($test_ref_id))
664 return $this->
__raiseError(
'No test id given. Aborting!',
667 global $rbacsystem, $tree,
$ilLog;
671 return $this->
__raiseError(
'Test is trashed. Aborting!',
678 return $this->
__raiseError(
'No test found for id: '.$test_ref_id,
684 $permission_ok =
false;
687 if($rbacsystem->checkAccess(
'write',$ref_id))
689 $permission_ok =
true;
695 return $this->
__raiseError(
'No permission to edit the object with id: '.$test_ref_id,
699 include_once
'./webservice/soap/classes/class.ilXMLResultSet.php';
700 include_once
'./webservice/soap/classes/class.ilXMLResultSetWriter.php';
703 $xmlResultSet->addColumn(
"user_id");
704 $xmlResultSet->addColumn(
"login");
705 $xmlResultSet->addColumn(
"firstname");
706 $xmlResultSet->addColumn(
"lastname");
707 $xmlResultSet->addColumn(
"matriculation");
709 include_once
'./Modules/Test/classes/class.ilObjTest.php';
710 $test_obj =
new ilObjTest($obj_id,
false);
711 $participants = $test_obj->getTestParticipants();
716 $data = $test_obj->getAllTestResults($participants,
false);
718 $xmlResultSet->addColumn(
"maximum_points");
719 $xmlResultSet->addColumn(
"received_points");
721 $titles = array_shift(
$data);
724 $xmlRow->setValue(0, $row[
"user_id"]);
725 $xmlRow->setValue(1, $row[
"login"]);
726 $xmlRow->setValue(2, $row[
"firstname"]);
727 $xmlRow->setValue(3, $row[
"lastname"]);
728 $xmlRow->setValue(4, $row[
"matriculation"]);
729 $xmlRow->setValue(5, $row[
"max_points"]);
730 $xmlRow->setValue(6, $row[
"reached_points"]);
731 $xmlResultSet->addRow($xmlRow);
734 $data = $test_obj->getDetailedTestResults($participants);
736 $xmlResultSet->addColumn(
"question_id");
737 $xmlResultSet->addColumn(
"question_title");
738 $xmlResultSet->addColumn(
"maximum_points");
739 $xmlResultSet->addColumn(
"received_points");
742 $xmlRow->setValue(0, $row[
"user_id"]);
743 $xmlRow->setValue(1, $row[
"login"]);
744 $xmlRow->setValue(2, $row[
"firstname"]);
745 $xmlRow->setValue(3, $row[
"lastname"]);
746 $xmlRow->setValue(4, $row[
"matriculation"]);
747 $xmlRow->setValue(5, $row[
"question_id"]);
748 $xmlRow->setValue(6, $row[
"question_title"]);
749 $xmlRow->setValue(7, $row[
"max_points"]);
750 $xmlRow->setValue(8, $row[
"reached_points"]);
751 $xmlResultSet->addRow($xmlRow);
757 return $xmlWriter->getXML();
static _instanciateQuestion($question_id)
Creates an instance of a question with a given question id.
XML Writer for XMLResultSet.
getPositionOfQuestion($sid, $active_id, $question_id, $pass)
get active user data
getPreviousReachedPoints($sid, $active_id, $question_id, $pass)
Returns the previous reached points in a given pass.
isAllowedCall($sid, $active_id, $saveaction=true)
removeTestResults($sid, $test_ref_id, $a_user_ids)
Remove test results for the chosen test and users.
$GLOBALS['loaded']
Global hash that tracks already loaded includes.
static _isInTrash($a_ref_id)
checks wether object is in trash
getTestResults($sid, $test_ref_id, $sum_only)
get results of test
static _getAllReferences($a_id)
get all reference ids of object
static _lookupObjectId($a_ref_id)
lookup object id
static _enabledAssessmentLogging()
check wether assessment logging is enabled or not
__raiseError($a_message, $a_code)
hasWritePermissionForTest($active_id)
saveQuestion($sid, $active_id, $question_id, $pass, $solution)
getNrOfQuestionsInPass($sid, $active_id, $pass)
Get the number of questions in a given pass for a given user.
Create styles array
The data for the language used.
getQuestionSolution($sid, $active_id, $question_id, $pass)
Get the the answers of a given question and pass for a given user.
initAuth($sid)
Init authentication.
saveQuestionSolution($sid, $active_id, $question_id, $pass, $solution)
Save the solution of a question.
static getInstanceByRefId($a_ref_id, $stop_on_error=true)
get an instance of an Ilias object by reference id
Add data(end) time
Method that wraps PHPs time in order to allow simulations with the workflow.
getTestUserData($sid, $active_id)
get active user data