00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
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
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
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
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 ?>