ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
SurveyQuestion Class Reference

Basic class for all survey question types. More...

+ Inheritance diagram for SurveyQuestion:
+ Collaboration diagram for SurveyQuestion:

Public Member Functions

 __construct ($title="", $description="", $author="", $questiontext="", $owner=-1)
 SurveyQuestion constructor The constructor takes possible arguments an creates an instance of the SurveyQuestion object. More...
 
 setComplete ($a_complete)
 Sets the complete state of the question. More...
 
 isComplete ()
 Returns 1, if a question is complete for use. More...
 
 questionTitleExists ($title, $questionpool_object="")
 Returns TRUE if the question title exists in the database. More...
 
 setTitle ($title="")
 Sets the title string of the SurveyQuestion object. More...
 
 setObligatory ($obligatory=1)
 Sets the obligatory state of the question. More...
 
 setOrientation ($orientation=0)
 Sets the orientation of the question output. More...
 
 setId ($id=-1)
 Sets the id of the SurveyQuestion object. More...
 
 setSurveyId ($id=-1)
 Sets the survey id of the SurveyQuestion object. More...
 
 setDescription ($description="")
 Sets the description string of the SurveyQuestion object. More...
 
 addMaterials ($materials_file, $materials_name="")
 Sets the materials uri. More...
 
 setMaterialsfile ($materials_filename, $materials_tempfilename="", $materials_name="")
 Sets and uploads the materials uri. More...
 
 deleteMaterial ($materials_name="")
 Deletes a materials uri with a given name. More...
 
 flushMaterials ()
 Deletes all materials uris. More...
 
 setAuthor ($author="")
 Sets the authors name of the SurveyQuestion object. More...
 
 setQuestiontext ($questiontext="")
 Sets the questiontext of the SurveyQuestion object. More...
 
 setOwner ($owner="")
 Sets the creator/owner ID of the SurveyQuestion object. More...
 
 getTitle ()
 Gets the title string of the SurveyQuestion object. More...
 
 getLabel ()
 
 getId ()
 Gets the id of the SurveyQuestion object. More...
 
 getObligatory ($survey_id="")
 Gets the obligatory state of the question. More...
 
 getSurveyId ()
 Gets the survey id of the SurveyQuestion object. More...
 
 getOrientation ()
 Gets the orientation of the question output. More...
 
 getDescription ()
 Gets the description string of the SurveyQuestion object. More...
 
 getAuthor ()
 Gets the authors name of the SurveyQuestion object. More...
 
 getOwner ()
 Gets the creator/owner ID of the SurveyQuestion object. More...
 
 getQuestiontext ()
 Gets the questiontext of the SurveyQuestion object. More...
 
 getObjId ()
 Get the reference id of the container object. More...
 
 setObjId ($obj_id=0)
 Set the reference id of the container object. More...
 
 duplicate ($for_survey=true, $title="", $author="", $owner="", $a_survey_id=0)
 Duplicates a survey question. More...
 
 copyObject ($target_questionpool, $title="")
 Copies an assOrderingQuestion object. More...
 
 copyXHTMLMediaObjectsOfQuestion ($a_q_id)
 Increases the media object usage counter when a question is duplicated. More...
 
 loadFromDb ($question_id)
 Loads a SurveyQuestion object from the database. More...
 
 saveCompletionStatus ($original_id="")
 Saves the complete flag to the database. More...
 
 saveToDb ($original_id="")
 Saves a SurveyQuestion object to a database. More...
 
 saveMaterial ()
 save material to db More...
 
 createNewQuestion ()
 Creates a new question with a 0 timestamp when a new question is created This assures that an ID is given to the question if a file upload or something else occurs. More...
 
 saveWorkingData ($limit_to=LIMIT_NO_LIMIT)
 Saves the learners input of the question to the database. More...
 
 getImagePath ()
 Returns the image path for web accessable images of a question. More...
 
 getMaterialsPath ()
 Returns the materials path for web accessable materials of a question. More...
 
 getImagePathWeb ()
 Returns the web image path for web accessable images of a question. More...
 
 getMaterialsPathWeb ()
 Returns the web image path for web accessable images of a question. More...
 
 saveCategoryToDb ($categorytext, $neutral=0)
 Saves a category to the database. More...
 
 deleteAdditionalTableData ($question_id)
 Deletes datasets from the additional question table in the database. More...
 
 delete ($question_id)
 Deletes a question and all materials from the database. More...
 
 syncWithOriginal ()
 
 getPhrase ($phrase_id)
 Returns a phrase for a given database id. More...
 
 phraseExists ($title)
 Returns true if the phrase title already exists for the current user. More...
 
 addInternalLink ($material_id, $title="")
 
 deleteMaterials ($a_array)
 Deletes materials. More...
 
 duplicateMaterials ($question_id)
 Duplicates the materials of a question. More...
 
 addMaterial ($obj_material)
 
 setMaterial ($material_id="", $is_import=false, $material_title="")
 Sets a material link for the question. More...
 
 getQuestionTypeID ()
 Returns the question type ID of the question. More...
 
 getQuestionType ()
 Returns the question type of the question. More...
 
 isHTML ($a_text)
 Checks if a given string contains HTML or not. More...
 
 QTIMaterialToString ($a_material)
 Reads an QTI material tag an creates a text string. More...
 
 addMaterialTag (&$a_xml_writer, $a_material, $close_material_tag=TRUE, $add_mobs=TRUE, $a_attrs=null)
 Creates an XML material tag from a plain text or xhtml text. More...
 
 prepareTextareaOutput ($txt_output, $prepare_for_latex_output=FALSE)
 Prepares a string for a text area output in surveys. More...
 
 getQuestionDataArray ($id)
 Returns the question data fields from the database. More...
 
getWorkingDataFromUserInput ($post_data)
 Creates the user data of the svy_answer table from the POST data. More...
 
 importAdditionalMetadata ($a_meta)
 Import additional meta data from the question import file. More...
 
 importResponses ($a_data)
 Import response data from the question import file. More...
 
 importAdjectives ($a_data)
 Import bipolar adjectives from the question import file. More...
 
 importMatrix ($a_data)
 Import matrix rows from the question import file. More...
 
 usableForPrecondition ()
 Returns if the question is usable for preconditions. More...
 
 getAvailableRelations ()
 Returns the available relations for the question. More...
 
 getPreconditionOptions ()
 Returns the options for preconditions. More...
 
 getPreconditionValueOutput ($value)
 Returns the output for a precondition value. More...
 
 getPreconditionSelectValue ($default="", $title, $variable)
 Creates a form property for the precondition value. More...
 
 setOriginalId ($original_id)
 
 getOriginalId ()
 
 getMaterial ()
 
 setSubtype ($a_subtype)
 
 getSubtype ()
 
 __get ($value)
 Object getter. More...
 
 __set ($key, $value)
 Object setter. More...
 
 getCopyIds ($a_group_by_survey=false)
 
 hasCopies ()
 
 stripSlashesAddSpaceFallback ($a_str)
 Strip slashes with add space fallback, see https://mantis.ilias.de/view.php?id=19727 and https://mantis.ilias.de/view.php?id=24200. More...
 

Static Public Member Functions

static _isComplete ($question_id)
 Checks whether the question is complete or not. More...
 
static _getQuestionType ($question_id)
 Returns the question type of a question with a given id. More...
 
static _getTitle ($question_id)
 Returns the question title of a question with a given id. More...
 
static _getOriginalId ($question_id, $a_return_question_id_if_no_original=true)
 Returns the original id of a question. More...
 
static _questionExists ($question_id)
 Returns true if the question already exists in the database. More...
 
static _resolveInternalLink ($internal_link)
 
static _resolveIntLinks ($question_id)
 
static _getInternalLinkHref ($target="", $a_parent_ref_id=null)
 
static _isWriteable ($question_id, $user_id)
 Returns true if the question is writeable by a certain user. More...
 
static _includeClass ($question_type, $gui=0)
 Include the php class file for a given question type. More...
 
static _getQuestionTypeName ($type_tag)
 Return the translation for a given question type tag. More...
 
static _instanciateQuestion ($question_id)
 Creates an instance of a question with a given question id. More...
 
static _instanciateQuestionGUI ($question_id)
 Creates an instance of a question GUI with a given question id. More...
 
static _instanciateQuestionEvaluation ($question_id, array $a_finished_ids=null)
 Creates an instance of a question evaluation with a given question id. More...
 
static _changeOriginalId ($a_question_id, $a_original_id, $a_object_id)
 Change original id of existing question in db. More...
 
static _lookupSurveyObjId ($a_question_id)
 
static lookupObjFi ($a_qid)
 Lookip obj fi. More...
 

Data Fields

 $id
 
 $title
 
 $description
 
 $owner
 
 $author
 
 $materials
 
 $survey_id
 
 $obj_id
 
 $questiontext
 
 $obligatory
 
 $ilias
 
 $tpl
 
 $lng
 
 $orientation
 
 $material
 
 $complete
 

Protected Attributes

 $cumulated
 An array containing the cumulated results of the question for a given survey. More...
 
 $log
 

Private Attributes

 $arrData
 data array containing the question data More...
 

Detailed Description

Basic class for all survey question types.

The SurveyQuestion class defines and encapsulates basic methods and attributes for survey question types to be used for all parent classes.

Author
Helmut Schottmüller helmu.nosp@m.t.sc.nosp@m.hottm.nosp@m.uell.nosp@m.er@ma.nosp@m.c.co.nosp@m.m
Version
$Id$

Definition at line 34 of file class.SurveyQuestion.php.

Constructor & Destructor Documentation

◆ __construct()

SurveyQuestion::__construct (   $title = "",
  $description = "",
  $author = "",
  $questiontext = "",
  $owner = -1 
)

SurveyQuestion constructor The constructor takes possible arguments an creates an instance of the SurveyQuestion object.

Parameters
string$titleA title string to describe the question
string$descriptionA description string to describe the question
string$authorA string containing the name of the questions author
integer$ownerA numerical ID to identify the owner/creator @access public

Reimplemented in SurveyMatrixQuestion, and SurveyTextQuestion.

Definition at line 162 of file class.SurveyQuestion.php.

163 {
164 global $ilias, $lng, $tpl;
165
166 $this->ilias = $ilias;
167 $this->lng = $lng;
168 $this->tpl = $tpl;
169 $this->complete = 0;
170 $this->title = $title;
171 $this->description = $description;
172 $this->questiontext = $questiontext;
173 $this->author = $author;
174 $this->cumulated = array();
175 if (!$this->author)
176 {
177 $this->author = $this->ilias->account->fullname;
178 }
179 $this->owner = $owner;
180 if ($this->owner == -1)
181 {
182 $this->owner = $this->ilias->account->id;
183 }
184 $this->id = -1;
185 $this->survey_id = -1;
186 $this->obligatory = 1;
187 $this->orientation = 0;
188 $this->materials = array();
189 $this->material = array();
190 $this->arrData = array();
191
192 $this->log = ilLoggerFactory::getLogger('svy');
193 }
static getLogger($a_component_id)
Get component logger.
redirection script todo: (a better solution should control the processing via a xml file)

References $author, $description, $ilias, $lng, $owner, $questiontext, $title, $tpl, and ilLoggerFactory\getLogger().

+ Here is the call graph for this function:

Member Function Documentation

◆ __get()

SurveyQuestion::__get (   $value)

Object getter.

Definition at line 2085 of file class.SurveyQuestion.php.

2086 {
2087 switch ($value)
2088 {
2089 default:
2090 if (array_key_exists($value, $this->arrData))
2091 {
2092 return $this->arrData[$value];
2093 }
2094 else
2095 {
2096 return null;
2097 }
2098 break;
2099 }
2100 }

◆ __set()

SurveyQuestion::__set (   $key,
  $value 
)

Object setter.

Definition at line 2105 of file class.SurveyQuestion.php.

2106 {
2107 switch ($key)
2108 {
2109 default:
2110 $this->arrData[$key] = $value;
2111 break;
2112 }
2113 }

◆ _changeOriginalId()

static SurveyQuestion::_changeOriginalId (   $a_question_id,
  $a_original_id,
  $a_object_id 
)
static

Change original id of existing question in db.

Parameters
int$a_question_id
int$a_original_id
int$a_object_id

Definition at line 2122 of file class.SurveyQuestion.php.

2123 {
2124 global $ilDB;
2125
2126 $ilDB->manipulate("UPDATE svy_question".
2127 " SET original_id = ".$ilDB->quote($a_original_id, "integer").",".
2128 " obj_fi = ".$ilDB->quote($a_object_id, "integer").
2129 " WHERE question_id = ".$ilDB->quote($a_question_id, "integer"));
2130 }
global $ilDB

References $ilDB.

Referenced by ilSurveyEditorGUI\executeCopyQuestionsToPoolObject().

+ Here is the caller graph for this function:

◆ _getInternalLinkHref()

static SurveyQuestion::_getInternalLinkHref (   $target = "",
  $a_parent_ref_id = null 
)
static

Definition at line 1590 of file class.SurveyQuestion.php.

1591 {
1592 global $ilDB;
1593 $linktypes = array(
1594 "lm" => "LearningModule",
1595 "pg" => "PageObject",
1596 "st" => "StructureObject",
1597 "git" => "GlossaryItem",
1598 "mob" => "MediaObject"
1599 );
1600 $href = "";
1601 if (preg_match("/il__(\w+)_(\d+)/", $target, $matches))
1602 {
1603 $type = $matches[1];
1604 $target_id = $matches[2];
1605 switch($linktypes[$matches[1]])
1606 {
1607 case "LearningModule":
1608 $href = ilUtil::removeTrailingPathSeparators(ILIAS_HTTP_PATH) ."/goto.php?target=" . $type . "_" . $target_id;
1609 break;
1610 case "PageObject":
1611 case "StructureObject":
1612 $href = ilUtil::removeTrailingPathSeparators(ILIAS_HTTP_PATH) ."/goto.php?target=" . $type . "_" . $target_id;
1613 break;
1614 case "GlossaryItem":
1615 $href = ilUtil::removeTrailingPathSeparators(ILIAS_HTTP_PATH) ."/goto.php?target=" . $type . "_" . $target_id;
1616 break;
1617 case "MediaObject":
1618 $href = ilUtil::removeTrailingPathSeparators(ILIAS_HTTP_PATH) . "/ilias.php?baseClass=ilLMPresentationGUI&obj_type=" . $linktypes[$type] . "&cmd=media&ref_id=".$a_parent_ref_id."&mob_id=".$target_id;
1619 break;
1620 }
1621 }
1622 return $href;
1623 }
static removeTrailingPathSeparators($path)
$target_id
Definition: goto.php:51

References $ilDB, $target, $target_id, and ilUtil\removeTrailingPathSeparators().

Referenced by SurveyQuestionGUI\getMaterialOutput(), and SurveyQuestionGUI\material().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _getOriginalId()

static SurveyQuestion::_getOriginalId (   $question_id,
  $a_return_question_id_if_no_original = true 
)
static

Returns the original id of a question.

Parameters
integer$question_idThe database id of the question
Returns
integer The database id of the original question @access public

Definition at line 1202 of file class.SurveyQuestion.php.

1203 {
1204 global $ilDB;
1205 $result = $ilDB->queryF("SELECT * FROM svy_question WHERE question_id = %s",
1206 array('integer'),
1207 array($question_id)
1208 );
1209 if ($result->numRows() > 0)
1210 {
1211 $row = $ilDB->fetchAssoc($result);
1212 if ($row["original_id"] > 0)
1213 {
1214 return $row["original_id"];
1215 }
1216 else if((bool)$a_return_question_id_if_no_original) // #12419
1217 {
1218 return $row["question_id"];
1219 }
1220 }
1221 else
1222 {
1223 return "";
1224 }
1225 }
$result

References $ilDB, $result, and $row.

Referenced by ilObjSurvey\cloneObject(), and copyObject().

+ Here is the caller graph for this function:

◆ _getQuestionType()

static SurveyQuestion::_getQuestionType (   $question_id)
static

Returns the question type of a question with a given id.

Parameters
integer$question_idThe database id of the question
Returns
string The question type string @access private

Definition at line 1146 of file class.SurveyQuestion.php.

1147 {
1148 global $ilDB;
1149
1150 if ($question_id < 1) return "";
1151
1152 $result = $ilDB->queryF("SELECT type_tag FROM svy_question, svy_qtype WHERE svy_question.question_id = %s AND svy_question.questiontype_fi = svy_qtype.questiontype_id",
1153 array('integer'),
1154 array($question_id)
1155 );
1156 if ($result->numRows() == 1)
1157 {
1158 $data = $ilDB->fetchAssoc($result);
1159 return $data["type_tag"];
1160 }
1161 else
1162 {
1163 return "";
1164 }
1165 }

References $data, $ilDB, and $result.

Referenced by ilObjSurvey\_instanciateQuestion(), _instanciateQuestion(), _instanciateQuestionEvaluation(), _instanciateQuestionGUI(), ilObjSurveyGUI\addLocatorItems(), ilObjSurveyQuestionPoolGUI\addLocatorItems(), ilSurveyConstraintsGUI\confirmDeleteConstraintsObject(), ilObjSurvey\getConstraints(), and ilObjSurvey\getUserSpecificResults().

+ Here is the caller graph for this function:

◆ _getQuestionTypeName()

static SurveyQuestion::_getQuestionTypeName (   $type_tag)
static

Return the translation for a given question type tag.

Parameters
string$type_tagThe type tag of the question type @access public

Definition at line 1734 of file class.SurveyQuestion.php.

1735 {
1736 if (file_exists("./Modules/SurveyQuestionPool/classes/class.".$type_tag.".php"))
1737 {
1738 global $lng;
1739 return $lng->txt($type_tag);
1740 }
1741 else
1742 {
1743 global $ilPluginAdmin;
1744 $pl_names = $ilPluginAdmin->getActivePluginsForSlot(IL_COMP_MODULE, "SurveyQuestionPool", "svyq");
1745 foreach ($pl_names as $pl_name)
1746 {
1747 $pl = ilPlugin::getPluginObject(IL_COMP_MODULE, "SurveyQuestionPool", "svyq", $pl_name);
1748 if (strcmp($pl->getQuestionType(), $type_tag) == 0)
1749 {
1750 return $pl->getQuestionTypeTranslation();
1751 }
1752 }
1753 }
1754 return "";
1755 }
const IL_COMP_MODULE
static getPluginObject($a_ctype, $a_cname, $a_slot_id, $a_pname)
Get plugin object.

References $lng, ilPlugin\getPluginObject(), and IL_COMP_MODULE.

Referenced by ilSurveyConstraintsGUI\constraintForm(), ilObjSurveyQuestionPoolGUI\deleteQuestionsObject(), SurveyMatrixQuestionEvaluation\exportResults(), SurveyQuestionEvaluation\exportResults(), ilSurveyEvaluationGUI\exportResultsDetailsExcel(), ilSurveyQuestionsTableGUI\fillRow(), ilSurveyResultsCumulatedTableGUI\getItems(), ilSurveyEditorGUI\removeQuestionsForm(), and ilSurveyEvaluationGUI\renderDetails().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _getTitle()

static SurveyQuestion::_getTitle (   $question_id)
static

Returns the question title of a question with a given id.

Parameters
integer$question_idThe database id of the question
Returns
string The question title @access private

Definition at line 1174 of file class.SurveyQuestion.php.

1175 {
1176 global $ilDB;
1177
1178 if ($question_id < 1) return "";
1179
1180 $result = $ilDB->queryF("SELECT title FROM svy_question WHERE svy_question.question_id = %s",
1181 array('integer'),
1182 array($question_id)
1183 );
1184 if ($result->numRows() == 1)
1185 {
1186 $data = $ilDB->fetchAssoc($result);
1187 return $data["title"];
1188 }
1189 else
1190 {
1191 return "";
1192 }
1193 }

References $data, $ilDB, and $result.

Referenced by ilObjSurveyGUI\addLocatorItems(), ilObjSurveyQuestionPoolGUI\addLocatorItems(), ilTermUsagesTableGUI\fillRow(), and ilSurveySyncTableGUI\importData().

+ Here is the caller graph for this function:

◆ _includeClass()

static SurveyQuestion::_includeClass (   $question_type,
  $gui = 0 
)
static

Include the php class file for a given question type.

Parameters
string$question_typeThe type tag of the question type
Returns
integer 0 if the class should be included, 1 if the GUI class should be included @access public

Definition at line 1701 of file class.SurveyQuestion.php.

1702 {
1703 $type = $question_type;
1704 if ($gui == 1) $type .= "GUI";
1705 else if ($gui == 2) $type .= "Evaluation";
1706 if (file_exists("./Modules/SurveyQuestionPool/classes/class.".$type.".php"))
1707 {
1708 include_once "./Modules/SurveyQuestionPool/classes/class.".$type.".php";
1709 return true;
1710 }
1711 else
1712 {
1713 global $ilPluginAdmin;
1714 $pl_names = $ilPluginAdmin->getActivePluginsForSlot(IL_COMP_MODULE, "SurveyQuestionPool", "svyq");
1715 foreach ($pl_names as $pl_name)
1716 {
1717 $pl = ilPlugin::getPluginObject(IL_COMP_MODULE, "SurveyQuestionPool", "svyq", $pl_name);
1718 if (strcmp($pl->getQuestionType(), $question_type) == 0)
1719 {
1720 $pl->includeClass("class.".$type.".php");
1721 return true;
1722 }
1723 }
1724 }
1725 return false;
1726 }

References ilPlugin\getPluginObject(), and IL_COMP_MODULE.

Referenced by SurveyQuestionGUI\_getQuestionGUI(), ilObjSurvey\_instanciateQuestion(), _instanciateQuestion(), _instanciateQuestionEvaluation(), _instanciateQuestionGUI(), ilSurveyConstraintsGUI\confirmDeleteConstraintsObject(), ilSurveyConstraintsGUI\constraintForm(), ilObjSurvey\getConstraints(), ilObjSurvey\getUserSpecificResults(), SurveyImportParser\handlerBeginTag(), and ilObjSurveyQuestionPool\toXML().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _instanciateQuestion()

static SurveyQuestion::_instanciateQuestion (   $question_id)
static

Creates an instance of a question with a given question id.

Parameters
integer$question_idThe question id
Returns
object The question instance @access public

Definition at line 1765 of file class.SurveyQuestion.php.

1766 {
1767 $question_type = self::_getQuestionType($question_id);
1768 if($question_type)
1769 {
1770 self::_includeClass($question_type);
1771 $question = new $question_type();
1772 $question->loadFromDb($question_id);
1773 return $question;
1774 }
1775 }
static _getQuestionType($question_id)
Returns the question type of a question with a given id.
static _includeClass($question_type, $gui=0)
Include the php class file for a given question type.

References _getQuestionType(), and _includeClass().

Referenced by _instanciateQuestionEvaluation(), ilSurveySkill\determineMaxScale(), ilObjSurveyQuestionPool\duplicateQuestion(), ilObjMediaObject\getParentObjectIdForUsage(), ilObjSurvey\importObject(), ilSurveyImporter\importXmlRepresentation(), ilObjSurveyQuestionPool\removeQuestion(), and ilSurveyExecutionGUI\saveActiveQuestionData().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _instanciateQuestionEvaluation()

static SurveyQuestion::_instanciateQuestionEvaluation (   $question_id,
array  $a_finished_ids = null 
)
static

Creates an instance of a question evaluation with a given question id.

Parameters
integer$question_idThe question id
Returns
object The question evaluation instance @access public

Definition at line 1803 of file class.SurveyQuestion.php.

1804 {
1805 $question = self::_instanciateQuestion($question_id);
1806 if($question)
1807 {
1808 $question_type = self::_getQuestionType($question_id);
1809 self::_includeClass($question_type, 2);
1810 $class = $question_type . "Evaluation";
1811 $ev = new $class($question, $a_finished_ids);
1812 return $ev;
1813 }
1814 }
static _instanciateQuestion($question_id)
Creates an instance of a question with a given question id.

References _getQuestionType(), _includeClass(), and _instanciateQuestion().

Referenced by ilSurveyEvaluationGUI\evaluation(), ilSurveyEvaluationGUI\exportCumulatedResults(), ilSurveyEvaluationGUI\exportEvaluationUser(), ilObjSurvey\getUserSpecificResults(), and ilSurveyEvaluationGUI\parseUserSpecificResults().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _instanciateQuestionGUI()

static SurveyQuestion::_instanciateQuestionGUI (   $question_id)
static

Creates an instance of a question GUI with a given question id.

Parameters
integer$question_idThe question id
Returns
object The question GUI instance @access public

Definition at line 1784 of file class.SurveyQuestion.php.

1785 {
1786 $question_type = self::_getQuestionType($question_id);
1787 if($question_type)
1788 {
1789 self::_includeClass($question_type, 1);
1790 $guitype = $question_type . "GUI";
1791 $question = new $guitype($question_id);
1792 return $question;
1793 }
1794 }

References _getQuestionType(), and _includeClass().

+ Here is the call graph for this function:

◆ _isComplete()

static SurveyQuestion::_isComplete (   $question_id)
static

Checks whether the question is complete or not.

Returns
boolean TRUE if the question is complete, FALSE otherwise @access public

Definition at line 715 of file class.SurveyQuestion.php.

716 {
717 global $ilDB;
718
719 $result = $ilDB->queryF("SELECT complete FROM svy_question WHERE question_id = %s",
720 array('integer'),
721 array($question_id)
722 );
723 if ($result->numRows())
724 {
725 $row = $ilDB->fetchAssoc($result);
726 if ($row["complete"] == 1)
727 {
728 return TRUE;
729 }
730 }
731 return FALSE;
732 }

References $ilDB, $result, and $row.

Referenced by ilSurveyPageGUI\insertNewQuestion(), ilObjSurvey\insertQuestion(), and SurveyQuestionGUI\save().

+ Here is the caller graph for this function:

◆ _isWriteable()

static SurveyQuestion::_isWriteable (   $question_id,
  $user_id 
)
static

Returns true if the question is writeable by a certain user.

Parameters
integer$question_idThe database id of the question
integer$user_idThe database id of the user
Returns
boolean True, if the question exists, otherwise False @access public

Definition at line 1633 of file class.SurveyQuestion.php.

1634 {
1635 global $ilDB;
1636
1637 if (($question_id < 1) || ($user_id < 1))
1638 {
1639 return false;
1640 }
1641
1642 $result = $ilDB->queryF("SELECT obj_fi FROM svy_question WHERE question_id = %s",
1643 array('integer'),
1644 array($question_id)
1645 );
1646 if ($result->numRows() == 1)
1647 {
1648 $row = $ilDB->fetchAssoc($result);
1649 $qpl_object_id = $row["obj_fi"];
1650 include_once "./Modules/SurveyQuestionPool/classes/class.ilObjSurveyQuestionPool.php";
1651 return ilObjSurveyQuestionPool::_isWriteable($qpl_object_id, $user_id);
1652 }
1653 else
1654 {
1655 return false;
1656 }
1657 }
static _isWriteable($object_id, $user_id)
Returns true, if the question pool is writeable by a given user.

References $ilDB, $result, $row, and ilObjSurveyQuestionPool\_isWriteable().

Referenced by SurveyQuestionGUI\save().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _lookupSurveyObjId()

static SurveyQuestion::_lookupSurveyObjId (   $a_question_id)
static

Definition at line 2161 of file class.SurveyQuestion.php.

2162 {
2163 global $ilDB;
2164
2165 $set = $ilDB->query("SELECT svy_svy.obj_fi FROM svy_svy_qst".
2166 " JOIN svy_svy ON (svy_svy.survey_id = svy_svy_qst.survey_fi)".
2167 " WHERE svy_svy_qst.question_fi = ".$ilDB->quote($a_question_id, "integer"));
2168 $row = $ilDB->fetchAssoc($set);
2169 if($ilDB->numRows($set))
2170 {
2171 return $row["obj_fi"];
2172 }
2173 }

References $ilDB, and $row.

Referenced by ilObjMediaObject\getParentObjectIdForUsage().

+ Here is the caller graph for this function:

◆ _questionExists()

static SurveyQuestion::_questionExists (   $question_id)
static

Returns true if the question already exists in the database.

Parameters
integer$question_idThe database id of the question
Returns
boolean True, if the question exists, otherwise False @access public

Definition at line 1315 of file class.SurveyQuestion.php.

1316 {
1317 global $ilDB;
1318
1319 if ($question_id < 1)
1320 {
1321 return false;
1322 }
1323
1324 $result = $ilDB->queryF("SELECT question_id FROM svy_question WHERE question_id = %s",
1325 array('integer'),
1326 array($question_id)
1327 );
1328 return ($result->numRows() == 1) ? true : false;
1329 }

References $ilDB, and $result.

Referenced by ilSurveySkill\read(), and SurveyQuestionGUI\save().

+ Here is the caller graph for this function:

◆ _resolveInternalLink()

static SurveyQuestion::_resolveInternalLink (   $internal_link)
static

Definition at line 1502 of file class.SurveyQuestion.php.

1503 {
1504 if (preg_match("/il_(\d+)_(\w+)_(\d+)/", $internal_link, $matches))
1505 {
1506 include_once "./Services/Link/classes/class.ilInternalLink.php";
1507 include_once "./Modules/LearningModule/classes/class.ilLMObject.php";
1508 include_once "./Modules/Glossary/classes/class.ilGlossaryTerm.php";
1509 switch ($matches[2])
1510 {
1511 case "lm":
1512 $resolved_link = ilLMObject::_getIdForImportId($internal_link);
1513 break;
1514 case "pg":
1515 $resolved_link = ilInternalLink::_getIdForImportId("PageObject", $internal_link);
1516 break;
1517 case "st":
1518 $resolved_link = ilInternalLink::_getIdForImportId("StructureObject", $internal_link);
1519 break;
1520 case "git":
1521 $resolved_link = ilInternalLink::_getIdForImportId("GlossaryItem", $internal_link);
1522 break;
1523 case "mob":
1524 $resolved_link = ilInternalLink::_getIdForImportId("MediaObject", $internal_link);
1525 break;
1526 }
1527 if (strcmp($resolved_link, "") == 0)
1528 {
1529 $resolved_link = $internal_link;
1530 }
1531 }
1532 else
1533 {
1534 $resolved_link = $internal_link;
1535 }
1536 return $resolved_link;
1537 }
static _getIdForImportId($a_import_id)
get current object id for import id (static)

References ilLMObject\_getIdForImportId(), and ilInternalLink\_getIdForImportId().

Referenced by _resolveIntLinks(), and setMaterial().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _resolveIntLinks()

static SurveyQuestion::_resolveIntLinks (   $question_id)
static

Definition at line 1539 of file class.SurveyQuestion.php.

1540 {
1541 global $ilDB;
1542 $resolvedlinks = 0;
1543 $result = $ilDB->queryF("SELECT * FROM svy_material WHERE question_fi = %s",
1544 array('integer'),
1545 array($question_id)
1546 );
1547 if ($result->numRows())
1548 {
1549 while ($row = $ilDB->fetchAssoc($result))
1550 {
1551 $internal_link = $row["internal_link"];
1552 include_once "./Modules/SurveyQuestionPool/classes/class.SurveyQuestion.php";
1553 $resolved_link = self::_resolveInternalLink($internal_link);
1554 if (strcmp($internal_link, $resolved_link) != 0)
1555 {
1556 // internal link was resolved successfully
1557 $affectedRows = $ilDB->manipulateF("UPDATE svy_material SET internal_link = %s, tstamp = %s WHERE material_id = %s",
1558 array('text', 'integer', 'integer'),
1559 array($resolved_link, time(), $row["material_id"])
1560 );
1561 $resolvedlinks++;
1562 }
1563 }
1564 }
1565 if ($resolvedlinks)
1566 {
1567 // there are resolved links -> reenter theses links to the database
1568
1569 // delete all internal links from the database
1570 include_once "./Services/Link/classes/class.ilInternalLink.php";
1571 ilInternalLink::_deleteAllLinksOfSource("sqst", $question_id);
1572
1573 $result = $ilDB->queryF("SELECT * FROM svy_material WHERE question_fi = %s",
1574 array('integer'),
1575 array($question_id)
1576 );
1577 if ($result->numRows())
1578 {
1579 while ($row = $ilDB->fetchAssoc($result))
1580 {
1581 if (preg_match("/il_(\d*?)_(\w+)_(\d+)/", $row["internal_link"], $matches))
1582 {
1583 ilInternalLink::_saveLink("sqst", $question_id, $matches[2], $matches[3], $matches[1]);
1584 }
1585 }
1586 }
1587 }
1588 }
static _resolveInternalLink($internal_link)

References $ilDB, $result, $row, ilInternalLink\_deleteAllLinksOfSource(), _resolveInternalLink(), and ilInternalLink\_saveLink().

Referenced by ilContObjParser\processPagesToParse().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ addInternalLink()

SurveyQuestion::addInternalLink (   $material_id,
  $title = "" 
)

Definition at line 1331 of file class.SurveyQuestion.php.

1332 {
1333 if (strlen($material_id))
1334 {
1335 if (strcmp($material_title, "") == 0)
1336 {
1337 if (preg_match("/il__(\w+)_(\d+)/", $material_id, $matches))
1338 {
1339 $type = $matches[1];
1340 $target_id = $matches[2];
1341 $material_title = $this->lng->txt("obj_$type") . ": ";
1342 switch ($type)
1343 {
1344 case "lm":
1345 include_once("./Modules/LearningModule/classes/class.ilObjContentObjectGUI.php");
1346 $cont_obj_gui = new ilObjContentObjectGUI("", $target_id, true);
1347 $cont_obj = $cont_obj_gui->object;
1348 $material_title .= $cont_obj->getTitle();
1349 break;
1350 case "pg":
1351 include_once("./Modules/LearningModule/classes/class.ilLMPageObject.php");
1352 include_once("./Modules/LearningModule/classes/class.ilLMObject.php");
1354 include_once("./Modules/LearningModule/classes/class.ilObjContentObjectGUI.php");
1355 $cont_obj_gui = new ilObjContentObjectGUI("", $lm_id, FALSE);
1356 $cont_obj = $cont_obj_gui->object;
1357 $pg_obj = new ilLMPageObject($cont_obj, $target_id);
1358 $material_title .= $pg_obj->getTitle();
1359 break;
1360 case "st":
1361 include_once("./Modules/LearningModule/classes/class.ilStructureObject.php");
1362 include_once("./Modules/LearningModule/classes/class.ilLMObject.php");
1364 include_once("./Modules/LearningModule/classes/class.ilObjContentObjectGUI.php");
1365 $cont_obj_gui = new ilObjContentObjectGUI("", $lm_id, FALSE);
1366 $cont_obj = $cont_obj_gui->object;
1367 $st_obj = new ilStructureObject($cont_obj, $target_id);
1368 $material_title .= $st_obj->getTitle();
1369 break;
1370 case "git":
1371 include_once "./Modules/Glossary/classes/class.ilGlossaryTerm.php";
1372 $material_title = $this->lng->txt("glossary_term") . ": " . ilGlossaryTerm::_lookGlossaryTerm($target_id);
1373 break;
1374 case "mob":
1375 break;
1376 }
1377 }
1378 }
1379 include_once "./Modules/SurveyQuestionPool/classes/class.ilSurveyMaterial.php";
1380 $mat = new ilSurveyMaterial();
1381 $mat->type = 0;
1382 $mat->internal_link = $material_id;
1383 $mat->title = $material_title;
1384 $this->addMaterial($mat);
1385 $this->saveMaterial();
1386 }
1387 }
addMaterial($obj_material)
saveMaterial()
save material to db
static _lookGlossaryTerm($term_id)
get glossary term
static _lookupContObjID($a_id)
get learning module / digibook id for lm object
Class ilLMPageObject.
Class ilObjContentObjectGUI.
Class ilStructreObject.
Survey material class.

References $target_id, ilGlossaryTerm\_lookGlossaryTerm(), ilLMObject\_lookupContObjID(), addMaterial(), and saveMaterial().

+ Here is the call graph for this function:

◆ addMaterial()

SurveyQuestion::addMaterial (   $obj_material)

Definition at line 1427 of file class.SurveyQuestion.php.

1428 {
1429 array_push($this->material, $obj_material);
1430 }

Referenced by addInternalLink().

+ Here is the caller graph for this function:

◆ addMaterials()

SurveyQuestion::addMaterials (   $materials_file,
  $materials_name = "" 
)

Sets the materials uri.

Parameters
string$materials_fileAn uri to additional materials
string$materials_nameAn uri name to additional materials @access public
See also
$materials

Definition at line 323 of file class.SurveyQuestion.php.

324 {
325 if (empty($materials_name))
326 {
327 $materials_name = $materials_file;
328 }
329 if ((!empty($materials_name))&&(!array_key_exists($materials_name, $this->materials)))
330 {
331 $this->materials[$materials_name] = $materials_file;
332 }
333 }

Referenced by setMaterialsfile().

+ Here is the caller graph for this function:

◆ addMaterialTag()

SurveyQuestion::addMaterialTag ( $a_xml_writer,
  $a_material,
  $close_material_tag = TRUE,
  $add_mobs = TRUE,
  $a_attrs = null 
)

Creates an XML material tag from a plain text or xhtml text.

Parameters
object$a_xml_writerReference to the ILIAS XML writer
string$a_materialplain text or html text containing the material
Returns
string XML material tag @access public

Definition at line 1878 of file class.SurveyQuestion.php.

1879 {
1880 include_once "./Services/RTE/classes/class.ilRTE.php";
1881 include_once("./Services/MediaObjects/classes/class.ilObjMediaObject.php");
1882
1883 $a_xml_writer->xmlStartTag("material");
1884 $attrs = array(
1885 "type" => "text/plain"
1886 );
1887 if ($this->isHTML($a_material))
1888 {
1889 $attrs["type"] = "text/xhtml";
1890 }
1891 if (is_array($a_attrs))
1892 {
1893 $attrs = array_merge($attrs, $a_attrs);
1894 }
1895 $a_xml_writer->xmlElement("mattext", $attrs, ilRTE::_replaceMediaObjectImageSrc($a_material, 0));
1896
1897 if ($add_mobs)
1898 {
1899 $mobs = ilObjMediaObject::_getMobsOfObject("spl:html", $this->getId());
1900 foreach ($mobs as $mob)
1901 {
1902 $mob_obj = new ilObjMediaObject($mob);
1903 $imgattrs = array(
1904 "label" => "il_" . IL_INST_ID . "_mob_" . $mob,
1905 "uri" => "objects/" . "il_" . IL_INST_ID . "_mob_" . $mob . "/" . $mob_obj->getTitle(),
1906 "type" => "spl:html",
1907 "id" => $this->getId()
1908 );
1909 $a_xml_writer->xmlElement("matimage", $imgattrs, NULL);
1910 }
1911 }
1912 if ($close_material_tag) $a_xml_writer->xmlEndTag("material");
1913 }
getId()
Gets the id of the SurveyQuestion object.
isHTML($a_text)
Checks if a given string contains HTML or not.
Class ilObjMediaObject.
static _getMobsOfObject($a_type, $a_id, $a_usage_hist_nr=0, $a_lang="-")
get mobs of object
static _replaceMediaObjectImageSrc($a_text, $a_direction=0, $nic=IL_INST_ID)
Replaces image source from mob image urls with the mob id or replaces mob id with the correct image s...
$mobs

References $mobs, ilObjMediaObject\_getMobsOfObject(), ilRTE\_replaceMediaObjectImageSrc(), getId(), and isHTML().

Referenced by SurveyMatrixQuestion\insertXML(), SurveyMetricQuestion\insertXML(), SurveyMultipleChoiceQuestion\insertXML(), SurveySingleChoiceQuestion\insertXML(), and SurveyTextQuestion\insertXML().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ copyObject()

SurveyQuestion::copyObject (   $target_questionpool,
  $title = "" 
)

Copies an assOrderingQuestion object.

@access public

Definition at line 634 of file class.SurveyQuestion.php.

635 {
636 if ($this->getId() <= 0)
637 {
638 // The question has not been saved. It cannot be copied
639 return;
640 }
641 $clone = $this;
642 $original_id = self::_getOriginalId($this->getId(), false);
643 $clone->setId(-1);
644 $source_questionpool = $this->getObjId();
645 $clone->setObjId($target_questionpool);
646 if ($title)
647 {
648 $clone->setTitle($title);
649 }
650
651 $clone->saveToDb();
652
653 // duplicate the materials
654 $clone->duplicateMaterials($original_id);
655 // copy XHTML media objects
656 $clone->copyXHTMLMediaObjectsOfQuestion($original_id);
657 return $clone->getId();
658 }
getObjId()
Get the reference id of the container object.
static _getOriginalId($question_id, $a_return_question_id_if_no_original=true)
Returns the original id of a question.

References $title, _getOriginalId(), getId(), and getObjId().

+ Here is the call graph for this function:

◆ copyXHTMLMediaObjectsOfQuestion()

SurveyQuestion::copyXHTMLMediaObjectsOfQuestion (   $a_q_id)

Increases the media object usage counter when a question is duplicated.

Parameters
integer$a_q_idThe question id of the original question @access public

Definition at line 666 of file class.SurveyQuestion.php.

667 {
668 include_once("./Services/MediaObjects/classes/class.ilObjMediaObject.php");
669 $mobs = ilObjMediaObject::_getMobsOfObject("spl:html", $a_q_id);
670 foreach ($mobs as $mob)
671 {
672 ilObjMediaObject::_saveUsage($mob, "spl:html", $this->getId());
673 }
674 }
static _saveUsage($a_mob_id, $a_type, $a_id, $a_usage_hist_nr=0, $a_lang="-")
Save usage of mob within another container (e.g.

References $mobs, ilObjMediaObject\_getMobsOfObject(), ilObjMediaObject\_saveUsage(), and getId().

+ Here is the call graph for this function:

◆ createNewQuestion()

SurveyQuestion::createNewQuestion ( )

Creates a new question with a 0 timestamp when a new question is created This assures that an ID is given to the question if a file upload or something else occurs.

Returns
integer ID of the new question

Definition at line 868 of file class.SurveyQuestion.php.

869 {
870 global $ilDB;
871
872 $obj_id = $this->getObjId();
873 if ($obj_id > 0)
874 {
875 $next_id = $ilDB->nextId('svy_question');
876 $affectedRows = $ilDB->manipulateF("INSERT INTO svy_question (question_id, questiontype_fi, " .
877 "obj_fi, owner_fi, title, description, author, questiontext, obligatory, complete, " .
878 "created, original_id, tstamp) VALUES " .
879 "(%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)",
880 array('integer', 'integer', 'integer', 'integer', 'text', 'text', 'text', 'text',
881 'text', 'text', 'integer', 'integer', 'integer'),
882 array(
883 $next_id,
884 $this->getQuestionTypeID(),
885 $obj_id,
886 $this->getOwner(),
887 NULL,
888 NULL,
889 $this->getAuthor(),
890 NULL,
891 "1",
892 "0",
893 time(),
894 NULL,
895 0
896 )
897 );
898 $this->log->debug("INSERT INTO svy_question question_id= ".$next_id." questiontype_fi= ".$this->getQuestionTypeID());
899
900 $this->setId($next_id);
901 }
902 return $this->getId();
903 }
setId($id=-1)
Sets the id of the SurveyQuestion object.
getOwner()
Gets the creator/owner ID of the SurveyQuestion object.
getQuestionTypeID()
Returns the question type ID of the question.
getAuthor()
Gets the authors name of the SurveyQuestion object.

References $ilDB, $obj_id, getAuthor(), getId(), getObjId(), getOwner(), getQuestionTypeID(), and setId().

+ Here is the call graph for this function:

◆ delete()

SurveyQuestion::delete (   $question_id)

Deletes a question and all materials from the database.

Parameters
integer$question_idThe database id of the question @access private

Definition at line 1034 of file class.SurveyQuestion.php.

1035 {
1036 global $ilDB;
1037
1038 if ($question_id < 1) return;
1039
1040 $result = $ilDB->queryF("SELECT obj_fi FROM svy_question WHERE question_id = %s",
1041 array('integer'),
1042 array($question_id)
1043 );
1044 if ($result->numRows() == 1)
1045 {
1046 $row = $ilDB->fetchAssoc($result);
1047 $obj_id = $row["obj_fi"];
1048 }
1049 else
1050 {
1051 return;
1052 }
1053
1054 $affectedRows = $ilDB->manipulateF("DELETE FROM svy_answer WHERE question_fi = %s",
1055 array('integer'),
1056 array($question_id)
1057 );
1058
1059 $affectedRows = $ilDB->manipulateF("DELETE FROM svy_constraint WHERE question_fi = %s",
1060 array('integer'),
1061 array($question_id)
1062 );
1063
1064 $result = $ilDB->queryF("SELECT constraint_fi FROM svy_qst_constraint WHERE question_fi = %s",
1065 array('integer'),
1066 array($question_id)
1067 );
1068 while ($row = $ilDB->fetchObject($result))
1069 {
1070 $affectedRows = $ilDB->manipulateF("DELETE FROM svy_constraint WHERE constraint_id = %s",
1071 array('integer'),
1072 array($row->constraint_fi)
1073 );
1074 }
1075
1076 $affectedRows = $ilDB->manipulateF("DELETE FROM svy_qst_constraint WHERE question_fi = %s",
1077 array('integer'),
1078 array($question_id)
1079 );
1080 $affectedRows = $ilDB->manipulateF("DELETE FROM svy_qblk_qst WHERE question_fi = %s",
1081 array('integer'),
1082 array($question_id)
1083 );
1084 $affectedRows = $ilDB->manipulateF("DELETE FROM svy_svy_qst WHERE question_fi = %s",
1085 array('integer'),
1086 array($question_id)
1087 );
1088 $affectedRows = $ilDB->manipulateF("DELETE FROM svy_variable WHERE question_fi = %s",
1089 array('integer'),
1090 array($question_id)
1091 );
1092 $affectedRows = $ilDB->manipulateF("DELETE FROM svy_question WHERE question_id = %s",
1093 array('integer'),
1094 array($question_id)
1095 );
1096
1097 $this->deleteAdditionalTableData($question_id);
1098
1099 $affectedRows = $ilDB->manipulateF("DELETE FROM svy_material WHERE question_fi = %s",
1100 array('integer'),
1101 array($question_id)
1102 );
1103
1104 $this->log->debug("SET OF DELETES svy_answer, svy_constraint, svy_qst_constraint, svy_qblk_qst, svy_qst_oblig, svy_svy_qst, svy_variable, svy_question, svy_material WHERE question_fi = ".$question_id);
1105
1106 include_once "./Services/Link/classes/class.ilInternalLink.php";
1107 ilInternalLink::_deleteAllLinksOfSource("sqst", $question_id);
1108
1109 $directory = CLIENT_WEB_DIR . "/survey/" . $obj_id . "/$question_id";
1110 if (preg_match("/\d+/", $obj_id) and preg_match("/\d+/", $question_id) and is_dir($directory))
1111 {
1112 ilUtil::delDir($directory);
1113 }
1114
1115 include_once("./Services/MediaObjects/classes/class.ilObjMediaObject.php");
1116 $mobs = ilObjMediaObject::_getMobsOfObject("spl:html", $question_id);
1117 // remaining usages are not in text anymore -> delete them
1118 // and media objects (note: delete method of ilObjMediaObject
1119 // checks whether object is used in another context; if yes,
1120 // the object is not deleted!)
1121 foreach($mobs as $mob)
1122 {
1123 ilObjMediaObject::_removeUsage($mob, "spl:html", $question_id);
1124 $mob_obj = new ilObjMediaObject($mob);
1125 $mob_obj->delete();
1126 }
1127
1128 include_once("./Modules/Survey/classes/class.ilSurveySkill.php");
1130
1131 $this->log->debug("UPDATE svy_question");
1132
1133 // #12772 - untie question copies from pool question
1134 $ilDB->manipulate("UPDATE svy_question".
1135 " SET original_id = NULL".
1136 " WHERE original_id = ".$ilDB->quote($question_id, "integer"));
1137 }
deleteAdditionalTableData($question_id)
Deletes datasets from the additional question table in the database.
static _removeUsage($a_mob_id, $a_type, $a_id, $a_usage_hist_nr=0, $a_lang="-")
Remove usage of mob in another container.
static handleQuestionDeletion($a_question_id, $a_obj_id)
Remove question skill assignment.
static delDir($a_dir, $a_clean_only=false)
removes a dir and all its content (subdirs and files) recursively

References $ilDB, $mobs, $obj_id, $result, $row, ilInternalLink\_deleteAllLinksOfSource(), ilObjMediaObject\_getMobsOfObject(), ilObjMediaObject\_removeUsage(), ilUtil\delDir(), deleteAdditionalTableData(), and ilSurveySkill\handleQuestionDeletion().

+ Here is the call graph for this function:

◆ deleteAdditionalTableData()

SurveyQuestion::deleteAdditionalTableData (   $question_id)

Deletes datasets from the additional question table in the database.

Parameters
integer$question_idThe question id which should be deleted in the additional question table @access public

Reimplemented in SurveyMatrixQuestion.

Definition at line 1016 of file class.SurveyQuestion.php.

1017 {
1018 global $ilDB;
1019
1020 $this->log->debug("DELETE FROM ".$this->getAdditionalTableName());
1021
1022 $affectedRows = $ilDB->manipulateF("DELETE FROM " . $this->getAdditionalTableName() . " WHERE question_fi = %s",
1023 array('integer'),
1024 array($question_id)
1025 );
1026 }

References $ilDB.

Referenced by delete().

+ Here is the caller graph for this function:

◆ deleteMaterial()

SurveyQuestion::deleteMaterial (   $materials_name = "")

Deletes a materials uri with a given name.

Parameters
string$indexA materials_name of the materials uri @access public
See also
$materials

Definition at line 370 of file class.SurveyQuestion.php.

371 {
372 foreach ($this->materials as $key => $value)
373 {
374 if (strcmp($key, $materials_name)==0)
375 {
376 if (file_exists($this->getMaterialsPath().$value))
377 {
378 unlink($this->getMaterialsPath().$value);
379 }
380 unset($this->materials[$key]);
381 }
382 }
383 }
getMaterialsPath()
Returns the materials path for web accessable materials of a question.

References getMaterialsPath().

+ Here is the call graph for this function:

◆ deleteMaterials()

SurveyQuestion::deleteMaterials (   $a_array)

Deletes materials.

Parameters
array$a_arrayArray with indexes of the materials to delete

Definition at line 1394 of file class.SurveyQuestion.php.

1395 {
1396 foreach ($a_array as $idx)
1397 {
1398 unset($this->material[$idx]);
1399 }
1400 $this->material = array_values($this->material);
1401 $this->saveMaterial();
1402 }

References saveMaterial().

+ Here is the call graph for this function:

◆ duplicate()

SurveyQuestion::duplicate (   $for_survey = true,
  $title = "",
  $author = "",
  $owner = "",
  $a_survey_id = 0 
)

Duplicates a survey question.

@access public

Definition at line 587 of file class.SurveyQuestion.php.

588 {
589 if ($this->getId() <= 0)
590 {
591 // The question has not been saved. It cannot be duplicated
592 return;
593 }
594 // duplicate the question in database
595 $clone = $this;
596 $original_id = $this->getId();
597 $clone->setId(-1);
598 if ($a_survey_id > 0)
599 {
600 $clone->setObjId($a_survey_id);
601 }
602 if ($title)
603 {
604 $clone->setTitle($title);
605 }
606 if ($author)
607 {
608 $clone->setAuthor($author);
609 }
610 if ($owner)
611 {
612 $clone->setOwner($owner);
613 }
614 if ($for_survey)
615 {
616 $clone->saveToDb($original_id);
617 }
618 else
619 {
620 $clone->saveToDb();
621 }
622 // duplicate the materials
623 $clone->duplicateMaterials($original_id);
624 // copy XHTML media objects
625 $clone->copyXHTMLMediaObjectsOfQuestion($original_id);
626 return $clone->getId();
627 }

References $author, $owner, $title, and getId().

+ Here is the call graph for this function:

◆ duplicateMaterials()

SurveyQuestion::duplicateMaterials (   $question_id)

Duplicates the materials of a question.

Parameters
integer$question_idThe database id of the original survey question @access public

Definition at line 1410 of file class.SurveyQuestion.php.

1411 {
1412 foreach ($this->materials as $filename)
1413 {
1414 $materialspath = $this->getMaterialsPath();
1415 $materialspath_original = preg_replace("/([^\d])$this->id([^\d])/", "\${1}$question_id\${2}", $materialspath);
1416 if (!file_exists($materialspath))
1417 {
1418 ilUtil::makeDirParents($materialspath);
1419 }
1420 if (!copy($materialspath_original . $filename, $materialspath . $filename))
1421 {
1422 print "material could not be duplicated!!!! ";
1423 }
1424 }
1425 }
if(! $in) print
static makeDirParents($a_dir)
Create a new directory and all parent directories.

References $filename, getMaterialsPath(), ilUtil\makeDirParents(), and print.

+ Here is the call graph for this function:

◆ flushMaterials()

SurveyQuestion::flushMaterials ( )

Deletes all materials uris.

@access public

See also
$materials

Definition at line 391 of file class.SurveyQuestion.php.

392 {
393 $this->materials = array();
394 }

◆ getAuthor()

SurveyQuestion::getAuthor ( )

Gets the authors name of the SurveyQuestion object.

Returns
string The string containing the name of the questions author @access public
See also
$author

Definition at line 530 of file class.SurveyQuestion.php.

531 {
532 return (strlen($this->author)) ? $this->author : NULL;
533 }

Referenced by createNewQuestion(), SurveyMatrixQuestion\insertXML(), SurveyMetricQuestion\insertXML(), SurveyMultipleChoiceQuestion\insertXML(), SurveySingleChoiceQuestion\insertXML(), SurveyTextQuestion\insertXML(), SurveyMatrixQuestion\isComplete(), SurveyMetricQuestion\isComplete(), SurveyMultipleChoiceQuestion\isComplete(), SurveySingleChoiceQuestion\isComplete(), SurveyTextQuestion\isComplete(), and saveToDb().

+ Here is the caller graph for this function:

◆ getAvailableRelations()

SurveyQuestion::getAvailableRelations ( )

Returns the available relations for the question.

Returns
array An array containing the available relations @access public

Reimplemented in SurveyMetricQuestion, SurveyMultipleChoiceQuestion, and SurveySingleChoiceQuestion.

Definition at line 2015 of file class.SurveyQuestion.php.

2016 {
2017 // overwrite in inherited classes
2018 return array();
2019 }

◆ getCopyIds()

SurveyQuestion::getCopyIds (   $a_group_by_survey = false)

Definition at line 2132 of file class.SurveyQuestion.php.

2133 {
2134 global $ilDB;
2135
2136 $set = $ilDB->query("SELECT q.question_id,s.obj_fi".
2137 " FROM svy_question q".
2138 " JOIN svy_svy_qst sq ON (sq.question_fi = q.question_id)".
2139 " JOIN svy_svy s ON (s.survey_id = sq.survey_fi)".
2140 " WHERE original_id = ".$ilDB->quote($this->getId(), "integer"));
2141 $res = array();
2142 while($row = $ilDB->fetchAssoc($set))
2143 {
2144 if(!$a_group_by_survey)
2145 {
2146 $res[] = $row["question_id"];
2147 }
2148 else
2149 {
2150 $res[$row["obj_fi"]][] = $row["question_id"];
2151 }
2152 }
2153 return $res;
2154 }

References $ilDB, $res, and $row.

Referenced by hasCopies().

+ Here is the caller graph for this function:

◆ getDescription()

SurveyQuestion::getDescription ( )

Gets the description string of the SurveyQuestion object.

Returns
string The description string to describe the question @access public
See also
$description

Definition at line 518 of file class.SurveyQuestion.php.

519 {
520 return (strlen($this->description)) ? $this->description : NULL;
521 }

Referenced by SurveyMatrixQuestion\insertXML(), SurveyMetricQuestion\insertXML(), SurveyMultipleChoiceQuestion\insertXML(), SurveySingleChoiceQuestion\insertXML(), SurveyTextQuestion\insertXML(), and saveToDb().

+ Here is the caller graph for this function:

◆ getId()

SurveyQuestion::getId ( )

Gets the id of the SurveyQuestion object.

Returns
integer The id of the SurveyQuestion object @access public
See also
$id

Definition at line 460 of file class.SurveyQuestion.php.

461 {
462 return $this->id;
463 }

References $id.

Referenced by addMaterialTag(), SurveyMatrixQuestion\checkUserInput(), SurveyMetricQuestion\checkUserInput(), SurveyMultipleChoiceQuestion\checkUserInput(), SurveySingleChoiceQuestion\checkUserInput(), SurveyTextQuestion\checkUserInput(), copyObject(), copyXHTMLMediaObjectsOfQuestion(), createNewQuestion(), duplicate(), SurveyMatrixQuestion\getWorkingDataFromUserInput(), SurveyMetricQuestion\getWorkingDataFromUserInput(), SurveyMultipleChoiceQuestion\getWorkingDataFromUserInput(), SurveySingleChoiceQuestion\getWorkingDataFromUserInput(), SurveyTextQuestion\getWorkingDataFromUserInput(), SurveyMatrixQuestion\insertXML(), SurveyMetricQuestion\insertXML(), SurveyMultipleChoiceQuestion\insertXML(), SurveySingleChoiceQuestion\insertXML(), SurveyTextQuestion\insertXML(), loadFromDb(), SurveyMatrixQuestion\saveBipolarAdjectives(), SurveyMultipleChoiceQuestion\saveCategoriesToDb(), SurveySingleChoiceQuestion\saveCategoriesToDb(), SurveyMatrixQuestion\saveColumnsToDb(), saveCompletionStatus(), SurveyMatrixQuestion\saveLayout(), saveMaterial(), SurveyMatrixQuestion\saveRowsToDb(), SurveyMetricQuestion\saveToDb(), SurveyMultipleChoiceQuestion\saveToDb(), saveToDb(), SurveySingleChoiceQuestion\saveToDb(), SurveyTextQuestion\saveToDb(), SurveyMatrixQuestion\saveToDb(), SurveyMatrixQuestion\saveUserInput(), SurveyMetricQuestion\saveUserInput(), SurveyMultipleChoiceQuestion\saveUserInput(), SurveySingleChoiceQuestion\saveUserInput(), SurveyTextQuestion\saveUserInput(), and syncWithOriginal().

+ Here is the caller graph for this function:

◆ getImagePath()

SurveyQuestion::getImagePath ( )

Returns the image path for web accessable images of a question.

The image path is under the CLIENT_WEB_DIR in assessment/REFERENCE_ID_OF_QUESTION_POOL/ID_OF_QUESTION/images

@access public

Definition at line 921 of file class.SurveyQuestion.php.

922 {
923 return CLIENT_WEB_DIR . "/survey/$this->obj_id/$this->id/images/";
924 }

◆ getImagePathWeb()

SurveyQuestion::getImagePathWeb ( )

Returns the web image path for web accessable images of a question.

The image path is under the web accessable data dir in assessment/REFERENCE_ID_OF_QUESTION_POOL/ID_OF_QUESTION/images

@access public

Definition at line 943 of file class.SurveyQuestion.php.

944 {
945 $webdir = ilUtil::removeTrailingPathSeparators(CLIENT_WEB_DIR) . "/survey/$this->obj_id/$this->id/images/";
946 return str_replace(ilUtil::removeTrailingPathSeparators(ILIAS_ABSOLUTE_PATH), ilUtil::removeTrailingPathSeparators(ILIAS_HTTP_PATH), $webdir);
947 }

References ilUtil\removeTrailingPathSeparators().

+ Here is the call graph for this function:

◆ getLabel()

SurveyQuestion::getLabel ( )

Definition at line 448 of file class.SurveyQuestion.php.

449 {
450 return $this->label;
451 }

◆ getMaterial()

SurveyQuestion::getMaterial ( )

Definition at line 2066 of file class.SurveyQuestion.php.

2067 {
2068 return $this->material;
2069 }

References $material.

◆ getMaterialsPath()

SurveyQuestion::getMaterialsPath ( )

Returns the materials path for web accessable materials of a question.

The materials path is under the CLIENT_WEB_DIR in assessment/REFERENCE_ID_OF_QUESTION_POOL/ID_OF_QUESTION/materials

@access public

Definition at line 932 of file class.SurveyQuestion.php.

933 {
934 return CLIENT_WEB_DIR . "/survey/$this->obj_id/$this->id/materials/";
935 }

Referenced by deleteMaterial(), duplicateMaterials(), and setMaterialsfile().

+ Here is the caller graph for this function:

◆ getMaterialsPathWeb()

SurveyQuestion::getMaterialsPathWeb ( )

Returns the web image path for web accessable images of a question.

The image path is under the web accessable data dir in assessment/REFERENCE_ID_OF_QUESTION_POOL/ID_OF_QUESTION/images

@access public

Definition at line 955 of file class.SurveyQuestion.php.

956 {
957 $webdir = ilUtil::removeTrailingPathSeparators(CLIENT_WEB_DIR) . "/survey/$this->obj_id/$this->id/materials/";
958 return str_replace(ilUtil::removeTrailingPathSeparators(ILIAS_ABSOLUTE_PATH), ilUtil::removeTrailingPathSeparators(ILIAS_HTTP_PATH), $webdir);
959 }

References ilUtil\removeTrailingPathSeparators().

+ Here is the call graph for this function:

◆ getObjId()

SurveyQuestion::getObjId ( )

Get the reference id of the container object.

Returns
integer The reference id of the container object @access public
See also
$obj_id

Definition at line 566 of file class.SurveyQuestion.php.

566 {
567 return $this->obj_id;
568 }

References $obj_id.

Referenced by copyObject(), createNewQuestion(), and saveToDb().

+ Here is the caller graph for this function:

◆ getObligatory()

SurveyQuestion::getObligatory (   $survey_id = "")

Gets the obligatory state of the question.

Returns
integer 1, if the question is obligatory, otherwise 0
See also
$obligatory

Definition at line 471 of file class.SurveyQuestion.php.

472 {
473 return ($this->obligatory) ? 1 : 0;
474 }

Referenced by SurveyMatrixQuestion\checkUserInput(), SurveyMetricQuestion\checkUserInput(), SurveyMultipleChoiceQuestion\checkUserInput(), SurveySingleChoiceQuestion\checkUserInput(), SurveyTextQuestion\checkUserInput(), SurveyMatrixQuestion\insertXML(), SurveyMetricQuestion\insertXML(), SurveyMultipleChoiceQuestion\insertXML(), SurveySingleChoiceQuestion\insertXML(), SurveyTextQuestion\insertXML(), and saveToDb().

+ Here is the caller graph for this function:

◆ getOrientation()

SurveyQuestion::getOrientation ( )

Gets the orientation of the question output.

Returns
integer 0 = vertical, 1 = horizontal @access public
See also
$orientation

Definition at line 495 of file class.SurveyQuestion.php.

496 {
497 switch ($this->orientation)
498 {
499 case 0:
500 case 1:
501 case 2:
502 break;
503 default:
504 $this->orientation = 0;
505 break;
506 }
507 return $this->orientation;
508 }

References $orientation.

Referenced by SurveyMultipleChoiceQuestion\insertXML(), SurveySingleChoiceQuestion\insertXML(), SurveyMultipleChoiceQuestion\saveToDb(), and SurveySingleChoiceQuestion\saveToDb().

+ Here is the caller graph for this function:

◆ getOriginalId()

SurveyQuestion::getOriginalId ( )

Definition at line 2061 of file class.SurveyQuestion.php.

2062 {
2063 return $this->original_id;
2064 }

Referenced by SurveyMatrixQuestion\syncWithOriginal(), and syncWithOriginal().

+ Here is the caller graph for this function:

◆ getOwner()

SurveyQuestion::getOwner ( )

Gets the creator/owner ID of the SurveyQuestion object.

Returns
integer The numerical ID to identify the owner/creator @access public
See also
$owner

Definition at line 542 of file class.SurveyQuestion.php.

543 {
544 return $this->owner;
545 }

References $owner.

Referenced by createNewQuestion(), and saveToDb().

+ Here is the caller graph for this function:

◆ getPhrase()

SurveyQuestion::getPhrase (   $phrase_id)

Returns a phrase for a given database id.

Returns
String The title of the phrase @access public

Definition at line 1275 of file class.SurveyQuestion.php.

1276 {
1277 global $ilDB;
1278
1279 $result = $ilDB->queryF("SELECT title FROM svy_phrase WHERE phrase_id = %s",
1280 array('integer'),
1281 array($phrase_id)
1282 );
1283 if ($row = $ilDB->fetchAssoc($result))
1284 {
1285 return $row["title"];
1286 }
1287 return "";
1288 }

References $ilDB, $result, and $row.

◆ getPreconditionOptions()

SurveyQuestion::getPreconditionOptions ( )

Returns the options for preconditions.

Returns
array

Reimplemented in SurveyMultipleChoiceQuestion, and SurveySingleChoiceQuestion.

Definition at line 2026 of file class.SurveyQuestion.php.

2027 {
2028 // overwrite in inherited classes
2029 }

Referenced by SurveyMatrixQuestion\getPreconditionSelectValue().

+ Here is the caller graph for this function:

◆ getPreconditionSelectValue()

SurveyQuestion::getPreconditionSelectValue (   $default = "",
  $title,
  $variable 
)

Creates a form property for the precondition value.

Returns
The ILIAS form element @access public

Reimplemented in SurveyMatrixQuestion, SurveyMetricQuestion, SurveyMultipleChoiceQuestion, and SurveySingleChoiceQuestion.

Definition at line 2050 of file class.SurveyQuestion.php.

2051 {
2052 // overwrite in inherited classes
2053 return null;
2054 }

◆ getPreconditionValueOutput()

SurveyQuestion::getPreconditionValueOutput (   $value)

Returns the output for a precondition value.

Parameters
string$valueThe precondition value
Returns
string The output of the precondition value @access public

Reimplemented in SurveyMatrixQuestion, SurveyMultipleChoiceQuestion, and SurveySingleChoiceQuestion.

Definition at line 2038 of file class.SurveyQuestion.php.

2039 {
2040 // overwrite in inherited classes
2041 return $value;
2042 }

◆ getQuestionDataArray()

SurveyQuestion::getQuestionDataArray (   $id)

Returns the question data fields from the database.

Parameters
integer$idThe question ID from the database
Returns
array Array containing the question fields and data from the database @access public

Reimplemented in SurveyMatrixQuestion, SurveyMetricQuestion, SurveyMultipleChoiceQuestion, SurveySingleChoiceQuestion, and SurveyTextQuestion.

Definition at line 1933 of file class.SurveyQuestion.php.

1934 {
1935 return array();
1936 }

◆ getQuestiontext()

SurveyQuestion::getQuestiontext ( )

Gets the questiontext of the SurveyQuestion object.

Returns
string The questiontext of the question object @access public
See also
$questiontext

Definition at line 554 of file class.SurveyQuestion.php.

555 {
556 return (strlen($this->questiontext)) ? $this->questiontext : NULL;
557 }

Referenced by SurveyMatrixQuestion\insertXML(), SurveyMetricQuestion\insertXML(), SurveyMultipleChoiceQuestion\insertXML(), SurveySingleChoiceQuestion\insertXML(), SurveyTextQuestion\insertXML(), SurveyMatrixQuestion\isComplete(), SurveyMetricQuestion\isComplete(), SurveyMultipleChoiceQuestion\isComplete(), SurveySingleChoiceQuestion\isComplete(), SurveyTextQuestion\isComplete(), and saveToDb().

+ Here is the caller graph for this function:

◆ getQuestionType()

SurveyQuestion::getQuestionType ( )

Returns the question type of the question.

Returns
integer The question type of the question @access public

Reimplemented in SurveyMatrixQuestion, SurveyMetricQuestion, SurveyMultipleChoiceQuestion, SurveySingleChoiceQuestion, and SurveyTextQuestion.

Definition at line 1689 of file class.SurveyQuestion.php.

1690 {
1691 return "";
1692 }

Referenced by getQuestionTypeID().

+ Here is the caller graph for this function:

◆ getQuestionTypeID()

SurveyQuestion::getQuestionTypeID ( )

Returns the question type ID of the question.

Returns
integer The question type of the question @access public

Reimplemented in SurveyMetricQuestion.

Definition at line 1665 of file class.SurveyQuestion.php.

1666 {
1667 global $ilDB;
1668 $result = $ilDB->queryF("SELECT questiontype_id FROM svy_qtype WHERE type_tag = %s",
1669 array('text'),
1670 array($this->getQuestionType())
1671 );
1672 if ($result->numRows() == 1)
1673 {
1674 $row = $ilDB->fetchAssoc($result);
1675 return $row["questiontype_id"];
1676 }
1677 else
1678 {
1679 return 0;
1680 }
1681 }
getQuestionType()
Returns the question type of the question.

References $ilDB, $result, $row, and getQuestionType().

Referenced by createNewQuestion(), and saveToDb().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getSubtype()

SurveyQuestion::getSubtype ( )

Reimplemented in SurveyMatrixQuestion, and SurveyMetricQuestion.

Definition at line 2076 of file class.SurveyQuestion.php.

2077 {
2078 // do nothing
2079 return null;
2080 }

◆ getSurveyId()

SurveyQuestion::getSurveyId ( )

Gets the survey id of the SurveyQuestion object.

Returns
integer The survey id of the SurveyQuestion object @access public
See also
$survey_id

Definition at line 483 of file class.SurveyQuestion.php.

484 {
485 return $this->survey_id;
486 }

References $survey_id.

◆ getTitle()

SurveyQuestion::getTitle ( )

◆ getWorkingDataFromUserInput()

& SurveyQuestion::getWorkingDataFromUserInput (   $post_data)

Creates the user data of the svy_answer table from the POST data.

Returns
array User data according to the svy_answer table @access public

Reimplemented in SurveyMatrixQuestion, SurveyMetricQuestion, SurveyMultipleChoiceQuestion, SurveySingleChoiceQuestion, and SurveyTextQuestion.

Definition at line 1944 of file class.SurveyQuestion.php.

1945 {
1946 // overwrite in inherited classes
1947 $data = array();
1948 return $data;
1949 }

References $data.

◆ hasCopies()

SurveyQuestion::hasCopies ( )

Definition at line 2156 of file class.SurveyQuestion.php.

2157 {
2158 return (bool)sizeof($this->getCopyIds());
2159 }
getCopyIds($a_group_by_survey=false)

References getCopyIds().

+ Here is the call graph for this function:

◆ importAdditionalMetadata()

SurveyQuestion::importAdditionalMetadata (   $a_meta)

Import additional meta data from the question import file.

Usually the meta data section is used to store question elements which are not part of the standard XML schema.

Returns
array $a_meta Array containing the additional meta data @access public

Reimplemented in SurveyMatrixQuestion, SurveyMultipleChoiceQuestion, and SurveySingleChoiceQuestion.

Definition at line 1959 of file class.SurveyQuestion.php.

1960 {
1961 // overwrite in inherited classes
1962 }

◆ importAdjectives()

SurveyQuestion::importAdjectives (   $a_data)

Import bipolar adjectives from the question import file.

Returns
array $a_data Array containing the adjectives @access public

Reimplemented in SurveyMatrixQuestion.

Definition at line 1981 of file class.SurveyQuestion.php.

1982 {
1983 // overwrite in inherited classes
1984 }

◆ importMatrix()

SurveyQuestion::importMatrix (   $a_data)

Import matrix rows from the question import file.

Returns
array $a_data Array containing the matrix rows @access public

Reimplemented in SurveyMatrixQuestion.

Definition at line 1992 of file class.SurveyQuestion.php.

1993 {
1994 // overwrite in inherited classes
1995 }

◆ importResponses()

SurveyQuestion::importResponses (   $a_data)

Import response data from the question import file.

Returns
array $a_data Array containing the response data @access public

Reimplemented in SurveyMatrixQuestion, SurveyMetricQuestion, SurveyMultipleChoiceQuestion, SurveySingleChoiceQuestion, and SurveyTextQuestion.

Definition at line 1970 of file class.SurveyQuestion.php.

1971 {
1972 // overwrite in inherited classes
1973 }

◆ isComplete()

SurveyQuestion::isComplete ( )

Returns 1, if a question is complete for use.

Returns
integer 1, if the question is complete for use, otherwise 0 @access public

Reimplemented in SurveyMatrixQuestion, SurveyMetricQuestion, SurveyMultipleChoiceQuestion, SurveySingleChoiceQuestion, and SurveyTextQuestion.

Definition at line 212 of file class.SurveyQuestion.php.

213 {
214 return 0;
215 }

Referenced by saveCompletionStatus(), and saveToDb().

+ Here is the caller graph for this function:

◆ isHTML()

SurveyQuestion::isHTML (   $a_text)

Checks if a given string contains HTML or not.

Parameters
string$a_textText which should be checked
Returns
boolean @access public

Definition at line 1824 of file class.SurveyQuestion.php.

1825 {
1826 if (preg_match("/<[^>]*?>/", $a_text))
1827 {
1828 return TRUE;
1829 }
1830 else
1831 {
1832 return FALSE;
1833 }
1834 }

Referenced by addMaterialTag().

+ Here is the caller graph for this function:

◆ loadFromDb()

SurveyQuestion::loadFromDb (   $question_id)

Loads a SurveyQuestion object from the database.

Parameters
integer$question_idA unique key which defines the question in the database @access public

Reimplemented in SurveyMatrixQuestion, SurveyMetricQuestion, SurveyMultipleChoiceQuestion, SurveySingleChoiceQuestion, and SurveyTextQuestion.

Definition at line 682 of file class.SurveyQuestion.php.

683 {
684 global $ilDB;
685
686 $result = $ilDB->queryF("SELECT * FROM svy_material WHERE question_fi = %s",
687 array('integer'),
688 array($this->getId())
689 );
690 $this->material = array();
691 if ($result->numRows())
692 {
693 include_once "./Modules/SurveyQuestionPool/classes/class.ilSurveyMaterial.php";
694 while ($row = $ilDB->fetchAssoc($result))
695 {
696 $mat = new ilSurveyMaterial();
697 $mat->type = $row['material_type'];
698 $mat->internal_link = $row['internal_link'];
699 $mat->title = $row['material_title'];
700 $mat->import_id = $row['import_id'];
701 $mat->text_material = $row['text_material'];
702 $mat->external_link = $row['external_link'];
703 $mat->file_material = $row['file_material'];
704 array_push($this->material, $mat);
705 }
706 }
707 }

References $ilDB, $result, $row, and getId().

+ Here is the call graph for this function:

◆ lookupObjFi()

static SurveyQuestion::lookupObjFi (   $a_qid)
static

Lookip obj fi.

Parameters

return

Definition at line 2181 of file class.SurveyQuestion.php.

2182 {
2183 global $ilDB;
2184
2185 $set = $ilDB->query("SELECT obj_fi FROM svy_question ".
2186 " WHERE question_id = ".$ilDB->quote($a_qid, "integer")
2187 );
2188 $rec = $ilDB->fetchAssoc($set);
2189 return $rec["obj_fi"];
2190 }

References $ilDB.

Referenced by ilTermUsagesTableGUI\fillRow(), and ilSurveyQuestionTableGUI\importData().

+ Here is the caller graph for this function:

◆ phraseExists()

SurveyQuestion::phraseExists (   $title)

Returns true if the phrase title already exists for the current user.

Parameters
string$titleThe title of the phrase
Returns
boolean True, if the title exists, otherwise False @access public

Definition at line 1297 of file class.SurveyQuestion.php.

1298 {
1299 global $ilUser, $ilDB;
1300
1301 $result = $ilDB->queryF("SELECT phrase_id FROM svy_phrase WHERE title = %s AND owner_fi = %s",
1302 array('text', 'integer'),
1303 array($title, $ilUser->getId())
1304 );
1305 return ($result->numRows() == 0) ? false : true;
1306 }
$ilUser
Definition: imgupload.php:18

References $ilDB, $ilUser, $result, and $title.

◆ prepareTextareaOutput()

SurveyQuestion::prepareTextareaOutput (   $txt_output,
  $prepare_for_latex_output = FALSE 
)

Prepares a string for a text area output in surveys.

Parameters
string$txt_outputString which should be prepared for output @access public

Definition at line 1921 of file class.SurveyQuestion.php.

1922 {
1923 return ilUtil::prepareTextareaOutput($txt_output, $prepare_for_latex_output);
1924 }
static prepareTextareaOutput($txt_output, $prepare_for_latex_output=FALSE, $omitNl2BrWhenTextArea=false)
Prepares a string for a text area output where latex code may be in it If the text is HTML-free,...

References ilUtil\prepareTextareaOutput().

+ Here is the call graph for this function:

◆ QTIMaterialToString()

SurveyQuestion::QTIMaterialToString (   $a_material)

Reads an QTI material tag an creates a text string.

Parameters
string$a_materialQTI material tag
Returns
string text or xhtml string @access public

Definition at line 1843 of file class.SurveyQuestion.php.

1844 {
1845 $svy_log = ilLoggerFactory::getLogger("svy");
1846 $svy_log->debug("material count: ".$a_material->getMaterialCount());
1847
1848 $result = "";
1849 for ($i = 0; $i < $a_material->getMaterialCount(); $i++)
1850 {
1851 $material = $a_material->getMaterial($i);
1852 if (strcmp($material["type"], "mattext") == 0)
1853 {
1854 $result .= $material["material"]->getContent();
1855 }
1856 if (strcmp($material["type"], "matimage") == 0)
1857 {
1858 $matimage = $material["material"];
1859 if (preg_match("/(il_([0-9]+)_mob_([0-9]+))/", $matimage->getLabel(), $matches))
1860 {
1861 // import an mediaobject which was inserted using tiny mce
1862 if (!is_array($_SESSION["import_mob_xhtml"])) $_SESSION["import_mob_xhtml"] = array();
1863 array_push($_SESSION["import_mob_xhtml"], array("mob" => $matimage->getLabel(), "uri" => $matimage->getUri()));
1864 }
1865 }
1866 }
1867 return $result;
1868 }
$_SESSION["AccountId"]

References $_SESSION, $material, $result, and ilLoggerFactory\getLogger().

+ Here is the call graph for this function:

◆ questionTitleExists()

SurveyQuestion::questionTitleExists (   $title,
  $questionpool_object = "" 
)

Returns TRUE if the question title exists in the database.

Parameters
string$titleThe title of the question
string$questionpool_referenceThe reference id of a container question pool
Returns
boolean The result of the title check @access public

Definition at line 225 of file class.SurveyQuestion.php.

226 {
227 global $ilDB;
228
229 $refwhere = "";
230 if (strcmp($questionpool_object, "") != 0)
231 {
232 $refwhere = sprintf(" AND obj_fi = %s",
233 $ilDB->quote($questionpool_object, 'integer')
234 );
235 }
236 $result = $ilDB->queryF("SELECT question_id FROM svy_question WHERE title = %s$refwhere",
237 array('text'),
238 array($title)
239 );
240 return ($result->numRows() > 0) ? true : false;
241 }
sprintf('%.4f', $callTime)

References $ilDB, $result, $title, and sprintf.

◆ saveCategoryToDb()

SurveyQuestion::saveCategoryToDb (   $categorytext,
  $neutral = 0 
)

Saves a category to the database.

Parameters
string$categorytextThe description of the category
Returns
integer The database id of the category @access public
See also
$categories

Definition at line 969 of file class.SurveyQuestion.php.

970 {
971 global $ilUser, $ilDB;
972
973 $result = $ilDB->queryF("SELECT title, category_id FROM svy_category WHERE title = %s AND neutral = %s AND owner_fi = %s",
974 array('text','text','integer'),
975 array($categorytext, $neutral, $ilUser->getId())
976 );
977 $insert = FALSE;
978 $returnvalue = "";
979 if ($result->numRows())
980 {
981 $insert = TRUE;
982 while ($row = $ilDB->fetchAssoc($result))
983 {
984 if (strcmp($row["title"], $categorytext) == 0)
985 {
986 $returnvalue = $row["category_id"];
987 $insert = FALSE;
988 }
989 }
990 }
991 else
992 {
993 $insert = TRUE;
994 }
995 if ($insert)
996 {
997 $next_id = $ilDB->nextId('svy_category');
998 $affectedRows = $ilDB->manipulateF("INSERT INTO svy_category (category_id, title, neutral, owner_fi, tstamp) VALUES (%s, %s, %s, %s, %s)",
999 array('integer','text','text','integer','integer'),
1000 array($next_id, $categorytext, $neutral, $ilUser->getId(), time())
1001 );
1002
1003 $this->log->debug("INSERT INTO svy_category id=".$next_id);
1004
1005 $returnvalue = $next_id;
1006 }
1007 return $returnvalue;
1008 }
$insert

References $ilDB, $ilUser, $insert, $result, and $row.

Referenced by SurveyMultipleChoiceQuestion\saveCategoriesToDb(), and SurveySingleChoiceQuestion\saveCategoriesToDb().

+ Here is the caller graph for this function:

◆ saveCompletionStatus()

SurveyQuestion::saveCompletionStatus (   $original_id = "")

Saves the complete flag to the database.

@access public

Definition at line 739 of file class.SurveyQuestion.php.

740 {
741 global $ilDB;
742
743 $question_id = $this->getId();
744 if (strlen($original_id))
745 {
746 $question_id = $original_id;
747 }
748
749 if ($this->getId() > 0)
750 {
751 $this->log->debug("UPDATE svy_question question_id=".$question_id);
752
753 // update existing dataset
754 $affectedRows = $ilDB->manipulateF("UPDATE svy_question SET complete = %s, tstamp = %s WHERE question_id = %s",
755 array('text', 'integer', 'integer'),
756 array($this->isComplete(), time(), $question_id)
757 );
758 }
759 }
isComplete()
Returns 1, if a question is complete for use.

References $ilDB, getId(), and isComplete().

Referenced by SurveyMultipleChoiceQuestion\saveCategoriesToDb(), SurveySingleChoiceQuestion\saveCategoriesToDb(), SurveyMatrixQuestion\saveColumnsToDb(), and SurveyMatrixQuestion\saveRowsToDb().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ saveMaterial()

SurveyQuestion::saveMaterial ( )

save material to db

Definition at line 825 of file class.SurveyQuestion.php.

826 {
827 global $ilDB;
828
829 include_once "./Services/Link/classes/class.ilInternalLink.php";
830
831 $this->log->debug("DELETE: svy_material question_fi=".$this->getId());
832
833 $affectedRows = $ilDB->manipulateF("DELETE FROM svy_material WHERE question_fi = %s",
834 array('integer'),
835 array($this->getId())
836 );
838
839 foreach ($this->material as $material)
840 {
841 $next_id = $ilDB->nextId('svy_material');
842
843 $this->log->debug("INSERT: svy_material question_fi=".$this->getId());
844
845 $affectedRows = $ilDB->manipulateF("INSERT INTO svy_material " .
846 "(material_id, question_fi, internal_link, import_id, material_title, tstamp," .
847 "text_material, external_link, file_material, material_type) ".
848 "VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s)",
849 array('integer','integer','text','text','text','integer','text','text','text','integer'),
850 array(
851 $next_id, $this->getId(), $material->internal_link, $material->import_id,
852 $material->title, time(), $material->text_material, $material->external_link,
853 $material->file_material, $material->type)
854 );
855 if (preg_match("/il_(\d*?)_(\w+)_(\d+)/", $material->internal_link, $matches))
856 {
857 ilInternalLink::_saveLink("sqst", $this->getId(), $matches[2], $matches[3], $matches[1]);
858 }
859 }
860 }

References $ilDB, $material, ilInternalLink\_deleteAllLinksOfSource(), ilInternalLink\_saveLink(), and getId().

Referenced by addInternalLink(), deleteMaterials(), SurveyMetricQuestion\saveToDb(), SurveyMultipleChoiceQuestion\saveToDb(), SurveySingleChoiceQuestion\saveToDb(), SurveyTextQuestion\saveToDb(), SurveyMatrixQuestion\saveToDb(), and setMaterial().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ saveToDb()

SurveyQuestion::saveToDb (   $original_id = "")

Saves a SurveyQuestion object to a database.

Parameters
integer$original_id@access public

Reimplemented in SurveyMetricQuestion, SurveyMultipleChoiceQuestion, SurveySingleChoiceQuestion, and SurveyTextQuestion.

Definition at line 767 of file class.SurveyQuestion.php.

768 {
769 global $ilDB;
770
771 // cleanup RTE images which are not inserted into the question text
772 include_once("./Services/RTE/classes/class.ilRTE.php");
773 ilRTE::_cleanupMediaObjectUsage($this->getQuestiontext(), "spl:html", $this->getId());
774 $affectedRows = 0;
775 if ($this->getId() == -1)
776 {
777 // Write new dataset
778 $next_id = $ilDB->nextId('svy_question');
779 $affectedRows = $ilDB->insert("svy_question", array(
780 "question_id" => array("integer", $next_id),
781 "questiontype_fi" => array("integer", $this->getQuestionTypeID()),
782 "obj_fi" => array("integer", $this->getObjId()),
783 "owner_fi" => array("integer", $this->getOwner()),
784 "title" => array("text", $this->getTitle()),
785 "label" => array("text", (strlen($this->label)) ? $this->label : null),
786 "description" => array("text", $this->getDescription()),
787 "author" => array("text", $this->getAuthor()),
788 "questiontext" => array("clob", ilRTE::_replaceMediaObjectImageSrc($this->getQuestiontext(), 0)),
789 "obligatory" => array("text", $this->getObligatory()),
790 "complete" => array("text", $this->isComplete()),
791 "created" => array("integer", time()),
792 "original_id" => array("integer", ($original_id) ? $original_id : NULL),
793 "tstamp" => array("integer", time())
794 ));
795
796 //$this->log->debug("INSERT: svy_question id=".$next_id." questiontype_fi=".$this->getQuestionTypeID()." obj_fi".$this->getObjId()." title=".$this->getTitle()." ...");
797
798 $this->setId($next_id);
799 }
800 else
801 {
802 // update existing dataset
803 $affectedRows = $ilDB->update("svy_question", array(
804 "title" => array("text", $this->getTitle()),
805 "label" => array("text", (strlen($this->label)) ? $this->label : null),
806 "description" => array("text", $this->getDescription()),
807 "author" => array("text", $this->getAuthor()),
808 "questiontext" => array("clob", ilRTE::_replaceMediaObjectImageSrc($this->getQuestiontext(), 0)),
809 "obligatory" => array("text", $this->getObligatory()),
810 "complete" => array("text", $this->isComplete()),
811 "tstamp" => array("integer", time())
812 ), array(
813 "question_id" => array("integer", $this->getId())
814 ));
815
816 $this->log->debug("UPDATE svy_question id=".$this->getId()." SET: title=".$this->getTitle()." ...");
817 }
818
819 return $affectedRows;
820 }
getDescription()
Gets the description string of the SurveyQuestion object.
getQuestiontext()
Gets the questiontext of the SurveyQuestion object.
getObligatory($survey_id="")
Gets the obligatory state of the question.
getTitle()
Gets the title string of the SurveyQuestion object.
static _cleanupMediaObjectUsage($a_text, $a_usage_type, $a_usage_id)
Synchronises appearances of media objects in $a_text with media object usage table.

References $ilDB, ilRTE\_cleanupMediaObjectUsage(), ilRTE\_replaceMediaObjectImageSrc(), getAuthor(), getDescription(), getId(), getObjId(), getObligatory(), getOwner(), getQuestiontext(), getQuestionTypeID(), getTitle(), isComplete(), and setId().

Referenced by syncWithOriginal().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ saveWorkingData()

SurveyQuestion::saveWorkingData (   $limit_to = LIMIT_NO_LIMIT)

Saves the learners input of the question to the database.

@access public

See also
$answers

Definition at line 911 of file class.SurveyQuestion.php.

912 {
913 }

◆ setAuthor()

SurveyQuestion::setAuthor (   $author = "")

Sets the authors name of the SurveyQuestion object.

Parameters
string$authorA string containing the name of the questions author @access public
See also
$author

Definition at line 403 of file class.SurveyQuestion.php.

404 {
405 if (!$author)
406 {
407 $author = $this->ilias->account->fullname;
408 }
409 $this->author = $author;
410 }

References $author.

Referenced by SurveyMatrixQuestion\loadFromDb(), SurveyMetricQuestion\loadFromDb(), SurveyMultipleChoiceQuestion\loadFromDb(), SurveySingleChoiceQuestion\loadFromDb(), and SurveyTextQuestion\loadFromDb().

+ Here is the caller graph for this function:

◆ setComplete()

SurveyQuestion::setComplete (   $a_complete)

Sets the complete state of the question.

Parameters
integer$a_complete1 if complete, 0 otherwise @access public

Definition at line 201 of file class.SurveyQuestion.php.

202 {
203 $this->complete = ($a_complete) ? 1 : 0;
204 }

Referenced by SurveyMatrixQuestion\loadFromDb(), SurveyMetricQuestion\loadFromDb(), SurveyMultipleChoiceQuestion\loadFromDb(), SurveySingleChoiceQuestion\loadFromDb(), and SurveyTextQuestion\loadFromDb().

+ Here is the caller graph for this function:

◆ setDescription()

SurveyQuestion::setDescription (   $description = "")

Sets the description string of the SurveyQuestion object.

Parameters
string$descriptionA description string to describe the question @access public
See also
$description

Definition at line 310 of file class.SurveyQuestion.php.

311 {
312 $this->description = $description;
313 }

References $description.

Referenced by SurveyMatrixQuestion\loadFromDb(), SurveyMetricQuestion\loadFromDb(), SurveyMultipleChoiceQuestion\loadFromDb(), SurveySingleChoiceQuestion\loadFromDb(), and SurveyTextQuestion\loadFromDb().

+ Here is the caller graph for this function:

◆ setId()

SurveyQuestion::setId (   $id = -1)

Sets the id of the SurveyQuestion object.

Parameters
integer$idA unique integer value @access public
See also
$id

Definition at line 286 of file class.SurveyQuestion.php.

287 {
288 $this->id = $id;
289 }

References $id.

Referenced by createNewQuestion(), SurveyMatrixQuestion\loadFromDb(), SurveyMetricQuestion\loadFromDb(), SurveyMultipleChoiceQuestion\loadFromDb(), SurveySingleChoiceQuestion\loadFromDb(), SurveyTextQuestion\loadFromDb(), saveToDb(), and syncWithOriginal().

+ Here is the caller graph for this function:

◆ setMaterial()

SurveyQuestion::setMaterial (   $material_id = "",
  $is_import = false,
  $material_title = "" 
)

Sets a material link for the question.

Parameters
string$material_idAn internal link pointing to the material
boolean$is_importA boolean indication that the internal link was imported from another ILIAS installation @access public

Definition at line 1439 of file class.SurveyQuestion.php.

1440 {
1441 if (strcmp($material_id, "") != 0)
1442 {
1443 $import_id = "";
1444 if ($is_import)
1445 {
1446 $import_id = $material_id;
1447 $material_id = self::_resolveInternalLink($import_id);
1448 }
1449 if (strcmp($material_title, "") == 0)
1450 {
1451 if (preg_match("/il__(\w+)_(\d+)/", $material_id, $matches))
1452 {
1453 $type = $matches[1];
1454 $target_id = $matches[2];
1455 $material_title = $this->lng->txt("obj_$type") . ": ";
1456 switch ($type)
1457 {
1458 case "lm":
1459 include_once("./Modules/LearningModule/classes/class.ilObjContentObjectGUI.php");
1460 $cont_obj_gui = new ilObjContentObjectGUI("", $target_id, true);
1461 $cont_obj = $cont_obj_gui->object;
1462 $material_title .= $cont_obj->getTitle();
1463 break;
1464 case "pg":
1465 include_once("./Modules/LearningModule/classes/class.ilLMPageObject.php");
1466 include_once("./Modules/LearningModule/classes/class.ilLMObject.php");
1468 include_once("./Modules/LearningModule/classes/class.ilObjContentObjectGUI.php");
1469 $cont_obj_gui = new ilObjContentObjectGUI("", $lm_id, FALSE);
1470 $cont_obj = $cont_obj_gui->object;
1471 $pg_obj = new ilLMPageObject($cont_obj, $target_id);
1472 $material_title .= $pg_obj->getTitle();
1473 break;
1474 case "st":
1475 include_once("./Modules/LearningModule/classes/class.ilStructureObject.php");
1476 include_once("./Modules/LearningModule/classes/class.ilLMObject.php");
1478 include_once("./Modules/LearningModule/classes/class.ilObjContentObjectGUI.php");
1479 $cont_obj_gui = new ilObjContentObjectGUI("", $lm_id, FALSE);
1480 $cont_obj = $cont_obj_gui->object;
1481 $st_obj = new ilStructureObject($cont_obj, $target_id);
1482 $material_title .= $st_obj->getTitle();
1483 break;
1484 case "git":
1485 include_once "./Modules/Glossary/classes/class.ilGlossaryTerm.php";
1486 $material_title = $this->lng->txt("glossary_term") . ": " . ilGlossaryTerm::_lookGlossaryTerm($target_id);
1487 break;
1488 case "mob":
1489 break;
1490 }
1491 }
1492 }
1493 $this->material = array(
1494 "internal_link" => $material_id,
1495 "import_id" => $import_id,
1496 "title" => $material_title
1497 );
1498 }
1499 $this->saveMaterial();
1500 }

References $target_id, ilGlossaryTerm\_lookGlossaryTerm(), ilLMObject\_lookupContObjID(), _resolveInternalLink(), and saveMaterial().

+ Here is the call graph for this function:

◆ setMaterialsfile()

SurveyQuestion::setMaterialsfile (   $materials_filename,
  $materials_tempfilename = "",
  $materials_name = "" 
)

Sets and uploads the materials uri.

Parameters
stringstringstring$materials_filename,$materials_tempfilename,$materials@access public
See also
$materials

Definition at line 342 of file class.SurveyQuestion.php.

343 {
344 if (!empty($materials_filename))
345 {
346 $materialspath = $this->getMaterialsPath();
347 if (!file_exists($materialspath))
348 {
349 ilUtil::makeDirParents($materialspath);
350 }
351 if (ilUtil::moveUploadedFile($materials_tempfilename, $materials_filename,
352 $materialspath.$materials_filename))
353 {
354 print "image not uploaded!!!! ";
355 }
356 else
357 {
358 $this->addMaterials($materials_filename, $materials_name);
359 }
360 }
361 }
addMaterials($materials_file, $materials_name="")
Sets the materials uri.
static moveUploadedFile($a_file, $a_name, $a_target, $a_raise_errors=true, $a_mode="move_uploaded")
move uploaded file

References addMaterials(), getMaterialsPath(), ilUtil\makeDirParents(), ilUtil\moveUploadedFile(), and print.

+ Here is the call graph for this function:

◆ setObjId()

SurveyQuestion::setObjId (   $obj_id = 0)

Set the reference id of the container object.

Parameters
integer$obj_idThe reference id of the container object @access public
See also
$obj_id

Definition at line 577 of file class.SurveyQuestion.php.

578 {
579 $this->obj_id = $obj_id;
580 }

References $obj_id.

Referenced by SurveyMatrixQuestion\loadFromDb(), SurveyMetricQuestion\loadFromDb(), SurveyMultipleChoiceQuestion\loadFromDb(), SurveySingleChoiceQuestion\loadFromDb(), and SurveyTextQuestion\loadFromDb().

+ Here is the caller graph for this function:

◆ setObligatory()

SurveyQuestion::setObligatory (   $obligatory = 1)

Sets the obligatory state of the question.

Parameters
integer$obligatory1, if the question is obligatory, otherwise 0 @access public
See also
$obligatory

Definition at line 262 of file class.SurveyQuestion.php.

263 {
264 $this->obligatory = ($obligatory) ? 1 : 0;
265 }

References $obligatory.

Referenced by SurveyMatrixQuestion\loadFromDb(), SurveyMetricQuestion\loadFromDb(), SurveyMultipleChoiceQuestion\loadFromDb(), SurveySingleChoiceQuestion\loadFromDb(), and SurveyTextQuestion\loadFromDb().

+ Here is the caller graph for this function:

◆ setOrientation()

SurveyQuestion::setOrientation (   $orientation = 0)

Sets the orientation of the question output.

Parameters
integer$orientation0 = vertical, 1 = horizontal @access public
See also
$orientation

Definition at line 274 of file class.SurveyQuestion.php.

275 {
276 $this->orientation = ($orientation) ? $orientation : 0;
277 }

References $orientation.

Referenced by SurveyMultipleChoiceQuestion\importAdditionalMetadata(), SurveySingleChoiceQuestion\importAdditionalMetadata(), SurveyMultipleChoiceQuestion\loadFromDb(), and SurveySingleChoiceQuestion\loadFromDb().

+ Here is the caller graph for this function:

◆ setOriginalId()

SurveyQuestion::setOriginalId (   $original_id)

Definition at line 2056 of file class.SurveyQuestion.php.

2057 {
2058 $this->original_id = $original_id;
2059 }

Referenced by SurveyMatrixQuestion\loadFromDb(), SurveyMetricQuestion\loadFromDb(), SurveyMultipleChoiceQuestion\loadFromDb(), SurveySingleChoiceQuestion\loadFromDb(), SurveyTextQuestion\loadFromDb(), and syncWithOriginal().

+ Here is the caller graph for this function:

◆ setOwner()

SurveyQuestion::setOwner (   $owner = "")

Sets the creator/owner ID of the SurveyQuestion object.

Parameters
integer$ownerA numerical ID to identify the owner/creator @access public
See also
$owner

Definition at line 431 of file class.SurveyQuestion.php.

432 {
433 $this->owner = $owner;
434 }

References $owner.

Referenced by SurveyMatrixQuestion\loadFromDb(), SurveyMetricQuestion\loadFromDb(), SurveyMultipleChoiceQuestion\loadFromDb(), SurveySingleChoiceQuestion\loadFromDb(), and SurveyTextQuestion\loadFromDb().

+ Here is the caller graph for this function:

◆ setQuestiontext()

SurveyQuestion::setQuestiontext (   $questiontext = "")

Sets the questiontext of the SurveyQuestion object.

Parameters
string$questiontextA string containing the questiontext @access public
See also
$questiontext

Definition at line 419 of file class.SurveyQuestion.php.

420 {
421 $this->questiontext = $questiontext;
422 }

References $questiontext.

Referenced by SurveyMatrixQuestion\loadFromDb(), SurveyMetricQuestion\loadFromDb(), SurveyMultipleChoiceQuestion\loadFromDb(), SurveySingleChoiceQuestion\loadFromDb(), and SurveyTextQuestion\loadFromDb().

+ Here is the caller graph for this function:

◆ setSubtype()

SurveyQuestion::setSubtype (   $a_subtype)

Reimplemented in SurveyMatrixQuestion, and SurveyMetricQuestion.

Definition at line 2071 of file class.SurveyQuestion.php.

2072 {
2073 // do nothing
2074 }

◆ setSurveyId()

SurveyQuestion::setSurveyId (   $id = -1)

Sets the survey id of the SurveyQuestion object.

Parameters
integer$idA unique integer value @access public
See also
$survey_id

Definition at line 298 of file class.SurveyQuestion.php.

299 {
300 $this->survey_id = $id;
301 }

References $id.

◆ setTitle()

SurveyQuestion::setTitle (   $title = "")

Sets the title string of the SurveyQuestion object.

Parameters
string$titleA title string to describe the question @access public
See also
$title

Definition at line 250 of file class.SurveyQuestion.php.

251 {
252 $this->title = $title;
253 }

References $title.

Referenced by SurveyMatrixQuestion\loadFromDb(), SurveyMetricQuestion\loadFromDb(), SurveyMultipleChoiceQuestion\loadFromDb(), SurveySingleChoiceQuestion\loadFromDb(), and SurveyTextQuestion\loadFromDb().

+ Here is the caller graph for this function:

◆ stripSlashesAddSpaceFallback()

SurveyQuestion::stripSlashesAddSpaceFallback (   $a_str)

Strip slashes with add space fallback, see https://mantis.ilias.de/view.php?id=19727 and https://mantis.ilias.de/view.php?id=24200.

Parameters
string$a_strstring
Returns
string

Definition at line 2199 of file class.SurveyQuestion.php.

2200 {
2201 $str = ilUtil::stripSlashes($a_str);
2202 if ($str != $a_str)
2203 {
2204 $str = ilUtil::stripSlashes(str_replace("<", "< ", $a_str));
2205 }
2206 return $str;
2207 }
static stripSlashes($a_str, $a_strip_html=true, $a_allow="")
strip slashes if magic qoutes is enabled

References ilUtil\stripSlashes().

Referenced by SurveyTextQuestion\saveUserInput().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ syncWithOriginal()

SurveyQuestion::syncWithOriginal ( )

Reimplemented in SurveyMatrixQuestion.

Definition at line 1227 of file class.SurveyQuestion.php.

1228 {
1229 global $ilDB;
1230
1231 if ($this->getOriginalId())
1232 {
1233 $id = $this->getId();
1234 $original = $this->getOriginalId();
1235
1236 $this->setId($this->getOriginalId());
1237 $this->setOriginalId(NULL);
1238 $this->saveToDb();
1239
1240 $this->setId($id);
1241 $this->setOriginalId($original);
1242
1243 $this->log->debug("DELETE FROM svy_material WHERE question_fi = ".$this->getOriginalId());
1244
1245 include_once "./Services/Link/classes/class.ilInternalLink.php";
1246 $affectedRows = $ilDB->manipulateF("DELETE FROM svy_material WHERE question_fi = %s",
1247 array('integer'),
1248 array($this->getOriginalId())
1249 );
1250 ilInternalLink::_deleteAllLinksOfSource("sqst", $this->original_id);
1251 if (strlen($this->material["internal_link"]))
1252 {
1253 $next_id = $ilDB->nextId('svy_material');
1254 $affectedRows = $ilDB->manipulateF("INSERT INTO svy_material (material_id, question_fi, internal_link, import_id, material_title, tstamp) VALUES (%s, %s, %s, %s, %s, %s)",
1255 array('integer', 'integer', 'text', 'text', 'text', 'integer'),
1256 array($next_id, $this->getOriginalId(), $this->material["internal_link"], $this->material["import_id"], $this->material["title"], time())
1257 );
1258
1259 $this->log->debug("INSERT svy_material material_id=".$next_id." question_fi=".$this->getOriginalId());
1260
1261 if (preg_match("/il_(\d*?)_(\w+)_(\d+)/", $this->material["internal_link"], $matches))
1262 {
1263 ilInternalLink::_saveLink("sqst", $this->getOriginalId(), $matches[2], $matches[3], $matches[1]);
1264 }
1265 }
1266 }
1267 }
setOriginalId($original_id)
saveToDb($original_id="")
Saves a SurveyQuestion object to a database.

References $ilDB, ilInternalLink\_deleteAllLinksOfSource(), ilInternalLink\_saveLink(), getId(), getOriginalId(), saveToDb(), setId(), and setOriginalId().

+ Here is the call graph for this function:

◆ usableForPrecondition()

SurveyQuestion::usableForPrecondition ( )

Returns if the question is usable for preconditions.

Returns
boolean TRUE if the question is usable for a precondition, FALSE otherwise @access public

Reimplemented in SurveyMatrixQuestion, SurveyMetricQuestion, SurveyMultipleChoiceQuestion, SurveySingleChoiceQuestion, and SurveyTextQuestion.

Definition at line 2003 of file class.SurveyQuestion.php.

2004 {
2005 // overwrite in inherited classes
2006 return FALSE;
2007 }

Field Documentation

◆ $arrData

SurveyQuestion::$arrData
private

data array containing the question data

Definition at line 145 of file class.SurveyQuestion.php.

◆ $author

◆ $complete

SurveyQuestion::$complete

Definition at line 135 of file class.SurveyQuestion.php.

◆ $cumulated

SurveyQuestion::$cumulated
protected

An array containing the cumulated results of the question for a given survey.

Definition at line 140 of file class.SurveyQuestion.php.

◆ $description

◆ $id

◆ $ilias

SurveyQuestion::$ilias

Definition at line 111 of file class.SurveyQuestion.php.

Referenced by __construct().

◆ $lng

◆ $log

SurveyQuestion::$log
protected

Definition at line 150 of file class.SurveyQuestion.php.

◆ $material

◆ $materials

SurveyQuestion::$materials

Definition at line 76 of file class.SurveyQuestion.php.

◆ $obj_id

SurveyQuestion::$obj_id

Definition at line 90 of file class.SurveyQuestion.php.

Referenced by createNewQuestion(), delete(), getObjId(), and setObjId().

◆ $obligatory

SurveyQuestion::$obligatory

Definition at line 104 of file class.SurveyQuestion.php.

Referenced by setObligatory().

◆ $orientation

◆ $owner

◆ $questiontext

◆ $survey_id

◆ $title

◆ $tpl

SurveyQuestion::$tpl

Definition at line 118 of file class.SurveyQuestion.php.

Referenced by __construct().


The documentation for this class was generated from the following file: