ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
ilSoapTestAdministration Class Reference
+ Inheritance diagram for ilSoapTestAdministration:
+ Collaboration diagram for ilSoapTestAdministration:

Public Member Functions

 isAllowedCall ($sid, $active_id, $saveaction=true)
 
 saveQuestion ($sid, $active_id, $question_id, $pass, $solution)
 
 saveQuestionSolution ($sid, $active_id, $question_id, $pass, $solution)
 Save the solution of a question. More...
 
 getQuestionSolution ($sid, $active_id, $question_id, $pass)
 Get the the answers of a given question and pass for a given user. More...
 
 getTestUserData ($sid, $active_id)
 get active user data More...
 
 getPositionOfQuestion ($sid, $active_id, $question_id, $pass)
 get active user data More...
 
 getPreviousReachedPoints ($sid, $active_id, $question_id, $pass)
 Returns the previous reached points in a given pass. More...
 
 getNrOfQuestionsInPass ($sid, $active_id, $pass)
 Get the number of questions in a given pass for a given user. More...
 
 removeTestResults ($sid, $test_ref_id, $a_user_ids)
 Remove test results for the chosen test and users. More...
 
 getTestResults ($sid, $test_ref_id, $sum_only)
 get results of test More...
 
- Public Member Functions inherited from ilSoapAdministration
 __construct ($use_nusoap=true)
 Constructor. More...
 
 initErrorWriter ()
 Overwrite error handler. More...
 
 __explodeSid ($sid)
 
 __setMessage ($a_str)
 
 __getMessage ()
 
 __appendMessage ($a_str)
 
 __setMessageCode ($a_code)
 
 __getMessageCode ()
 
 initAuth ($sid)
 Init authentication. More...
 
 initIlias ()
 
 __initAuthenticationObject ($a_auth_mode=AUTH_LOCAL)
 
 __raiseError ($a_message, $a_code)
 
 getNIC ($sid)
 get client information from current as xml result set More...
 
 isFault ($object)
 
 checkObjectAccess ($ref_id, $expected_type, $permission, $returnObject=false)
 check access for ref id: expected type, permission, return object instance if returnobject is true More...
 
 getInstallationInfoXML ()
 
 getClientInfoXML ($clientid)
 

Private Member Functions

 hasWritePermissionForTest ($active_id)
 

Additional Inherited Members

- Static Public Member Functions inherited from ilSoapAdministration
static return_bytes ($val)
 calculate bytes from K,M,G modifiers e.g: 8M = 8 * 1024 * 1024 bytes More...
 
- Data Fields inherited from ilSoapAdministration
 $sauth = null
 
 $error_method = null
 
- Protected Attributes inherited from ilSoapAdministration
 $soap_check = true
 

Detailed Description

Definition at line 35 of file class.ilSoapTestAdministration.php.

Member Function Documentation

◆ getNrOfQuestionsInPass()

ilSoapTestAdministration::getNrOfQuestionsInPass (   $sid,
  $active_id,
  $pass 
)

Get the number of questions in a given pass for a given user.

Parameters
string$sidSession ID
long$active_idActive user ID
integer$passTest pass
Returns
integer Question position in the given test pass

Definition at line 506 of file class.ilSoapTestAdministration.php.

References $ilDB, $lng, $pass, $result, $row, ilSoapAdministration\__getMessage(), ilSoapAdministration\__getMessageCode(), ilSoapAdministration\__raiseError(), array, ilSoapAdministration\initAuth(), ilSoapAdministration\initIlias(), and isAllowedCall().

507  {
508  $this->initAuth($sid);
509  $this->initIlias();
510 
511  if (!$this->__checkSession($sid)) {
512  return $this->__raiseError($this->__getMessage(), $this->__getMessageCode());
513  }
514  if (!$this->isAllowedCall($sid, $active_id, false)) {
515  return $this->__raiseError("The required user information is only available for active users.", "");
516  }
517 
518  global $lng, $ilDB;
519 
520  $result = $ilDB->queryF(
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",
522  array('integer'),
523  array($active_id)
524  );
525  if ($result->numRows() != 1) {
526  return 0;
527  }
528  $row = $ilDB->fetchAssoc($result);
529  $is_random = $row["random_test"];
530 
531  include_once "./Modules/Test/classes/class.ilTestSequence.php";
532  $sequence = new ilTestSequence($active_id, $pass, $is_random);
533  return $sequence->getUserQuestionCount();
534  }
$result
isAllowedCall($sid, $active_id, $saveaction=true)
Test sequence handler.
__raiseError($a_message, $a_code)
Create styles array
The data for the language used.
global $lng
Definition: privfeed.php:17
initAuth($sid)
Init authentication.
global $ilDB
+ Here is the call graph for this function:

◆ getPositionOfQuestion()

ilSoapTestAdministration::getPositionOfQuestion (   $sid,
  $active_id,
  $question_id,
  $pass 
)

get active user data

Parameters
string$sidSession ID
long$active_idActive user ID
integer$question_idQuestion ID
integer$passTest pass
Returns
integer Question position in the given test pass

Definition at line 406 of file class.ilSoapTestAdministration.php.

References $ilDB, $lng, $pass, $result, $row, ilSoapAdministration\__getMessage(), ilSoapAdministration\__getMessageCode(), ilSoapAdministration\__raiseError(), array, ilSoapAdministration\initAuth(), ilSoapAdministration\initIlias(), and isAllowedCall().

407  {
408  $this->initAuth($sid);
409  $this->initIlias();
410 
411  if (!$this->__checkSession($sid)) {
412  return $this->__raiseError($this->__getMessage(), $this->__getMessageCode());
413  }
414  if (!$this->isAllowedCall($sid, $active_id, false)) {
415  return $this->__raiseError("The required user information is only available for active users.", "");
416  }
417 
418  global $lng, $ilDB;
419 
420  $result = $ilDB->queryF(
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",
422  array('integer'),
423  array($active_id)
424  );
425  if ($result->numRows() != 1) {
426  return -1;
427  }
428  $row = $ilDB->fetchAssoc($result);
429  $is_random = $row["random_test"];
430 
431  include_once "./Modules/Test/classes/class.ilTestSequence.php";
432  $sequence = new ilTestSequence($active_id, $pass, $is_random);
433  return $sequence->getSequenceForQuestion($question_id);
434  }
$result
isAllowedCall($sid, $active_id, $saveaction=true)
Test sequence handler.
__raiseError($a_message, $a_code)
Create styles array
The data for the language used.
global $lng
Definition: privfeed.php:17
initAuth($sid)
Init authentication.
global $ilDB
+ Here is the call graph for this function:

◆ getPreviousReachedPoints()

ilSoapTestAdministration::getPreviousReachedPoints (   $sid,
  $active_id,
  $question_id,
  $pass 
)

Returns the previous reached points in a given pass.

Parameters
string$sidSession ID
long$active_idActive user ID
integer$question_idQuestion ID
integer$passTest pass
Returns
array Reached points of the previous questions in this pass

Definition at line 446 of file class.ilSoapTestAdministration.php.

References $ilDB, $lng, $pass, $result, $row, ilSoapAdministration\__getMessage(), ilSoapAdministration\__getMessageCode(), ilSoapAdministration\__raiseError(), array, ilSoapAdministration\initAuth(), ilSoapAdministration\initIlias(), and isAllowedCall().

447  {
448  $this->initAuth($sid);
449  $this->initIlias();
450 
451  if (!$this->__checkSession($sid)) {
452  return $this->__raiseError($this->__getMessage(), $this->__getMessageCode());
453  }
454  if (!$this->isAllowedCall($sid, $active_id, false)) {
455  return $this->__raiseError("The required user information is only available for active users.", "");
456  }
457 
458  global $lng, $ilDB;
459 
460  $result = $ilDB->queryF(
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",
462  array('integer'),
463  array($active_id)
464  );
465  if ($result->numRows() != 1) {
466  return -1;
467  }
468  $row = $ilDB->fetchAssoc($result);
469  $is_random = $row["random_test"];
470 
471  include_once "./Modules/Test/classes/class.ilTestSequence.php";
472  $sequence = new ilTestSequence($active_id, $pass, $is_random);
473  $result = $ilDB->queryF(
474  "SELECT question_fi, points FROM tst_test_result WHERE active_fi = %s AND pass = %s",
475  array('integer', 'integer'),
476  array($active_id, $pass)
477  );
478  $reachedpoints = array();
479  while ($row = $ilDB->fetchAssoc($result)) {
480  $reachedpoints[$row["question_fi"]] = $row["points"];
481  }
482  $atposition = false;
483  $pointsforposition = array();
484  foreach ($sequence->getUserSequence() as $seq) {
485  if (!$atposition) {
486  $qid = $sequence->getQuestionForSequence($seq);
487  if ($qid == $question_id) {
488  $atposition = true;
489  } else {
490  array_push($pointsforposition, $reachedpoints[$qid]);
491  }
492  }
493  }
494  return $pointsforposition;
495  }
$result
isAllowedCall($sid, $active_id, $saveaction=true)
Test sequence handler.
__raiseError($a_message, $a_code)
Create styles array
The data for the language used.
global $lng
Definition: privfeed.php:17
initAuth($sid)
Init authentication.
global $ilDB
+ Here is the call graph for this function:

◆ getQuestionSolution()

ilSoapTestAdministration::getQuestionSolution (   $sid,
  $active_id,
  $question_id,
  $pass 
)

Get the the answers of a given question and pass for a given user.

Parameters
string$sidSession ID
long$active_idActive user ID
integer$question_idQuestion ID
integer$passTest pass
Returns
array String array containing the question solution (in triplets of value1, value2, points)

Definition at line 267 of file class.ilSoapTestAdministration.php.

References $ilDB, $pass, $result, $row, ilSoapAdministration\__getMessage(), ilSoapAdministration\__getMessageCode(), ilSoapAdministration\__raiseError(), array, ilSoapAdministration\initAuth(), ilSoapAdministration\initIlias(), and isAllowedCall().

268  {
269  $this->initAuth($sid);
270  $this->initIlias();
271 
272  if (!$this->__checkSession($sid)) {
273  return $this->__raiseError($this->__getMessage(), $this->__getMessageCode());
274  }
275  if (!$this->isAllowedCall($sid, $active_id, false)) {
276  return $this->__raiseError("The required user information is only available for active users.", "");
277  }
278  $solution = array();
279  // Include main header
280  global $ilDB;
281 
282  $use_previous_answers = 1;
283 
284  $result = $ilDB->queryF(
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",
286  array('integer'),
287  array($active_id)
288  );
289  if ($result->numRows()) {
290  $row = $ilDB->fetchAssoc($result);
291  $use_previous_answers = $row["use_previous_answers"];
292  }
293  $lastpass = 0;
294  if ($use_previous_answers) {
295  $result = $ilDB->queryF(
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)
299  );
300  if ($result->numRows() == 1) {
301  $row = $ilDB->fetchAssoc($result);
302  $lastpass = $row["maxpass"];
303  }
304  } else {
305  $lastpass = $pass;
306  }
307 
308  if (($active_id > 0) && ($question_id > 0) && (strlen($lastpass) > 0)) {
309  $result = $ilDB->queryF(
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)
313  );
314  if ($result->numRows()) {
315  while ($row = $ilDB->fetchAssoc($result)) {
316  array_push($solution, $row["value1"]);
317  array_push($solution, $row["value2"]);
318  array_push($solution, $row["points"]);
319  }
320  }
321  }
322  return $solution;
323  }
$result
isAllowedCall($sid, $active_id, $saveaction=true)
__raiseError($a_message, $a_code)
Create styles array
The data for the language used.
initAuth($sid)
Init authentication.
global $ilDB
+ Here is the call graph for this function:

◆ getTestResults()

ilSoapTestAdministration::getTestResults (   $sid,
  $test_ref_id,
  $sum_only 
)

get results of test

Parameters
string$sid
int$test_ref_id
boolean$sum_only
Returns
XMLResultSet with columns sum only = true: user_id, login, firstname, lastname, matriculation, maximum points, received points sum only = false: user_id, login, firstname, lastname, matriculation, question id, question title, question points, received points

Definition at line 605 of file class.ilSoapTestAdministration.php.

References $data, $ilLog, $row, ilSoapAdministration\__getMessage(), ilSoapAdministration\__getMessageCode(), ilSoapAdministration\__raiseError(), ilObject\_getAllReferences(), ilObject\_isInTrash(), ilObject\_lookupObjectId(), ilSoapAdministration\initAuth(), and ilSoapAdministration\initIlias().

606  {
607  $this->initAuth($sid);
608  $this->initIlias();
609 
610  if (!$this->__checkSession($sid)) {
611  return $this->__raiseError($this->__getMessage(), $this->__getMessageCode());
612  }
613  if (!strlen($test_ref_id)) {
614  return $this->__raiseError(
615  'No test id given. Aborting!',
616  'Client'
617  );
618  }
619  global $rbacsystem, $tree, $ilLog;
620 
621  if (ilObject::_isInTrash($test_ref_id)) {
622  return $this->__raiseError(
623  'Test is trashed. Aborting!',
624  'Client'
625  );
626  }
627 
628  // get obj_id
629  if (!$obj_id = ilObject::_lookupObjectId($test_ref_id)) {
630  return $this->__raiseError(
631  'No test found for id: ' . $test_ref_id,
632  'Client'
633  );
634  }
635 
636 
637  // Check access
638  $permission_ok = false;
639  foreach ($ref_ids = ilObject::_getAllReferences($obj_id) as $ref_id) {
640  if ($rbacsystem->checkAccess('write', $ref_id)) {
641  $permission_ok = true;
642  break;
643  }
644  }
645  if (!$permission_ok) {
646  return $this->__raiseError(
647  'No permission to edit the object with id: ' . $test_ref_id,
648  'Server'
649  );
650  }
651  // store into xml result set
652  include_once './webservice/soap/classes/class.ilXMLResultSet.php';
653  include_once './webservice/soap/classes/class.ilXMLResultSetWriter.php';
654 
655  $xmlResultSet = new ilXMLResultSet();
656  $xmlResultSet->addColumn("user_id");
657  $xmlResultSet->addColumn("login");
658  $xmlResultSet->addColumn("firstname");
659  $xmlResultSet->addColumn("lastname");
660  $xmlResultSet->addColumn("matriculation");
661 
662  include_once './Modules/Test/classes/class.ilObjTest.php';
663  $test_obj = new ilObjTest($obj_id, false);
664  $participants = $test_obj->getTestParticipants();
665 
666 
667  if ($sum_only) {
668  $data = $test_obj->getAllTestResults($participants, false);
669  // create xml
670  $xmlResultSet->addColumn("maximum_points");
671  $xmlResultSet->addColumn("received_points");
672  // skip titles
673  $titles = array_shift($data);
674  foreach ($data as $row) {
675  $xmlRow = new ilXMLResultSetRow();
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);
684  }
685  } else {
686  $data = $test_obj->getDetailedTestResults($participants);
687  // create xml
688  $xmlResultSet->addColumn("question_id");
689  $xmlResultSet->addColumn("question_title");
690  $xmlResultSet->addColumn("maximum_points");
691  $xmlResultSet->addColumn("received_points");
692  foreach ($data as $row) {
693  $xmlRow = new ilXMLResultSetRow();
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);
704  }
705  }
706  // create writer
707  $xmlWriter = new ilXMLResultSetWriter($xmlResultSet);
708  $xmlWriter->start();
709  return $xmlWriter->getXML();
710  }
XML Writer for XMLResultSet.
static _isInTrash($a_ref_id)
checks wether object is in trash
static _getAllReferences($a_id)
get all reference ids of object
static _lookupObjectId($a_ref_id)
lookup object id
__raiseError($a_message, $a_code)
initAuth($sid)
Init authentication.
+ Here is the call graph for this function:

◆ getTestUserData()

ilSoapTestAdministration::getTestUserData (   $sid,
  $active_id 
)

get active user data

Parameters
string$sid
long$active_id
Returns
array String array containing fullname, title, firstname, lastname, login

Definition at line 333 of file class.ilSoapTestAdministration.php.

References $data, $ilDB, $lng, $result, $row, $userdata, ilSoapAdministration\__getMessage(), ilSoapAdministration\__getMessageCode(), ilSoapAdministration\__raiseError(), array, ilSoapAdministration\initAuth(), ilSoapAdministration\initIlias(), and isAllowedCall().

334  {
335  $this->initAuth($sid);
336  $this->initIlias();
337 
338  if (!$this->__checkSession($sid)) {
339  return $this->__raiseError($this->__getMessage(), $this->__getMessageCode());
340  }
341  if (!$this->isAllowedCall($sid, $active_id, false)) {
342  return $this->__raiseError("The required user information is only available for active users.", "");
343  }
344 
345  global $lng, $ilDB;
346 
347  $result = $ilDB->queryF(
348  "SELECT user_fi, test_fi FROM tst_active WHERE active_id = %s",
349  array('integer'),
350  array($active_id)
351  );
352  $row = $ilDB->fetchAssoc($result);
353  $user_id = $row["user_fi"];
354  $test_id = $row["test_fi"];
355 
356  $result = $ilDB->queryF(
357  "SELECT anonymity FROM tst_tests WHERE test_id = %s",
358  array('integer'),
359  array($test_id)
360  );
361  $row = $ilDB->fetchAssoc($result);
362  $anonymity = $row["anonymity"];
363 
364  $result = $ilDB->queryF(
365  "SELECT firstname, lastname, title, login FROM usr_data WHERE usr_id = %s",
366  array('integer'),
367  array($user_id)
368  );
369 
370  $userdata = array();
371  if ($result->numRows() == 0) {
372  $userdata["fullname"] = $lng->txt("deleted_user");
373  $userdata["title"] = "";
374  $userdata["firstname"] = "";
375  $userdata["lastname"] = $lng->txt("anonymous");
376  $userdata["login"] = "";
377  } else {
378  $data = $ilDB->fetchAssoc($result);
379  if (($user_id == ANONYMOUS_USER_ID) || ($anonymity)) {
380  $userdata["fullname"] = $lng->txt("anonymous");
381  $userdata["title"] = "";
382  $userdata["firstname"] = "";
383  $userdata["lastname"] = $lng->txt("anonymous");
384  $userdata["login"] = "";
385  } else {
386  $userdata["fullname"] = trim($data["title"] . " " . $data["firstname"] . " " . $data["lastname"]);
387  $userdata["title"] = $data["title"];
388  $userdata["firstname"] = $data["firstname"];
389  $userdata["lastname"] = $data["lastname"];
390  $userdata["login"] = $data["login"];
391  }
392  }
393  return array_values($userdata);
394  }
$result
isAllowedCall($sid, $active_id, $saveaction=true)
$userdata
Definition: demo.php:48
__raiseError($a_message, $a_code)
Create styles array
The data for the language used.
global $lng
Definition: privfeed.php:17
initAuth($sid)
Init authentication.
global $ilDB
+ Here is the call graph for this function:

◆ hasWritePermissionForTest()

ilSoapTestAdministration::hasWritePermissionForTest (   $active_id)
private

Definition at line 37 of file class.ilSoapTestAdministration.php.

References $ilDB, $result, $row, ilObject\_getAllReferences(), and array.

Referenced by isAllowedCall().

38  {
39  global $ilDB;
40  global $ilAccess;
41 
42  $permission_ok = false;
43  $result = $ilDB->queryF(
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",
45  array('integer'),
46  array($active_id)
47  );
48  $row = $ilDB->fetchAssoc($result);
49  if ($row['obj_fi']) {
50  $obj_id = $row['obj_fi'];
51  foreach ($ref_ids = ilObject::_getAllReferences($obj_id) as $ref_id) {
52  if ($ilAccess->checkAccess("write", "", $ref_id)) {
53  $permission_ok = true;
54  break;
55  }
56  }
57  }
58  return $permission_ok;
59  }
$result
static _getAllReferences($a_id)
get all reference ids of object
Create styles array
The data for the language used.
global $ilDB
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ isAllowedCall()

ilSoapTestAdministration::isAllowedCall (   $sid,
  $active_id,
  $saveaction = true 
)

Definition at line 61 of file class.ilSoapTestAdministration.php.

References $client, $ilDB, $ilUser, $result, $row, $time, array, hasWritePermissionForTest(), and time.

Referenced by getNrOfQuestionsInPass(), getPositionOfQuestion(), getPreviousReachedPoints(), getQuestionSolution(), getTestUserData(), saveQuestion(), and saveQuestionSolution().

62  {
63  global $ilDB;
64  global $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 $ilClientIniFile;
84  $expires = $ilClientIniFile->readVariable('session', 'expire');
85  if ($diff <= $expires) {
86  return true;
87  } else {
88  return false;
89  }
90  } else {
91  return false;
92  }
93  } else {
94  return false;
95  }
96  } else {
97  $result = $ilDB->queryF(
98  "SELECT user_fi FROM tst_active WHERE active_id = %s",
99  array('integer'),
100  array($active_id)
101  );
102  $row = $ilDB->fetchAssoc($result);
103  if ($row['user_fi'] == $ilUser->getId()) {
104  return true;
105  } else {
106  return false;
107  }
108  }
109  }
$result
$client
Definition: resume.php:9
$time
Definition: cron.php:21
$ilUser
Definition: imgupload.php:18
Create styles array
The data for the language used.
global $ilDB
Add data(end) time
Method that wraps PHPs time in order to allow simulations with the workflow.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ removeTestResults()

ilSoapTestAdministration::removeTestResults (   $sid,
  $test_ref_id,
  $a_user_ids 
)

Remove test results for the chosen test and users.

Parameters
string$sid
int$test_ref_id
array$a_user_ids
Returns
bool

Definition at line 543 of file class.ilSoapTestAdministration.php.

References $GLOBALS, $ilLog, ilSoapAdministration\__getMessage(), ilSoapAdministration\__getMessageCode(), ilSoapAdministration\__raiseError(), ilObject\_isInTrash(), array, ilObjectFactory\getInstanceByRefId(), ilSoapAdministration\initAuth(), and ilSoapAdministration\initIlias().

544  {
545  $this->initAuth($sid);
546  $this->initIlias();
547 
548  if (!$this->__checkSession($sid)) {
549  return $this->__raiseError($this->__getMessage(), $this->__getMessageCode());
550  }
551  if (!strlen($test_ref_id)) {
552  return $this->__raiseError(
553  'No test id given. Aborting!',
554  'Client'
555  );
556  }
557  global $rbacsystem, $tree, $ilLog;
558 
559  global $ilAccess; /* @var ilAccessHandler $ilAccess */
560  if (!$ilAccess->checkAccess('write', '', $test_ref_id)) {
561  return $this->__raiseError('no permission. Aborting!', 'Client');
562  }
563 
564  if (ilObject::_isInTrash($test_ref_id)) {
565  return $this->__raiseError(
566  'Test is trashed. Aborting!',
567  'Client'
568  );
569  }
570 
571  if (!$tst = ilObjectFactory::getInstanceByRefId($test_ref_id, false)) {
572  return $this->__raiseError('No test found for id: ' . $test_ref_id, 'Client');
573  }
574  if ($tst->getType() != 'tst') {
575  return $this->__raiseError('Object with ref_id ' . $test_ref_id . ' is not of type test. Aborting', 'Client');
576  }
577 
578  // Dirty hack
579  if (isset($a_user_ids['item'])) {
580  $a_user_ids = $a_user_ids['item'];
581  }
582 
583  include_once './Modules/Test/classes/class.ilObjTest.php';
584  include_once './Modules/Test/classes/class.ilTestParticipantData.php';
585  $part = new ilTestParticipantData($GLOBALS['ilDB'], $GLOBALS['lng']);
586  $part->setUserIds((array) $a_user_ids);
587  $part->load($tst->getTestId());
588  $tst->removeTestResults($part);
589 
590  return true;
591  }
$GLOBALS['loaded']
Global hash that tracks already loaded includes.
static _isInTrash($a_ref_id)
checks wether object is in trash
__raiseError($a_message, $a_code)
Create styles array
The data for the language used.
initAuth($sid)
Init authentication.
static getInstanceByRefId($a_ref_id, $stop_on_error=true)
get an instance of an Ilias object by reference id
+ Here is the call graph for this function:

◆ saveQuestion()

ilSoapTestAdministration::saveQuestion (   $sid,
  $active_id,
  $question_id,
  $pass,
  $solution 
)

Definition at line 111 of file class.ilSoapTestAdministration.php.

References $GLOBALS, $i, $ilDB, $ilUser, $pass, ilSoapAdministration\__getMessage(), ilSoapAdministration\__getMessageCode(), ilSoapAdministration\__raiseError(), ilObjAssessmentFolder\_enabledAssessmentLogging(), assQuestion\_instanciateQuestion(), array, ilSoapAdministration\initAuth(), ilSoapAdministration\initIlias(), isAllowedCall(), and time.

112  {
113  $this->initAuth($sid);
114  $this->initIlias();
115 
116  if (!$this->__checkSession($sid)) {
117  return $this->__raiseError($this->__getMessage(), $this->__getMessageCode());
118  }
119  if (!$this->isAllowedCall($sid, $active_id)) {
120  return $this->__raiseError("The required user information is only available for active users.", "");
121  }
122 
123  if (is_array($solution) && (array_key_exists("item", $solution))) {
124  $solution = $solution["item"];
125  }
126 
127  global $ilDB, $ilUser;
128 
129  require_once 'Modules/TestQuestionPool/classes/class.ilAssQuestionProcessLockerFactory.php';
130  $processLockerFactory = new ilAssQuestionProcessLockerFactory(new ilSetting('assessment'), $ilDB);
131  $processLockerFactory->setQuestionId($question_id);
132  $processLockerFactory->setUserId($ilUser->getId());
133  include_once("./Modules/Test/classes/class.ilObjAssessmentFolder.php");
134  $processLockerFactory->setAssessmentLogEnabled(ilObjAssessmentFolder::_enabledAssessmentLogging());
135  $processLocker = $processLockerFactory->getLocker();
136 
137  $totalrows = 0;
138 
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) {
141  $ilDB = $GLOBALS['ilDB'];
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'),
146  array($active_id, $question_id, $pass)
147  );
148  }
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]),
158  "pass" => array("integer", $pass),
159  "tstamp" => array("integer", time())
160  ));
161  $totalrows += $affectedRows;
162  }
163  });
164 
165  if ($totalrows != 0) {
166  include_once "./Modules/TestQuestionPool/classes/class.assQuestion.php";
167  $question = assQuestion::_instanciateQuestion($question_id);
168  $question->setProcessLocker($processLocker);
169  $question->calculateResultsFromSolution($active_id, $pass);
170  }
171  });
172 
173  if ($totalrows == 0) {
174  return $this->__raiseError(
175  "Wrong solution data. ILIAS did not execute any database queries: Solution data: " . print_r($solution, true),
176  'No result'
177  );
178  }
179 
180  return true;
181  }
static _instanciateQuestion($question_id)
Creates an instance of a question with a given question id.
isAllowedCall($sid, $active_id, $saveaction=true)
$GLOBALS['loaded']
Global hash that tracks already loaded includes.
static _enabledAssessmentLogging()
check wether assessment logging is enabled or not
__raiseError($a_message, $a_code)
$ilUser
Definition: imgupload.php:18
Create styles array
The data for the language used.
initAuth($sid)
Init authentication.
global $ilDB
$i
Definition: disco.tpl.php:19
Add data(end) time
Method that wraps PHPs time in order to allow simulations with the workflow.
+ Here is the call graph for this function:

◆ saveQuestionSolution()

ilSoapTestAdministration::saveQuestionSolution (   $sid,
  $active_id,
  $question_id,
  $pass,
  $solution 
)

Save the solution of a question.

Parameters
string$sidSession ID
long$active_idActive user ID
integer$question_idQuestion ID
integer$passTest pass
string$solutionXML string containing the solution
Returns
array String array containing the question solution (in triplets of value1, value2, points)

Definition at line 194 of file class.ilSoapTestAdministration.php.

References $GLOBALS, $i, $ilDB, $pass, ilSoapAdministration\__getMessage(), ilSoapAdministration\__getMessageCode(), ilSoapAdministration\__raiseError(), assQuestion\_instanciateQuestion(), array, ilSoapAdministration\initAuth(), ilSoapAdministration\initIlias(), isAllowedCall(), and time.

195  {
196  $this->initAuth($sid);
197  $this->initIlias();
198 
199  if (!$this->__checkSession($sid)) {
200  return $this->__raiseError($this->__getMessage(), $this->__getMessageCode());
201  }
202  if (!$this->isAllowedCall($sid, $active_id)) {
203  return $this->__raiseError("The required user information is only available for active users.", "");
204  }
205 
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]));
213  }
214  }
215  }
216  }
217  }
218 
219  if (count($solutions) == 0) {
220  return $this->__raiseError("Wrong solution data. ILIAS did not find one or more solution triplets: $solution", "");
221  }
222 
223  // Include main header
224  $ilDB = $GLOBALS['ilDB'];
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'),
229  array($active_id, $question_id, $pass)
230  );
231  }
232  $totalrows = 0;
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]),
242  "pass" => array("integer", $pass),
243  "tstamp" => array("integer", time())
244  ));
245  $totalrows += $affectedRows;
246  }
247  if (count($totalrows) == 0) {
248  return $this->__raiseError("Wrong solution data. ILIAS did not execute any database queries");
249  } else {
250  include_once "./Modules/TestQuestionPool/classes/class.assQuestion.php";
251  $question = assQuestion::_instanciateQuestion($question_id);
252  $question->calculateResultsFromSolution($active_id, $pass);
253  }
254  return "TRUE";
255  }
static _instanciateQuestion($question_id)
Creates an instance of a question with a given question id.
isAllowedCall($sid, $active_id, $saveaction=true)
$GLOBALS['loaded']
Global hash that tracks already loaded includes.
__raiseError($a_message, $a_code)
Create styles array
The data for the language used.
initAuth($sid)
Init authentication.
global $ilDB
$i
Definition: disco.tpl.php:19
Add data(end) time
Method that wraps PHPs time in order to allow simulations with the workflow.
+ Here is the call graph for this function:

The documentation for this class was generated from the following file: