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

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

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