33include_once 
'./webservice/soap/classes/class.ilSoapAdministration.php';
 
   39                parent::ilSoapAdministration();
 
   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",
 
   55                        $obj_id = 
$row[
'obj_fi'];
 
   58                                if ($ilAccess->checkAccess(
"write", 
"", 
$ref_id)) 
 
   60                                        $permission_ok = 
true;
 
   65                return $permission_ok;
 
   77                        $result = 
$ilDB->queryF(
"SELECT * FROM tst_times WHERE active_fi = %s ORDER BY started DESC",
 
   84                                if (preg_match(
"/(\\d{4})-(\\d{2})-(\\d{2}) (\\d{2}):(\\d{2}):(\\d{2})/", 
$row[
"started"], $matches))
 
   86                                        $time = mktime($matches[4], $matches[5], $matches[6], $matches[2], $matches[3], $matches[1]);
 
   90                                        global $ilClientIniFile;
 
   91                                        $expires = $ilClientIniFile->readVariable(
'session',
'expire');
 
   92                                        if ($diff <= $expires)
 
  113                        $result = 
$ilDB->queryF(
"SELECT user_fi FROM tst_active WHERE active_id = %s",
 
  134                if(!$this->__checkSession($sid))
 
  140                        return $this->
__raiseError(
"The required user information is only available for active users.", 
"");
 
  143                if (is_array($solution) && (array_key_exists(
"item", $solution))) $solution = $solution[
"item"];
 
  147                require_once 
'Modules/TestQuestionPool/classes/class.ilAssQuestionProcessLockerFactory.php';
 
  149                $processLockerFactory->setQuestionId($question_id);
 
  150                $processLockerFactory->setUserId(
$ilUser->getId());
 
  151                include_once (
"./Modules/Test/classes/class.ilObjAssessmentFolder.php");
 
  153                $processLocker  = $processLockerFactory->getLocker();
 
  155                $processLocker->requestPersistWorkingStateLock();
 
  156                $processLocker->requestUserSolutionUpdateLock();
 
  159                if (($active_id > 0) && ($question_id > 0) && (strlen(
$pass) > 0))
 
  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)
 
  167                for($i = 0; $i < count($solution); $i += 3)
 
  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())
 
  180                        $totalrows += $affectedRows;
 
  183                $processLocker->releaseUserSolutionUpdateLock();
 
  187                        $processLocker->releasePersistWorkingStateLock();
 
  189                                "Wrong solution data. ILIAS did not execute any database queries: Solution data: " . print_r($solution, 
true), 
 
  195                        include_once 
"./Modules/TestQuestionPool/classes/class.assQuestion.php";
 
  197                        $question->setProcessLocker($processLocker);
 
  198                        $question->calculateResultsFromSolution($active_id, 
$pass);
 
  200                        $processLocker->releasePersistWorkingStateLock();
 
  221                if(!$this->__checkSession($sid))
 
  227                        return $this->
__raiseError(
"The required user information is only available for active users.", 
"");
 
  230                $solutions = array();
 
  231                if (preg_match(
"/<values>(.*?)<\/values>/is", $solution, $matches))
 
  233                        if (preg_match_all(
"/<value>(.*?)<\/value><value>(.*?)<\/value><points>(.*?)<\/points>/is", $solution, $matches, PREG_SET_ORDER))
 
  235                                foreach ($matches as $match)
 
  237                                        if (count($match) == 4)
 
  239                                                for ($i = 1; $i < count($match); $i++)
 
  241                                                        array_push($solutions, trim($match[$i]));
 
  248                if (count($solutions) == 0)
 
  250                        return $this->
__raiseError(
"Wrong solution data. ILIAS did not find one or more solution triplets: $solution", 
"");
 
  255                if (($active_id > 0) && ($question_id > 0) && (strlen(
$pass) > 0))
 
  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)
 
  263                for($i = 0; $i < count($solutions); $i += 3)
 
  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())
 
  276                        $totalrows += $affectedRows;
 
  278                if (count($totalrows) == 0)
 
  280                        return $this->
__raiseError(
"Wrong solution data. ILIAS did not execute any database queries");
 
  284                        include_once 
"./Modules/TestQuestionPool/classes/class.assQuestion.php";
 
  286                        $question->calculateResultsFromSolution($active_id, 
$pass);
 
  306                if(!$this->__checkSession($sid))
 
  312                        return $this->
__raiseError(
"The required user information is only available for active users.", 
"");
 
  318                $use_previous_answers = 1;
 
  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",
 
  327                        $use_previous_answers = 
$row[
"use_previous_answers"];
 
  330                if ($use_previous_answers)
 
  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)
 
  339                                $lastpass = 
$row[
"maxpass"];
 
  347                if (($active_id > 0) && ($question_id > 0) && (strlen($lastpass) > 0))
 
  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)
 
  357                                        array_push($solution, 
$row[
"value1"]);
 
  358                                        array_push($solution, 
$row[
"value2"]);
 
  359                                        array_push($solution, 
$row[
"points"]);
 
  379                if(!$this->__checkSession($sid))
 
  385                        return $this->
__raiseError(
"The required user information is only available for active users.", 
"");
 
  390                $result = 
$ilDB->queryF(
"SELECT user_fi, test_fi FROM tst_active WHERE active_id = %s",
 
  395                $user_id = 
$row[
"user_fi"];
 
  396                $test_id = 
$row[
"test_fi"];
 
  398                $result = 
$ilDB->queryF(
"SELECT anonymity FROM tst_tests WHERE test_id = %s",
 
  403                $anonymity = 
$row[
"anonymity"];
 
  405                $result = 
$ilDB->queryF(
"SELECT firstname, lastname, title, login FROM usr_data WHERE usr_id = %s",
 
  413                        $userdata[
"fullname"] = 
$lng->txt(
"deleted_user");
 
  414                        $userdata[
"title"] = 
"";
 
  415                        $userdata[
"firstname"] = 
"";
 
  416                        $userdata[
"lastname"] = 
$lng->txt(
"anonymous");
 
  417                        $userdata[
"login"] = 
"";
 
  422                        if (($user_id == ANONYMOUS_USER_ID) || ($anonymity))
 
  424                                $userdata[
"fullname"] = 
$lng->txt(
"anonymous");
 
  425                                $userdata[
"title"] = 
"";
 
  426                                $userdata[
"firstname"] = 
"";
 
  427                                $userdata[
"lastname"] = 
$lng->txt(
"anonymous");
 
  428                                $userdata[
"login"] = 
"";
 
  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"];
 
  439                return array_values($userdata);
 
  457                if(!$this->__checkSession($sid))
 
  463                        return $this->
__raiseError(
"The required user information is only available for active users.", 
"");
 
  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",
 
  472                if (
$result->numRows() != 1) 
return -1;
 
  474                $is_random = 
$row[
"random_test"];
 
  476                include_once 
"./Modules/Test/classes/class.ilTestSequence.php";
 
  478                return $sequence->getSequenceForQuestion($question_id);
 
  496                if(!$this->__checkSession($sid))
 
  502                        return $this->
__raiseError(
"The required user information is only available for active users.", 
"");
 
  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",
 
  511                if (
$result->numRows() != 1) 
return -1;
 
  513                $is_random = 
$row[
"random_test"];
 
  515                include_once 
"./Modules/Test/classes/class.ilTestSequence.php";
 
  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)
 
  521                $reachedpoints = array();
 
  524                        $reachedpoints[
$row[
"question_fi"]] = 
$row[
"points"];
 
  527                $pointsforposition = array();
 
  528                foreach ($sequence->getUserSequence() as $seq)
 
  532                                $qid = $sequence->getQuestionForSequence($seq);
 
  533                                if ($qid == $question_id)
 
  539                                        array_push($pointsforposition, $reachedpoints[$qid]);
 
  543                return $pointsforposition;
 
  560                if(!$this->__checkSession($sid))
 
  566                        return $this->
__raiseError(
"The required user information is only available for active users.", 
"");
 
  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",
 
  575                if (
$result->numRows() != 1) 
return 0;
 
  577                $is_random = 
$row[
"random_test"];
 
  579                include_once 
"./Modules/Test/classes/class.ilTestSequence.php";
 
  581                return $sequence->getUserQuestionCount();
 
  596                if(!$this->__checkSession($sid))
 
  600                if(!strlen($test_ref_id))
 
  602                        return $this->
__raiseError(
'No test id given. Aborting!',
 
  605                global $rbacsystem, $tree, 
$ilLog;
 
  608                if( !$ilAccess->checkAccess(
'write', 
'', $test_ref_id) )
 
  610                        return $this->
__raiseError(
'no permission. Aborting!', 
'Client');
 
  615                        return $this->
__raiseError(
'Test is trashed. Aborting!',
 
  621                        return $this->
__raiseError(
'No test found for id: '.$test_ref_id,
'Client');
 
  623                if($tst->getType() != 
'tst')
 
  625                        return $this->
__raiseError(
'Object with ref_id '.$test_ref_id.
' is not of type test. Aborting',
'Client');
 
  629                if(isset($a_user_ids[
'item']))
 
  631                        $a_user_ids = $a_user_ids[
'item'];
 
  634                foreach((array) $a_user_ids as $user_id)
 
  636                        $tst->removeTestResultsForUser($user_id);
 
  658                if(!$this->__checkSession($sid))
 
  662                if(!strlen($test_ref_id))
 
  664                        return $this->
__raiseError(
'No test id given. Aborting!',
 
  667                global $rbacsystem, $tree, 
$ilLog;
 
  671                        return $this->
__raiseError(
'Test is trashed. Aborting!',
 
  678                        return $this->
__raiseError(
'No test found for id: '.$test_ref_id,
 
  684                $permission_ok = 
false;
 
  687                        if($rbacsystem->checkAccess(
'write',
$ref_id))
 
  689                                $permission_ok = 
true;
 
  695                        return $this->
__raiseError(
'No permission to edit the object with id: '.$test_ref_id,
 
  699                include_once 
'./webservice/soap/classes/class.ilXMLResultSet.php';
 
  700                include_once 
'./webservice/soap/classes/class.ilXMLResultSetWriter.php';
 
  703                $xmlResultSet->addColumn(
"user_id");
 
  704                $xmlResultSet->addColumn(
"login");
 
  705                $xmlResultSet->addColumn(
"firstname");
 
  706                $xmlResultSet->addColumn(
"lastname");
 
  707                $xmlResultSet->addColumn(
"matriculation");
 
  709                include_once 
'./Modules/Test/classes/class.ilObjTest.php';
 
  710                $test_obj = 
new ilObjTest($obj_id, 
false);
 
  711                $participants =  $test_obj->getTestParticipants();
 
  716                        $data =  $test_obj->getAllTestResults($participants, 
false);
 
  718                        $xmlResultSet->addColumn(
"maximum_points");
 
  719                        $xmlResultSet->addColumn(
"received_points");
 
  721                        $titles = array_shift(
$data);
 
  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);
 
  734                        $data =  $test_obj->getDetailedTestResults($participants);
 
  736                        $xmlResultSet->addColumn(
"question_id");
 
  737                        $xmlResultSet->addColumn(
"question_title");                     
 
  738                        $xmlResultSet->addColumn(
"maximum_points");
 
  739                        $xmlResultSet->addColumn(
"received_points");
 
  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);
 
  757                return $xmlWriter->getXML();
 
static _instanciateQuestion($question_id)
Creates an instance of a question with a given question id.
_enabledAssessmentLogging()
check wether assessment logging is enabled or not
getInstanceByRefId($a_ref_id, $stop_on_error=true)
get an instance of an Ilias object by reference id
_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
__raiseError($a_message, $a_code)
getNrOfQuestionsInPass($sid, $active_id, $pass)
Get the number of questions in a given pass for a given user.
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.
removeTestResults($sid, $test_ref_id, $a_user_ids)
Remove test results for the chosen test and users.
getTestUserData($sid, $active_id)
get active user data
getPreviousReachedPoints($sid, $active_id, $question_id, $pass)
Returns the previous reached points in a given pass.
getPositionOfQuestion($sid, $active_id, $question_id, $pass)
get active user data
getQuestionSolution($sid, $active_id, $question_id, $pass)
Get the the answers of a given question and pass for a given user.
getTestResults($sid, $test_ref_id, $sum_only)
get results of test
hasWritePermissionForTest($active_id)
XML Writer for XMLResultSet.