ILIAS  release_9 Revision v9.13-25-g2c18ec4c24f
class.ilSoapTestAdministration.php
Go to the documentation of this file.
1 <?php
2 
25 include_once './webservice/soap/classes/class.ilSoapAdministration.php';
26 
28 {
29  private function hasWritePermissionForTest(int $active_id): bool
30  {
31  global $DIC;
32 
33  $ilDB = $DIC['ilDB'];
34  global $DIC;
35 
36  $ilAccess = $DIC['ilAccess'];
37 
38  $permission_ok = false;
39  $result = $ilDB->queryF(
40  "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",
41  array('integer'),
42  array($active_id)
43  );
44  $row = $ilDB->fetchAssoc($result);
45  if ($row['obj_fi']) {
46  $obj_id = $row['obj_fi'];
47  foreach ($ref_ids = ilObject::_getAllReferences($obj_id) as $ref_id) {
48  if ($ilAccess->checkAccess("write", "", $ref_id)) {
49  $permission_ok = true;
50  break;
51  }
52  }
53  }
54  return $permission_ok;
55  }
56 
57  public function isAllowedCall(string $sid, int $active_id, bool $saveaction = true): bool
58  {
59  global $DIC;
60 
61  $ilDB = $DIC['ilDB'];
62  global $DIC;
63 
64  $ilUser = $DIC['ilUser'];
65 
66  if ($this->hasWritePermissionForTest($active_id)) {
67  return true;
68  }
69 
70  if ($saveaction) {
71  $result = $ilDB->queryF(
72  "SELECT * FROM tst_times WHERE active_fi = %s ORDER BY started DESC",
73  array('integer'),
74  array($active_id)
75  );
76  if ($result->numRows()) {
77  $row = $ilDB->fetchAssoc($result);
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]);
80  $now = time();
81  $diff = $now - $time;
82  $client = explode("::", $sid);
83  global $DIC;
84 
85  $ilClientIniFile = $DIC['ilClientIniFile'];
86  $expires = $ilClientIniFile->readVariable('session', 'expire');
87  return $diff <= $expires;
88  }
89 
90  return false;
91  }
92 
93  return false;
94  }
95 
96  $result = $ilDB->queryF(
97  "SELECT user_fi FROM tst_active WHERE active_id = %s",
98  array('integer'),
99  array($active_id)
100  );
101  $row = $ilDB->fetchAssoc($result);
102 
103  return (int) $row['user_fi'] === $ilUser->getId();
104  }
105 
109  public function saveQuestion(string $sid, int $active_id, int $question_id, int $pass, array $solution)
110  {
111  $this->initAuth($sid);
112  $this->initIlias();
113 
114  if (!$this->checkSession($sid)) {
115  return $this->raiseError($this->getMessage(), $this->getMessageCode());
116  }
117  if (!$this->isAllowedCall($sid, $active_id)) {
118  return $this->raiseError("The required user information is only available for active users.", "");
119  }
120 
121  global $DIC;
122 
123  $ilDB = $DIC['ilDB'];
124  $ilUser = $DIC['ilUser'];
125 
126  require_once 'Modules/TestQuestionPool/classes/class.ilAssQuestionProcessLockerFactory.php';
127  $processLockerFactory = new ilAssQuestionProcessLockerFactory(new ilSetting('assessment'), $ilDB);
128  $processLockerFactory->setQuestionId($question_id);
129  $processLockerFactory->setUserId($ilUser->getId());
130  include_once("./Modules/Test/classes/class.ilObjAssessmentFolder.php");
131  $processLockerFactory->setAssessmentLogEnabled(ilObjAssessmentFolder::_enabledAssessmentLogging());
132  $processLocker = $processLockerFactory->getLocker();
133 
134  $totalrows = 0;
135 
136  $processLocker->executePersistWorkingStateLockOperation(function () use (
137  &$totalrows,
138  $processLocker,
139  $active_id,
140  $question_id,
141  $pass,
142  $solution
143  ) {
144  $processLocker->executeUserSolutionUpdateLockOperation(function () use (
145  &$totalrows,
146  $active_id,
147  $question_id,
148  $pass,
149  $solution
150  ) {
151  $ilDB = $GLOBALS['DIC']['ilDB'];
152  if (($active_id > 0) && ($question_id > 0) && ($pass > 0)) {
153  $affectedRows = $ilDB->manipulateF(
154  "DELETE FROM tst_solutions WHERE active_fi = %s AND question_fi = %s AND pass = %s",
155  array('integer', 'integer', 'integer'),
156  array($active_id, $question_id, $pass)
157  );
158  }
159  for ($i = 0, $iMax = count($solution); $i < $iMax; $i += 3) {
160  $next_id = $ilDB->nextId('tst_solutions');
161  $affectedRows = $ilDB->insert("tst_solutions", array(
162  "solution_id" => array("integer", $next_id),
163  "active_fi" => array("integer", $active_id),
164  "question_fi" => array("integer", $question_id),
165  "value1" => array("clob", $solution[$i]),
166  "value2" => array("clob", $solution[$i + 1]),
167  "points" => array("float", $solution[$i + 2]),
168  "pass" => array("integer", $pass),
169  "tstamp" => array("integer", time())
170  ));
171  $totalrows += $affectedRows;
172  }
173  });
174 
175  if ($totalrows !== 0) {
176  include_once "./Modules/TestQuestionPool/classes/class.assQuestion.php";
177  $question = assQuestion::instantiateQuestion($question_id);
178  $question->setProcessLocker($processLocker);
179  $question->calculateResultsFromSolution($active_id, $pass);
180  }
181  });
182 
183  if ($totalrows === 0) {
184  return $this->raiseError(
185  "Wrong solution data. ILIAS did not execute any database queries: Solution data: " . print_r(
186  $solution,
187  true
188  ),
189  'No result'
190  );
191  }
192  return true;
193  }
194 
198  public function saveQuestionSolution(string $sid, int $active_id, int $question_id, int $pass, int $solution)
199  {
200  $this->initAuth($sid);
201  $this->initIlias();
202 
203  if (!$this->checkSession($sid)) {
204  return $this->raiseError($this->getMessage(), $this->getMessageCode());
205  }
206  if (!$this->isAllowedCall($sid, $active_id)) {
207  return $this->raiseError("The required user information is only available for active users.", "");
208  }
209 
210  $solutions = [];
211  if (preg_match("/<values>(.*?)<\/values>/is", $solution, $matches)) {
212  if (preg_match_all(
213  "/<value>(.*?)<\/value><value>(.*?)<\/value><points>(.*?)<\/points>/is",
214  $solution,
215  $matches,
216  PREG_SET_ORDER
217  )) {
218  foreach ($matches as $match) {
219  if (count($match) === 4) {
220  for ($i = 1, $iMax = count($match); $i < $iMax; $i++) {
221  $solutions[] = trim($match[$i]);
222  }
223  }
224  }
225  }
226  }
227 
228  if (count($solutions) === 0) {
229  return $this->raiseError(
230  "Wrong solution data. ILIAS did not find one or more solution triplets: $solution",
231  ""
232  );
233  }
234 
235  $ilDB = $GLOBALS['DIC']['ilDB'];
236  if (($active_id > 0) && ($question_id > 0) && ($pass > 0)) {
237  $affectedRows = $ilDB->manipulateF(
238  "DELETE FROM tst_solutions WHERE active_fi = %s AND question_fi = %s AND pass = %s",
239  array('integer', 'integer', 'integer'),
240  array($active_id, $question_id, $pass)
241  );
242  }
243  $totalrows = 0;
244  for ($i = 0, $iMax = count($solutions); $i < $iMax; $i += 3) {
245  $next_id = $ilDB->nextId('tst_solutions');
246  $affectedRows = $ilDB->insert("tst_solutions", array(
247  "solution_id" => array("integer", $next_id),
248  "active_fi" => array("integer", $active_id),
249  "question_fi" => array("integer", $question_id),
250  "value1" => array("clob", $solutions[$i]),
251  "value2" => array("clob", $solutions[$i + 1]),
252  "points" => array("float", $solutions[$i + 2]),
253  "pass" => array("integer", $pass),
254  "tstamp" => array("integer", time())
255  ));
256  $totalrows += $affectedRows;
257  }
258  if ($totalrows === 0) {
259  return $this->raiseError("Wrong solution data. ILIAS did not execute any database queries", '');
260  }
261 
262  include_once "./Modules/TestQuestionPool/classes/class.assQuestion.php";
263  $question = assQuestion::instantiateQuestion($question_id);
264  $question->calculateResultsFromSolution($active_id, $pass);
265  return "TRUE";
266  }
267 
271  public function getQuestionSolution(string $sid, int $active_id, int $question_id, int $pass)
272  {
273  $this->initAuth($sid);
274  $this->initIlias();
275 
276  if (!$this->checkSession($sid)) {
277  return $this->raiseError($this->getMessage(), $this->getMessageCode());
278  }
279  if (!$this->isAllowedCall($sid, $active_id, false)) {
280  return $this->raiseError("The required user information is only available for active users.", "");
281  }
282  $solution = array();
283 
284  global $DIC;
285 
286  $ilDB = $DIC['ilDB'];
287 
288  $use_previous_answers = 1;
289 
290  $result = $ilDB->queryF(
291  "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",
292  array('integer'),
293  array($active_id)
294  );
295  if ($result->numRows()) {
296  $row = $ilDB->fetchAssoc($result);
297  $use_previous_answers = $row["use_previous_answers"];
298  }
299  $lastpass = 0;
300  if ($use_previous_answers) {
301  $result = $ilDB->queryF(
302  "SELECT MAX(pass) maxpass FROM tst_test_result WHERE active_fi = %s AND question_fi = %s",
303  array('integer', 'integer'),
304  array($active_id, $question_id)
305  );
306  if ($result->numRows() === 1) {
307  $row = $ilDB->fetchAssoc($result);
308  $lastpass = (int) $row["maxpass"];
309  }
310  } else {
311  $lastpass = $pass;
312  }
313 
314  if (($active_id > 0) && ($question_id > 0) && ($lastpass > 0)) {
315  $result = $ilDB->queryF(
316  "SELECT * FROM tst_solutions WHERE active_fi = %s AND question_fi = %s AND pass = %s",
317  array('integer', 'integer', 'integer'),
318  array($active_id, $question_id, $lastpass)
319  );
320  if ($result->numRows()) {
321  while ($row = $ilDB->fetchAssoc($result)) {
322  $solution[] = $row["value1"];
323  $solution[] = $row["value2"];
324  $solution[] = $row["points"];
325  }
326  }
327  }
328  return $solution;
329  }
330 
334  public function getTestUserData(string $sid, int $active_id)
335  {
336  $this->initAuth($sid);
337  $this->initIlias();
338 
339  if (!$this->checkSession($sid)) {
340  return $this->raiseError($this->getMessage(), $this->getMessageCode());
341  }
342  if (!$this->isAllowedCall($sid, $active_id, false)) {
343  return $this->raiseError("The required user information is only available for active users.", "");
344  }
345 
346  global $DIC;
347 
348  $lng = $DIC['lng'];
349  $ilDB = $DIC['ilDB'];
350 
351  $result = $ilDB->queryF(
352  "SELECT user_fi, test_fi FROM tst_active WHERE active_id = %s",
353  array('integer'),
354  array($active_id)
355  );
356  $row = $ilDB->fetchAssoc($result);
357  $user_id = $row["user_fi"];
358  $test_id = $row["test_fi"];
359 
360  $result = $ilDB->queryF(
361  "SELECT anonymity FROM tst_tests WHERE test_id = %s",
362  array('integer'),
363  array($test_id)
364  );
365  $row = $ilDB->fetchAssoc($result);
366  $anonymity = $row["anonymity"];
367 
368  $result = $ilDB->queryF(
369  "SELECT firstname, lastname, title, login FROM usr_data WHERE usr_id = %s",
370  array('integer'),
371  array($user_id)
372  );
373 
374  $userdata = array();
375  if ($result->numRows() === 0) {
376  $userdata["fullname"] = $lng->txt("deleted_user");
377  $userdata["title"] = "";
378  $userdata["firstname"] = "";
379  $userdata["lastname"] = $lng->txt("anonymous");
380  $userdata["login"] = "";
381  } else {
382  $data = $ilDB->fetchAssoc($result);
383  if ((int) $user_id === ANONYMOUS_USER_ID || $anonymity) {
384  $userdata["fullname"] = $lng->txt("anonymous");
385  $userdata["title"] = "";
386  $userdata["firstname"] = "";
387  $userdata["lastname"] = $lng->txt("anonymous");
388  $userdata["login"] = "";
389  } else {
390  $userdata["fullname"] = trim($data["title"] . " " . $data["firstname"] . " " . $data["lastname"]);
391  $userdata["title"] = $data["title"];
392  $userdata["firstname"] = $data["firstname"];
393  $userdata["lastname"] = $data["lastname"];
394  $userdata["login"] = $data["login"];
395  }
396  }
397  return array_values($userdata);
398  }
399 
403  public function getPositionOfQuestion(string $sid, int $active_id, int $question_id, int $pass)
404  {
405  $this->initAuth($sid);
406  $this->initIlias();
407 
408  if (!$this->checkSession($sid)) {
409  return $this->raiseError($this->getMessage(), $this->getMessageCode());
410  }
411  if (!$this->isAllowedCall($sid, $active_id, false)) {
412  return $this->raiseError("The required user information is only available for active users.", "");
413  }
414 
415  global $DIC;
416 
417  $lng = $DIC['lng'];
418  $ilDB = $DIC['ilDB'];
419  $questioninfo = $DIC->testQuestionPool()->questionInfo();
420 
421  $result = $ilDB->queryF(
422  "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",
423  array('integer'),
424  array($active_id)
425  );
426  if ($result->numRows() !== 1) {
427  return -1;
428  }
429  $row = $ilDB->fetchAssoc($result);
430  $is_random = $row["random_test"];
431 
432  include_once "./Modules/Test/classes/class.ilTestSequence.php";
433  $sequence = new ilTestSequence($ilDB, $active_id, $pass, $questioninfo);
434  return $sequence->getSequenceForQuestion($question_id);
435  }
436 
440  public function getPreviousReachedPoints(string $sid, int $active_id, int $question_id, int $pass)
441  {
442  $this->initAuth($sid);
443  $this->initIlias();
444 
445  if (!$this->checkSession($sid)) {
446  return $this->raiseError($this->getMessage(), $this->getMessageCode());
447  }
448  if (!$this->isAllowedCall($sid, $active_id, false)) {
449  return $this->raiseError("The required user information is only available for active users.", "");
450  }
451 
452  global $DIC;
453 
454  $lng = $DIC['lng'];
455  $ilDB = $DIC['ilDB'];
456  $questioninfo = $DIC->testQuestionPool()->questionInfo();
457 
458  $result = $ilDB->queryF(
459  "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",
460  array('integer'),
461  array($active_id)
462  );
463  if ($result->numRows() !== 1) {
464  return -1;
465  }
466  $row = $ilDB->fetchAssoc($result);
467  $is_random = $row["random_test"];
468 
469  include_once "./Modules/Test/classes/class.ilTestSequence.php";
470  $sequence = new ilTestSequence($ilDB, $active_id, $pass, $questioninfo);
471  $result = $ilDB->queryF(
472  "SELECT question_fi, points FROM tst_test_result WHERE active_fi = %s AND pass = %s",
473  array('integer', 'integer'),
474  array($active_id, $pass)
475  );
476  $reachedpoints = array();
477  while ($row = $ilDB->fetchAssoc($result)) {
478  $reachedpoints[$row["question_fi"]] = $row["points"];
479  }
480  $atposition = false;
481  $pointsforposition = array();
482  foreach ($sequence->getUserSequence() as $seq) {
483  if (!$atposition) {
484  $qid = $sequence->getQuestionForSequence($seq);
485  if ($qid == $question_id) {
486  $atposition = true;
487  } else {
488  $pointsforposition[] = $reachedpoints[$qid];
489  }
490  }
491  }
492  return $pointsforposition;
493  }
494 
498  public function getNrOfQuestionsInPass(string $sid, int $active_id, int $pass)
499  {
500  $this->initAuth($sid);
501  $this->initIlias();
502 
503  if (!$this->checkSession($sid)) {
504  return $this->raiseError($this->getMessage(), $this->getMessageCode());
505  }
506  if (!$this->isAllowedCall($sid, $active_id, false)) {
507  return $this->raiseError("The required user information is only available for active users.", "");
508  }
509 
510  global $DIC;
511 
512  $lng = $DIC['lng'];
513  $ilDB = $DIC['ilDB'];
514  $questioninfo = $DIC->testQuestionPool()->questionInfo();
515 
516  $result = $ilDB->queryF(
517  "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",
518  array('integer'),
519  array($active_id)
520  );
521  if ($result->numRows() !== 1) {
522  return 0;
523  }
524  $row = $ilDB->fetchAssoc($result);
525  $is_random = $row["random_test"];
526 
527  include_once "./Modules/Test/classes/class.ilTestSequence.php";
528  $sequence = new ilTestSequence($ilDB, $active_id, $pass, $questioninfo);
529  return $sequence->getUserQuestionCount();
530  }
531 
535  public function removeTestResults(string $sid, int $test_ref_id, array $a_user_ids)
536  {
537  $this->initAuth($sid);
538  $this->initIlias();
539 
540  if (!$this->checkSession($sid)) {
541  return $this->raiseError($this->getMessage(), $this->getMessageCode());
542  }
543  if (!($test_ref_id > 0)) {
544  return $this->raiseError(
545  'No test id given. Aborting!',
546  'Client'
547  );
548  }
549  global $DIC;
550 
551  $rbacsystem = $DIC['rbacsystem'];
552  $tree = $DIC['tree'];
553  $ilLog = $DIC['ilLog'];
554 
555  if (!$this->checkManageParticipantsAccess($test_ref_id)) {
556  return $this->raiseError('no permission. Aborting!', 'Client');
557  }
558 
559  if (ilObject::_isInTrash($test_ref_id)) {
560  return $this->raiseError(
561  'Test is trashed. Aborting!',
562  'Client'
563  );
564  }
565 
566  if (!$tst = ilObjectFactory::getInstanceByRefId($test_ref_id, false)) {
567  return $this->raiseError('No test found for id: ' . $test_ref_id, 'Client');
568  }
569  if ($tst->getType() !== 'tst') {
570  return $this->raiseError(
571  'Object with ref_id ' . $test_ref_id . ' is not of type test. Aborting',
572  'Client'
573  );
574  }
575 
576  // Dirty hack
577  if (isset($a_user_ids['item'])) {
578  $a_user_ids = $a_user_ids['item'];
579  }
580 
581  include_once './Modules/Test/classes/class.ilObjTest.php';
582  include_once './Modules/Test/classes/class.ilTestParticipantData.php';
583  require_once 'Modules/Test/classes/class.ilTestParticipantAccessFilter.php';
584  $part = new ilTestParticipantData($GLOBALS['DIC']['ilDB'], $GLOBALS['DIC']['lng']);
585  $part->setParticipantAccessFilter(
586  ilTestParticipantAccessFilter::getManageParticipantsUserFilter($test_ref_id)
587  );
588  $part->setUserIdsFilter((array) $a_user_ids);
589  $part->load($tst->getTestId());
590  $tst->removeTestResults($part);
591 
592  return true;
593  }
594 
598  public function getTestResults(string $sid, int $test_ref_id, bool $sum_only)
599  {
600  $this->initAuth($sid);
601  $this->initIlias();
602 
603  if (!$this->checkSession($sid)) {
604  return $this->raiseError($this->getMessage(), $this->getMessageCode());
605  }
606  if (!($test_ref_id > 0)) {
607  return $this->raiseError(
608  'No test id given. Aborting!',
609  'Client'
610  );
611  }
612  global $DIC;
613 
614  $rbacsystem = $DIC['rbacsystem'];
615  $tree = $DIC['tree'];
616  $ilLog = $DIC['ilLog'];
617 
618  if (ilObject::_isInTrash($test_ref_id)) {
619  return $this->raiseError(
620  'Test is trashed. Aborting!',
621  'Client'
622  );
623  }
624 
625  if (!$obj_id = ilObject::_lookupObjectId($test_ref_id)) {
626  return $this->raiseError(
627  'No test found for id: ' . $test_ref_id,
628  'Client'
629  );
630  }
631 
632  $permission_ok = false;
633  foreach ($ref_ids = ilObject::_getAllReferences($obj_id) as $ref_id) {
634  if ($rbacsystem->checkAccess('write', $ref_id)) {
635  $permission_ok = true;
636  break;
637  }
638  }
639  if (!$permission_ok && $this->checkParticipantsResultsAccess($test_ref_id)) {
640  $permission_ok = $this->checkParticipantsResultsAccess($test_ref_id);
641  }
642 
643  if (!$permission_ok) {
644  return $this->raiseError(
645  'No permission to edit the object with id: ' . $test_ref_id,
646  'Server'
647  );
648  }
649 
650  include_once './webservice/soap/classes/class.ilXMLResultSet.php';
651  include_once './webservice/soap/classes/class.ilXMLResultSetWriter.php';
652 
653  $xmlResultSet = new ilXMLResultSet();
654  $xmlResultSet->addColumn("user_id");
655  $xmlResultSet->addColumn("login");
656  $xmlResultSet->addColumn("firstname");
657  $xmlResultSet->addColumn("lastname");
658  $xmlResultSet->addColumn("matriculation");
659 
660  include_once './Modules/Test/classes/class.ilObjTest.php';
661  $test_obj = new ilObjTest($obj_id, false);
662  $participants = $test_obj->getTestParticipants();
663 
664  require_once 'Modules/Test/classes/class.ilTestParticipantAccessFilter.php';
665  require_once 'Modules/Test/classes/class.ilTestParticipantList.php';
666  $accessFilter = ilTestParticipantAccessFilter::getAccessResultsUserFilter($test_ref_id);
667  $participantList = new ilTestParticipantList($test_obj);
668  $participantList->initializeFromDbRows($participants);
669  $participantList = $participantList->getAccessFilteredList($accessFilter);
670  $participantList = $participantList->getScoredParticipantList();
671  foreach ($participants as $activeId => $part) {
672  if ($participantList->isActiveIdInList($activeId)) {
673  $participants[$activeId]['passed'] = $participantList->getParticipantByActiveId($activeId)->getScoring()->isPassed();
674  continue;
675  }
676 
677  unset($participants[$activeId]);
678  }
679 
680  if ($sum_only) {
681  $data = $test_obj->getAllTestResults($participants, false);
682 
683  $xmlResultSet->addColumn("maximum_points");
684  $xmlResultSet->addColumn("received_points");
685  $xmlResultSet->addColumn("passed");
686  // skip titles
687  $titles = array_shift($data);
688  foreach ($data as $row) {
689  $xmlRow = new ilXMLResultSetRow();
690  $xmlRow->setValue(0, $row["user_id"]);
691  $xmlRow->setValue(1, $row["login"]);
692  $xmlRow->setValue(2, $row["firstname"]);
693  $xmlRow->setValue(3, $row["lastname"]);
694  $xmlRow->setValue(4, $row["matriculation"]);
695  $xmlRow->setValue(5, $row["max_points"]);
696  $xmlRow->setValue(6, $row["reached_points"]);
697  $xmlRow->setValue(7, $row["passed"]);
698  $xmlResultSet->addRow($xmlRow);
699  }
700  } else {
701  $data = $test_obj->getDetailedTestResults($participants);
702 
703  $xmlResultSet->addColumn("question_id");
704  $xmlResultSet->addColumn("question_title");
705  $xmlResultSet->addColumn("maximum_points");
706  $xmlResultSet->addColumn("received_points");
707  $xmlResultSet->addColumn("passed");
708  foreach ($data as $row) {
709  $xmlRow = new ilXMLResultSetRow();
710  $xmlRow->setValue(0, $row["user_id"]);
711  $xmlRow->setValue(1, $row["login"]);
712  $xmlRow->setValue(2, $row["firstname"]);
713  $xmlRow->setValue(3, $row["lastname"]);
714  $xmlRow->setValue(4, $row["matriculation"]);
715  $xmlRow->setValue(5, $row["question_id"]);
716  $xmlRow->setValue(6, $row["question_title"]);
717  $xmlRow->setValue(7, $row["max_points"]);
718  $xmlRow->setValue(8, $row["reached_points"]);
719  $xmlRow->setValue(9, $row["passed"]);
720  $xmlResultSet->addRow($xmlRow);
721  }
722  }
723 
724  $xmlWriter = new ilXMLResultSetWriter($xmlResultSet);
725  $xmlWriter->start();
726  return $xmlWriter->getXML();
727  }
728 
729  protected function checkManageParticipantsAccess(int $refId): bool
730  {
731  return $this->getTestAccess($refId)->checkManageParticipantsAccess();
732  }
733 
734  protected function checkParticipantsResultsAccess(int $refId): bool
735  {
736  return $this->getTestAccess($refId)->checkParticipantsResultsAccess();
737  }
738 
739  protected function getTestAccess(int $refId): ilTestAccess
740  {
741  require_once 'Modules/Test/classes/class.ilTestAccess.php';
742 
744  return new ilTestAccess($refId, $testId);
745  }
746 }
isAllowedCall(string $sid, int $active_id, bool $saveaction=true)
XML Writer for XMLResultSet.
getTestResults(string $sid, int $test_ref_id, bool $sum_only)
const ANONYMOUS_USER_ID
Definition: constants.php:27
getQuestionSolution(string $sid, int $active_id, int $question_id, int $pass)
static _getAllReferences(int $id)
get all reference ids for object ID
raiseError(string $a_message, $a_code)
Row Class for XMLResultSet.
$refId
Definition: xapitoken.php:58
saveQuestionSolution(string $sid, int $active_id, int $question_id, int $pass, int $solution)
Test sequence handler.
global $DIC
Definition: feed.php:28
removeTestResults(string $sid, int $test_ref_id, array $a_user_ids)
$client
static instantiateQuestion(int $question_id)
$ref_id
Definition: ltiauth.php:67
$GLOBALS["DIC"]
Definition: wac.php:31
$lng
getNrOfQuestionsInPass(string $sid, int $active_id, int $pass)
static _isInTrash(int $ref_id)
static getInstanceByRefId(int $ref_id, bool $stop_on_error=true)
get an instance of an Ilias object by reference id
static _lookupObjectId(int $ref_id)
static _getTestIDFromObjectID($object_id)
Returns the ILIAS test id for a given object id.
saveQuestion(string $sid, int $active_id, int $question_id, int $pass, array $solution)
getPositionOfQuestion(string $sid, int $active_id, int $question_id, int $pass)
getPreviousReachedPoints(string $sid, int $active_id, int $question_id, int $pass)
getTestUserData(string $sid, int $active_id)