• Main Page
  • Related Pages
  • Modules
  • Namespaces
  • Data Structures
  • Files
  • File List
  • Globals

webservice/soap/classes/class.ilSoapTestAdministration.php

Go to the documentation of this file.
00001 <?php
00002   /*
00003    +-----------------------------------------------------------------------------+
00004    | ILIAS open source                                                           |
00005    +-----------------------------------------------------------------------------+
00006    | Copyright (c) 1998-2001 ILIAS open source, University of Cologne            |
00007    |                                                                             |
00008    | This program is free software; you can redistribute it and/or               |
00009    | modify it under the terms of the GNU General Public License                 |
00010    | as published by the Free Software Foundation; either version 2              |
00011    | of the License, or (at your option) any later version.                      |
00012    |                                                                             |
00013    | This program is distributed in the hope that it will be useful,             |
00014    | but WITHOUT ANY WARRANTY; without even the implied warranty of              |
00015    | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the               |
00016    | GNU General Public License for more details.                                |
00017    |                                                                             |
00018    | You should have received a copy of the GNU General Public License           |
00019    | along with this program; if not, write to the Free Software                 |
00020    | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA. |
00021    +-----------------------------------------------------------------------------+
00022   */
00023 
00024 
00033 include_once './webservice/soap/classes/class.ilSoapAdministration.php';
00034 
00035 class ilSoapTestAdministration extends ilSoapAdministration
00036 {
00037         function ilSoapTestAdministration()
00038         {
00039                 parent::ilSoapAdministration();
00040         }
00041 
00042         function saveQuestionResult($sid,$user_id,$test_id,$question_id,$pass,$solution)
00043         {
00044                 include_once './include/inc.header.php';
00045                 if(!$this->__checkSession($sid))
00046                 {
00047                         return $this->__raiseError($this->sauth->getMessage(),$this->sauth->getMessageCode());
00048                 }
00049 
00050                 // Include main header
00051                 include_once "./Modules/Test/classes/class.ilObjTest.php";
00052                 $active_id = ilObjTest::_getActiveIdOfUser($user_id, $test_id);
00053                 $ilDB = $GLOBALS['ilDB'];
00054                 if (($active_id > 0) && ($question_id > 0) && (strlen($pass) > 0))
00055                 {
00056                         $deletequery = sprintf("DELETE FROM tst_solutions WHERE active_fi = %s AND question_fi = %s AND pass = %s",
00057                                 $ilDB->quote($active_id . ""),
00058                                 $ilDB->quote($question_id . ""),
00059                                 $ilDB->quote($pass . "")
00060                         );
00061                         $ilDB->query($deletequery);
00062                 }
00063                 $saved_solutions = FALSE;
00064                 for($i = 0; $i < count($solution); $i += 3)
00065                 {
00066                         $query = sprintf("INSERT INTO tst_solutions ".
00067                                 "SET active_fi = %s, ".
00068                                 "question_fi = %s, ".
00069                                 "value1 = %s, ".
00070                                 "value2 = %s, ".
00071                                 "points = %s, ".
00072                                 "pass = %s",
00073                                 $ilDB->quote($active_id . ""),
00074                                 $ilDB->quote($question_id . ""),
00075                                 $ilDB->quote($solution[$i]),
00076                                 $ilDB->quote($solution[$i+1]),
00077                                 $ilDB->quote($solution[$i+2]),
00078                                 $ilDB->quote($pass . "")
00079                         );
00080                         $ilDB->query($query);
00081                         $saved_solutions = TRUE;
00082                 }
00083                 return $saved_solutions;
00084         }
00085 
00086         function saveQuestion($sid,$active_id,$question_id,$pass,$solution)
00087         {
00088                 if(!$this->__checkSession($sid))
00089                 {
00090                         return $this->__raiseError($this->sauth->getMessage(),$this->sauth->getMessageCode());
00091                 }                       
00092 
00093                 // Include main header
00094                 include_once './include/inc.header.php';
00095                 $ilDB = $GLOBALS['ilDB'];
00096                 if (($active_id > 0) && ($question_id > 0) && (strlen($pass) > 0))
00097                 {
00098                         $deletequery = sprintf("DELETE FROM tst_solutions WHERE active_fi = %s AND question_fi = %s AND pass = %s",
00099                                 $ilDB->quote($active_id . ""),
00100                                 $ilDB->quote($question_id . ""),
00101                                 $ilDB->quote($pass . "")
00102                         );
00103                         $ilDB->query($deletequery);
00104                 }
00105                 for($i = 0; $i < count($solution); $i += 3)
00106                 {
00107                         $query = sprintf("INSERT INTO tst_solutions ".
00108                                 "SET active_fi = %s, ".
00109                                 "question_fi = %s, ".
00110                                 "value1 = %s, ".
00111                                 "value2 = %s, ".
00112                                 "points = %s, ".
00113                                 "pass = %s",
00114                                 $ilDB->quote($active_id . ""),
00115                                 $ilDB->quote($question_id . ""),
00116                                 $ilDB->quote($solution[$i]),
00117                                 $ilDB->quote($solution[$i+1]),
00118                                 $ilDB->quote($solution[$i+2]),
00119                                 $ilDB->quote($pass . "")
00120                         );
00121                         $ilDB->query($query);
00122                 }
00123                 return true;
00124         }
00125 
00126         function getQuestionSolution($sid,$active_id,$question_id,$pass)
00127         {
00128                 if(!$this->__checkSession($sid))
00129                 {
00130                         return $this->__raiseError($this->sauth->getMessage(),$this->sauth->getMessageCode());
00131                 }                       
00132                 $solution = array();
00133                 // Include main header
00134                 include_once './include/inc.header.php';
00135                 $ilDB = $GLOBALS['ilDB'];
00136                 if (($active_id > 0) && ($question_id > 0) && (strlen($pass) > 0))
00137                 {
00138                         $query = sprintf("SELECT * FROM tst_solutions ".
00139                                 "WHERE active_fi = %s AND ".
00140                                 "question_fi = %s AND ".
00141                                 "pass = %s",
00142                                 $ilDB->quote($active_id . ""),
00143                                 $ilDB->quote($question_id . ""),
00144                                 $ilDB->quote($pass . "")
00145                         );
00146                         $result = $ilDB->query($query);
00147                         if ($result->numRows())
00148                         {
00149                                 while ($row = $result->fetchRow(DB_FETCHMODE_ASSOC))
00150                                 {
00151                                         array_push($solution, $row["value1"]);
00152                                         array_push($solution, $row["value2"]);
00153                                         array_push($solution, $row["points"]);
00154                                 }
00155                         }
00156                 }
00157                 return $solution;
00158         }
00159 }
00160 ?>

Generated on Fri Dec 13 2013 17:57:03 for ILIAS Release_3_9_x_branch .rev 46835 by  doxygen 1.7.1