ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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
 
 $tpl
 
 $lng
 
 $orientation
 
 $material
 
 $complete
 

Protected Attributes

 $user
 
 $db
 
 $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 165 of file class.SurveyQuestion.php.

166 {
167 global $DIC;
168
169 $this->user = $DIC->user();
170 $this->db = $DIC->database();
171 $lng = $DIC->language();
172 $tpl = $DIC["tpl"];
173 $ilUser = $DIC->user();
174
175 $this->lng = $lng;
176 $this->tpl = $tpl;
177 $this->complete = 0;
178 $this->title = $title;
179 $this->description = $description;
180 $this->questiontext = $questiontext;
181 $this->author = $author;
182 $this->cumulated = array();
183 if (!$this->author) {
184 $this->author = $ilUser->fullname;
185 }
186 $this->owner = $owner;
187 if ($this->owner == -1) {
188 $this->owner = $ilUser->getId();
189 }
190 $this->id = -1;
191 $this->survey_id = -1;
192 $this->obligatory = 1;
193 $this->orientation = 0;
194 $this->materials = array();
195 $this->material = array();
196 $this->arrData = array();
197
198 $this->log = ilLoggerFactory::getLogger('svy');
199 }
user()
Definition: user.php:4
static getLogger($a_component_id)
Get component logger.
global $DIC
Definition: saml.php:7
$ilUser
Definition: imgupload.php:18

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

+ Here is the call graph for this function:

Member Function Documentation

◆ __get()

SurveyQuestion::__get (   $value)

Object getter.

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

2047 {
2048 switch ($value) {
2049 default:
2050 if (array_key_exists($value, $this->arrData)) {
2051 return $this->arrData[$value];
2052 } else {
2053 return null;
2054 }
2055 break;
2056 }
2057 }

◆ __set()

SurveyQuestion::__set (   $key,
  $value 
)

Object setter.

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

2063 {
2064 switch ($key) {
2065 default:
2066 $this->arrData[$key] = $value;
2067 break;
2068 }
2069 }
$key
Definition: croninfo.php:18

References $key.

◆ _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 2078 of file class.SurveyQuestion.php.

2079 {
2080 global $DIC;
2081
2082 $ilDB = $DIC->database();
2083
2084 $ilDB->manipulate("UPDATE svy_question" .
2085 " SET original_id = " . $ilDB->quote($a_original_id, "integer") . "," .
2086 " obj_fi = " . $ilDB->quote($a_object_id, "integer") .
2087 " WHERE question_id = " . $ilDB->quote($a_question_id, "integer"));
2088 }
global $ilDB

References $DIC, and $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 1565 of file class.SurveyQuestion.php.

1566 {
1567 global $DIC;
1568
1569 $ilDB = $DIC->database();
1570 $linktypes = array(
1571 "lm" => "LearningModule",
1572 "pg" => "PageObject",
1573 "st" => "StructureObject",
1574 "git" => "GlossaryItem",
1575 "mob" => "MediaObject"
1576 );
1577 $href = "";
1578 if (preg_match("/il__(\w+)_(\d+)/", $target, $matches)) {
1579 $type = $matches[1];
1580 $target_id = $matches[2];
1581 switch ($linktypes[$matches[1]]) {
1582 case "LearningModule":
1583 $href = ilUtil::removeTrailingPathSeparators(ILIAS_HTTP_PATH) . "/goto.php?target=" . $type . "_" . $target_id;
1584 break;
1585 case "PageObject":
1586 case "StructureObject":
1587 $href = ilUtil::removeTrailingPathSeparators(ILIAS_HTTP_PATH) . "/goto.php?target=" . $type . "_" . $target_id;
1588 break;
1589 case "GlossaryItem":
1590 $href = ilUtil::removeTrailingPathSeparators(ILIAS_HTTP_PATH) . "/goto.php?target=" . $type . "_" . $target_id;
1591 break;
1592 case "MediaObject":
1593 $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;
1594 break;
1595 }
1596 }
1597 return $href;
1598 }
static removeTrailingPathSeparators($path)
$target_id
Definition: goto.php:49
$type

References $DIC, $ilDB, $target, $target_id, $type, 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 1197 of file class.SurveyQuestion.php.

1198 {
1199 global $DIC;
1200
1201 $ilDB = $DIC->database();
1202 $result = $ilDB->queryF(
1203 "SELECT * FROM svy_question WHERE question_id = %s",
1204 array('integer'),
1205 array($question_id)
1206 );
1207 if ($result->numRows() > 0) {
1208 $row = $ilDB->fetchAssoc($result);
1209 if ($row["original_id"] > 0) {
1210 return $row["original_id"];
1211 } elseif ((bool) $a_return_question_id_if_no_original) { // #12419
1212 return $row["question_id"];
1213 }
1214 } else {
1215 return "";
1216 }
1217 }
$result

References $DIC, $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 1137 of file class.SurveyQuestion.php.

1138 {
1139 global $DIC;
1140
1141 $ilDB = $DIC->database();
1142
1143 if ($question_id < 1) {
1144 return "";
1145 }
1146
1147 $result = $ilDB->queryF(
1148 "SELECT type_tag FROM svy_question, svy_qtype WHERE svy_question.question_id = %s AND svy_question.questiontype_fi = svy_qtype.questiontype_id",
1149 array('integer'),
1150 array($question_id)
1151 );
1152 if ($result->numRows() == 1) {
1153 $data = $ilDB->fetchAssoc($result);
1154 return $data["type_tag"];
1155 } else {
1156 return "";
1157 }
1158 }

References $data, $DIC, $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 1706 of file class.SurveyQuestion.php.

1707 {
1708 if (file_exists("./Modules/SurveyQuestionPool/classes/class." . $type_tag . ".php")) {
1709 global $DIC;
1710
1711 $lng = $DIC->language();
1712 return $lng->txt($type_tag);
1713 } else {
1714 global $DIC;
1715
1716 $ilPluginAdmin = $DIC["ilPluginAdmin"];
1717 $pl_names = $ilPluginAdmin->getActivePluginsForSlot(IL_COMP_MODULE, "SurveyQuestionPool", "svyq");
1718 foreach ($pl_names as $pl_name) {
1719 $pl = ilPlugin::getPluginObject(IL_COMP_MODULE, "SurveyQuestionPool", "svyq", $pl_name);
1720 if (strcmp($pl->getQuestionType(), $type_tag) == 0) {
1721 return $pl->getQuestionTypeTranslation();
1722 }
1723 }
1724 }
1725 return "";
1726 }
const IL_COMP_MODULE
static getPluginObject($a_ctype, $a_cname, $a_slot_id, $a_pname)
Get plugin object.

References $DIC, $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 1167 of file class.SurveyQuestion.php.

1168 {
1169 global $DIC;
1170
1171 $ilDB = $DIC->database();
1172
1173 if ($question_id < 1) {
1174 return "";
1175 }
1176
1177 $result = $ilDB->queryF(
1178 "SELECT title FROM svy_question WHERE svy_question.question_id = %s",
1179 array('integer'),
1180 array($question_id)
1181 );
1182 if ($result->numRows() == 1) {
1183 $data = $ilDB->fetchAssoc($result);
1184 return $data["title"];
1185 } else {
1186 return "";
1187 }
1188 }

References $data, $DIC, $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 1673 of file class.SurveyQuestion.php.

1674 {
1675 $type = $question_type;
1676 if ($gui == 1) {
1677 $type .= "GUI";
1678 } elseif ($gui == 2) {
1679 $type .= "Evaluation";
1680 }
1681 if (file_exists("./Modules/SurveyQuestionPool/classes/class." . $type . ".php")) {
1682 include_once "./Modules/SurveyQuestionPool/classes/class." . $type . ".php";
1683 return true;
1684 } else {
1685 global $DIC;
1686
1687 $ilPluginAdmin = $DIC["ilPluginAdmin"];
1688 $pl_names = $ilPluginAdmin->getActivePluginsForSlot(IL_COMP_MODULE, "SurveyQuestionPool", "svyq");
1689 foreach ($pl_names as $pl_name) {
1690 $pl = ilPlugin::getPluginObject(IL_COMP_MODULE, "SurveyQuestionPool", "svyq", $pl_name);
1691 if (strcmp($pl->getQuestionType(), $question_type) == 0) {
1692 $pl->includeClass("class." . $type . ".php");
1693 return true;
1694 }
1695 }
1696 }
1697 return false;
1698 }

References $DIC, $type, 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 1736 of file class.SurveyQuestion.php.

1737 {
1738 $question_type = self::_getQuestionType($question_id);
1739 if ($question_type) {
1740 self::_includeClass($question_type);
1741 $question = new $question_type();
1742 $question->loadFromDb($question_id);
1743 return $question;
1744 }
1745 }
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 1772 of file class.SurveyQuestion.php.

1773 {
1774 $question = self::_instanciateQuestion($question_id);
1775 if ($question) {
1776 $question_type = self::_getQuestionType($question_id);
1777 self::_includeClass($question_type, 2);
1778 $class = $question_type . "Evaluation";
1779 $ev = new $class($question, $a_finished_ids);
1780 return $ev;
1781 }
1782 }
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 1754 of file class.SurveyQuestion.php.

1755 {
1756 $question_type = self::_getQuestionType($question_id);
1757 if ($question_type) {
1758 self::_includeClass($question_type, 1);
1759 $guitype = $question_type . "GUI";
1760 $question = new $guitype($question_id);
1761 return $question;
1762 }
1763 }

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 704 of file class.SurveyQuestion.php.

705 {
706 global $DIC;
707
708 $ilDB = $DIC->database();
709
710 $result = $ilDB->queryF(
711 "SELECT complete FROM svy_question WHERE question_id = %s",
712 array('integer'),
713 array($question_id)
714 );
715 if ($result->numRows()) {
716 $row = $ilDB->fetchAssoc($result);
717 if ($row["complete"] == 1) {
718 return true;
719 }
720 }
721 return false;
722 }

References $DIC, $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 1608 of file class.SurveyQuestion.php.

1609 {
1610 global $DIC;
1611
1612 $ilDB = $DIC->database();
1613
1614 if (($question_id < 1) || ($user_id < 1)) {
1615 return false;
1616 }
1617
1618 $result = $ilDB->queryF(
1619 "SELECT obj_fi FROM svy_question WHERE question_id = %s",
1620 array('integer'),
1621 array($question_id)
1622 );
1623 if ($result->numRows() == 1) {
1624 $row = $ilDB->fetchAssoc($result);
1625 $qpl_object_id = $row["obj_fi"];
1626 include_once "./Modules/SurveyQuestionPool/classes/class.ilObjSurveyQuestionPool.php";
1627 return ilObjSurveyQuestionPool::_isWriteable($qpl_object_id, $user_id);
1628 } else {
1629 return false;
1630 }
1631 }
static _isWriteable($object_id, $user_id)
Returns true, if the question pool is writeable by a given user.

References $DIC, $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 2115 of file class.SurveyQuestion.php.

2116 {
2117 global $DIC;
2118
2119 $ilDB = $DIC->database();
2120
2121 $set = $ilDB->query("SELECT svy_svy.obj_fi FROM svy_svy_qst" .
2122 " JOIN svy_svy ON (svy_svy.survey_id = svy_svy_qst.survey_fi)" .
2123 " WHERE svy_svy_qst.question_fi = " . $ilDB->quote($a_question_id, "integer"));
2124 $row = $ilDB->fetchAssoc($set);
2125 if ($ilDB->numRows($set)) {
2126 return $row["obj_fi"];
2127 }
2128 }

References $DIC, $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 1308 of file class.SurveyQuestion.php.

1309 {
1310 global $DIC;
1311
1312 $ilDB = $DIC->database();
1313
1314 if ($question_id < 1) {
1315 return false;
1316 }
1317
1318 $result = $ilDB->queryF(
1319 "SELECT question_id FROM svy_question WHERE question_id = %s",
1320 array('integer'),
1321 array($question_id)
1322 );
1323 return ($result->numRows() == 1) ? true : false;
1324 }

References $DIC, $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 1484 of file class.SurveyQuestion.php.

1485 {
1486 if (preg_match("/il_(\d+)_(\w+)_(\d+)/", $internal_link, $matches)) {
1487 include_once "./Services/Link/classes/class.ilInternalLink.php";
1488 include_once "./Modules/LearningModule/classes/class.ilLMObject.php";
1489 include_once "./Modules/Glossary/classes/class.ilGlossaryTerm.php";
1490 switch ($matches[2]) {
1491 case "lm":
1492 $resolved_link = ilLMObject::_getIdForImportId($internal_link);
1493 break;
1494 case "pg":
1495 $resolved_link = ilInternalLink::_getIdForImportId("PageObject", $internal_link);
1496 break;
1497 case "st":
1498 $resolved_link = ilInternalLink::_getIdForImportId("StructureObject", $internal_link);
1499 break;
1500 case "git":
1501 $resolved_link = ilInternalLink::_getIdForImportId("GlossaryItem", $internal_link);
1502 break;
1503 case "mob":
1504 $resolved_link = ilInternalLink::_getIdForImportId("MediaObject", $internal_link);
1505 break;
1506 }
1507 if (strcmp($resolved_link, "") == 0) {
1508 $resolved_link = $internal_link;
1509 }
1510 } else {
1511 $resolved_link = $internal_link;
1512 }
1513 return $resolved_link;
1514 }
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 1516 of file class.SurveyQuestion.php.

1517 {
1518 global $DIC;
1519
1520 $ilDB = $DIC->database();
1521 $resolvedlinks = 0;
1522 $result = $ilDB->queryF(
1523 "SELECT * FROM svy_material WHERE question_fi = %s",
1524 array('integer'),
1525 array($question_id)
1526 );
1527 if ($result->numRows()) {
1528 while ($row = $ilDB->fetchAssoc($result)) {
1529 $internal_link = $row["internal_link"];
1530 include_once "./Modules/SurveyQuestionPool/classes/class.SurveyQuestion.php";
1531 $resolved_link = self::_resolveInternalLink($internal_link);
1532 if (strcmp($internal_link, $resolved_link) != 0) {
1533 // internal link was resolved successfully
1534 $affectedRows = $ilDB->manipulateF(
1535 "UPDATE svy_material SET internal_link = %s, tstamp = %s WHERE material_id = %s",
1536 array('text', 'integer', 'integer'),
1537 array($resolved_link, time(), $row["material_id"])
1538 );
1539 $resolvedlinks++;
1540 }
1541 }
1542 }
1543 if ($resolvedlinks) {
1544 // there are resolved links -> reenter theses links to the database
1545
1546 // delete all internal links from the database
1547 include_once "./Services/Link/classes/class.ilInternalLink.php";
1548 ilInternalLink::_deleteAllLinksOfSource("sqst", $question_id);
1549
1550 $result = $ilDB->queryF(
1551 "SELECT * FROM svy_material WHERE question_fi = %s",
1552 array('integer'),
1553 array($question_id)
1554 );
1555 if ($result->numRows()) {
1556 while ($row = $ilDB->fetchAssoc($result)) {
1557 if (preg_match("/il_(\d*?)_(\w+)_(\d+)/", $row["internal_link"], $matches)) {
1558 ilInternalLink::_saveLink("sqst", $question_id, $matches[2], $matches[3], $matches[1]);
1559 }
1560 }
1561 }
1562 }
1563 }
static _resolveInternalLink($internal_link)

References $DIC, $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 1326 of file class.SurveyQuestion.php.

1327 {
1328 if (strlen($material_id)) {
1329 if (strcmp($material_title, "") == 0) {
1330 if (preg_match("/il__(\w+)_(\d+)/", $material_id, $matches)) {
1331 $type = $matches[1];
1332 $target_id = $matches[2];
1333 $material_title = $this->lng->txt("obj_$type") . ": ";
1334 switch ($type) {
1335 case "lm":
1336 include_once("./Modules/LearningModule/classes/class.ilObjContentObjectGUI.php");
1337 $cont_obj_gui = new ilObjContentObjectGUI("", $target_id, true);
1338 $cont_obj = $cont_obj_gui->object;
1339 $material_title .= $cont_obj->getTitle();
1340 break;
1341 case "pg":
1342 include_once("./Modules/LearningModule/classes/class.ilLMPageObject.php");
1343 include_once("./Modules/LearningModule/classes/class.ilLMObject.php");
1345 include_once("./Modules/LearningModule/classes/class.ilObjContentObjectGUI.php");
1346 $cont_obj_gui = new ilObjContentObjectGUI("", $lm_id, false);
1347 $cont_obj = $cont_obj_gui->object;
1348 $pg_obj = new ilLMPageObject($cont_obj, $target_id);
1349 $material_title .= $pg_obj->getTitle();
1350 break;
1351 case "st":
1352 include_once("./Modules/LearningModule/classes/class.ilStructureObject.php");
1353 include_once("./Modules/LearningModule/classes/class.ilLMObject.php");
1355 include_once("./Modules/LearningModule/classes/class.ilObjContentObjectGUI.php");
1356 $cont_obj_gui = new ilObjContentObjectGUI("", $lm_id, false);
1357 $cont_obj = $cont_obj_gui->object;
1358 $st_obj = new ilStructureObject($cont_obj, $target_id);
1359 $material_title .= $st_obj->getTitle();
1360 break;
1361 case "git":
1362 include_once "./Modules/Glossary/classes/class.ilGlossaryTerm.php";
1363 $material_title = $this->lng->txt("glossary_term") . ": " . ilGlossaryTerm::_lookGlossaryTerm($target_id);
1364 break;
1365 case "mob":
1366 break;
1367 }
1368 }
1369 }
1370 include_once "./Modules/SurveyQuestionPool/classes/class.ilSurveyMaterial.php";
1371 $mat = new ilSurveyMaterial();
1372 $mat->type = 0;
1373 $mat->internal_link = $material_id;
1374 $mat->title = $material_title;
1375 $this->addMaterial($mat);
1376 $this->saveMaterial();
1377 }
1378 }
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, $type, ilGlossaryTerm\_lookGlossaryTerm(), ilLMObject\_lookupContObjID(), addMaterial(), and saveMaterial().

+ Here is the call graph for this function:

◆ addMaterial()

SurveyQuestion::addMaterial (   $obj_material)

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

1415 {
1416 array_push($this->material, $obj_material);
1417 }

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 330 of file class.SurveyQuestion.php.

331 {
332 if (empty($materials_name)) {
333 $materials_name = $materials_file;
334 }
335 if ((!empty($materials_name))&&(!array_key_exists($materials_name, $this->materials))) {
336 $this->materials[$materials_name] = $materials_file;
337 }
338 }

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 1841 of file class.SurveyQuestion.php.

1842 {
1843 include_once "./Services/RTE/classes/class.ilRTE.php";
1844 include_once("./Services/MediaObjects/classes/class.ilObjMediaObject.php");
1845
1846 $a_xml_writer->xmlStartTag("material");
1847 $attrs = array(
1848 "type" => "text/plain"
1849 );
1850 if ($this->isHTML($a_material)) {
1851 $attrs["type"] = "text/xhtml";
1852 }
1853 if (is_array($a_attrs)) {
1854 $attrs = array_merge($attrs, $a_attrs);
1855 }
1856 $a_xml_writer->xmlElement("mattext", $attrs, ilRTE::_replaceMediaObjectImageSrc($a_material, 0));
1857
1858 if ($add_mobs) {
1859 $mobs = ilObjMediaObject::_getMobsOfObject("spl:html", $this->getId());
1860 foreach ($mobs as $mob) {
1861 $mob_obj = new ilObjMediaObject($mob);
1862 $imgattrs = array(
1863 "label" => "il_" . IL_INST_ID . "_mob_" . $mob,
1864 "uri" => "objects/" . "il_" . IL_INST_ID . "_mob_" . $mob . "/" . $mob_obj->getTitle(),
1865 "type" => "spl:html",
1866 "id" => $this->getId()
1867 );
1868 $a_xml_writer->xmlElement("matimage", $imgattrs, null);
1869 }
1870 }
1871 if ($close_material_tag) {
1872 $a_xml_writer->xmlEndTag("material");
1873 }
1874 }
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 627 of file class.SurveyQuestion.php.

628 {
629 if ($this->getId() <= 0) {
630 // The question has not been saved. It cannot be copied
631 return;
632 }
633 $clone = $this;
634 $original_id = self::_getOriginalId($this->getId(), false);
635 $clone->setId(-1);
636 $source_questionpool = $this->getObjId();
637 $clone->setObjId($target_questionpool);
638 if ($title) {
639 $clone->setTitle($title);
640 }
641
642 $clone->saveToDb();
643
644 // duplicate the materials
645 $clone->duplicateMaterials($original_id);
646 // copy XHTML media objects
647 $clone->copyXHTMLMediaObjectsOfQuestion($original_id);
648 return $clone->getId();
649 }
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 657 of file class.SurveyQuestion.php.

658 {
659 include_once("./Services/MediaObjects/classes/class.ilObjMediaObject.php");
660 $mobs = ilObjMediaObject::_getMobsOfObject("spl:html", $a_q_id);
661 foreach ($mobs as $mob) {
662 ilObjMediaObject::_saveUsage($mob, "spl:html", $this->getId());
663 }
664 }
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 854 of file class.SurveyQuestion.php.

855 {
857
858 $obj_id = $this->getObjId();
859 if ($obj_id > 0) {
860 $next_id = $ilDB->nextId('svy_question');
861 $affectedRows = $ilDB->manipulateF(
862 "INSERT INTO svy_question (question_id, questiontype_fi, " .
863 "obj_fi, owner_fi, title, description, author, questiontext, obligatory, complete, " .
864 "created, original_id, tstamp) VALUES " .
865 "(%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)",
866 array('integer', 'integer', 'integer', 'integer', 'text', 'text', 'text', 'text',
867 'text', 'text', 'integer', 'integer', 'integer'),
868 array(
869 $next_id,
870 $this->getQuestionTypeID(),
871 $obj_id,
872 $this->getOwner(),
873 null,
874 null,
875 $this->getAuthor(),
876 null,
877 "1",
878 "0",
879 time(),
880 null,
881 0
882 )
883 );
884 $this->log->debug("INSERT INTO svy_question question_id= " . $next_id . " questiontype_fi= " . $this->getQuestionTypeID());
885
886 $this->setId($next_id);
887 }
888 return $this->getId();
889 }
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 $db, $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 1018 of file class.SurveyQuestion.php.

1019 {
1020 $ilDB = $this->db;
1021
1022 if ($question_id < 1) {
1023 return;
1024 }
1025
1026 $result = $ilDB->queryF(
1027 "SELECT obj_fi FROM svy_question WHERE question_id = %s",
1028 array('integer'),
1029 array($question_id)
1030 );
1031 if ($result->numRows() == 1) {
1032 $row = $ilDB->fetchAssoc($result);
1033 $obj_id = $row["obj_fi"];
1034 } else {
1035 return;
1036 }
1037
1038 $affectedRows = $ilDB->manipulateF(
1039 "DELETE FROM svy_answer WHERE question_fi = %s",
1040 array('integer'),
1041 array($question_id)
1042 );
1043
1044 $affectedRows = $ilDB->manipulateF(
1045 "DELETE FROM svy_constraint WHERE question_fi = %s",
1046 array('integer'),
1047 array($question_id)
1048 );
1049
1050 $result = $ilDB->queryF(
1051 "SELECT constraint_fi FROM svy_qst_constraint WHERE question_fi = %s",
1052 array('integer'),
1053 array($question_id)
1054 );
1055 while ($row = $ilDB->fetchObject($result)) {
1056 $affectedRows = $ilDB->manipulateF(
1057 "DELETE FROM svy_constraint WHERE constraint_id = %s",
1058 array('integer'),
1059 array($row->constraint_fi)
1060 );
1061 }
1062
1063 $affectedRows = $ilDB->manipulateF(
1064 "DELETE FROM svy_qst_constraint WHERE question_fi = %s",
1065 array('integer'),
1066 array($question_id)
1067 );
1068 $affectedRows = $ilDB->manipulateF(
1069 "DELETE FROM svy_qblk_qst WHERE question_fi = %s",
1070 array('integer'),
1071 array($question_id)
1072 );
1073 $affectedRows = $ilDB->manipulateF(
1074 "DELETE FROM svy_svy_qst WHERE question_fi = %s",
1075 array('integer'),
1076 array($question_id)
1077 );
1078 $affectedRows = $ilDB->manipulateF(
1079 "DELETE FROM svy_variable WHERE question_fi = %s",
1080 array('integer'),
1081 array($question_id)
1082 );
1083 $affectedRows = $ilDB->manipulateF(
1084 "DELETE FROM svy_question WHERE question_id = %s",
1085 array('integer'),
1086 array($question_id)
1087 );
1088
1089 $this->deleteAdditionalTableData($question_id);
1090
1091 $affectedRows = $ilDB->manipulateF(
1092 "DELETE FROM svy_material WHERE question_fi = %s",
1093 array('integer'),
1094 array($question_id)
1095 );
1096
1097 $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);
1098
1099 include_once "./Services/Link/classes/class.ilInternalLink.php";
1100 ilInternalLink::_deleteAllLinksOfSource("sqst", $question_id);
1101
1102 $directory = CLIENT_WEB_DIR . "/survey/" . $obj_id . "/$question_id";
1103 if (preg_match("/\d+/", $obj_id) and preg_match("/\d+/", $question_id) and is_dir($directory)) {
1104 ilUtil::delDir($directory);
1105 }
1106
1107 include_once("./Services/MediaObjects/classes/class.ilObjMediaObject.php");
1108 $mobs = ilObjMediaObject::_getMobsOfObject("spl:html", $question_id);
1109 // remaining usages are not in text anymore -> delete them
1110 // and media objects (note: delete method of ilObjMediaObject
1111 // checks whether object is used in another context; if yes,
1112 // the object is not deleted!)
1113 foreach ($mobs as $mob) {
1114 ilObjMediaObject::_removeUsage($mob, "spl:html", $question_id);
1115 $mob_obj = new ilObjMediaObject($mob);
1116 $mob_obj->delete();
1117 }
1118
1119 include_once("./Modules/Survey/classes/class.ilSurveySkill.php");
1121
1122 $this->log->debug("UPDATE svy_question");
1123
1124 // #12772 - untie question copies from pool question
1125 $ilDB->manipulate("UPDATE svy_question" .
1126 " SET original_id = NULL" .
1127 " WHERE original_id = " . $ilDB->quote($question_id, "integer"));
1128 }
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 $db, $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 999 of file class.SurveyQuestion.php.

1000 {
1001 $ilDB = $this->db;
1002
1003 $this->log->debug("DELETE FROM " . $this->getAdditionalTableName());
1004
1005 $affectedRows = $ilDB->manipulateF(
1006 "DELETE FROM " . $this->getAdditionalTableName() . " WHERE question_fi = %s",
1007 array('integer'),
1008 array($question_id)
1009 );
1010 }

References $db, and $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 373 of file class.SurveyQuestion.php.

374 {
375 foreach ($this->materials as $key => $value) {
376 if (strcmp($key, $materials_name)==0) {
377 if (file_exists($this->getMaterialsPath() . $value)) {
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 $key, and 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 1385 of file class.SurveyQuestion.php.

1386 {
1387 foreach ($a_array as $idx) {
1388 unset($this->material[$idx]);
1389 }
1390 $this->material = array_values($this->material);
1391 $this->saveMaterial();
1392 }

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 588 of file class.SurveyQuestion.php.

589 {
590 if ($this->getId() <= 0) {
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 $clone->setObjId($a_survey_id);
600 }
601 if ($title) {
602 $clone->setTitle($title);
603 }
604 if ($author) {
605 $clone->setAuthor($author);
606 }
607 if ($owner) {
608 $clone->setOwner($owner);
609 }
610 if ($for_survey) {
611 $clone->saveToDb($original_id);
612 } else {
613 $clone->saveToDb();
614 }
615 // duplicate the materials
616 $clone->duplicateMaterials($original_id);
617 // copy XHTML media objects
618 $clone->copyXHTMLMediaObjectsOfQuestion($original_id);
619 return $clone->getId();
620 }

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 1400 of file class.SurveyQuestion.php.

1401 {
1402 foreach ($this->materials as $filename) {
1403 $materialspath = $this->getMaterialsPath();
1404 $materialspath_original = preg_replace("/([^\d])$this->id([^\d])/", "\${1}$question_id\${2}", $materialspath);
1405 if (!file_exists($materialspath)) {
1406 ilUtil::makeDirParents($materialspath);
1407 }
1408 if (!copy($materialspath_original . $filename, $materialspath . $filename)) {
1409 print "material could not be duplicated!!!! ";
1410 }
1411 }
1412 }
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 1976 of file class.SurveyQuestion.php.

1977 {
1978 // overwrite in inherited classes
1979 return array();
1980 }

◆ getCopyIds()

SurveyQuestion::getCopyIds (   $a_group_by_survey = false)

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

2091 {
2092 $ilDB = $this->db;
2093
2094 $set = $ilDB->query("SELECT q.question_id,s.obj_fi" .
2095 " FROM svy_question q" .
2096 " JOIN svy_svy_qst sq ON (sq.question_fi = q.question_id)" .
2097 " JOIN svy_svy s ON (s.survey_id = sq.survey_fi)" .
2098 " WHERE original_id = " . $ilDB->quote($this->getId(), "integer"));
2099 $res = array();
2100 while ($row = $ilDB->fetchAssoc($set)) {
2101 if (!$a_group_by_survey) {
2102 $res[] = $row["question_id"];
2103 } else {
2104 $res[$row["obj_fi"]][] = $row["question_id"];
2105 }
2106 }
2107 return $res;
2108 }
foreach($_POST as $key=> $value) $res

References $db, $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 461 of file class.SurveyQuestion.php.

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

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 907 of file class.SurveyQuestion.php.

908 {
909 return CLIENT_WEB_DIR . "/survey/$this->obj_id/$this->id/images/";
910 }

◆ 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 929 of file class.SurveyQuestion.php.

930 {
931 $webdir = ilUtil::removeTrailingPathSeparators(CLIENT_WEB_DIR) . "/survey/$this->obj_id/$this->id/images/";
932 return str_replace(ilUtil::removeTrailingPathSeparators(ILIAS_ABSOLUTE_PATH), ilUtil::removeTrailingPathSeparators(ILIAS_HTTP_PATH), $webdir);
933 }

References ilUtil\removeTrailingPathSeparators().

+ Here is the call graph for this function:

◆ getLabel()

SurveyQuestion::getLabel ( )

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

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

◆ getMaterial()

SurveyQuestion::getMaterial ( )

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

2028 {
2029 return $this->material;
2030 }

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 918 of file class.SurveyQuestion.php.

919 {
920 return CLIENT_WEB_DIR . "/survey/$this->obj_id/$this->id/materials/";
921 }

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 941 of file class.SurveyQuestion.php.

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

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.

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

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 472 of file class.SurveyQuestion.php.

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

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 496 of file class.SurveyQuestion.php.

497 {
498 switch ($this->orientation) {
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 2022 of file class.SurveyQuestion.php.

2023 {
2024 return $this->original_id;
2025 }

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 1266 of file class.SurveyQuestion.php.

1267 {
1268 $ilDB = $this->db;
1269
1270 $result = $ilDB->queryF(
1271 "SELECT title FROM svy_phrase WHERE phrase_id = %s",
1272 array('integer'),
1273 array($phrase_id)
1274 );
1275 if ($row = $ilDB->fetchAssoc($result)) {
1276 return $row["title"];
1277 }
1278 return "";
1279 }

References $db, $ilDB, $result, and $row.

◆ getPreconditionOptions()

SurveyQuestion::getPreconditionOptions ( )

Returns the options for preconditions.

Returns
array

Reimplemented in SurveyMultipleChoiceQuestion, and SurveySingleChoiceQuestion.

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

1988 {
1989 // overwrite in inherited classes
1990 }

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 2011 of file class.SurveyQuestion.php.

2012 {
2013 // overwrite in inherited classes
2014 return null;
2015 }

◆ 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 1999 of file class.SurveyQuestion.php.

2000 {
2001 // overwrite in inherited classes
2002 return $value;
2003 }

◆ 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 1894 of file class.SurveyQuestion.php.

1895 {
1896 return array();
1897 }

◆ 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 1661 of file class.SurveyQuestion.php.

1662 {
1663 return "";
1664 }

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 1639 of file class.SurveyQuestion.php.

1640 {
1641 $ilDB = $this->db;
1642 $result = $ilDB->queryF(
1643 "SELECT questiontype_id FROM svy_qtype WHERE type_tag = %s",
1644 array('text'),
1645 array($this->getQuestionType())
1646 );
1647 if ($result->numRows() == 1) {
1648 $row = $ilDB->fetchAssoc($result);
1649 return $row["questiontype_id"];
1650 } else {
1651 return 0;
1652 }
1653 }
getQuestionType()
Returns the question type of the question.

References $db, $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 2037 of file class.SurveyQuestion.php.

2038 {
2039 // do nothing
2040 return null;
2041 }

◆ 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 484 of file class.SurveyQuestion.php.

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

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 1905 of file class.SurveyQuestion.php.

1906 {
1907 // overwrite in inherited classes
1908 $data = array();
1909 return $data;
1910 }

References $data.

◆ hasCopies()

SurveyQuestion::hasCopies ( )

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

2111 {
2112 return (bool) sizeof($this->getCopyIds());
2113 }
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 1920 of file class.SurveyQuestion.php.

1921 {
1922 // overwrite in inherited classes
1923 }

◆ 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 1942 of file class.SurveyQuestion.php.

1943 {
1944 // overwrite in inherited classes
1945 }

◆ 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 1953 of file class.SurveyQuestion.php.

1954 {
1955 // overwrite in inherited classes
1956 }

◆ 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 1931 of file class.SurveyQuestion.php.

1932 {
1933 // overwrite in inherited classes
1934 }

◆ 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 218 of file class.SurveyQuestion.php.

219 {
220 return 0;
221 }

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 1792 of file class.SurveyQuestion.php.

1793 {
1794 if (preg_match("/<[^>]*?>/", $a_text)) {
1795 return true;
1796 } else {
1797 return false;
1798 }
1799 }

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 672 of file class.SurveyQuestion.php.

673 {
675
676 $result = $ilDB->queryF(
677 "SELECT * FROM svy_material WHERE question_fi = %s",
678 array('integer'),
679 array($this->getId())
680 );
681 $this->material = array();
682 if ($result->numRows()) {
683 include_once "./Modules/SurveyQuestionPool/classes/class.ilSurveyMaterial.php";
684 while ($row = $ilDB->fetchAssoc($result)) {
685 $mat = new ilSurveyMaterial();
686 $mat->type = $row['material_type'];
687 $mat->internal_link = $row['internal_link'];
688 $mat->title = $row['material_title'];
689 $mat->import_id = $row['import_id'];
690 $mat->text_material = $row['text_material'];
691 $mat->external_link = $row['external_link'];
692 $mat->file_material = $row['file_material'];
693 array_push($this->material, $mat);
694 }
695 }
696 }

References $db, $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 2136 of file class.SurveyQuestion.php.

2137 {
2138 global $DIC;
2139
2140 $ilDB = $DIC->database();
2141
2142 $set = $ilDB->query(
2143 "SELECT obj_fi FROM svy_question " .
2144 " WHERE question_id = " . $ilDB->quote($a_qid, "integer")
2145 );
2146 $rec = $ilDB->fetchAssoc($set);
2147 return $rec["obj_fi"];
2148 }

References $DIC, and $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 1288 of file class.SurveyQuestion.php.

1289 {
1291 $ilDB = $this->db;
1292
1293 $result = $ilDB->queryF(
1294 "SELECT phrase_id FROM svy_phrase WHERE title = %s AND owner_fi = %s",
1295 array('text', 'integer'),
1296 array($title, $ilUser->getId())
1297 );
1298 return ($result->numRows() == 0) ? false : true;
1299 }

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

◆ 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 1882 of file class.SurveyQuestion.php.

1883 {
1884 return ilUtil::prepareTextareaOutput($txt_output, $prepare_for_latex_output);
1885 }
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 1808 of file class.SurveyQuestion.php.

1809 {
1810 $svy_log = ilLoggerFactory::getLogger("svy");
1811 $svy_log->debug("material count: " . $a_material->getMaterialCount());
1812
1813 $result = "";
1814 for ($i = 0; $i < $a_material->getMaterialCount(); $i++) {
1815 $material = $a_material->getMaterial($i);
1816 if (strcmp($material["type"], "mattext") == 0) {
1817 $result .= $material["material"]->getContent();
1818 }
1819 if (strcmp($material["type"], "matimage") == 0) {
1820 $matimage = $material["material"];
1821 if (preg_match("/(il_([0-9]+)_mob_([0-9]+))/", $matimage->getLabel(), $matches)) {
1822 // import an mediaobject which was inserted using tiny mce
1823 if (!is_array($_SESSION["import_mob_xhtml"])) {
1824 $_SESSION["import_mob_xhtml"] = array();
1825 }
1826 array_push($_SESSION["import_mob_xhtml"], array("mob" => $matimage->getLabel(), "uri" => $matimage->getUri()));
1827 }
1828 }
1829 }
1830 return $result;
1831 }
$_SESSION["AccountId"]
$i
Definition: disco.tpl.php:19

References $_SESSION, $i, $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 231 of file class.SurveyQuestion.php.

232 {
234
235 $refwhere = "";
236 if (strcmp($questionpool_object, "") != 0) {
237 $refwhere = sprintf(
238 " AND obj_fi = %s",
239 $ilDB->quote($questionpool_object, 'integer')
240 );
241 }
242 $result = $ilDB->queryF(
243 "SELECT question_id FROM svy_question WHERE title = %s$refwhere",
244 array('text'),
245 array($title)
246 );
247 return ($result->numRows() > 0) ? true : false;
248 }
sprintf('%.4f', $callTime)

References $db, $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 955 of file class.SurveyQuestion.php.

956 {
959
960 $result = $ilDB->queryF(
961 "SELECT title, category_id FROM svy_category WHERE title = %s AND neutral = %s AND owner_fi = %s",
962 array('text','text','integer'),
963 array($categorytext, $neutral, $ilUser->getId())
964 );
965 $insert = false;
966 $returnvalue = "";
967 if ($result->numRows()) {
968 $insert = true;
969 while ($row = $ilDB->fetchAssoc($result)) {
970 if (strcmp($row["title"], $categorytext) == 0) {
971 $returnvalue = $row["category_id"];
972 $insert = false;
973 }
974 }
975 } else {
976 $insert = true;
977 }
978 if ($insert) {
979 $next_id = $ilDB->nextId('svy_category');
980 $affectedRows = $ilDB->manipulateF(
981 "INSERT INTO svy_category (category_id, title, neutral, owner_fi, tstamp) VALUES (%s, %s, %s, %s, %s)",
982 array('integer','text','text','integer','integer'),
983 array($next_id, $categorytext, $neutral, $ilUser->getId(), time())
984 );
985
986 $this->log->debug("INSERT INTO svy_category id=" . $next_id);
987
988 $returnvalue = $next_id;
989 }
990 return $returnvalue;
991 }
$insert

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

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 729 of file class.SurveyQuestion.php.

730 {
732
733 $question_id = $this->getId();
734 if (strlen($original_id)) {
735 $question_id = $original_id;
736 }
737
738 if ($this->getId() > 0) {
739 $this->log->debug("UPDATE svy_question question_id=" . $question_id);
740
741 // update existing dataset
742 $affectedRows = $ilDB->manipulateF(
743 "UPDATE svy_question SET complete = %s, tstamp = %s WHERE question_id = %s",
744 array('text', 'integer', 'integer'),
745 array($this->isComplete(), time(), $question_id)
746 );
747 }
748 }
isComplete()
Returns 1, if a question is complete for use.

References $db, $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 811 of file class.SurveyQuestion.php.

812 {
814
815 include_once "./Services/Link/classes/class.ilInternalLink.php";
816
817 $this->log->debug("DELETE: svy_material question_fi=" . $this->getId());
818
819 $affectedRows = $ilDB->manipulateF(
820 "DELETE FROM svy_material WHERE question_fi = %s",
821 array('integer'),
822 array($this->getId())
823 );
825
826 foreach ($this->material as $material) {
827 $next_id = $ilDB->nextId('svy_material');
828
829 $this->log->debug("INSERT: svy_material question_fi=" . $this->getId());
830
831 $affectedRows = $ilDB->manipulateF(
832 "INSERT INTO svy_material " .
833 "(material_id, question_fi, internal_link, import_id, material_title, tstamp," .
834 "text_material, external_link, file_material, material_type) " .
835 "VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s)",
836 array('integer','integer','text','text','text','integer','text','text','text','integer'),
837 array(
838 $next_id, $this->getId(), $material->internal_link, $material->import_id,
839 $material->title, time(), $material->text_material, $material->external_link,
840 $material->file_material, $material->type)
841 );
842 if (preg_match("/il_(\d*?)_(\w+)_(\d+)/", $material->internal_link, $matches)) {
843 ilInternalLink::_saveLink("sqst", $this->getId(), $matches[2], $matches[3], $matches[1]);
844 }
845 }
846 }

References $db, $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 756 of file class.SurveyQuestion.php.

757 {
759
760 // cleanup RTE images which are not inserted into the question text
761 include_once("./Services/RTE/classes/class.ilRTE.php");
762 ilRTE::_cleanupMediaObjectUsage($this->getQuestiontext(), "spl:html", $this->getId());
763 $affectedRows = 0;
764 if ($this->getId() == -1) {
765 // Write new dataset
766 $next_id = $ilDB->nextId('svy_question');
767 $affectedRows = $ilDB->insert("svy_question", array(
768 "question_id" => array("integer", $next_id),
769 "questiontype_fi" => array("integer", $this->getQuestionTypeID()),
770 "obj_fi" => array("integer", $this->getObjId()),
771 "owner_fi" => array("integer", $this->getOwner()),
772 "title" => array("text", $this->getTitle()),
773 "label" => array("text", (strlen($this->label)) ? $this->label : null),
774 "description" => array("text", $this->getDescription()),
775 "author" => array("text", $this->getAuthor()),
776 "questiontext" => array("clob", ilRTE::_replaceMediaObjectImageSrc($this->getQuestiontext(), 0)),
777 "obligatory" => array("text", $this->getObligatory()),
778 "complete" => array("text", $this->isComplete()),
779 "created" => array("integer", time()),
780 "original_id" => array("integer", ($original_id) ? $original_id : null),
781 "tstamp" => array("integer", time())
782 ));
783
784 //$this->log->debug("INSERT: svy_question id=".$next_id." questiontype_fi=".$this->getQuestionTypeID()." obj_fi".$this->getObjId()." title=".$this->getTitle()." ...");
785
786 $this->setId($next_id);
787 } else {
788 // update existing dataset
789 $affectedRows = $ilDB->update("svy_question", array(
790 "title" => array("text", $this->getTitle()),
791 "label" => array("text", (strlen($this->label)) ? $this->label : null),
792 "description" => array("text", $this->getDescription()),
793 "author" => array("text", $this->getAuthor()),
794 "questiontext" => array("clob", ilRTE::_replaceMediaObjectImageSrc($this->getQuestiontext(), 0)),
795 "obligatory" => array("text", $this->getObligatory()),
796 "complete" => array("text", $this->isComplete()),
797 "tstamp" => array("integer", time())
798 ), array(
799 "question_id" => array("integer", $this->getId())
800 ));
801
802 $this->log->debug("UPDATE svy_question id=" . $this->getId() . " SET: title=" . $this->getTitle() . " ...");
803 }
804
805 return $affectedRows;
806 }
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 $db, $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 897 of file class.SurveyQuestion.php.

898 {
899 }

◆ 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 {
406
407 if (!$author) {
408 $author = $ilUser->fullname;
409 }
410 $this->author = $author;
411 }

References $author, $ilUser, and $user.

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 207 of file class.SurveyQuestion.php.

208 {
209 $this->complete = ($a_complete) ? 1 : 0;
210 }

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 317 of file class.SurveyQuestion.php.

318 {
319 $this->description = $description;
320 }

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 293 of file class.SurveyQuestion.php.

294 {
295 $this->id = $id;
296 }

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 1426 of file class.SurveyQuestion.php.

1427 {
1428 if (strcmp($material_id, "") != 0) {
1429 $import_id = "";
1430 if ($is_import) {
1431 $import_id = $material_id;
1432 $material_id = self::_resolveInternalLink($import_id);
1433 }
1434 if (strcmp($material_title, "") == 0) {
1435 if (preg_match("/il__(\w+)_(\d+)/", $material_id, $matches)) {
1436 $type = $matches[1];
1437 $target_id = $matches[2];
1438 $material_title = $this->lng->txt("obj_$type") . ": ";
1439 switch ($type) {
1440 case "lm":
1441 include_once("./Modules/LearningModule/classes/class.ilObjContentObjectGUI.php");
1442 $cont_obj_gui = new ilObjContentObjectGUI("", $target_id, true);
1443 $cont_obj = $cont_obj_gui->object;
1444 $material_title .= $cont_obj->getTitle();
1445 break;
1446 case "pg":
1447 include_once("./Modules/LearningModule/classes/class.ilLMPageObject.php");
1448 include_once("./Modules/LearningModule/classes/class.ilLMObject.php");
1450 include_once("./Modules/LearningModule/classes/class.ilObjContentObjectGUI.php");
1451 $cont_obj_gui = new ilObjContentObjectGUI("", $lm_id, false);
1452 $cont_obj = $cont_obj_gui->object;
1453 $pg_obj = new ilLMPageObject($cont_obj, $target_id);
1454 $material_title .= $pg_obj->getTitle();
1455 break;
1456 case "st":
1457 include_once("./Modules/LearningModule/classes/class.ilStructureObject.php");
1458 include_once("./Modules/LearningModule/classes/class.ilLMObject.php");
1460 include_once("./Modules/LearningModule/classes/class.ilObjContentObjectGUI.php");
1461 $cont_obj_gui = new ilObjContentObjectGUI("", $lm_id, false);
1462 $cont_obj = $cont_obj_gui->object;
1463 $st_obj = new ilStructureObject($cont_obj, $target_id);
1464 $material_title .= $st_obj->getTitle();
1465 break;
1466 case "git":
1467 include_once "./Modules/Glossary/classes/class.ilGlossaryTerm.php";
1468 $material_title = $this->lng->txt("glossary_term") . ": " . ilGlossaryTerm::_lookGlossaryTerm($target_id);
1469 break;
1470 case "mob":
1471 break;
1472 }
1473 }
1474 }
1475 $this->material = array(
1476 "internal_link" => $material_id,
1477 "import_id" => $import_id,
1478 "title" => $material_title
1479 );
1480 }
1481 $this->saveMaterial();
1482 }

References $target_id, $type, 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 347 of file class.SurveyQuestion.php.

348 {
349 if (!empty($materials_filename)) {
350 $materialspath = $this->getMaterialsPath();
351 if (!file_exists($materialspath)) {
352 ilUtil::makeDirParents($materialspath);
353 }
354 if (ilUtil::moveUploadedFile(
355 $materials_tempfilename,
356 $materials_filename,
357 $materialspath . $materials_filename
358 )) {
359 print "image not uploaded!!!! ";
360 } else {
361 $this->addMaterials($materials_filename, $materials_name);
362 }
363 }
364 }
addMaterials($materials_file, $materials_name="")
Sets the materials uri.

References addMaterials(), getMaterialsPath(), ilUtil\makeDirParents(), 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 578 of file class.SurveyQuestion.php.

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

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 269 of file class.SurveyQuestion.php.

270 {
271 $this->obligatory = ($obligatory) ? 1 : 0;
272 }

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 281 of file class.SurveyQuestion.php.

282 {
283 $this->orientation = ($orientation) ? $orientation : 0;
284 }

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 2017 of file class.SurveyQuestion.php.

2018 {
2019 $this->original_id = $original_id;
2020 }

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 432 of file class.SurveyQuestion.php.

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

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 420 of file class.SurveyQuestion.php.

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

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 2032 of file class.SurveyQuestion.php.

2033 {
2034 // do nothing
2035 }

◆ 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 305 of file class.SurveyQuestion.php.

306 {
307 $this->survey_id = $id;
308 }

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 257 of file class.SurveyQuestion.php.

258 {
259 $this->title = $title;
260 }

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 2157 of file class.SurveyQuestion.php.

2158 {
2159 $str = ilUtil::stripSlashes($a_str);
2160 if ($str != $a_str) {
2161 $str = ilUtil::stripSlashes(str_replace("<", "< ", $a_str));
2162 }
2163 return $str;
2164 }
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 1219 of file class.SurveyQuestion.php.

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

References $db, $id, $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 1964 of file class.SurveyQuestion.php.

1965 {
1966 // overwrite in inherited classes
1967 return false;
1968 }

Field Documentation

◆ $arrData

SurveyQuestion::$arrData
private

data array containing the question data

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

◆ $author

◆ $complete

SurveyQuestion::$complete

Definition at line 138 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 143 of file class.SurveyQuestion.php.

◆ $db

◆ $description

◆ $id

◆ $lng

◆ $log

SurveyQuestion::$log
protected

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

◆ $material

◆ $materials

SurveyQuestion::$materials

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

◆ $obj_id

SurveyQuestion::$obj_id

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

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

◆ $obligatory

SurveyQuestion::$obligatory

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

Referenced by setObligatory().

◆ $orientation

◆ $owner

◆ $questiontext

◆ $survey_id

◆ $title

◆ $tpl

SurveyQuestion::$tpl

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

Referenced by __construct().

◆ $user


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