ILIAS  release_5-0 Revision 5.0.0-1144-gc4397b1f870
All Data Structures Namespaces Files Functions Variables Modules Pages
ilSoapTestAdministration Class Reference
+ Inheritance diagram for ilSoapTestAdministration:
+ Collaboration diagram for ilSoapTestAdministration:

Public Member Functions

 ilSoapTestAdministration ()
 
 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
 ilSoapAdministration ($use_nusoap=true)
 
 initErrorWriter ()
 Overwrite error handler. More...
 
 __explodeSid ($sid)
 
 __setMessage ($a_str)
 
 __getMessage ()
 
 __appendMessage ($a_str)
 
 __setMessageCode ($a_code)
 
 __getMessageCode ()
 
 initAuth ($sid)
 
 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 555 of file class.ilSoapTestAdministration.php.

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

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

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

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

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

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

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

302  {
303  $this->initAuth($sid);
304  $this->initIlias();
305 
306  if(!$this->__checkSession($sid))
307  {
308  return $this->__raiseError($this->__getMessage(),$this->__getMessageCode());
309  }
310  if (!$this->isAllowedCall($sid, $active_id, false))
311  {
312  return $this->__raiseError("The required user information is only available for active users.", "");
313  }
314  $solution = array();
315  // Include main header
316  global $ilDB;
317 
318  $use_previous_answers = 1;
319 
320  $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",
321  array('integer'),
322  array($active_id)
323  );
324  if ($result->numRows())
325  {
326  $row = $ilDB->fetchAssoc($result);
327  $use_previous_answers = $row["use_previous_answers"];
328  }
329  $lastpass = 0;
330  if ($use_previous_answers)
331  {
332  $result = $ilDB->queryF("SELECT MAX(pass) maxpass FROM tst_test_result WHERE active_fi = %s AND question_fi = %s",
333  array('integer', 'integer'),
334  array($active_id, $question_id)
335  );
336  if ($result->numRows() == 1)
337  {
338  $row = $ilDB->fetchAssoc($result);
339  $lastpass = $row["maxpass"];
340  }
341  }
342  else
343  {
344  $lastpass = $pass;
345  }
346 
347  if (($active_id > 0) && ($question_id > 0) && (strlen($lastpass) > 0))
348  {
349  $result = $ilDB->queryF("SELECT * FROM tst_solutions WHERE active_fi = %s AND question_fi = %s AND pass = %s",
350  array('integer', 'integer', 'integer'),
351  array($active_id, $question_id, $lastpass)
352  );
353  if ($result->numRows())
354  {
355  while ($row = $ilDB->fetchAssoc($result))
356  {
357  array_push($solution, $row["value1"]);
358  array_push($solution, $row["value2"]);
359  array_push($solution, $row["points"]);
360  }
361  }
362  }
363  return $solution;
364  }
$result
isAllowedCall($sid, $active_id, $saveaction=true)
__raiseError($a_message, $a_code)
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 _getAllReferences($a_id)
get all reference ids of object
static _lookupObjectId($a_ref_id)
lookup object id
__raiseError($a_message, $a_code)
_isInTrash($a_ref_id)
checks wether object is in trash
$ref_id
Definition: sahs_server.php:39
+ 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 374 of file class.ilSoapTestAdministration.php.

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

375  {
376  $this->initAuth($sid);
377  $this->initIlias();
378 
379  if(!$this->__checkSession($sid))
380  {
381  return $this->__raiseError($this->__getMessage(),$this->__getMessageCode());
382  }
383  if (!$this->isAllowedCall($sid, $active_id, false))
384  {
385  return $this->__raiseError("The required user information is only available for active users.", "");
386  }
387 
388  global $lng, $ilDB;
389 
390  $result = $ilDB->queryF("SELECT user_fi, test_fi FROM tst_active WHERE active_id = %s",
391  array('integer'),
392  array($active_id)
393  );
394  $row = $ilDB->fetchAssoc($result);
395  $user_id = $row["user_fi"];
396  $test_id = $row["test_fi"];
397 
398  $result = $ilDB->queryF("SELECT anonymity FROM tst_tests WHERE test_id = %s",
399  array('integer'),
400  array($test_id)
401  );
402  $row = $ilDB->fetchAssoc($result);
403  $anonymity = $row["anonymity"];
404 
405  $result = $ilDB->queryF("SELECT firstname, lastname, title, login FROM usr_data WHERE usr_id = %s",
406  array('integer'),
407  array($user_id)
408  );
409 
410  $userdata = array();
411  if ($result->numRows() == 0)
412  {
413  $userdata["fullname"] = $lng->txt("deleted_user");
414  $userdata["title"] = "";
415  $userdata["firstname"] = "";
416  $userdata["lastname"] = $lng->txt("anonymous");
417  $userdata["login"] = "";
418  }
419  else
420  {
421  $data = $ilDB->fetchAssoc($result);
422  if (($user_id == ANONYMOUS_USER_ID) || ($anonymity))
423  {
424  $userdata["fullname"] = $lng->txt("anonymous");
425  $userdata["title"] = "";
426  $userdata["firstname"] = "";
427  $userdata["lastname"] = $lng->txt("anonymous");
428  $userdata["login"] = "";
429  }
430  else
431  {
432  $userdata["fullname"] = trim($data["title"] . " " . $data["firstname"] . " " . $data["lastname"]);
433  $userdata["title"] = $data["title"];
434  $userdata["firstname"] = $data["firstname"];
435  $userdata["lastname"] = $data["lastname"];
436  $userdata["login"] = $data["login"];
437  }
438  }
439  return array_values($userdata);
440  }
$result
isAllowedCall($sid, $active_id, $saveaction=true)
__raiseError($a_message, $a_code)
global $lng
Definition: privfeed.php:40
global $ilDB
+ Here is the call graph for this function:

◆ hasWritePermissionForTest()

ilSoapTestAdministration::hasWritePermissionForTest (   $active_id)
private

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

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

Referenced by isAllowedCall().

43  {
44  global $ilDB;
45  global $ilAccess;
46 
47  $permission_ok = false;
48  $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",
49  array('integer'),
50  array($active_id)
51  );
52  $row = $ilDB->fetchAssoc($result);
53  if ($row['obj_fi'])
54  {
55  $obj_id = $row['obj_fi'];
56  foreach($ref_ids = ilObject::_getAllReferences($obj_id) as $ref_id)
57  {
58  if ($ilAccess->checkAccess("write", "", $ref_id))
59  {
60  $permission_ok = true;
61  break;
62  }
63  }
64  }
65  return $permission_ok;
66  }
$result
static _getAllReferences($a_id)
get all reference ids of object
$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:

◆ ilSoapTestAdministration()

ilSoapTestAdministration::ilSoapTestAdministration ( )

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

38  {
39  parent::ilSoapAdministration();
40  }

◆ isAllowedCall()

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

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

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

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

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

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

592  {
593  $this->initAuth($sid);
594  $this->initIlias();
595 
596  if(!$this->__checkSession($sid))
597  {
598  return $this->__raiseError($this->__getMessage(),$this->__getMessageCode());
599  }
600  if(!strlen($test_ref_id))
601  {
602  return $this->__raiseError('No test id given. Aborting!',
603  'Client');
604  }
605  global $rbacsystem, $tree, $ilLog;
606 
607  global $ilAccess; /* @var ilAccessHandler $ilAccess */
608  if( !$ilAccess->checkAccess('write', '', $test_ref_id) )
609  {
610  return $this->__raiseError('no permission. Aborting!', 'Client');
611  }
612 
613  if(ilObject::_isInTrash($test_ref_id))
614  {
615  return $this->__raiseError('Test is trashed. Aborting!',
616  'Client');
617  }
618 
619  if(!$tst = ilObjectFactory::getInstanceByRefId($test_ref_id,false))
620  {
621  return $this->__raiseError('No test found for id: '.$test_ref_id,'Client');
622  }
623  if($tst->getType() != 'tst')
624  {
625  return $this->__raiseError('Object with ref_id '.$test_ref_id.' is not of type test. Aborting','Client');
626  }
627 
628  // Dirty hack
629  if(isset($a_user_ids['item']))
630  {
631  $a_user_ids = $a_user_ids['item'];
632  }
633 
634  foreach((array) $a_user_ids as $user_id)
635  {
636  $tst->removeTestResultsForUser($user_id);
637  }
638  return true;
639  }
getInstanceByRefId($a_ref_id, $stop_on_error=true)
get an instance of an Ilias object by reference id
__raiseError($a_message, $a_code)
_isInTrash($a_ref_id)
checks wether object is in trash
+ Here is the call graph for this function:

◆ saveQuestion()

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

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

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

130  {
131  $this->initAuth($sid);
132  $this->initIlias();
133 
134  if(!$this->__checkSession($sid))
135  {
136  return $this->__raiseError($this->__getMessage(),$this->__getMessageCode());
137  }
138  if (!$this->isAllowedCall($sid, $active_id))
139  {
140  return $this->__raiseError("The required user information is only available for active users.", "");
141  }
142 
143  if (is_array($solution) && (array_key_exists("item", $solution))) $solution = $solution["item"];
144 
145  global $ilDB, $ilUser;
146 
147  require_once 'Modules/TestQuestionPool/classes/class.ilAssQuestionProcessLockerFactory.php';
148  $processLockerFactory = new ilAssQuestionProcessLockerFactory(new ilSetting('assessment'), $ilDB);
149  $processLockerFactory->setQuestionId($question_id);
150  $processLockerFactory->setUserId($ilUser->getId());
151  include_once ("./Modules/Test/classes/class.ilObjAssessmentFolder.php");
152  $processLockerFactory->setAssessmentLogEnabled(ilObjAssessmentFolder::_enabledAssessmentLogging());
153  $processLocker = $processLockerFactory->getLocker();
154 
155  $processLocker->requestPersistWorkingStateLock();
156  $processLocker->requestUserSolutionUpdateLock();
157 
158  $ilDB = $GLOBALS['ilDB'];
159  if (($active_id > 0) && ($question_id > 0) && (strlen($pass) > 0))
160  {
161  $affectedRows = $ilDB->manipulateF("DELETE FROM tst_solutions WHERE active_fi = %s AND question_fi = %s AND pass = %s",
162  array('integer', 'integer', 'integer'),
163  array($active_id, $question_id, $pass)
164  );
165  }
166  $totalrows = 0;
167  for($i = 0; $i < count($solution); $i += 3)
168  {
169  $next_id = $ilDB->nextId('tst_solutions');
170  $affectedRows = $ilDB->insert("tst_solutions", array(
171  "solution_id" => array("integer", $next_id),
172  "active_fi" => array("integer", $active_id),
173  "question_fi" => array("integer", $question_id),
174  "value1" => array("clob", $solution[$i]),
175  "value2" => array("clob", $solution[$i+1]),
176  "points" => array("float", $solution[$i+2]),
177  "pass" => array("integer", $pass),
178  "tstamp" => array("integer", time())
179  ));
180  $totalrows += $affectedRows;
181  }
182 
183  $processLocker->releaseUserSolutionUpdateLock();
184 
185  if($totalrows == 0)
186  {
187  $processLocker->releasePersistWorkingStateLock();
188  return $this->__raiseError(
189  "Wrong solution data. ILIAS did not execute any database queries: Solution data: " . print_r($solution, true),
190  'No result'
191  );
192  }
193  else
194  {
195  include_once "./Modules/TestQuestionPool/classes/class.assQuestion.php";
196  $question = assQuestion::_instanciateQuestion($question_id);
197  $question->setProcessLocker($processLocker);
198  $question->calculateResultsFromSolution($active_id, $pass);
199 
200  $processLocker->releasePersistWorkingStateLock();
201  }
202  return true;
203  }
ILIAS Setting Class.
static _instanciateQuestion($question_id)
Creates an instance of a question with a given question id.
isAllowedCall($sid, $active_id, $saveaction=true)
_enabledAssessmentLogging()
check wether assessment logging is enabled or not
$GLOBALS['ct_recipient']
__raiseError($a_message, $a_code)
global $ilUser
Definition: imgupload.php:15
global $ilDB
+ 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 216 of file class.ilSoapTestAdministration.php.

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

217  {
218  $this->initAuth($sid);
219  $this->initIlias();
220 
221  if(!$this->__checkSession($sid))
222  {
223  return $this->__raiseError($this->__getMessage(),$this->__getMessageCode());
224  }
225  if (!$this->isAllowedCall($sid, $active_id))
226  {
227  return $this->__raiseError("The required user information is only available for active users.", "");
228  }
229 
230  $solutions = array();
231  if (preg_match("/<values>(.*?)<\/values>/is", $solution, $matches))
232  {
233  if (preg_match_all("/<value>(.*?)<\/value><value>(.*?)<\/value><points>(.*?)<\/points>/is", $solution, $matches, PREG_SET_ORDER))
234  {
235  foreach ($matches as $match)
236  {
237  if (count($match) == 4)
238  {
239  for ($i = 1; $i < count($match); $i++)
240  {
241  array_push($solutions, trim($match[$i]));
242  }
243  }
244  }
245  }
246  }
247 
248  if (count($solutions) == 0)
249  {
250  return $this->__raiseError("Wrong solution data. ILIAS did not find one or more solution triplets: $solution", "");
251  }
252 
253  // Include main header
254  $ilDB = $GLOBALS['ilDB'];
255  if (($active_id > 0) && ($question_id > 0) && (strlen($pass) > 0))
256  {
257  $affectedRows = $ilDB->manipulateF("DELETE FROM tst_solutions WHERE active_fi = %s AND question_fi = %s AND pass = %s",
258  array('integer', 'integer', 'integer'),
259  array($active_id, $question_id, $pass)
260  );
261  }
262  $totalrows = 0;
263  for($i = 0; $i < count($solutions); $i += 3)
264  {
265  $next_id = $ilDB->nextId('tst_solutions');
266  $affectedRows = $ilDB->insert("tst_solutions", array(
267  "solution_id" => array("integer", $next_id),
268  "active_fi" => array("integer", $active_id),
269  "question_fi" => array("integer", $question_id),
270  "value1" => array("clob", $solutions[$i]),
271  "value2" => array("clob", $solutions[$i+1]),
272  "points" => array("float", $solutions[$i+2]),
273  "pass" => array("integer", $pass),
274  "tstamp" => array("integer", time())
275  ));
276  $totalrows += $affectedRows;
277  }
278  if (count($totalrows) == 0)
279  {
280  return $this->__raiseError("Wrong solution data. ILIAS did not execute any database queries");
281  }
282  else
283  {
284  include_once "./Modules/TestQuestionPool/classes/class.assQuestion.php";
285  $question = assQuestion::_instanciateQuestion($question_id);
286  $question->calculateResultsFromSolution($active_id, $pass);
287  }
288  return "TRUE";
289  }
static _instanciateQuestion($question_id)
Creates an instance of a question with a given question id.
isAllowedCall($sid, $active_id, $saveaction=true)
$GLOBALS['ct_recipient']
__raiseError($a_message, $a_code)
global $ilDB
+ Here is the call graph for this function:

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