33 include_once
'./webservice/soap/classes/class.ilSoapAdministration.php';
42 $permission_ok =
false;
44 "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'];
52 if ($ilAccess->checkAccess(
"write",
"", $ref_id)) {
53 $permission_ok =
true;
58 return $permission_ok;
72 "SELECT * FROM tst_times WHERE active_fi = %s ORDER BY started DESC",
78 if (preg_match(
"/(\\d{4})-(\\d{2})-(\\d{2}) (\\d{2}):(\\d{2}):(\\d{2})/",
$row[
"started"], $matches)) {
79 $time = mktime($matches[4], $matches[5], $matches[6], $matches[2], $matches[3], $matches[1]);
83 global $ilClientIniFile;
84 $expires = $ilClientIniFile->readVariable(
'session',
'expire');
85 if ($diff <= $expires) {
98 "SELECT user_fi FROM tst_active WHERE active_id = %s",
103 if (
$row[
'user_fi'] == $ilUser->getId()) {
116 if (!$this->__checkSession($sid)) {
120 return $this->
__raiseError(
"The required user information is only available for active users.",
"");
123 if (is_array($solution) && (array_key_exists(
"item", $solution))) {
124 $solution = $solution[
"item"];
129 require_once
'Modules/TestQuestionPool/classes/class.ilAssQuestionProcessLockerFactory.php';
131 $processLockerFactory->setQuestionId($question_id);
132 $processLockerFactory->setUserId($ilUser->getId());
133 include_once(
"./Modules/Test/classes/class.ilObjAssessmentFolder.php");
135 $processLocker = $processLockerFactory->getLocker();
139 $processLocker->executePersistWorkingStateLockOperation(
function () use (&$totalrows, $processLocker, $active_id, $question_id,
$pass, $solution) {
140 $processLocker->executeUserSolutionUpdateLockOperation(
function () use (&$totalrows, $active_id, $question_id,
$pass, $solution) {
142 if (($active_id > 0) && ($question_id > 0) && (strlen(
$pass) > 0)) {
143 $affectedRows = $ilDB->manipulateF(
144 "DELETE FROM tst_solutions WHERE active_fi = %s AND question_fi = %s AND pass = %s",
145 array(
'integer',
'integer',
'integer'),
149 for (
$i = 0;
$i < count($solution);
$i += 3) {
150 $next_id = $ilDB->nextId(
'tst_solutions');
151 $affectedRows = $ilDB->insert(
"tst_solutions",
array(
152 "solution_id" =>
array(
"integer", $next_id),
153 "active_fi" =>
array(
"integer", $active_id),
154 "question_fi" =>
array(
"integer", $question_id),
155 "value1" =>
array(
"clob", $solution[
$i]),
156 "value2" =>
array(
"clob", $solution[$i+1]),
157 "points" =>
array(
"float", $solution[$i+2]),
161 $totalrows += $affectedRows;
165 if ($totalrows != 0) {
166 include_once
"./Modules/TestQuestionPool/classes/class.assQuestion.php";
168 $question->setProcessLocker($processLocker);
169 $question->calculateResultsFromSolution($active_id,
$pass);
173 if ($totalrows == 0) {
175 "Wrong solution data. ILIAS did not execute any database queries: Solution data: " . print_r($solution,
true),
199 if (!$this->__checkSession($sid)) {
203 return $this->
__raiseError(
"The required user information is only available for active users.",
"");
206 $solutions =
array();
207 if (preg_match(
"/<values>(.*?)<\/values>/is", $solution, $matches)) {
208 if (preg_match_all(
"/<value>(.*?)<\/value><value>(.*?)<\/value><points>(.*?)<\/points>/is", $solution, $matches, PREG_SET_ORDER)) {
209 foreach ($matches as $match) {
210 if (count($match) == 4) {
211 for (
$i = 1;
$i < count($match);
$i++) {
212 array_push($solutions, trim($match[
$i]));
219 if (count($solutions) == 0) {
220 return $this->
__raiseError(
"Wrong solution data. ILIAS did not find one or more solution triplets: $solution",
"");
225 if (($active_id > 0) && ($question_id > 0) && (strlen(
$pass) > 0)) {
226 $affectedRows =
$ilDB->manipulateF(
227 "DELETE FROM tst_solutions WHERE active_fi = %s AND question_fi = %s AND pass = %s",
228 array(
'integer',
'integer',
'integer'),
233 for (
$i = 0;
$i < count($solutions);
$i += 3) {
234 $next_id =
$ilDB->nextId(
'tst_solutions');
235 $affectedRows =
$ilDB->insert(
"tst_solutions",
array(
236 "solution_id" =>
array(
"integer", $next_id),
237 "active_fi" =>
array(
"integer", $active_id),
238 "question_fi" =>
array(
"integer", $question_id),
239 "value1" =>
array(
"clob", $solutions[
$i]),
240 "value2" =>
array(
"clob", $solutions[$i+1]),
241 "points" =>
array(
"float", $solutions[$i+2]),
245 $totalrows += $affectedRows;
247 if (count($totalrows) == 0) {
248 return $this->
__raiseError(
"Wrong solution data. ILIAS did not execute any database queries");
250 include_once
"./Modules/TestQuestionPool/classes/class.assQuestion.php";
252 $question->calculateResultsFromSolution($active_id,
$pass);
272 if (!$this->__checkSession($sid)) {
276 return $this->
__raiseError(
"The required user information is only available for active users.",
"");
282 $use_previous_answers = 1;
285 "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",
291 $use_previous_answers =
$row[
"use_previous_answers"];
294 if ($use_previous_answers) {
296 "SELECT MAX(pass) maxpass FROM tst_test_result WHERE active_fi = %s AND question_fi = %s",
297 array(
'integer',
'integer'),
298 array($active_id, $question_id)
302 $lastpass =
$row[
"maxpass"];
308 if (($active_id > 0) && ($question_id > 0) && (strlen($lastpass) > 0)) {
310 "SELECT * FROM tst_solutions WHERE active_fi = %s AND question_fi = %s AND pass = %s",
311 array(
'integer',
'integer',
'integer'),
312 array($active_id, $question_id, $lastpass)
316 array_push($solution,
$row[
"value1"]);
317 array_push($solution,
$row[
"value2"]);
318 array_push($solution,
$row[
"points"]);
338 if (!$this->__checkSession($sid)) {
342 return $this->
__raiseError(
"The required user information is only available for active users.",
"");
348 "SELECT user_fi, test_fi FROM tst_active WHERE active_id = %s",
353 $user_id =
$row[
"user_fi"];
354 $test_id =
$row[
"test_fi"];
357 "SELECT anonymity FROM tst_tests WHERE test_id = %s",
362 $anonymity =
$row[
"anonymity"];
365 "SELECT firstname, lastname, title, login FROM usr_data WHERE usr_id = %s",
372 $userdata[
"fullname"] = $lng->txt(
"deleted_user");
375 $userdata[
"lastname"] = $lng->txt(
"anonymous");
379 if (($user_id == ANONYMOUS_USER_ID) || ($anonymity)) {
380 $userdata[
"fullname"] = $lng->txt(
"anonymous");
383 $userdata[
"lastname"] = $lng->txt(
"anonymous");
388 $userdata[
"firstname"] = $data[
"firstname"];
389 $userdata[
"lastname"] = $data[
"lastname"];
411 if (!$this->__checkSession($sid)) {
415 return $this->
__raiseError(
"The required user information is only available for active users.",
"");
421 "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",
429 $is_random =
$row[
"random_test"];
431 include_once
"./Modules/Test/classes/class.ilTestSequence.php";
433 return $sequence->getSequenceForQuestion($question_id);
451 if (!$this->__checkSession($sid)) {
455 return $this->
__raiseError(
"The required user information is only available for active users.",
"");
461 "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 $is_random =
$row[
"random_test"];
471 include_once
"./Modules/Test/classes/class.ilTestSequence.php";
474 "SELECT question_fi, points FROM tst_test_result WHERE active_fi = %s AND pass = %s",
475 array(
'integer',
'integer'),
478 $reachedpoints =
array();
480 $reachedpoints[
$row[
"question_fi"]] = $row[
"points"];
483 $pointsforposition =
array();
484 foreach ($sequence->getUserSequence() as $seq) {
486 $qid = $sequence->getQuestionForSequence($seq);
487 if ($qid == $question_id) {
490 array_push($pointsforposition, $reachedpoints[$qid]);
494 return $pointsforposition;
511 if (!$this->__checkSession($sid)) {
515 return $this->
__raiseError(
"The required user information is only available for active users.",
"");
521 "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",
529 $is_random =
$row[
"random_test"];
531 include_once
"./Modules/Test/classes/class.ilTestSequence.php";
533 return $sequence->getUserQuestionCount();
548 if (!$this->__checkSession($sid)) {
551 if (!strlen($test_ref_id)) {
553 'No test id given. Aborting!',
557 global $rbacsystem, $tree,
$ilLog;
560 if (!$ilAccess->checkAccess(
'write',
'', $test_ref_id)) {
561 return $this->
__raiseError(
'no permission. Aborting!',
'Client');
566 'Test is trashed. Aborting!',
572 return $this->
__raiseError(
'No test found for id: ' . $test_ref_id,
'Client');
574 if ($tst->getType() !=
'tst') {
575 return $this->
__raiseError(
'Object with ref_id ' . $test_ref_id .
' is not of type test. Aborting',
'Client');
579 if (isset($a_user_ids[
'item'])) {
580 $a_user_ids = $a_user_ids[
'item'];
583 include_once
'./Modules/Test/classes/class.ilObjTest.php';
584 include_once
'./Modules/Test/classes/class.ilTestParticipantData.php';
586 $part->setUserIds((
array) $a_user_ids);
587 $part->load($tst->getTestId());
588 $tst->removeTestResults($part);
610 if (!$this->__checkSession($sid)) {
613 if (!strlen($test_ref_id)) {
615 'No test id given. Aborting!',
619 global $rbacsystem, $tree,
$ilLog;
623 'Test is trashed. Aborting!',
631 'No test found for id: ' . $test_ref_id,
638 $permission_ok =
false;
640 if ($rbacsystem->checkAccess(
'write', $ref_id)) {
641 $permission_ok =
true;
645 if (!$permission_ok) {
647 'No permission to edit the object with id: ' . $test_ref_id,
652 include_once
'./webservice/soap/classes/class.ilXMLResultSet.php';
653 include_once
'./webservice/soap/classes/class.ilXMLResultSetWriter.php';
656 $xmlResultSet->addColumn(
"user_id");
657 $xmlResultSet->addColumn(
"login");
658 $xmlResultSet->addColumn(
"firstname");
659 $xmlResultSet->addColumn(
"lastname");
660 $xmlResultSet->addColumn(
"matriculation");
662 include_once
'./Modules/Test/classes/class.ilObjTest.php';
663 $test_obj =
new ilObjTest($obj_id,
false);
664 $participants = $test_obj->getTestParticipants();
668 $data = $test_obj->getAllTestResults($participants,
false);
670 $xmlResultSet->addColumn(
"maximum_points");
671 $xmlResultSet->addColumn(
"received_points");
673 $titles = array_shift(
$data);
676 $xmlRow->setValue(0, $row[
"user_id"]);
677 $xmlRow->setValue(1, $row[
"login"]);
678 $xmlRow->setValue(2, $row[
"firstname"]);
679 $xmlRow->setValue(3, $row[
"lastname"]);
680 $xmlRow->setValue(4, $row[
"matriculation"]);
681 $xmlRow->setValue(5, $row[
"max_points"]);
682 $xmlRow->setValue(6, $row[
"reached_points"]);
683 $xmlResultSet->addRow($xmlRow);
686 $data = $test_obj->getDetailedTestResults($participants);
688 $xmlResultSet->addColumn(
"question_id");
689 $xmlResultSet->addColumn(
"question_title");
690 $xmlResultSet->addColumn(
"maximum_points");
691 $xmlResultSet->addColumn(
"received_points");
694 $xmlRow->setValue(0, $row[
"user_id"]);
695 $xmlRow->setValue(1, $row[
"login"]);
696 $xmlRow->setValue(2, $row[
"firstname"]);
697 $xmlRow->setValue(3, $row[
"lastname"]);
698 $xmlRow->setValue(4, $row[
"matriculation"]);
699 $xmlRow->setValue(5, $row[
"question_id"]);
700 $xmlRow->setValue(6, $row[
"question_title"]);
701 $xmlRow->setValue(7, $row[
"max_points"]);
702 $xmlRow->setValue(8, $row[
"reached_points"]);
703 $xmlResultSet->addRow($xmlRow);
709 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