ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
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 552 of file class.ilSoapTestAdministration.php.

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

553  {
554  $this->initAuth($sid);
555  $this->initIlias();
556 
557  if(!$this->__checkSession($sid))
558  {
559  return $this->__raiseError($this->__getMessage(),$this->__getMessageCode());
560  }
561  if (!$this->isAllowedCall($sid, $active_id, false))
562  {
563  return $this->__raiseError("The required user information is only available for active users.", "");
564  }
565 
566  global $lng, $ilDB;
567 
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",
569  array('integer'),
570  array($active_id)
571  );
572  if ($result->numRows() != 1) return 0;
573  $row = $ilDB->fetchAssoc($result);
574  $is_random = $row["random_test"];
575 
576  include_once "./Modules/Test/classes/class.ilTestSequence.php";
577  $sequence = new ilTestSequence($active_id, $pass, $is_random);
578  return $sequence->getUserQuestionCount();
579  }
$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 449 of file class.ilSoapTestAdministration.php.

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

450  {
451  $this->initAuth($sid);
452  $this->initIlias();
453 
454  if(!$this->__checkSession($sid))
455  {
456  return $this->__raiseError($this->__getMessage(),$this->__getMessageCode());
457  }
458  if (!$this->isAllowedCall($sid, $active_id, false))
459  {
460  return $this->__raiseError("The required user information is only available for active users.", "");
461  }
462 
463  global $lng, $ilDB;
464 
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",
466  array('integer'),
467  array($active_id)
468  );
469  if ($result->numRows() != 1) return -1;
470  $row = $ilDB->fetchAssoc($result);
471  $is_random = $row["random_test"];
472 
473  include_once "./Modules/Test/classes/class.ilTestSequence.php";
474  $sequence = new ilTestSequence($active_id, $pass, $is_random);
475  return $sequence->getSequenceForQuestion($question_id);
476  }
$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 488 of file class.ilSoapTestAdministration.php.

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

489  {
490  $this->initAuth($sid);
491  $this->initIlias();
492 
493  if(!$this->__checkSession($sid))
494  {
495  return $this->__raiseError($this->__getMessage(),$this->__getMessageCode());
496  }
497  if (!$this->isAllowedCall($sid, $active_id, false))
498  {
499  return $this->__raiseError("The required user information is only available for active users.", "");
500  }
501 
502  global $lng, $ilDB;
503 
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",
505  array('integer'),
506  array($active_id)
507  );
508  if ($result->numRows() != 1) return -1;
509  $row = $ilDB->fetchAssoc($result);
510  $is_random = $row["random_test"];
511 
512  include_once "./Modules/Test/classes/class.ilTestSequence.php";
513  $sequence = new ilTestSequence($active_id, $pass, $is_random);
514  $result = $ilDB->queryF("SELECT question_fi, points FROM tst_test_result WHERE active_fi = %s AND pass = %s",
515  array('integer', 'integer'),
516  array($active_id, $pass)
517  );
518  $reachedpoints = array();
519  while ($row = $ilDB->fetchAssoc($result))
520  {
521  $reachedpoints[$row["question_fi"]] = $row["points"];
522  }
523  $atposition = FALSE;
524  $pointsforposition = array();
525  foreach ($sequence->getUserSequence() as $seq)
526  {
527  if (!$atposition)
528  {
529  $qid = $sequence->getQuestionForSequence($seq);
530  if ($qid == $question_id)
531  {
532  $atposition = TRUE;
533  }
534  else
535  {
536  array_push($pointsforposition, $reachedpoints[$qid]);
537  }
538  }
539  }
540  return $pointsforposition;
541  }
$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 298 of file class.ilSoapTestAdministration.php.

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

299  {
300  $this->initAuth($sid);
301  $this->initIlias();
302 
303  if(!$this->__checkSession($sid))
304  {
305  return $this->__raiseError($this->__getMessage(),$this->__getMessageCode());
306  }
307  if (!$this->isAllowedCall($sid, $active_id, false))
308  {
309  return $this->__raiseError("The required user information is only available for active users.", "");
310  }
311  $solution = array();
312  // Include main header
313  global $ilDB;
314 
315  $use_previous_answers = 1;
316 
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",
318  array('integer'),
319  array($active_id)
320  );
321  if ($result->numRows())
322  {
323  $row = $ilDB->fetchAssoc($result);
324  $use_previous_answers = $row["use_previous_answers"];
325  }
326  $lastpass = 0;
327  if ($use_previous_answers)
328  {
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)
332  );
333  if ($result->numRows() == 1)
334  {
335  $row = $ilDB->fetchAssoc($result);
336  $lastpass = $row["maxpass"];
337  }
338  }
339  else
340  {
341  $lastpass = $pass;
342  }
343 
344  if (($active_id > 0) && ($question_id > 0) && (strlen($lastpass) > 0))
345  {
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)
349  );
350  if ($result->numRows())
351  {
352  while ($row = $ilDB->fetchAssoc($result))
353  {
354  array_push($solution, $row["value1"]);
355  array_push($solution, $row["value2"]);
356  array_push($solution, $row["points"]);
357  }
358  }
359  }
360  return $solution;
361  }
$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 653 of file class.ilSoapTestAdministration.php.

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

654  {
655  $this->initAuth($sid);
656  $this->initIlias();
657 
658  if(!$this->__checkSession($sid))
659  {
660  return $this->__raiseError($this->__getMessage(),$this->__getMessageCode());
661  }
662  if(!strlen($test_ref_id))
663  {
664  return $this->__raiseError('No test id given. Aborting!',
665  'Client');
666  }
667  global $rbacsystem, $tree, $ilLog;
668 
669  if(ilObject::_isInTrash($test_ref_id))
670  {
671  return $this->__raiseError('Test is trashed. Aborting!',
672  'Client');
673  }
674 
675  // get obj_id
676  if(!$obj_id = ilObject::_lookupObjectId($test_ref_id))
677  {
678  return $this->__raiseError('No test found for id: '.$test_ref_id,
679  'Client');
680  }
681 
682 
683  // Check access
684  $permission_ok = false;
685  foreach($ref_ids = ilObject::_getAllReferences($obj_id) as $ref_id)
686  {
687  if($rbacsystem->checkAccess('write',$ref_id))
688  {
689  $permission_ok = true;
690  break;
691  }
692  }
693  if(!$permission_ok)
694  {
695  return $this->__raiseError('No permission to edit the object with id: '.$test_ref_id,
696  'Server');
697  }
698  // store into xml result set
699  include_once './webservice/soap/classes/class.ilXMLResultSet.php';
700  include_once './webservice/soap/classes/class.ilXMLResultSetWriter.php';
701 
702  $xmlResultSet = new ilXMLResultSet();
703  $xmlResultSet->addColumn("user_id");
704  $xmlResultSet->addColumn("login");
705  $xmlResultSet->addColumn("firstname");
706  $xmlResultSet->addColumn("lastname");
707  $xmlResultSet->addColumn("matriculation");
708 
709  include_once './Modules/Test/classes/class.ilObjTest.php';
710  $test_obj = new ilObjTest($obj_id, false);
711  $participants = $test_obj->getTestParticipants();
712 
713 
714  if ($sum_only)
715  {
716  $data = $test_obj->getAllTestResults($participants, false);
717  // create xml
718  $xmlResultSet->addColumn("maximum_points");
719  $xmlResultSet->addColumn("received_points");
720  // skip titles
721  $titles = array_shift($data);
722  foreach ($data as $row) {
723  $xmlRow = new ilXMLResultSetRow();
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);
732  }
733  } else {
734  $data = $test_obj->getDetailedTestResults($participants);
735  // create xml
736  $xmlResultSet->addColumn("question_id");
737  $xmlResultSet->addColumn("question_title");
738  $xmlResultSet->addColumn("maximum_points");
739  $xmlResultSet->addColumn("received_points");
740  foreach ($data as $row) {
741  $xmlRow = new ilXMLResultSetRow();
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);
752  }
753  }
754  // create writer
755  $xmlWriter = new ilXMLResultSetWriter($xmlResultSet);
756  $xmlWriter->start();
757  return $xmlWriter->getXML();
758  }
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)
$ref_id
Definition: sahs_server.php:39
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 371 of file class.ilSoapTestAdministration.php.

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

372  {
373  $this->initAuth($sid);
374  $this->initIlias();
375 
376  if(!$this->__checkSession($sid))
377  {
378  return $this->__raiseError($this->__getMessage(),$this->__getMessageCode());
379  }
380  if (!$this->isAllowedCall($sid, $active_id, false))
381  {
382  return $this->__raiseError("The required user information is only available for active users.", "");
383  }
384 
385  global $lng, $ilDB;
386 
387  $result = $ilDB->queryF("SELECT user_fi, test_fi FROM tst_active WHERE active_id = %s",
388  array('integer'),
389  array($active_id)
390  );
391  $row = $ilDB->fetchAssoc($result);
392  $user_id = $row["user_fi"];
393  $test_id = $row["test_fi"];
394 
395  $result = $ilDB->queryF("SELECT anonymity FROM tst_tests WHERE test_id = %s",
396  array('integer'),
397  array($test_id)
398  );
399  $row = $ilDB->fetchAssoc($result);
400  $anonymity = $row["anonymity"];
401 
402  $result = $ilDB->queryF("SELECT firstname, lastname, title, login FROM usr_data WHERE usr_id = %s",
403  array('integer'),
404  array($user_id)
405  );
406 
407  $userdata = array();
408  if ($result->numRows() == 0)
409  {
410  $userdata["fullname"] = $lng->txt("deleted_user");
411  $userdata["title"] = "";
412  $userdata["firstname"] = "";
413  $userdata["lastname"] = $lng->txt("anonymous");
414  $userdata["login"] = "";
415  }
416  else
417  {
418  $data = $ilDB->fetchAssoc($result);
419  if (($user_id == ANONYMOUS_USER_ID) || ($anonymity))
420  {
421  $userdata["fullname"] = $lng->txt("anonymous");
422  $userdata["title"] = "";
423  $userdata["firstname"] = "";
424  $userdata["lastname"] = $lng->txt("anonymous");
425  $userdata["login"] = "";
426  }
427  else
428  {
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"];
434  }
435  }
436  return array_values($userdata);
437  }
$result
isAllowedCall($sid, $active_id, $saveaction=true)
__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, $ref_id, $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("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",
44  array('integer'),
45  array($active_id)
46  );
47  $row = $ilDB->fetchAssoc($result);
48  if ($row['obj_fi'])
49  {
50  $obj_id = $row['obj_fi'];
51  foreach($ref_ids = ilObject::_getAllReferences($obj_id) as $ref_id)
52  {
53  if ($ilAccess->checkAccess("write", "", $ref_id))
54  {
55  $permission_ok = true;
56  break;
57  }
58  }
59  }
60  return $permission_ok;
61  }
$result
static _getAllReferences($a_id)
get all reference ids of object
Create styles array
The data for the language used.
$ref_id
Definition: sahs_server.php:39
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 63 of file class.ilSoapTestAdministration.php.

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

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

64  {
65  global $ilDB;
66  global $ilUser;
67 
68  if ($this->hasWritePermissionForTest($active_id)) return TRUE;
69 
70  if ($saveaction)
71  {
72  $result = $ilDB->queryF("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  {
78  $row = $ilDB->fetchAssoc($result);
79  if (preg_match("/(\\d{4})-(\\d{2})-(\\d{2}) (\\d{2}):(\\d{2}):(\\d{2})/", $row["started"], $matches))
80  {
81  $time = mktime($matches[4], $matches[5], $matches[6], $matches[2], $matches[3], $matches[1]);
82  $now = time();
83  $diff = $now - $time;
84  $client = explode("::", $sid);
85  global $ilClientIniFile;
86  $expires = $ilClientIniFile->readVariable('session','expire');
87  if ($diff <= $expires)
88  {
89  return TRUE;
90  }
91  else
92  {
93  return FALSE;
94  }
95  }
96  else
97  {
98  return FALSE;
99  }
100  }
101  else
102  {
103  return FALSE;
104  }
105  }
106  else
107  {
108  $result = $ilDB->queryF("SELECT user_fi FROM tst_active WHERE active_id = %s",
109  array('integer'),
110  array($active_id)
111  );
112  $row = $ilDB->fetchAssoc($result);
113  if ($row['user_fi'] == $ilUser->getId())
114  {
115  return TRUE;
116  }
117  else
118  {
119  return FALSE;
120  }
121  }
122  }
$result
$client
$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 588 of file class.ilSoapTestAdministration.php.

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

589  {
590  $this->initAuth($sid);
591  $this->initIlias();
592 
593  if(!$this->__checkSession($sid))
594  {
595  return $this->__raiseError($this->__getMessage(),$this->__getMessageCode());
596  }
597  if(!strlen($test_ref_id))
598  {
599  return $this->__raiseError('No test id given. Aborting!',
600  'Client');
601  }
602  global $rbacsystem, $tree, $ilLog;
603 
604  global $ilAccess; /* @var ilAccessHandler $ilAccess */
605  if( !$ilAccess->checkAccess('write', '', $test_ref_id) )
606  {
607  return $this->__raiseError('no permission. Aborting!', 'Client');
608  }
609 
610  if(ilObject::_isInTrash($test_ref_id))
611  {
612  return $this->__raiseError('Test is trashed. Aborting!',
613  'Client');
614  }
615 
616  if(!$tst = ilObjectFactory::getInstanceByRefId($test_ref_id,false))
617  {
618  return $this->__raiseError('No test found for id: '.$test_ref_id,'Client');
619  }
620  if($tst->getType() != 'tst')
621  {
622  return $this->__raiseError('Object with ref_id '.$test_ref_id.' is not of type test. Aborting','Client');
623  }
624 
625  // Dirty hack
626  if(isset($a_user_ids['item']))
627  {
628  $a_user_ids = $a_user_ids['item'];
629  }
630 
631  include_once './Modules/Test/classes/class.ilObjTest.php';
632  include_once './Modules/Test/classes/class.ilTestParticipantData.php';
633  $part = new ilTestParticipantData($GLOBALS['ilDB'], $GLOBALS['lng']);
634  $part->setUserIds((array) $a_user_ids);
635  $part->load($tst->getTestId());
636  $tst->removeTestResults($part);
637 
638  return true;
639  }
$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 124 of file class.ilSoapTestAdministration.php.

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

125  {
126  $this->initAuth($sid);
127  $this->initIlias();
128 
129  if(!$this->__checkSession($sid))
130  {
131  return $this->__raiseError($this->__getMessage(),$this->__getMessageCode());
132  }
133  if (!$this->isAllowedCall($sid, $active_id))
134  {
135  return $this->__raiseError("The required user information is only available for active users.", "");
136  }
137 
138  if (is_array($solution) && (array_key_exists("item", $solution))) $solution = $solution["item"];
139 
140  global $ilDB, $ilUser;
141 
142  require_once 'Modules/TestQuestionPool/classes/class.ilAssQuestionProcessLockerFactory.php';
143  $processLockerFactory = new ilAssQuestionProcessLockerFactory(new ilSetting('assessment'), $ilDB);
144  $processLockerFactory->setQuestionId($question_id);
145  $processLockerFactory->setUserId($ilUser->getId());
146  include_once ("./Modules/Test/classes/class.ilObjAssessmentFolder.php");
147  $processLockerFactory->setAssessmentLogEnabled(ilObjAssessmentFolder::_enabledAssessmentLogging());
148  $processLocker = $processLockerFactory->getLocker();
149 
150  $totalrows = 0;
151 
152  $processLocker->executePersistWorkingStateLockOperation(function() use (&$totalrows, $processLocker, $active_id, $question_id, $pass, $solution) {
153 
154  $processLocker->executeUserSolutionUpdateLockOperation(function() use (&$totalrows, $active_id, $question_id, $pass, $solution) {
155 
156  $ilDB = $GLOBALS['ilDB'];
157  if (($active_id > 0) && ($question_id > 0) && (strlen($pass) > 0))
158  {
159  $affectedRows = $ilDB->manipulateF("DELETE FROM tst_solutions WHERE active_fi = %s AND question_fi = %s AND pass = %s",
160  array('integer', 'integer', 'integer'),
161  array($active_id, $question_id, $pass)
162  );
163  }
164  for($i = 0; $i < count($solution); $i += 3)
165  {
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]),
174  "pass" => array("integer", $pass),
175  "tstamp" => array("integer", time())
176  ));
177  $totalrows += $affectedRows;
178  }
179  });
180 
181  if($totalrows != 0)
182  {
183  include_once "./Modules/TestQuestionPool/classes/class.assQuestion.php";
184  $question = assQuestion::_instanciateQuestion($question_id);
185  $question->setProcessLocker($processLocker);
186  $question->calculateResultsFromSolution($active_id, $pass);
187  }
188 
189  });
190 
191  if($totalrows == 0)
192  {
193  return $this->__raiseError(
194  "Wrong solution data. ILIAS did not execute any database queries: Solution data: " . print_r($solution, true),
195  'No result'
196  );
197  }
198 
199  return true;
200  }
ILIAS Setting Class.
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
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 213 of file class.ilSoapTestAdministration.php.

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

214  {
215  $this->initAuth($sid);
216  $this->initIlias();
217 
218  if(!$this->__checkSession($sid))
219  {
220  return $this->__raiseError($this->__getMessage(),$this->__getMessageCode());
221  }
222  if (!$this->isAllowedCall($sid, $active_id))
223  {
224  return $this->__raiseError("The required user information is only available for active users.", "");
225  }
226 
227  $solutions = array();
228  if (preg_match("/<values>(.*?)<\/values>/is", $solution, $matches))
229  {
230  if (preg_match_all("/<value>(.*?)<\/value><value>(.*?)<\/value><points>(.*?)<\/points>/is", $solution, $matches, PREG_SET_ORDER))
231  {
232  foreach ($matches as $match)
233  {
234  if (count($match) == 4)
235  {
236  for ($i = 1; $i < count($match); $i++)
237  {
238  array_push($solutions, trim($match[$i]));
239  }
240  }
241  }
242  }
243  }
244 
245  if (count($solutions) == 0)
246  {
247  return $this->__raiseError("Wrong solution data. ILIAS did not find one or more solution triplets: $solution", "");
248  }
249 
250  // Include main header
251  $ilDB = $GLOBALS['ilDB'];
252  if (($active_id > 0) && ($question_id > 0) && (strlen($pass) > 0))
253  {
254  $affectedRows = $ilDB->manipulateF("DELETE FROM tst_solutions WHERE active_fi = %s AND question_fi = %s AND pass = %s",
255  array('integer', 'integer', 'integer'),
256  array($active_id, $question_id, $pass)
257  );
258  }
259  $totalrows = 0;
260  for($i = 0; $i < count($solutions); $i += 3)
261  {
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]),
270  "pass" => array("integer", $pass),
271  "tstamp" => array("integer", time())
272  ));
273  $totalrows += $affectedRows;
274  }
275  if (count($totalrows) == 0)
276  {
277  return $this->__raiseError("Wrong solution data. ILIAS did not execute any database queries");
278  }
279  else
280  {
281  include_once "./Modules/TestQuestionPool/classes/class.assQuestion.php";
282  $question = assQuestion::_instanciateQuestion($question_id);
283  $question->calculateResultsFromSolution($active_id, $pass);
284  }
285  return "TRUE";
286  }
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
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: