ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
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.

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
__raiseError($a_message, $a_code)
isAllowedCall($sid, $active_id, $saveaction=true)
Test sequence handler.
global $lng
Definition: privfeed.php:40
global $ilDB

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

+ 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.

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 }

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

+ 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.

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 }

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

+ 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.

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 }

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

+ 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 656 of file class.ilSoapTestAdministration.php.

657 {
658 $this->initAuth($sid);
659 $this->initIlias();
660
661 if(!$this->__checkSession($sid))
662 {
663 return $this->__raiseError($this->__getMessage(),$this->__getMessageCode());
664 }
665 if(!strlen($test_ref_id))
666 {
667 return $this->__raiseError('No test id given. Aborting!',
668 'Client');
669 }
670 global $rbacsystem, $tree, $ilLog;
671
672 if(ilObject::_isInTrash($test_ref_id))
673 {
674 return $this->__raiseError('Test is trashed. Aborting!',
675 'Client');
676 }
677
678 // get obj_id
679 if(!$obj_id = ilObject::_lookupObjectId($test_ref_id))
680 {
681 return $this->__raiseError('No test found for id: '.$test_ref_id,
682 'Client');
683 }
684
685
686 // Check access
687 $permission_ok = false;
688 foreach($ref_ids = ilObject::_getAllReferences($obj_id) as $ref_id)
689 {
690 if($rbacsystem->checkAccess('write',$ref_id))
691 {
692 $permission_ok = true;
693 break;
694 }
695 }
696 if(!$permission_ok)
697 {
698 return $this->__raiseError('No permission to edit the object with id: '.$test_ref_id,
699 'Server');
700 }
701 // store into xml result set
702 include_once './webservice/soap/classes/class.ilXMLResultSet.php';
703 include_once './webservice/soap/classes/class.ilXMLResultSetWriter.php';
704
705 $xmlResultSet = new ilXMLResultSet();
706 $xmlResultSet->addColumn("user_id");
707 $xmlResultSet->addColumn("login");
708 $xmlResultSet->addColumn("firstname");
709 $xmlResultSet->addColumn("lastname");
710 $xmlResultSet->addColumn("matriculation");
711
712 include_once './Modules/Test/classes/class.ilObjTest.php';
713 $test_obj = new ilObjTest($obj_id, false);
714 $participants = $test_obj->getTestParticipants();
715
716
717 if ($sum_only)
718 {
719 $data = $test_obj->getAllTestResults($participants, false);
720 // create xml
721 $xmlResultSet->addColumn("maximum_points");
722 $xmlResultSet->addColumn("received_points");
723 // skip titles
724 $titles = array_shift($data);
725 foreach ($data as $row) {
726 $xmlRow = new ilXMLResultSetRow();
727 $xmlRow->setValue(0, $row["user_id"]);
728 $xmlRow->setValue(1, $row["login"]);
729 $xmlRow->setValue(2, $row["firstname"]);
730 $xmlRow->setValue(3, $row["lastname"]);
731 $xmlRow->setValue(4, $row["matriculation"]);
732 $xmlRow->setValue(5, $row["max_points"]);
733 $xmlRow->setValue(6, $row["reached_points"]);
734 $xmlResultSet->addRow($xmlRow);
735 }
736 } else {
737 $data = $test_obj->getDetailedTestResults($participants);
738 // create xml
739 $xmlResultSet->addColumn("question_id");
740 $xmlResultSet->addColumn("question_title");
741 $xmlResultSet->addColumn("maximum_points");
742 $xmlResultSet->addColumn("received_points");
743 foreach ($data as $row) {
744 $xmlRow = new ilXMLResultSetRow();
745 $xmlRow->setValue(0, $row["user_id"]);
746 $xmlRow->setValue(1, $row["login"]);
747 $xmlRow->setValue(2, $row["firstname"]);
748 $xmlRow->setValue(3, $row["lastname"]);
749 $xmlRow->setValue(4, $row["matriculation"]);
750 $xmlRow->setValue(5, $row["question_id"]);
751 $xmlRow->setValue(6, $row["question_title"]);
752 $xmlRow->setValue(7, $row["max_points"]);
753 $xmlRow->setValue(8, $row["reached_points"]);
754 $xmlResultSet->addRow($xmlRow);
755 }
756 }
757 // create writer
758 $xmlWriter = new ilXMLResultSetWriter($xmlResultSet);
759 $xmlWriter->start();
760 return $xmlWriter->getXML();
761 }
_isInTrash($a_ref_id)
checks wether object is in trash
static _lookupObjectId($a_ref_id)
lookup object id
static _getAllReferences($a_id)
get all reference ids of object
XML Writer for XMLResultSet.
$data
$ref_id
Definition: sahs_server.php:39

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

+ 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.

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 }

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

+ Here is the call graph for this function:

◆ hasWritePermissionForTest()

ilSoapTestAdministration::hasWritePermissionForTest (   $active_id)
private

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

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 }

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

Referenced by isAllowedCall().

+ 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.

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 }
global $ilUser
Definition: imgupload.php:15

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

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

+ 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.

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 include_once './Modules/Test/classes/class.ilObjTest.php';
635 include_once './Modules/Test/classes/class.ilTestParticipantData.php';
636 $part = new ilTestParticipantData($GLOBALS['ilDB'], $GLOBALS['lng']);
637 $part->setUserIds((array) $a_user_ids);
638 $part->load($tst->getTestId());
639 $tst->removeTestResults($part);
640
641 return true;
642 }
getInstanceByRefId($a_ref_id, $stop_on_error=true)
get an instance of an Ilias object by reference id
$GLOBALS['PHPCAS_CLIENT']
This global variable is used by the interface class phpCAS.
Definition: CAS.php:276

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

+ 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.

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 }
static _instanciateQuestion($question_id)
Creates an instance of a question with a given question id.
_enabledAssessmentLogging()
check wether assessment logging is enabled or not
ILIAS Setting Class.

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

+ 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.

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 }

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

+ Here is the call graph for this function:

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