Go to the documentation of this file.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
00025 define ("QT_UNKNOWN", 0);
00026 define ("QT_MULTIPLE_CHOICE_SR", 1);
00027 define ("QT_MULTIPLE_CHOICE_MR", 2);
00028 define ("QT_CLOZE", 3);
00029 define ("QT_MATCHING", 4);
00030 define ("QT_ORDERING", 5);
00031 define ("QT_IMAGEMAP", 6);
00032 define ("QT_JAVAAPPLET", 7);
00033 define ("QT_TEXT", 8);
00034
00043 class ilQTIItem
00044 {
00045 var $ident;
00046 var $title;
00047 var $maxattempts;
00048 var $label;
00049 var $xmllang;
00050
00051 var $comment;
00052 var $ilias_version;
00053 var $author;
00054 var $questiontype;
00055 var $duration;
00056 var $questiontext;
00057 var $resprocessing;
00058 var $itemfeedback;
00059 var $presentation;
00060 var $presentationitem;
00061 var $suggested_solutions;
00062
00063 function ilQTIItem()
00064 {
00065 $this->response = array();
00066 $this->resprocessing = array();
00067 $this->itemfeedback = array();
00068 $this->presentation = NULL;
00069 $this->presentationitem = array();
00070 $this->suggested_solutions = array();
00071 }
00072
00073 function setIdent($a_ident)
00074 {
00075 $this->ident = $a_ident;
00076 }
00077
00078 function getIdent()
00079 {
00080 return $this->ident;
00081 }
00082
00083 function setTitle($a_title)
00084 {
00085 $this->title = $a_title;
00086 }
00087
00088 function getTitle()
00089 {
00090 return $this->title;
00091 }
00092
00093 function setComment($a_comment)
00094 {
00095 if (preg_match("/(.*?)\=(.*)/", $a_comment, $matches))
00096 {
00097
00098 switch ($matches[1])
00099 {
00100 case "ILIAS Version":
00101 $this->ilias_version = $matches[2];
00102 return;
00103 break;
00104 case "Questiontype":
00105 $this->questiontype = $matches[2];
00106 return;
00107 break;
00108 case "Author":
00109 $this->author = $matches[2];
00110 return;
00111 break;
00112 }
00113 }
00114 $this->comment = $a_comment;
00115 }
00116
00117 function getComment()
00118 {
00119 return $this->comment;
00120 }
00121
00122 function setDuration($a_duration)
00123 {
00124 if (preg_match("/P(\d+)Y(\d+)M(\d+)DT(\d+)H(\d+)M(\d+)S/", $a_duration, $matches))
00125 {
00126 $this->duration = array(
00127 "h" => $matches[4],
00128 "m" => $matches[5],
00129 "s" => $matches[6]
00130 );
00131 }
00132 }
00133
00134 function getDuration()
00135 {
00136 return $this->duration;
00137 }
00138
00139 function setQuestiontext($a_questiontext)
00140 {
00141 $this->questiontext = $a_questiontext;
00142 }
00143
00144 function getQuestiontext()
00145 {
00146 return $this->questiontext;
00147 }
00148
00149 function addResprocessing($a_resprocessing)
00150 {
00151 array_push($this->resprocessing, $a_resprocessing);
00152 }
00153
00154 function addItemfeedback($a_itemfeedback)
00155 {
00156 array_push($this->itemfeedback, $a_itemfeedback);
00157 }
00158
00159 function setMaxattempts($a_maxattempts)
00160 {
00161 $this->maxattempts = $a_maxattempts;
00162 }
00163
00164 function getMaxattempts()
00165 {
00166 return $this->maxattempts;
00167 }
00168
00169 function setLabel($a_label)
00170 {
00171 $this->label = $a_label;
00172 }
00173
00174 function getLabel()
00175 {
00176 return $this->label;
00177 }
00178
00179 function setXmllang($a_xmllang)
00180 {
00181 $this->xmllang = $a_xmllang;
00182 }
00183
00184 function getXmllang()
00185 {
00186 return $this->xmllang;
00187 }
00188
00189 function setPresentation($a_presentation)
00190 {
00191 $this->presentation = $a_presentation;
00192 }
00193
00194 function getPresentation()
00195 {
00196 return $this->presentation;
00197 }
00198
00199 function collectResponses()
00200 {
00201 $result = array();
00202 if ($this->presentation != NULL)
00203 {
00204 }
00205 }
00206
00207 function setQuestiontype($a_questiontype)
00208 {
00209 $this->questiontype = $a_questiontype;
00210 }
00211
00212 function getQuestiontype()
00213 {
00214 return $this->questiontype;
00215 }
00216
00217 function addPresentationitem($a_presentationitem)
00218 {
00219 array_push($this->presentationitem, $a_presentationitem);
00220 }
00221
00222 function determineQuestionType()
00223 {
00224 switch ($this->questiontype)
00225 {
00226 case "ORDERING QUESTION":
00227 return QT_ORDERING;
00228 case "MULTIPLE CHOICE QUESTION":
00229 break;
00230 case "MATCHING QUESTION":
00231 return QT_MATCHING;
00232 case "CLOZE QUESTION":
00233 return QT_CLOZE;
00234 case "IMAGE MAP QUESTION":
00235 return QT_IMAGEMAP;
00236 case "JAVA APPLET QUESTION":
00237 return QT_JAVAAPPLET;
00238 case "TEXT QUESTION":
00239 return QT_TEXT;
00240 }
00241 if (!$this->presentation) return QT_UNKNOWN;
00242 foreach ($this->presentation->order as $entry)
00243 {
00244 switch ($entry["type"])
00245 {
00246 case "response":
00247 $response = $this->presentation->response[$entry["index"]];
00248 switch ($response->getResponsetype())
00249 {
00250 case RT_RESPONSE_LID:
00251 switch ($response->getRCardinality())
00252 {
00253 case R_CARDINALITY_ORDERED:
00254 return QT_ORDERING;
00255 break;
00256 case R_CARDINALITY_SINGLE:
00257 return QT_MULTIPLE_CHOICE_SR;
00258 break;
00259 case R_CARDINALITY_MULTIPLE:
00260 return QT_MULTIPLE_CHOICE_MR;
00261 break;
00262 }
00263 break;
00264 case RT_RESPONSE_XY:
00265 return QT_IMAGEMAP;
00266 break;
00267 case RT_RESPONSE_STR:
00268 switch ($response->getRCardinality())
00269 {
00270 case R_CARDINALITY_ORDERED:
00271 return QT_TEXT;
00272 break;
00273 case R_CARDINALITY_SINGLE:
00274 return QT_CLOZE;
00275 break;
00276 }
00277 break;
00278 case RT_RESPONSE_GRP:
00279 return QT_MATCHING;
00280 break;
00281 default:
00282 break;
00283 }
00284 break;
00285 case "material":
00286 $material = $this->presentation->material[$entry["index"]];
00287 if (count($material->matapplet) > 0) return QT_JAVAAPPLET;
00288 break;
00289 }
00290 }
00291 return QT_UNKNOWN;
00292 }
00293
00294 function setAuthor($a_author)
00295 {
00296 $this->author = $a_author;
00297 }
00298
00299 function getAuthor()
00300 {
00301 return $this->author;
00302 }
00303
00304 function addSuggestedSolution($a_solution, $a_gap_index)
00305 {
00306 array_push($this->suggested_solutions, array("solution" => $a_solution, "gap_index" => $a_gap_index));
00307 }
00308 }
00309 ?>