33 include_once
'./webservice/soap/classes/class.ilSoapAdministration.php';
44 $ilAccess = $DIC[
'ilAccess'];
46 $permission_ok =
false;
48 "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",
54 $obj_id =
$row[
'obj_fi'];
56 if ($ilAccess->checkAccess(
"write",
"", $ref_id)) {
57 $permission_ok =
true;
62 return $permission_ok;
80 "SELECT * FROM tst_times WHERE active_fi = %s ORDER BY started DESC",
86 if (preg_match(
"/(\\d{4})-(\\d{2})-(\\d{2}) (\\d{2}):(\\d{2}):(\\d{2})/",
$row[
"started"], $matches)) {
87 $time = mktime($matches[4], $matches[5], $matches[6], $matches[2], $matches[3], $matches[1]);
93 $ilClientIniFile = $DIC[
'ilClientIniFile'];
94 $expires = $ilClientIniFile->readVariable(
'session',
'expire');
95 if ($diff <= $expires) {
108 "SELECT user_fi FROM tst_active WHERE active_id = %s",
126 if (!$this->__checkSession($sid)) {
130 return $this->
__raiseError(
"The required user information is only available for active users.",
"");
133 if (is_array($solution) && (array_key_exists(
"item", $solution))) {
134 $solution = $solution[
"item"];
139 $ilDB = $DIC[
'ilDB'];
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) {
153 $processLocker->executeUserSolutionUpdateLockOperation(
function () use (&$totalrows, $active_id, $question_id,
$pass, $solution) {
155 if (($active_id > 0) && ($question_id > 0) && (strlen(
$pass) > 0)) {
156 $affectedRows =
$ilDB->manipulateF(
157 "DELETE FROM tst_solutions WHERE active_fi = %s AND question_fi = %s AND pass = %s",
158 array(
'integer',
'integer',
'integer'),
159 array($active_id, $question_id,
$pass)
162 for (
$i = 0;
$i < count($solution);
$i += 3) {
163 $next_id =
$ilDB->nextId(
'tst_solutions');
164 $affectedRows =
$ilDB->insert(
"tst_solutions", array(
165 "solution_id" => array(
"integer", $next_id),
166 "active_fi" => array(
"integer", $active_id),
167 "question_fi" => array(
"integer", $question_id),
168 "value1" => array(
"clob", $solution[
$i]),
169 "value2" => array(
"clob", $solution[$i+1]),
170 "points" => array(
"float", $solution[$i+2]),
171 "pass" => array(
"integer",
$pass),
172 "tstamp" => array(
"integer", time())
174 $totalrows += $affectedRows;
178 if ($totalrows != 0) {
179 include_once
"./Modules/TestQuestionPool/classes/class.assQuestion.php";
181 $question->setProcessLocker($processLocker);
182 $question->calculateResultsFromSolution($active_id,
$pass);
186 if ($totalrows == 0) {
188 "Wrong solution data. ILIAS did not execute any database queries: Solution data: " . print_r($solution,
true),
212 if (!$this->__checkSession($sid)) {
216 return $this->
__raiseError(
"The required user information is only available for active users.",
"");
219 $solutions = array();
220 if (preg_match(
"/<values>(.*?)<\/values>/is", $solution, $matches)) {
221 if (preg_match_all(
"/<value>(.*?)<\/value><value>(.*?)<\/value><points>(.*?)<\/points>/is", $solution, $matches, PREG_SET_ORDER)) {
222 foreach ($matches as $match) {
223 if (count($match) == 4) {
224 for (
$i = 1;
$i < count($match);
$i++) {
225 array_push($solutions, trim($match[
$i]));
232 if (count($solutions) == 0) {
233 return $this->
__raiseError(
"Wrong solution data. ILIAS did not find one or more solution triplets: $solution",
"");
238 if (($active_id > 0) && ($question_id > 0) && (strlen(
$pass) > 0)) {
239 $affectedRows =
$ilDB->manipulateF(
240 "DELETE FROM tst_solutions WHERE active_fi = %s AND question_fi = %s AND pass = %s",
241 array(
'integer',
'integer',
'integer'),
242 array($active_id, $question_id,
$pass)
246 for (
$i = 0;
$i < count($solutions);
$i += 3) {
247 $next_id =
$ilDB->nextId(
'tst_solutions');
248 $affectedRows =
$ilDB->insert(
"tst_solutions", array(
249 "solution_id" => array(
"integer", $next_id),
250 "active_fi" => array(
"integer", $active_id),
251 "question_fi" => array(
"integer", $question_id),
252 "value1" => array(
"clob", $solutions[
$i]),
253 "value2" => array(
"clob", $solutions[$i+1]),
254 "points" => array(
"float", $solutions[$i+2]),
255 "pass" => array(
"integer",
$pass),
256 "tstamp" => array(
"integer", time())
258 $totalrows += $affectedRows;
260 if (count($totalrows) == 0) {
261 return $this->
__raiseError(
"Wrong solution data. ILIAS did not execute any database queries");
263 include_once
"./Modules/TestQuestionPool/classes/class.assQuestion.php";
265 $question->calculateResultsFromSolution($active_id,
$pass);
285 if (!$this->__checkSession($sid)) {
289 return $this->
__raiseError(
"The required user information is only available for active users.",
"");
295 $ilDB = $DIC[
'ilDB'];
297 $use_previous_answers = 1;
300 "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",
306 $use_previous_answers =
$row[
"use_previous_answers"];
309 if ($use_previous_answers) {
311 "SELECT MAX(pass) maxpass FROM tst_test_result WHERE active_fi = %s AND question_fi = %s",
312 array(
'integer',
'integer'),
313 array($active_id, $question_id)
317 $lastpass =
$row[
"maxpass"];
323 if (($active_id > 0) && ($question_id > 0) && (strlen($lastpass) > 0)) {
325 "SELECT * FROM tst_solutions WHERE active_fi = %s AND question_fi = %s AND pass = %s",
326 array(
'integer',
'integer',
'integer'),
327 array($active_id, $question_id, $lastpass)
331 array_push($solution,
$row[
"value1"]);
332 array_push($solution,
$row[
"value2"]);
333 array_push($solution,
$row[
"points"]);
353 if (!$this->__checkSession($sid)) {
357 if (!$this->checkActiveIdResultsAccess($active_id)) {
358 return $this->
__raiseError(
"The required user information is only available for active users.",
"");
365 $ilDB = $DIC[
'ilDB'];
368 "SELECT user_fi, test_fi FROM tst_active WHERE active_id = %s",
373 $user_id =
$row[
"user_fi"];
374 $test_id =
$row[
"test_fi"];
377 "SELECT anonymity FROM tst_tests WHERE test_id = %s",
382 $anonymity =
$row[
"anonymity"];
385 "SELECT firstname, lastname, title, login FROM usr_data WHERE usr_id = %s",
392 $userdata[
"fullname"] =
$lng->txt(
"deleted_user");
393 $userdata[
"title"] =
"";
394 $userdata[
"firstname"] =
"";
395 $userdata[
"lastname"] =
$lng->txt(
"anonymous");
396 $userdata[
"login"] =
"";
399 if (($user_id == ANONYMOUS_USER_ID) || ($anonymity)) {
400 $userdata[
"fullname"] =
$lng->txt(
"anonymous");
401 $userdata[
"title"] =
"";
402 $userdata[
"firstname"] =
"";
403 $userdata[
"lastname"] =
$lng->txt(
"anonymous");
404 $userdata[
"login"] =
"";
406 $userdata[
"fullname"] = trim(
$data[
"title"] .
" " .
$data[
"firstname"] .
" " .
$data[
"lastname"]);
407 $userdata[
"title"] = $data[
"title"];
408 $userdata[
"firstname"] = $data[
"firstname"];
409 $userdata[
"lastname"] = $data[
"lastname"];
410 $userdata[
"login"] = $data[
"login"];
413 return array_values($userdata);
431 if (!$this->__checkSession($sid)) {
435 return $this->
__raiseError(
"The required user information is only available for active users.",
"");
441 $ilDB = $DIC[
'ilDB'];
444 "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",
452 $is_random =
$row[
"random_test"];
454 include_once
"./Modules/Test/classes/class.ilTestSequence.php";
456 return $sequence->getSequenceForQuestion($question_id);
474 if (!$this->__checkSession($sid)) {
478 return $this->
__raiseError(
"The required user information is only available for active users.",
"");
484 $ilDB = $DIC[
'ilDB'];
487 "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",
495 $is_random =
$row[
"random_test"];
497 include_once
"./Modules/Test/classes/class.ilTestSequence.php";
500 "SELECT question_fi, points FROM tst_test_result WHERE active_fi = %s AND pass = %s",
501 array(
'integer',
'integer'),
502 array($active_id,
$pass)
504 $reachedpoints = array();
506 $reachedpoints[
$row[
"question_fi"]] = $row[
"points"];
509 $pointsforposition = array();
510 foreach ($sequence->getUserSequence() as $seq) {
512 $qid = $sequence->getQuestionForSequence($seq);
513 if ($qid == $question_id) {
516 array_push($pointsforposition, $reachedpoints[$qid]);
520 return $pointsforposition;
537 if (!$this->__checkSession($sid)) {
541 return $this->
__raiseError(
"The required user information is only available for active users.",
"");
547 $ilDB = $DIC[
'ilDB'];
550 "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",
558 $is_random =
$row[
"random_test"];
560 include_once
"./Modules/Test/classes/class.ilTestSequence.php";
562 return $sequence->getUserQuestionCount();
577 if (!$this->__checkSession($sid)) {
580 if (!strlen($test_ref_id)) {
582 'No test id given. Aborting!',
588 $rbacsystem = $DIC[
'rbacsystem'];
589 $tree = $DIC[
'tree'];
593 return $this->
__raiseError(
'no permission. Aborting!',
'Client');
598 'Test is trashed. Aborting!',
604 return $this->
__raiseError(
'No test found for id: ' . $test_ref_id,
'Client');
606 if ($tst->getType() !=
'tst') {
607 return $this->
__raiseError(
'Object with ref_id ' . $test_ref_id .
' is not of type test. Aborting',
'Client');
611 if (isset($a_user_ids[
'item'])) {
612 $a_user_ids = $a_user_ids[
'item'];
615 include_once
'./Modules/Test/classes/class.ilObjTest.php';
616 include_once
'./Modules/Test/classes/class.ilTestParticipantData.php';
617 require_once
'Modules/Test/classes/class.ilTestParticipantAccessFilter.php';
619 $part->setParticipantAccessFilter(
622 $part->setUserIdsFilter((array) $a_user_ids);
623 $part->load($tst->getTestId());
624 $tst->removeTestResults($part);
646 if (!$this->__checkSession($sid)) {
649 if (!strlen($test_ref_id)) {
651 'No test id given. Aborting!',
657 $rbacsystem = $DIC[
'rbacsystem'];
658 $tree = $DIC[
'tree'];
663 'Test is trashed. Aborting!',
671 'No test found for id: ' . $test_ref_id,
678 $permission_ok =
false;
680 if ($rbacsystem->checkAccess(
'write', $ref_id)) {
681 $permission_ok =
true;
689 if (!$permission_ok) {
691 'No permission to edit the object with id: ' . $test_ref_id,
696 include_once
'./webservice/soap/classes/class.ilXMLResultSet.php';
697 include_once
'./webservice/soap/classes/class.ilXMLResultSetWriter.php';
700 $xmlResultSet->addColumn(
"user_id");
701 $xmlResultSet->addColumn(
"login");
702 $xmlResultSet->addColumn(
"firstname");
703 $xmlResultSet->addColumn(
"lastname");
704 $xmlResultSet->addColumn(
"matriculation");
706 include_once
'./Modules/Test/classes/class.ilObjTest.php';
707 $test_obj =
new ilObjTest($obj_id,
false);
708 $participants = $test_obj->getTestParticipants();
710 require_once
'Modules/Test/classes/class.ilTestParticipantAccessFilter.php';
711 require_once
'Modules/Test/classes/class.ilTestParticipantList.php';
714 $participantList->initializeFromDbRows($participants);
715 $participantList = $participantList->getAccessFilteredList($accessFilter);
716 foreach ($participants as $activeId => $part) {
717 if ($participantList->isActiveIdInList($activeId)) {
721 unset($participants[$activeId]);
725 $data = $test_obj->getAllTestResults($participants,
false);
727 $xmlResultSet->addColumn(
"maximum_points");
728 $xmlResultSet->addColumn(
"received_points");
730 $titles = array_shift(
$data);
733 $xmlRow->setValue(0, $row[
"user_id"]);
734 $xmlRow->setValue(1, $row[
"login"]);
735 $xmlRow->setValue(2, $row[
"firstname"]);
736 $xmlRow->setValue(3, $row[
"lastname"]);
737 $xmlRow->setValue(4, $row[
"matriculation"]);
738 $xmlRow->setValue(5, $row[
"max_points"]);
739 $xmlRow->setValue(6, $row[
"reached_points"]);
740 $xmlResultSet->addRow($xmlRow);
743 $data = $test_obj->getDetailedTestResults($participants);
745 $xmlResultSet->addColumn(
"question_id");
746 $xmlResultSet->addColumn(
"question_title");
747 $xmlResultSet->addColumn(
"maximum_points");
748 $xmlResultSet->addColumn(
"received_points");
751 $xmlRow->setValue(0, $row[
"user_id"]);
752 $xmlRow->setValue(1, $row[
"login"]);
753 $xmlRow->setValue(2, $row[
"firstname"]);
754 $xmlRow->setValue(3, $row[
"lastname"]);
755 $xmlRow->setValue(4, $row[
"matriculation"]);
756 $xmlRow->setValue(5, $row[
"question_id"]);
757 $xmlRow->setValue(6, $row[
"question_title"]);
758 $xmlRow->setValue(7, $row[
"max_points"]);
759 $xmlRow->setValue(8, $row[
"reached_points"]);
760 $xmlResultSet->addRow($xmlRow);
766 return $xmlWriter->getXML();
775 return $this->
getTestAccess($refId)->checkManageParticipantsAccess();
784 return $this->
getTestAccess($refId)->checkParticipantsResultsAccess();
793 require_once
'Modules/Test/classes/class.ilTestAccess.php';
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.
static _isInTrash($a_ref_id)
checks wether object is in trash
getTestResults($sid, $test_ref_id, $sum_only)
get results of test
if($_SERVER['argc']< 4) $client
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)
static _getTestIDFromObjectID($object_id)
Returns the ILIAS test id for a given object 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.
getQuestionSolution($sid, $active_id, $question_id, $pass)
Get the the answers of a given question and pass for a given user.
static getManageParticipantsUserFilter($refId)
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
static getAccessResultsUserFilter($refId)
checkParticipantsResultsAccess($refId)
checkManageParticipantsAccess($refId)
$GLOBALS['JPEG_Segment_Names']
Global Variable: XMP_tag_captions.
getTestUserData($sid, $active_id)
get active user data