ILIAS  release_7 Revision v7.30-3-g800a261c036
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...
 
static getMaxSumScore (int $survey_id)
 Get max sum score for specific survey (and this question type) More...
 

Data Fields

 $id
 
 $title
 
 $description
 
 $owner
 
 $author
 
 $materials
 
 $survey_id
 
 $obj_id
 
 $questiontext
 
 $obligatory
 
 $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 158 of file class.SurveyQuestion.php.

159 {
160 global $DIC;
161
162 $this->user = $DIC->user();
163 $this->db = $DIC->database();
164 $lng = $DIC->language();
165 $ilUser = $DIC->user();
166
167 $this->lng = $lng;
168 $this->complete = 0;
169 $this->title = $title;
170 $this->description = $description;
171 $this->questiontext = $questiontext;
172 $this->author = $author;
173 $this->cumulated = array();
174 if (!$this->author) {
175 $this->author = $ilUser->fullname;
176 }
177 $this->owner = $owner;
178 if ($this->owner == -1) {
179 $this->owner = $ilUser->getId();
180 }
181 $this->id = -1;
182 $this->survey_id = -1;
183 $this->obligatory = 1;
184 $this->orientation = 0;
185 $this->materials = array();
186 $this->material = array();
187 $this->arrData = array();
188
189 $this->log = ilLoggerFactory::getLogger('svy');
190 }
user()
Definition: user.php:4
static getLogger($a_component_id)
Get component logger.
global $DIC
Definition: goto.php:24
$ilUser
Definition: imgupload.php:18

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

+ Here is the call graph for this function:

Member Function Documentation

◆ __get()

SurveyQuestion::__get (   $value)

Object getter.

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

2008 {
2009 switch ($value) {
2010 default:
2011 if (array_key_exists($value, $this->arrData)) {
2012 return $this->arrData[$value];
2013 } else {
2014 return null;
2015 }
2016 break;
2017 }
2018 }

◆ __set()

SurveyQuestion::__set (   $key,
  $value 
)

Object setter.

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

2024 {
2025 switch ($key) {
2026 default:
2027 $this->arrData[$key] = $value;
2028 break;
2029 }
2030 }

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

2040 {
2041 global $DIC;
2042
2043 $ilDB = $DIC->database();
2044
2045 $ilDB->manipulate("UPDATE svy_question" .
2046 " SET original_id = " . $ilDB->quote($a_original_id, "integer") . "," .
2047 " obj_fi = " . $ilDB->quote($a_object_id, "integer") .
2048 " WHERE question_id = " . $ilDB->quote($a_question_id, "integer"));
2049 }
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 1532 of file class.SurveyQuestion.php.

1533 {
1534 global $DIC;
1535
1536 $ilDB = $DIC->database();
1537 $linktypes = array(
1538 "lm" => "LearningModule",
1539 "pg" => "PageObject",
1540 "st" => "StructureObject",
1541 "git" => "GlossaryItem",
1542 "mob" => "MediaObject"
1543 );
1544 $href = "";
1545 if (preg_match("/il__(\w+)_(\d+)/", $target, $matches)) {
1546 $type = $matches[1];
1547 $target_id = $matches[2];
1548 switch ($linktypes[$matches[1]]) {
1549 case "LearningModule":
1550 $href = ilUtil::removeTrailingPathSeparators(ILIAS_HTTP_PATH) . "/goto.php?target=" . $type . "_" . $target_id;
1551 break;
1552 case "PageObject":
1553 case "StructureObject":
1554 $href = ilUtil::removeTrailingPathSeparators(ILIAS_HTTP_PATH) . "/goto.php?target=" . $type . "_" . $target_id;
1555 break;
1556 case "GlossaryItem":
1557 $href = ilUtil::removeTrailingPathSeparators(ILIAS_HTTP_PATH) . "/goto.php?target=" . $type . "_" . $target_id;
1558 break;
1559 case "MediaObject":
1560 $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;
1561 break;
1562 }
1563 }
1564 return $href;
1565 }
static removeTrailingPathSeparators($path)
$target_id
Definition: goto.php:51
$type

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

1181 {
1182 global $DIC;
1183
1184 $ilDB = $DIC->database();
1185 $result = $ilDB->queryF(
1186 "SELECT * FROM svy_question WHERE question_id = %s",
1187 array('integer'),
1188 array($question_id)
1189 );
1190 if ($result->numRows() > 0) {
1191 $row = $ilDB->fetchAssoc($result);
1192 if ($row["original_id"] > 0) {
1193 return $row["original_id"];
1194 } elseif ((bool) $a_return_question_id_if_no_original) { // #12419
1195 return $row["question_id"];
1196 }
1197 } else {
1198 return "";
1199 }
1200 }
$result

References $DIC, $ilDB, and $result.

Referenced by 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 1120 of file class.SurveyQuestion.php.

1121 {
1122 global $DIC;
1123
1124 $ilDB = $DIC->database();
1125
1126 if ($question_id < 1) {
1127 return "";
1128 }
1129
1130 $result = $ilDB->queryF(
1131 "SELECT type_tag FROM svy_question, svy_qtype WHERE svy_question.question_id = %s AND svy_question.questiontype_fi = svy_qtype.questiontype_id",
1132 array('integer'),
1133 array($question_id)
1134 );
1135 if ($result->numRows() == 1) {
1136 $data = $ilDB->fetchAssoc($result);
1137 return $data["type_tag"];
1138 } else {
1139 return "";
1140 }
1141 }
$data
Definition: storeScorm.php:23

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

1672 {
1673 if (file_exists("./Modules/SurveyQuestionPool/Questions/class." . $type_tag . ".php")) {
1674 global $DIC;
1675
1676 $lng = $DIC->language();
1677 return $lng->txt($type_tag);
1678 } else {
1679 global $DIC;
1680
1681 $ilPluginAdmin = $DIC["ilPluginAdmin"];
1682 $pl_names = $ilPluginAdmin->getActivePluginsForSlot(IL_COMP_MODULE, "SurveyQuestionPool", "svyq");
1683 foreach ($pl_names as $pl_name) {
1684 $pl = ilPlugin::getPluginObject(IL_COMP_MODULE, "SurveyQuestionPool", "svyq", $pl_name);
1685 if (strcmp($pl->getQuestionType(), $type_tag) == 0) {
1686 return $pl->getQuestionTypeTranslation();
1687 }
1688 }
1689 }
1690 return "";
1691 }
const IL_COMP_MODULE
static getPluginObject(string $a_ctype, string $a_cname, string $a_slot_id, string $a_pname)

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

1151 {
1152 global $DIC;
1153
1154 $ilDB = $DIC->database();
1155
1156 if ($question_id < 1) {
1157 return "";
1158 }
1159
1160 $result = $ilDB->queryF(
1161 "SELECT title FROM svy_question WHERE svy_question.question_id = %s",
1162 array('integer'),
1163 array($question_id)
1164 );
1165 if ($result->numRows() == 1) {
1166 $data = $ilDB->fetchAssoc($result);
1167 return $data["title"];
1168 } else {
1169 return "";
1170 }
1171 }

References $data, $DIC, $ilDB, and $result.

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

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

1640 {
1641 $type = $question_type;
1642 if ($gui == 1) {
1643 $type .= "GUI";
1644 } elseif ($gui == 2) {
1645 $type .= "Evaluation";
1646 }
1647 if (file_exists("./Modules/SurveyQuestionPool/Questions/class." . $type . ".php")) {
1648 return true;
1649 } else {
1650 global $DIC;
1651
1652 $ilPluginAdmin = $DIC["ilPluginAdmin"];
1653 $pl_names = $ilPluginAdmin->getActivePluginsForSlot(IL_COMP_MODULE, "SurveyQuestionPool", "svyq");
1654 foreach ($pl_names as $pl_name) {
1655 $pl = ilPlugin::getPluginObject(IL_COMP_MODULE, "SurveyQuestionPool", "svyq", $pl_name);
1656 if (strcmp($pl->getQuestionType(), $question_type) == 0) {
1657 $pl->includeClass("class." . $type . ".php");
1658 return true;
1659 }
1660 }
1661 }
1662 return false;
1663 }

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

1702 {
1703 $question_type = self::_getQuestionType($question_id);
1704 if ($question_type) {
1705 self::_includeClass($question_type);
1706 $question = new $question_type();
1707 $question->loadFromDb($question_id);
1708 return $question;
1709 }
1710 }
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(), SurveySingleChoiceQuestion\compressable(), 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 1737 of file class.SurveyQuestion.php.

1738 {
1739 $question = self::_instanciateQuestion($question_id);
1740 if ($question) {
1741 $question_type = self::_getQuestionType($question_id);
1742 self::_includeClass($question_type, 2);
1743 $class = $question_type . "Evaluation";
1744 $ev = new $class($question, $a_finished_ids);
1745 return $ev;
1746 }
1747 }
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(), ilSurveyEvaluationGUI\getSumScores(), ilObjSurvey\getUserSpecificResults(), ilSurveyEvaluationGUI\parseUserSpecificResults(), and ilSurveyEvaluationGUI\renderChartOnly().

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

1720 {
1721 $question_type = self::_getQuestionType($question_id);
1722 if ($question_type) {
1723 self::_includeClass($question_type, 1);
1724 $guitype = $question_type . "GUI";
1725 $question = new $guitype($question_id);
1726 return $question;
1727 }
1728 }

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

694 {
695 global $DIC;
696
697 $ilDB = $DIC->database();
698
699 $result = $ilDB->queryF(
700 "SELECT complete FROM svy_question WHERE question_id = %s",
701 array('integer'),
702 array($question_id)
703 );
704 if ($result->numRows()) {
705 $row = $ilDB->fetchAssoc($result);
706 if ($row["complete"] == 1) {
707 return true;
708 }
709 }
710 return false;
711 }

References $DIC, $ilDB, and $result.

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

1576 {
1577 global $DIC;
1578
1579 $ilDB = $DIC->database();
1580
1581 if (($question_id < 1) || ($user_id < 1)) {
1582 return false;
1583 }
1584
1585 $result = $ilDB->queryF(
1586 "SELECT obj_fi FROM svy_question WHERE question_id = %s",
1587 array('integer'),
1588 array($question_id)
1589 );
1590 if ($result->numRows() == 1) {
1591 $row = $ilDB->fetchAssoc($result);
1592 $qpl_object_id = $row["obj_fi"];
1593 return ilObjSurveyQuestionPool::_isWriteable($qpl_object_id, $user_id);
1594 } else {
1595 return false;
1596 }
1597 }
static _isWriteable($object_id, $user_id)
Returns true, if the question pool is writeable by a given user.

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

2077 {
2078 global $DIC;
2079
2080 $ilDB = $DIC->database();
2081
2082 $set = $ilDB->query("SELECT svy_svy.obj_fi FROM svy_svy_qst" .
2083 " JOIN svy_svy ON (svy_svy.survey_id = svy_svy_qst.survey_fi)" .
2084 " WHERE svy_svy_qst.question_fi = " . $ilDB->quote($a_question_id, "integer"));
2085 $row = $ilDB->fetchAssoc($set);
2086 if ($ilDB->numRows($set)) {
2087 return $row["obj_fi"];
2088 }
2089 }

References $DIC, and $ilDB.

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

1291 {
1292 global $DIC;
1293
1294 $ilDB = $DIC->database();
1295
1296 if ($question_id < 1) {
1297 return false;
1298 }
1299
1300 $result = $ilDB->queryF(
1301 "SELECT question_id FROM svy_question WHERE question_id = %s",
1302 array('integer'),
1303 array($question_id)
1304 );
1305 return ($result->numRows() == 1) ? true : false;
1306 }
return true
Flag indicating whether or not HTTP headers will be sent when outputting captcha image/audio.

References $DIC, $ilDB, $result, and true.

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

1457 {
1458 if (preg_match("/il_(\d+)_(\w+)_(\d+)/", $internal_link, $matches)) {
1459 switch ($matches[2]) {
1460 case "lm":
1461 $resolved_link = ilLMObject::_getIdForImportId($internal_link);
1462 break;
1463 case "pg":
1464 $resolved_link = ilInternalLink::_getIdForImportId("PageObject", $internal_link);
1465 break;
1466 case "st":
1467 $resolved_link = ilInternalLink::_getIdForImportId("StructureObject", $internal_link);
1468 break;
1469 case "git":
1470 $resolved_link = ilInternalLink::_getIdForImportId("GlossaryItem", $internal_link);
1471 break;
1472 case "mob":
1473 $resolved_link = ilInternalLink::_getIdForImportId("MediaObject", $internal_link);
1474 break;
1475 }
1476 if (strcmp($resolved_link, "") == 0) {
1477 $resolved_link = $internal_link;
1478 }
1479 } else {
1480 $resolved_link = $internal_link;
1481 }
1482 return $resolved_link;
1483 }
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 1485 of file class.SurveyQuestion.php.

1486 {
1487 global $DIC;
1488
1489 $ilDB = $DIC->database();
1490 $resolvedlinks = 0;
1491 $result = $ilDB->queryF(
1492 "SELECT * FROM svy_material WHERE question_fi = %s",
1493 array('integer'),
1494 array($question_id)
1495 );
1496 if ($result->numRows()) {
1497 while ($row = $ilDB->fetchAssoc($result)) {
1498 $internal_link = $row["internal_link"];
1499 $resolved_link = self::_resolveInternalLink($internal_link);
1500 if (strcmp($internal_link, $resolved_link) != 0) {
1501 // internal link was resolved successfully
1502 $affectedRows = $ilDB->manipulateF(
1503 "UPDATE svy_material SET internal_link = %s, tstamp = %s WHERE material_id = %s",
1504 array('text', 'integer', 'integer'),
1505 array($resolved_link, time(), $row["material_id"])
1506 );
1507 $resolvedlinks++;
1508 }
1509 }
1510 }
1511 if ($resolvedlinks) {
1512 // there are resolved links -> reenter theses links to the database
1513
1514 // delete all internal links from the database
1515 ilInternalLink::_deleteAllLinksOfSource("sqst", $question_id);
1516
1517 $result = $ilDB->queryF(
1518 "SELECT * FROM svy_material WHERE question_fi = %s",
1519 array('integer'),
1520 array($question_id)
1521 );
1522 if ($result->numRows()) {
1523 while ($row = $ilDB->fetchAssoc($result)) {
1524 if (preg_match("/il_(\d*?)_(\w+)_(\d+)/", $row["internal_link"], $matches)) {
1525 ilInternalLink::_saveLink("sqst", $question_id, $matches[2], $matches[3], $matches[1]);
1526 }
1527 }
1528 }
1529 }
1530 }
static _resolveInternalLink($internal_link)

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

Referenced by ilContObjParser\processPagesToParse(), and ilQuestionPageParser\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 1308 of file class.SurveyQuestion.php.

1309 {
1310 if (strlen($material_id)) {
1311 if (strcmp($material_title, "") == 0) {
1312 if (preg_match("/il__(\w+)_(\d+)/", $material_id, $matches)) {
1313 $type = $matches[1];
1314 $target_id = $matches[2];
1315 $material_title = $this->lng->txt("obj_$type") . ": ";
1316 switch ($type) {
1317 case "lm":
1318 $cont_obj_gui = new ilObjContentObjectGUI("", $target_id, true);
1319 $cont_obj = $cont_obj_gui->object;
1320 $material_title .= $cont_obj->getTitle();
1321 break;
1322
1323 case "pg":
1325 $cont_obj_gui = new ilObjContentObjectGUI("", $lm_id, false);
1326 $cont_obj = $cont_obj_gui->object;
1327 $pg_obj = new ilLMPageObject($cont_obj, $target_id);
1328 $material_title .= $pg_obj->getTitle();
1329 break;
1330
1331 case "st":
1333 $cont_obj_gui = new ilObjContentObjectGUI("", $lm_id, false);
1334 $cont_obj = $cont_obj_gui->object;
1335 $st_obj = new ilStructureObject($cont_obj, $target_id);
1336 $material_title .= $st_obj->getTitle();
1337 break;
1338
1339 case "git":
1340 $material_title = $this->lng->txt("glossary_term") . ": " . ilGlossaryTerm::_lookGlossaryTerm($target_id);
1341 break;
1342 case "mob":
1343 break;
1344 }
1345 }
1346 }
1347
1348 $mat = new ilSurveyMaterial();
1349 $mat->type = 0;
1350 $mat->internal_link = $material_id;
1351 $mat->title = $material_title;
1352 $this->addMaterial($mat);
1353 $this->saveMaterial();
1354 }
1355 }
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 1391 of file class.SurveyQuestion.php.

1392 {
1393 array_push($this->material, $obj_material);
1394 }

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

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

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

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

1806 {
1807 $a_xml_writer->xmlStartTag("material");
1808 $attrs = array(
1809 "type" => "text/plain"
1810 );
1811 if ($this->isHTML($a_material)) {
1812 $attrs["type"] = "text/xhtml";
1813 }
1814 if (is_array($a_attrs)) {
1815 $attrs = array_merge($attrs, $a_attrs);
1816 }
1817 $a_xml_writer->xmlElement("mattext", $attrs, ilRTE::_replaceMediaObjectImageSrc($a_material, 0));
1818
1819 if ($add_mobs) {
1820 $mobs = ilObjMediaObject::_getMobsOfObject("spl:html", $this->getId());
1821 foreach ($mobs as $mob) {
1822 $mob_obj = new ilObjMediaObject($mob);
1823 $imgattrs = array(
1824 "label" => "il_" . IL_INST_ID . "_mob_" . $mob,
1825 "uri" => "objects/" . "il_" . IL_INST_ID . "_mob_" . $mob . "/" . $mob_obj->getTitle(),
1826 "type" => "spl:html",
1827 "id" => $this->getId()
1828 );
1829 $a_xml_writer->xmlElement("matimage", $imgattrs, null);
1830 }
1831 }
1832 if ($close_material_tag) {
1833 $a_xml_writer->xmlEndTag("material");
1834 }
1835 }
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...
const IL_INST_ID
Definition: constants.php:38
$mobs
Definition: imgupload.php:54

References $mobs, ilObjMediaObject\_getMobsOfObject(), ilRTE\_replaceMediaObjectImageSrc(), getId(), IL_INST_ID, 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 618 of file class.SurveyQuestion.php.

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

649 {
650 $mobs = ilObjMediaObject::_getMobsOfObject("spl:html", $a_q_id);
651 foreach ($mobs as $mob) {
652 ilObjMediaObject::_saveUsage($mob, "spl:html", $this->getId());
653 }
654 }
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 840 of file class.SurveyQuestion.php.

841 {
843
844 $obj_id = $this->getObjId();
845 if ($obj_id > 0) {
846 $next_id = $ilDB->nextId('svy_question');
847 $affectedRows = $ilDB->manipulateF(
848 "INSERT INTO svy_question (question_id, questiontype_fi, " .
849 "obj_fi, owner_fi, title, description, author, questiontext, obligatory, complete, " .
850 "created, original_id, tstamp) VALUES " .
851 "(%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)",
852 array('integer', 'integer', 'integer', 'integer', 'text', 'text', 'text', 'text',
853 'text', 'text', 'integer', 'integer', 'integer'),
854 array(
855 $next_id,
856 $this->getQuestionTypeID(),
857 $obj_id,
858 $this->getOwner(),
859 null,
860 null,
861 $this->getAuthor(),
862 null,
863 "1",
864 "0",
865 time(),
866 null,
867 0
868 )
869 );
870 $this->log->debug("INSERT INTO svy_question question_id= " . $next_id . " questiontype_fi= " . $this->getQuestionTypeID());
871
872 $this->setId($next_id);
873 }
874 return $this->getId();
875 }
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 1004 of file class.SurveyQuestion.php.

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

References $db, $ilDB, $mobs, $obj_id, $result, ilInternalLink\_deleteAllLinksOfSource(), ilObjMediaObject\_getMobsOfObject(), ilObjMediaObject\_removeUsage(), CLIENT_WEB_DIR, 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 985 of file class.SurveyQuestion.php.

986 {
988
989 $this->log->debug("DELETE FROM " . $this->getAdditionalTableName());
990
991 $affectedRows = $ilDB->manipulateF(
992 "DELETE FROM " . $this->getAdditionalTableName() . " WHERE question_fi = %s",
993 array('integer'),
994 array($question_id)
995 );
996 }

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

365 {
366 foreach ($this->materials as $key => $value) {
367 if (strcmp($key, $materials_name) == 0) {
368 if (file_exists($this->getMaterialsPath() . $value)) {
369 unlink($this->getMaterialsPath() . $value);
370 }
371 unset($this->materials[$key]);
372 }
373 }
374 }
getMaterialsPath()
Returns the materials path for web accessable materials of a question.

References getMaterialsPath().

+ Here is the call graph for this function:

◆ deleteMaterials()

SurveyQuestion::deleteMaterials (   $a_array)

Deletes materials.

Parameters
array$a_arrayArray with indexes of the materials to delete

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

1363 {
1364 foreach ($a_array as $idx) {
1365 unset($this->material[$idx]);
1366 }
1367 $this->material = array_values($this->material);
1368 $this->saveMaterial();
1369 }

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

580 {
581 if ($this->getId() <= 0) {
582 // The question has not been saved. It cannot be duplicated
583 return;
584 }
585 // duplicate the question in database
586 $clone = $this;
587 $original_id = $this->getId();
588 $clone->setId(-1);
589 if ($a_survey_id > 0) {
590 $clone->setObjId($a_survey_id);
591 }
592 if ($title) {
593 $clone->setTitle($title);
594 }
595 if ($author) {
596 $clone->setAuthor($author);
597 }
598 if ($owner) {
599 $clone->setOwner($owner);
600 }
601 if ($for_survey) {
602 $clone->saveToDb($original_id);
603 } else {
604 $clone->saveToDb();
605 }
606 // duplicate the materials
607 $clone->duplicateMaterials($original_id);
608 // copy XHTML media objects
609 $clone->copyXHTMLMediaObjectsOfQuestion($original_id);
610 return $clone->getId();
611 }

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

1378 {
1379 foreach ($this->materials as $filename) {
1380 $materialspath = $this->getMaterialsPath();
1381 $materialspath_original = preg_replace("/([^\d])$this->id([^\d])/", "\${1}$question_id\${2}", $materialspath);
1382 if (!file_exists($materialspath)) {
1383 ilUtil::makeDirParents($materialspath);
1384 }
1385 if (!copy($materialspath_original . $filename, $materialspath . $filename)) {
1386 print "material could not be duplicated!!!! ";
1387 }
1388 }
1389 }
if(! $in) print
$filename
Definition: buildRTE.php:89
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 382 of file class.SurveyQuestion.php.

383 {
384 $this->materials = array();
385 }

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

522 {
523 return (strlen($this->author)) ? $this->author : null;
524 }

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

1938 {
1939 // overwrite in inherited classes
1940 return array();
1941 }

◆ getCopyIds()

SurveyQuestion::getCopyIds (   $a_group_by_survey = false)

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

2052 {
2053 $ilDB = $this->db;
2054
2055 $set = $ilDB->query("SELECT q.question_id,s.obj_fi" .
2056 " FROM svy_question q" .
2057 " JOIN svy_svy_qst sq ON (sq.question_fi = q.question_id)" .
2058 " JOIN svy_svy s ON (s.survey_id = sq.survey_fi)" .
2059 " WHERE original_id = " . $ilDB->quote($this->getId(), "integer"));
2060 $res = array();
2061 while ($row = $ilDB->fetchAssoc($set)) {
2062 if (!$a_group_by_survey) {
2063 $res[] = $row["question_id"];
2064 } else {
2065 $res[$row["obj_fi"]][] = $row["question_id"];
2066 }
2067 }
2068 return $res;
2069 }
foreach($_POST as $key=> $value) $res

References $db, $ilDB, and $res.

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

510 {
511 return (strlen($this->description)) ? $this->description : null;
512 }

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

453 {
454 return $this->id;
455 }

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

894 {
895 return CLIENT_WEB_DIR . "/survey/$this->obj_id/$this->id/images/";
896 }

References CLIENT_WEB_DIR.

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

916 {
917 $webdir = ilUtil::removeTrailingPathSeparators(CLIENT_WEB_DIR) . "/survey/$this->obj_id/$this->id/images/";
918 return str_replace(ilUtil::removeTrailingPathSeparators(ILIAS_ABSOLUTE_PATH), ilUtil::removeTrailingPathSeparators(ILIAS_HTTP_PATH), $webdir);
919 }

References CLIENT_WEB_DIR, and ilUtil\removeTrailingPathSeparators().

+ Here is the call graph for this function:

◆ getLabel()

SurveyQuestion::getLabel ( )

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

441 {
442 return $this->label;
443 }

◆ getMaterial()

SurveyQuestion::getMaterial ( )

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

1989 {
1990 return $this->material;
1991 }

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

905 {
906 return CLIENT_WEB_DIR . "/survey/$this->obj_id/$this->id/materials/";
907 }

References CLIENT_WEB_DIR.

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

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

References CLIENT_WEB_DIR, and ilUtil\removeTrailingPathSeparators().

+ Here is the call graph for this function:

◆ getMaxSumScore()

static SurveyQuestion::getMaxSumScore ( int  $survey_id)
static

Get max sum score for specific survey (and this question type)

Parameters
int$survey_id
Returns
int

Reimplemented in SurveyMatrixQuestion, SurveyMultipleChoiceQuestion, and SurveySingleChoiceQuestion.

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

2132 : int
2133 {
2134 return 0;
2135 }

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

558 {
559 return $this->obj_id;
560 }

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

464 {
465 return ($this->obligatory) ? 1 : 0;
466 }

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

488 {
489 switch ($this->orientation) {
490 case 0:
491 case 1:
492 case 2:
493 break;
494 default:
495 $this->orientation = 0;
496 break;
497 }
498 return $this->orientation;
499 }

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

1984 {
1985 return $this->original_id;
1986 }

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

534 {
535 return $this->owner;
536 }

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

1249 {
1250 $ilDB = $this->db;
1251
1252 $result = $ilDB->queryF(
1253 "SELECT title FROM svy_phrase WHERE phrase_id = %s",
1254 array('integer'),
1255 array($phrase_id)
1256 );
1257 if ($row = $ilDB->fetchAssoc($result)) {
1258 return $row["title"];
1259 }
1260 return "";
1261 }

References $db, $ilDB, and $result.

◆ getPreconditionOptions()

SurveyQuestion::getPreconditionOptions ( )

Returns the options for preconditions.

Returns
array

Reimplemented in SurveyMultipleChoiceQuestion, and SurveySingleChoiceQuestion.

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

1949 {
1950 // overwrite in inherited classes
1951 }

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

1973 {
1974 // overwrite in inherited classes
1975 return null;
1976 }

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

1961 {
1962 // overwrite in inherited classes
1963 return $value;
1964 }

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

1856 {
1857 return array();
1858 }

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

546 {
547 return (strlen($this->questiontext)) ? $this->questiontext : null;
548 }

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

1628 {
1629 return "";
1630 }

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

1606 {
1607 $ilDB = $this->db;
1608 $result = $ilDB->queryF(
1609 "SELECT questiontype_id FROM svy_qtype WHERE type_tag = %s",
1610 array('text'),
1611 array($this->getQuestionType())
1612 );
1613 if ($result->numRows() == 1) {
1614 $row = $ilDB->fetchAssoc($result);
1615 return $row["questiontype_id"];
1616 } else {
1617 return 0;
1618 }
1619 }
getQuestionType()
Returns the question type of the question.

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

1999 {
2000 // do nothing
2001 return null;
2002 }

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

476 {
477 return $this->survey_id;
478 }

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

1867 {
1868 // overwrite in inherited classes
1869 $data = array();
1870 return $data;
1871 }

References $data.

◆ hasCopies()

SurveyQuestion::hasCopies ( )

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

2072 {
2073 return (bool) sizeof($this->getCopyIds());
2074 }
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 1881 of file class.SurveyQuestion.php.

1882 {
1883 // overwrite in inherited classes
1884 }

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

1904 {
1905 // overwrite in inherited classes
1906 }

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

1915 {
1916 // overwrite in inherited classes
1917 }

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

1893 {
1894 // overwrite in inherited classes
1895 }

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

210 {
211 return 0;
212 }

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

1758 {
1759 if (preg_match("/<[^>]*?>/", $a_text)) {
1760 return true;
1761 } else {
1762 return false;
1763 }
1764 }

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

663 {
665
666 $result = $ilDB->queryF(
667 "SELECT * FROM svy_material WHERE question_fi = %s",
668 array('integer'),
669 array($this->getId())
670 );
671 $this->material = array();
672 if ($result->numRows()) {
673 while ($row = $ilDB->fetchAssoc($result)) {
674 $mat = new ilSurveyMaterial();
675 $mat->type = $row['material_type'];
676 $mat->internal_link = $row['internal_link'];
677 $mat->title = $row['material_title'];
678 $mat->import_id = $row['import_id'];
679 $mat->text_material = $row['text_material'];
680 $mat->external_link = $row['external_link'];
681 $mat->file_material = $row['file_material'];
682 array_push($this->material, $mat);
683 }
684 }
685 }

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

2098 {
2099 global $DIC;
2100
2101 $ilDB = $DIC->database();
2102
2103 $set = $ilDB->query(
2104 "SELECT obj_fi FROM svy_question " .
2105 " WHERE question_id = " . $ilDB->quote($a_qid, "integer")
2106 );
2107 $rec = $ilDB->fetchAssoc($set);
2108 return $rec["obj_fi"];
2109 }

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

1271 {
1273 $ilDB = $this->db;
1274
1275 $result = $ilDB->queryF(
1276 "SELECT phrase_id FROM svy_phrase WHERE title = %s AND owner_fi = %s",
1277 array('text', 'integer'),
1278 array($title, $ilUser->getId())
1279 );
1280 return ($result->numRows() == 0) ? false : true;
1281 }

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

1844 {
1845 return ilUtil::prepareTextareaOutput($txt_output, $prepare_for_latex_output);
1846 }
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 1773 of file class.SurveyQuestion.php.

1774 {
1775 $svy_log = ilLoggerFactory::getLogger("svy");
1776 $svy_log->debug("material count: " . $a_material->getMaterialCount());
1777
1778 $result = "";
1779 for ($i = 0; $i < $a_material->getMaterialCount(); $i++) {
1780 $material = $a_material->getMaterial($i);
1781 if (strcmp($material["type"], "mattext") == 0) {
1782 $result .= $material["material"]->getContent();
1783 }
1784 if (strcmp($material["type"], "matimage") == 0) {
1785 $matimage = $material["material"];
1786 if (preg_match("/(il_([0-9]+)_mob_([0-9]+))/", $matimage->getLabel(), $matches)) {
1787 // import an mediaobject which was inserted using tiny mce
1788 if (!is_array($_SESSION["import_mob_xhtml"])) {
1789 $_SESSION["import_mob_xhtml"] = array();
1790 }
1791 array_push($_SESSION["import_mob_xhtml"], array("mob" => $matimage->getLabel(), "uri" => $matimage->getUri()));
1792 }
1793 }
1794 }
1795 return $result;
1796 }
$_SESSION["AccountId"]
$i
Definition: metadata.php:24

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

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

References $db, $ilDB, $result, $title, and true.

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

942 {
945
946 $result = $ilDB->queryF(
947 "SELECT title, category_id FROM svy_category WHERE title = %s AND neutral = %s AND owner_fi = %s",
948 array('text','text','integer'),
949 array($categorytext, $neutral, $ilUser->getId())
950 );
951 $insert = false;
952 $returnvalue = "";
953 if ($result->numRows()) {
954 $insert = true;
955 while ($row = $ilDB->fetchAssoc($result)) {
956 if (strcmp($row["title"], $categorytext) == 0) {
957 $returnvalue = $row["category_id"];
958 $insert = false;
959 }
960 }
961 } else {
962 $insert = true;
963 }
964 if ($insert) {
965 $next_id = $ilDB->nextId('svy_category');
966 $affectedRows = $ilDB->manipulateF(
967 "INSERT INTO svy_category (category_id, title, neutral, owner_fi, tstamp) VALUES (%s, %s, %s, %s, %s)",
968 array('integer','text','text','integer','integer'),
969 array($next_id, $categorytext, $neutral, $ilUser->getId(), time())
970 );
971
972 $this->log->debug("INSERT INTO svy_category id=" . $next_id);
973
974 $returnvalue = $next_id;
975 }
976 return $returnvalue;
977 }

References $db, $ilDB, $ilUser, $result, 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 718 of file class.SurveyQuestion.php.

719 {
721
722 $question_id = $this->getId();
723 if (strlen($original_id)) {
724 $question_id = $original_id;
725 }
726
727 if ($this->getId() > 0) {
728 $this->log->debug("UPDATE svy_question question_id=" . $question_id);
729
730 // update existing dataset
731 $affectedRows = $ilDB->manipulateF(
732 "UPDATE svy_question SET complete = %s, tstamp = %s WHERE question_id = %s",
733 array('text', 'integer', 'integer'),
734 array($this->isComplete(), time(), $question_id)
735 );
736 }
737 }
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 799 of file class.SurveyQuestion.php.

800 {
802
803 $this->log->debug("DELETE: svy_material question_fi=" . $this->getId());
804
805 $affectedRows = $ilDB->manipulateF(
806 "DELETE FROM svy_material WHERE question_fi = %s",
807 array('integer'),
808 array($this->getId())
809 );
811
812 foreach ($this->material as $material) {
813 $next_id = $ilDB->nextId('svy_material');
814
815 $this->log->debug("INSERT: svy_material question_fi=" . $this->getId());
816
817 $affectedRows = $ilDB->manipulateF(
818 "INSERT INTO svy_material " .
819 "(material_id, question_fi, internal_link, import_id, material_title, tstamp," .
820 "text_material, external_link, file_material, material_type) " .
821 "VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s)",
822 array('integer','integer','text','text','text','integer','text','text','text','integer'),
823 array(
824 $next_id, $this->getId(), $material->internal_link, $material->import_id,
825 $material->title, time(), $material->text_material, $material->external_link,
826 $material->file_material, $material->type)
827 );
828 if (preg_match("/il_(\d*?)_(\w+)_(\d+)/", $material->internal_link, $matches)) {
829 ilInternalLink::_saveLink("sqst", $this->getId(), $matches[2], $matches[3], $matches[1]);
830 }
831 }
832 }

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

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

884 {
885 }

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

395 {
397
398 if (!$author) {
399 $author = $ilUser->fullname;
400 }
401 $this->author = $author;
402 }

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

199 {
200 $this->complete = ($a_complete) ? 1 : 0;
201 }

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

309 {
310 $this->description = $description;
311 }

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

285 {
286 $this->id = $id;
287 }

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

1404 {
1405 if (strcmp($material_id, "") != 0) {
1406 $import_id = "";
1407 if ($is_import) {
1408 $import_id = $material_id;
1409 $material_id = self::_resolveInternalLink($import_id);
1410 }
1411 if (strcmp($material_title, "") == 0) {
1412 if (preg_match("/il__(\w+)_(\d+)/", $material_id, $matches)) {
1413 $type = $matches[1];
1414 $target_id = $matches[2];
1415 $material_title = $this->lng->txt("obj_$type") . ": ";
1416 switch ($type) {
1417 case "lm":
1418 $cont_obj_gui = new ilObjContentObjectGUI("", $target_id, true);
1419 $cont_obj = $cont_obj_gui->object;
1420 $material_title .= $cont_obj->getTitle();
1421 break;
1422
1423 case "pg":
1425 $cont_obj_gui = new ilObjContentObjectGUI("", $lm_id, false);
1426 $cont_obj = $cont_obj_gui->object;
1427 $pg_obj = new ilLMPageObject($cont_obj, $target_id);
1428 $material_title .= $pg_obj->getTitle();
1429 break;
1430
1431 case "st":
1433 $cont_obj_gui = new ilObjContentObjectGUI("", $lm_id, false);
1434 $cont_obj = $cont_obj_gui->object;
1435 $st_obj = new ilStructureObject($cont_obj, $target_id);
1436 $material_title .= $st_obj->getTitle();
1437 break;
1438
1439 case "git":
1440 $material_title = $this->lng->txt("glossary_term") . ": " . ilGlossaryTerm::_lookGlossaryTerm($target_id);
1441 break;
1442 case "mob":
1443 break;
1444 }
1445 }
1446 }
1447 $this->material = array(
1448 "internal_link" => $material_id,
1449 "import_id" => $import_id,
1450 "title" => $material_title
1451 );
1452 }
1453 $this->saveMaterial();
1454 }

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

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

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

+ Here is the call graph for this function:

◆ setObjId()

SurveyQuestion::setObjId (   $obj_id = 0)

Set the reference id of the container object.

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

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

570 {
571 $this->obj_id = $obj_id;
572 }

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

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

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

273 {
274 $this->orientation = ($orientation) ? $orientation : 0;
275 }

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

1979 {
1980 $this->original_id = $original_id;
1981 }

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

424 {
425 $this->owner = $owner;
426 }

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

412 {
413 $this->questiontext = $questiontext;
414 }

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

1994 {
1995 // do nothing
1996 }

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

297 {
298 $this->survey_id = $id;
299 }

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

249 {
250 $this->title = $title;
251 }

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

2119 {
2120 $str = ilUtil::stripSlashes($a_str);
2121 if ($str != $a_str) {
2122 $str = ilUtil::stripSlashes(str_replace("<", "< ", $a_str));
2123 }
2124 return $str;
2125 }
static stripSlashes($a_str, $a_strip_html=true, $a_allow="")
strip slashes if magic qoutes is enabled

References ilUtil\stripSlashes().

Referenced by SurveyMatrixQuestion\saveUserInput(), SurveyMultipleChoiceQuestion\saveUserInput(), SurveySingleChoiceQuestion\saveUserInput(), and 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 1202 of file class.SurveyQuestion.php.

1203 {
1204 $ilDB = $this->db;
1205
1206 if ($this->getOriginalId()) {
1207 $id = $this->getId();
1208 $original = $this->getOriginalId();
1209
1210 $this->setId($this->getOriginalId());
1211 $this->setOriginalId(null);
1212 $this->saveToDb();
1213
1214 $this->setId($id);
1215 $this->setOriginalId($original);
1216
1217 $this->log->debug("DELETE FROM svy_material WHERE question_fi = " . $this->getOriginalId());
1218
1219 $affectedRows = $ilDB->manipulateF(
1220 "DELETE FROM svy_material WHERE question_fi = %s",
1221 array('integer'),
1222 array($this->getOriginalId())
1223 );
1224 ilInternalLink::_deleteAllLinksOfSource("sqst", $this->original_id);
1225 if (strlen($this->material["internal_link"])) {
1226 $next_id = $ilDB->nextId('svy_material');
1227 $affectedRows = $ilDB->manipulateF(
1228 "INSERT INTO svy_material (material_id, question_fi, internal_link, import_id, material_title, tstamp) VALUES (%s, %s, %s, %s, %s, %s)",
1229 array('integer', 'integer', 'text', 'text', 'text', 'integer'),
1230 array($next_id, $this->getOriginalId(), $this->material["internal_link"], $this->material["import_id"], $this->material["title"], time())
1231 );
1232
1233 $this->log->debug("INSERT svy_material material_id=" . $next_id . " question_fi=" . $this->getOriginalId());
1234
1235 if (preg_match("/il_(\d*?)_(\w+)_(\d+)/", $this->material["internal_link"], $matches)) {
1236 ilInternalLink::_saveLink("sqst", $this->getOriginalId(), $matches[2], $matches[3], $matches[1]);
1237 }
1238 }
1239 }
1240 }
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 1925 of file class.SurveyQuestion.php.

1926 {
1927 // overwrite in inherited classes
1928 return false;
1929 }

Field Documentation

◆ $arrData

SurveyQuestion::$arrData
private

data array containing the question data

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

◆ $author

◆ $complete

SurveyQuestion::$complete

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

◆ $db

◆ $description

◆ $id

◆ $lng

◆ $log

SurveyQuestion::$log
protected

Definition at line 146 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

◆ $user


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