33 include_once 
'./webservice/soap/classes/class.ilSoapAdministration.php';
 
   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",
 
  118                         if (
$row[
'user_fi'] == $ilUser->getId())
 
  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"];
 
  146                 if (($active_id > 0) && ($question_id > 0) && (strlen(
$pass) > 0))
 
  148                         $affectedRows = $ilDB->manipulateF(
"DELETE FROM tst_solutions WHERE active_fi = %s AND question_fi = %s AND pass = %s",
 
  149                                 array(
'integer', 
'integer', 
'integer'),
 
  150                                 array($active_id, $question_id, 
$pass)
 
  154                 for($i = 0; $i < count($solution); $i += 3)
 
  156                         $next_id = $ilDB->nextId(
'tst_solutions');
 
  157                         $affectedRows = $ilDB->insert(
"tst_solutions", array(
 
  158                                 "solution_id" => array(
"integer", $next_id),
 
  159                                 "active_fi" => array(
"integer", $active_id),
 
  160                                 "question_fi" => array(
"integer", $question_id),
 
  161                                 "value1" => array(
"clob", $solution[$i]),
 
  162                                 "value2" => array(
"clob", $solution[$i+1]),
 
  163                                 "points" => array(
"float", $solution[$i+2]),
 
  164                                 "pass" => array(
"integer", 
$pass),
 
  165                                 "tstamp" => array(
"integer", time())
 
  167                         $totalrows += $affectedRows;
 
  171                         return $this->
__raiseError(
"Wrong solution data. ILIAS did not execute any database queries: Solution data: " . print_r($solution, 
true));
 
  175                         include_once 
"./Modules/TestQuestionPool/classes/class.assQuestion.php";
 
  177                         $question->calculateResultsFromSolution($active_id, 
$pass);
 
  204                         return $this->
__raiseError(
"The required user information is only available for active users.", 
"");
 
  207                 $solutions = array();
 
  208                 if (preg_match(
"/<values>(.*?)<\/values>/is", $solution, $matches))
 
  210                         if (preg_match_all(
"/<value>(.*?)<\/value><value>(.*?)<\/value><points>(.*?)<\/points>/is", $solution, $matches, PREG_SET_ORDER))
 
  212                                 foreach ($matches as $match)
 
  214                                         if (count($match) == 4)
 
  216                                                 for ($i = 1; $i < count($match); $i++)
 
  218                                                         array_push($solutions, trim($match[$i]));
 
  225                 if (count($solutions) == 0)
 
  227                         return $this->
__raiseError(
"Wrong solution data. ILIAS did not find one or more solution triplets: $solution", 
"");
 
  232                 if (($active_id > 0) && ($question_id > 0) && (strlen(
$pass) > 0))
 
  234                         $affectedRows = $ilDB->manipulateF(
"DELETE FROM tst_solutions WHERE active_fi = %s AND question_fi = %s AND pass = %s",
 
  235                                 array(
'integer', 
'integer', 
'integer'),
 
  236                                 array($active_id, $question_id, 
$pass)
 
  240                 for($i = 0; $i < count($solutions); $i += 3)
 
  242                         $next_id = $ilDB->nextId(
'tst_solutions');
 
  243                         $affectedRows = $ilDB->insert(
"tst_solutions", array(
 
  244                                 "solution_id" => array(
"integer", $next_id),
 
  245                                 "active_fi" => array(
"integer", $active_id),
 
  246                                 "question_fi" => array(
"integer", $question_id),
 
  247                                 "value1" => array(
"clob", $solutions[$i]),
 
  248                                 "value2" => array(
"clob", $solutions[$i+1]),
 
  249                                 "points" => array(
"float", $solutions[$i+2]),
 
  250                                 "pass" => array(
"integer", 
$pass),
 
  251                                 "tstamp" => array(
"integer", time())
 
  253                         $totalrows += $affectedRows;
 
  255                 if (count($totalrows) == 0)
 
  257                         return $this->
__raiseError(
"Wrong solution data. ILIAS did not execute any database queries");
 
  261                         include_once 
"./Modules/TestQuestionPool/classes/class.assQuestion.php";
 
  263                         $question->calculateResultsFromSolution($active_id, 
$pass);
 
  289                         return $this->
__raiseError(
"The required user information is only available for active users.", 
"");
 
  295                 $use_previous_answers = 1;
 
  297                 $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",
 
  304                         $use_previous_answers = 
$row[
"use_previous_answers"];
 
  307                 if ($use_previous_answers)
 
  309                         $result = $ilDB->queryF(
"SELECT MAX(pass) maxpass FROM tst_test_result WHERE active_fi = %s AND question_fi = %s",
 
  310                                 array(
'integer', 
'integer'),
 
  311                                 array($active_id, $question_id)
 
  316                                 $lastpass = 
$row[
"maxpass"];
 
  324                 if (($active_id > 0) && ($question_id > 0) && (strlen($lastpass) > 0))
 
  326                         $result = $ilDB->queryF(
"SELECT * FROM tst_solutions WHERE active_fi = %s AND question_fi = %s AND pass = %s",
 
  327                                 array(
'integer', 
'integer', 
'integer'),
 
  328                                 array($active_id, $question_id, $lastpass)
 
  334                                         array_push($solution, 
$row[
"value1"]);
 
  335                                         array_push($solution, 
$row[
"value2"]);
 
  336                                         array_push($solution, 
$row[
"points"]);
 
  362                         return $this->
__raiseError(
"The required user information is only available for active users.", 
"");
 
  367                 $result = $ilDB->queryF(
"SELECT user_fi, test_fi FROM tst_active WHERE active_id = %s",
 
  372                 $user_id = 
$row[
"user_fi"];
 
  373                 $test_id = 
$row[
"test_fi"];
 
  375                 $result = $ilDB->queryF(
"SELECT anonymity FROM tst_tests WHERE test_id = %s",
 
  380                 $anonymity = 
$row[
"anonymity"];
 
  382                 $result = $ilDB->queryF(
"SELECT firstname, lastname, title, login FROM usr_data WHERE usr_id = %s",
 
  390                         $userdata[
"fullname"] = $lng->txt(
"deleted_user");
 
  391                         $userdata[
"title"] = 
"";
 
  392                         $userdata[
"firstname"] = 
"";
 
  393                         $userdata[
"lastname"] = $lng->txt(
"anonymous");
 
  394                         $userdata[
"login"] = 
"";
 
  399                         if (($user_id == ANONYMOUS_USER_ID) || ($anonymity))
 
  401                                 $userdata[
"fullname"] = $lng->txt(
"anonymous");
 
  402                                 $userdata[
"title"] = 
"";
 
  403                                 $userdata[
"firstname"] = 
"";
 
  404                                 $userdata[
"lastname"] = $lng->txt(
"anonymous");
 
  405                                 $userdata[
"login"] = 
"";
 
  409                                 $userdata[
"fullname"] = trim(
$data[
"title"] . 
" " . 
$data[
"firstname"] . 
" " . 
$data[
"lastname"]);
 
  410                                 $userdata[
"title"] = $data[
"title"];
 
  411                                 $userdata[
"firstname"] = $data[
"firstname"];
 
  412                                 $userdata[
"lastname"] = $data[
"lastname"];
 
  413                                 $userdata[
"login"] = $data[
"login"];
 
  416                 return array_values($userdata);
 
  440                         return $this->
__raiseError(
"The required user information is only available for active users.", 
"");
 
  445                 $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",
 
  449                 if (
$result->numRows() != 1) 
return -1;
 
  451                 $is_random = 
$row[
"random_test"];
 
  453                 include_once 
"./Modules/Test/classes/class.ilTestSequence.php";
 
  455                 return $sequence->getSequenceForQuestion($question_id);
 
  479                         return $this->
__raiseError(
"The required user information is only available for active users.", 
"");
 
  484                 $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",
 
  488                 if (
$result->numRows() != 1) 
return -1;
 
  490                 $is_random = 
$row[
"random_test"];
 
  492                 include_once 
"./Modules/Test/classes/class.ilTestSequence.php";
 
  494                 $result = $ilDB->queryF(
"SELECT question_fi, points FROM tst_test_result WHERE active_fi = %s AND pass = %s",
 
  495                         array(
'integer', 
'integer'),
 
  496                         array($active_id, 
$pass)
 
  498                 $reachedpoints = array();
 
  501                         $reachedpoints[
$row[
"question_fi"]] = $row[
"points"];
 
  504                 $pointsforposition = array();
 
  505                 foreach ($sequence->getUserSequence() as $seq)
 
  509                                 $qid = $sequence->getQuestionForSequence($seq);
 
  510                                 if ($qid == $question_id)
 
  516                                         array_push($pointsforposition, $reachedpoints[$qid]);
 
  520                 return $pointsforposition;
 
  543                         return $this->
__raiseError(
"The required user information is only available for active users.", 
"");
 
  548                 $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",
 
  552                 if (
$result->numRows() != 1) 
return 0;
 
  554                 $is_random = 
$row[
"random_test"];
 
  556                 include_once 
"./Modules/Test/classes/class.ilTestSequence.php";
 
  558                 return $sequence->getUserQuestionCount();
 
  577                 if(!strlen($test_ref_id))
 
  579                         return $this->
__raiseError(
'No test id given. Aborting!',
 
  582                 global $rbacsystem, $tree, 
$ilLog;
 
  586                         return $this->
__raiseError(
'Test is trashed. Aborting!',
 
  592                         return $this->
__raiseError(
'No test found for id: '.$test_ref_id,
'Client');
 
  594                 if($tst->getType() != 
'tst')
 
  596                         return $this->
__raiseError(
'Object with ref_id '.$test_ref_id.
' is not of type test. Aborting',
'Client');
 
  600                 if(isset($a_user_ids[
'item']))
 
  602                         $a_user_ids = $a_user_ids[
'item'];
 
  605                 foreach((array) $a_user_ids as $user_id)
 
  607                         $tst->removeTestResultsForUser($user_id);
 
  633                 if(!strlen($test_ref_id))
 
  635                         return $this->
__raiseError(
'No test id given. Aborting!',
 
  638                 global $rbacsystem, $tree, 
$ilLog;
 
  642                         return $this->
__raiseError(
'Test is trashed. Aborting!',
 
  649                         return $this->
__raiseError(
'No test found for id: '.$test_ref_id,
 
  655                 $permission_ok = 
false;
 
  658                         if($rbacsystem->checkAccess(
'write',$ref_id))
 
  660                                 $permission_ok = 
true;
 
  666                         return $this->
__raiseError(
'No permission to edit the object with id: '.$test_ref_id,
 
  670                 include_once 
'./webservice/soap/classes/class.ilXMLResultSet.php';
 
  671                 include_once 
'./webservice/soap/classes/class.ilXMLResultSetWriter.php';
 
  674                 $xmlResultSet->addColumn(
"user_id");
 
  675                 $xmlResultSet->addColumn(
"login");
 
  676                 $xmlResultSet->addColumn(
"firstname");
 
  677                 $xmlResultSet->addColumn(
"lastname");
 
  678                 $xmlResultSet->addColumn(
"matriculation");
 
  680                 include_once 
'./Modules/Test/classes/class.ilObjTest.php';
 
  681                 $test_obj = 
new ilObjTest($obj_id, 
false);
 
  682                 $participants =  $test_obj->getTestParticipants();
 
  687                         $data =  $test_obj->getAllTestResults($participants, 
false);
 
  689                         $xmlResultSet->addColumn(
"maximum_points");
 
  690                         $xmlResultSet->addColumn(
"received_points");
 
  692                         $titles = array_shift(
$data);
 
  695                                 $xmlRow->setValue(0, $row[
"user_id"]);
 
  696                                 $xmlRow->setValue(1, $row[
"login"]);                
 
  697                                 $xmlRow->setValue(2, $row[
"firstname"]);
 
  698                                 $xmlRow->setValue(3, $row[
"lastname"]);
 
  699                                 $xmlRow->setValue(4, $row[
"matriculation"]);
 
  700                                 $xmlRow->setValue(5, $row[
"max_points"]);
 
  701                                 $xmlRow->setValue(6, $row[
"reached_points"]);
 
  702                                 $xmlResultSet->addRow($xmlRow);
 
  705                         $data =  $test_obj->getDetailedTestResults($participants);
 
  707                         $xmlResultSet->addColumn(
"question_id");
 
  708                         $xmlResultSet->addColumn(
"question_title");                     
 
  709                         $xmlResultSet->addColumn(
"maximum_points");
 
  710                         $xmlResultSet->addColumn(
"received_points");
 
  713                                 $xmlRow->setValue(0, $row[
"user_id"]);
 
  714                                 $xmlRow->setValue(1, $row[
"login"]);                
 
  715                                 $xmlRow->setValue(2, $row[
"firstname"]);
 
  716                                 $xmlRow->setValue(3, $row[
"lastname"]);
 
  717                                 $xmlRow->setValue(4, $row[
"matriculation"]);
 
  718                                 $xmlRow->setValue(5, $row[
"question_id"]);
 
  719                                 $xmlRow->setValue(6, $row[
"question_title"]);
 
  720                                 $xmlRow->setValue(7, $row[
"max_points"]);
 
  721                                 $xmlRow->setValue(8, $row[
"reached_points"]);
 
  722                                 $xmlResultSet->addRow($xmlRow);
 
  728                 return $xmlWriter->getXML();