ILIAS  release_8 Revision v8.24
SurveyQuestion Class Reference

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V. More...

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

Public Member Functions

 __construct (string $title="", string $description="", string $author="", string $questiontext="", int $owner=-1)
 
 setComplete (bool $a_complete)
 
 isComplete ()
 
 questionTitleExists (string $title, int $questionpool_object=0)
 
 setTitle (string $title="")
 
 setObligatory (bool $obligatory=true)
 
 setOrientation (int $orientation=0)
 
 setId (int $id=-1)
 
 setSurveyId (int $id=-1)
 
 setDescription (string $description="")
 
 addMaterials (string $materials_file, string $materials_name="")
 
 setMaterialsfile (string $materials_filename, string $materials_tempfilename="", string $materials_name="")
 Uploads and adds a material. More...
 
 deleteMaterial (string $materials_name="")
 
 flushMaterials ()
 Deletes all materials uris. More...
 
 setAuthor (string $author="")
 
 setQuestiontext (string $questiontext="")
 
 setOwner (int $owner=0)
 
 getTitle ()
 
 getLabel ()
 
 getId ()
 
 getObligatory ()
 
 getSurveyId ()
 
 getOrientation ()
 
 getDescription ()
 
 getAuthor ()
 
 getOwner ()
 
 getQuestiontext ()
 
 getObjId ()
 Get the reference(?) id of the container object. More...
 
 setObjId (int $obj_id=0)
 Set the reference(?) id of the container object. More...
 
 duplicate (bool $for_survey=true, string $title="", string $author="", int $owner=0, int $a_survey_id=0)
 
 copyObject (int $target_questionpool, string $title="")
 
 copyXHTMLMediaObjectsOfQuestion (int $a_q_id)
 Copy media object usages from other question. More...
 
 loadFromDb (int $question_id)
 load question data into object note: this base implementation only loads the material data More...
 
 saveCompletionStatus (int $original_id=0)
 Saves the complete flag to the database. More...
 
 saveToDb (int $original_id=0)
 Saves a SurveyQuestion object to a database. More...
 
 saveMaterial ()
 
 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...
 
 getImagePath ()
 Returns the image path for web accessible images of a question. More...
 
 getMaterialsPath ()
 Returns the materials path for web accessible materials of a question. More...
 
 getImagePathWeb ()
 Returns the web image path for web accessible images of a question. More...
 
 getMaterialsPathWeb ()
 Returns the web image path for web accessable images of a question. More...
 
 saveCategoryToDb (string $categorytext, int $neutral=0)
 Saves a category to the database. More...
 
 deleteAdditionalTableData (int $question_id)
 Deletes datasets from the additional question table in the database. More...
 
 delete (int $question_id)
 Deletes a question and all materials from the database. More...
 
 syncWithOriginal ()
 
 getPhrase (int $phrase_id)
 Returns a phrase title for phrase id. More...
 
 phraseExists (string $title)
 Returns true if the phrase title already exists for the current user(!) More...
 
 deleteMaterials (array $a_array)
 
 duplicateMaterials (int $question_id)
 Duplicates the materials of a question. More...
 
 addMaterial (ilSurveyMaterial $obj_material)
 
 getQuestionTypeID ()
 
 getQuestionType ()
 
 isHTML (string $a_text)
 
 QTIMaterialToString (ilQTIMaterial $a_material)
 Reads an QTI material tag an creates a text string. More...
 
 addMaterialTag (ilXmlWriter $a_xml_writer, string $a_material, bool $close_material_tag=true, bool $add_mobs=true, ?array $a_attrs=null)
 Creates an XML material tag from a plain text or xhtml text. More...
 
 prepareTextareaOutput (string $txt_output, bool $prepare_for_latex_output=false)
 Prepares string for a text area output in surveys. More...
 
 getQuestionDataArray (int $id)
 Returns the question data. More...
 
 getWorkingDataFromUserInput (array $post_data)
 Creates the user data of the svy_answer table from the POST data. More...
 
 importAdditionalMetadata (array $a_meta)
 Import additional meta data from the question import file. More...
 
 importResponses (array $a_data)
 Import response data from the question import file. More...
 
 importAdjectives (array $a_data)
 Import bipolar adjectives from the question import file. More...
 
 importMatrix (array $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 (string $value)
 Returns the output for a precondition value. More...
 
 getPreconditionSelectValue (string $default, string $title, string $variable)
 Creates a form property for the precondition value. More...
 
 setOriginalId (?int $original_id)
 
 getOriginalId ()
 
 getMaterial ()
 
 setSubtype (int $a_subtype)
 
 getSubtype ()
 
 __get (string $value)
 
 __set (string $key, string $value)
 
 getCopyIds (bool $a_group_by_survey=false)
 
 hasCopies ()
 
 stripSlashesAddSpaceFallback (string $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 (int $question_id)
 Checks whether the question is complete or not. More...
 
static _getQuestionType (int $question_id)
 Returns the question type of a question with a given id. More...
 
static _getTitle (int $question_id)
 Returns the question title of a question with a given id. More...
 
static _getOriginalId (int $question_id, bool $a_return_question_id_if_no_original=true)
 Returns the original id of a question. More...
 
static _questionExists (int $question_id)
 
static _resolveInternalLink (string $internal_link)
 
static _resolveIntLinks (int $question_id)
 
static _getInternalLinkHref (string $target="", int $a_parent_ref_id=null)
 
static _isWriteable (int $question_id, int $user_id)
 is question writeable by a certain user More...
 
static _includeClass (string $question_type, int $gui=0)
 Include the php class file for a given question type. More...
 
static _getQuestionTypeName (string $type_tag)
 Return the translation for a given question type. More...
 
static _instanciateQuestion (int $question_id)
 Get question object. More...
 
static _instanciateQuestionGUI (int $question_id)
 Get question gui object. More...
 
static _instanciateQuestionEvaluation (int $question_id, array $a_finished_ids=null)
 
static _changeOriginalId (int $a_question_id, int $a_original_id, int $a_object_id)
 Change original id of existing question in db. More...
 
static _lookupSurveyObjId (int $a_question_id)
 
static lookupObjFi (int $a_qid)
 
static getMaxSumScore (int $survey_id)
 Get max sum score for specific survey (and this question type) More...
 

Data Fields

int $id
 
string $title
 
string $description
 
int $owner
 
string $author
 
array $materials
 
int $survey_id
 
int $obj_id
 
string $questiontext
 
bool $obligatory
 
ilLanguage $lng
 
int $orientation
 
array $material
 
bool $complete
 

Protected Attributes

int $original_id
 
ILIAS SurveyQuestionPool Editing EditSessionRepository $edit_manager
 
ilObjUser $user
 
ilDBInterface $db
 
array $cumulated
 
ilLogger $log
 
ILIAS SurveyQuestionPool Export ImportSessionRepository $import_manager
 

Private Attributes

array $arrData
 

Detailed Description

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V.

ILIAS is licensed with the GPL-3.0, see https://www.gnu.org/licenses/gpl-3.0.en.html You should have received a copy of said license along with the source code, too.

If this is not the case or you just want to try ILIAS, you'll find us at: https://www.ilias.de https://github.com/ILIAS-eLearning 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

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

Constructor & Destructor Documentation

◆ __construct()

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

Reimplemented in SurveyMatrixQuestion, and SurveyTextQuestion.

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

58 {
59 global $DIC;
60
61 $this->user = $DIC->user();
62 $this->db = $DIC->database();
63 $lng = $DIC->language();
64 $ilUser = $DIC->user();
65
66 $this->lng = $lng;
67 $this->complete = 0;
68 $this->title = $title;
69 $this->description = $description;
70 $this->questiontext = $questiontext;
71 $this->author = $author;
72 $this->cumulated = array();
73 if (!$this->author) {
74 $this->author = $ilUser->fullname;
75 }
76 $this->owner = $owner;
77 if ($this->owner === -1) {
78 $this->owner = $ilUser->getId();
79 }
80 $this->id = -1;
81 $this->survey_id = -1;
82 $this->obligatory = 1;
83 $this->orientation = 0;
84 $this->materials = array();
85 $this->material = array();
86 $this->arrData = array();
87
88 $this->log = ilLoggerFactory::getLogger('svy');
89 $this->import_manager = $DIC->surveyQuestionPool()
90 ->internal()
91 ->repo()
92 ->import();
93
94 $this->edit_manager = $DIC->surveyQuestionPool()
95 ->internal()
96 ->repo()
97 ->editing();
98 }
static getLogger(string $a_component_id)
Get component logger.
global $DIC
Definition: feed.php:28
$ilUser
Definition: imgupload.php:34

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

+ Here is the call graph for this function:

Member Function Documentation

◆ __get()

SurveyQuestion::__get ( string  $value)

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

1614 : ?string
1615 {
1616 switch ($value) {
1617 default:
1618 if (array_key_exists($value, $this->arrData)) {
1619 return (string) $this->arrData[$value];
1620 }
1621
1622 return null;
1623 }
1624 }

◆ __set()

SurveyQuestion::__set ( string  $key,
string  $value 
)

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

1626 : void
1627 {
1628 switch ($key) {
1629 default:
1630 $this->arrData[$key] = $value;
1631 break;
1632 }
1633 }
string $key
Consumer key/client ID value.
Definition: System.php:193

References ILIAS\LTI\ToolProvider\$key.

◆ _changeOriginalId()

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

Change original id of existing question in db.

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

1642 : void {
1643 global $DIC;
1644
1645 $ilDB = $DIC->database();
1646
1647 $ilDB->manipulate("UPDATE svy_question" .
1648 " SET original_id = " . $ilDB->quote($a_original_id, "integer") . "," .
1649 " obj_fi = " . $ilDB->quote($a_object_id, "integer") .
1650 " WHERE question_id = " . $ilDB->quote($a_question_id, "integer"));
1651 }

Referenced by ilSurveyEditorGUI\executeCopyQuestionsToPoolObject().

+ Here is the caller graph for this function:

◆ _getInternalLinkHref()

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

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

1214 : string {
1215 $linktypes = array(
1216 "lm" => "LearningModule",
1217 "pg" => "PageObject",
1218 "st" => "StructureObject",
1219 "git" => "GlossaryItem",
1220 "mob" => "MediaObject"
1221 );
1222 $href = "";
1223 if (preg_match("/il__(\w+)_(\d+)/", $target, $matches)) {
1224 $type = $matches[1];
1225 $target_id = $matches[2];
1226 switch ($linktypes[$matches[1]]) {
1227 case "StructureObject":
1228 case "PageObject":
1229 case "GlossaryItem":
1230 case "LearningModule":
1231 $href = ilFileUtils::removeTrailingPathSeparators(ILIAS_HTTP_PATH) . "/goto.php?target=" . $type . "_" . $target_id;
1232 break;
1233 case "MediaObject":
1235 ILIAS_HTTP_PATH
1236 ) . "/ilias.php?baseClass=ilLMPresentationGUI&obj_type=" . $linktypes[$type] . "&cmd=media&ref_id=" . $a_parent_ref_id . "&mob_id=" . $target_id;
1237 break;
1238 }
1239 }
1240 return $href;
1241 }
static removeTrailingPathSeparators(string $path)
$target_id
Definition: goto.php:52
$type

References $target_id, $type, and ilFileUtils\removeTrailingPathSeparators().

Referenced by SurveyQuestionGUI\getMaterialOutput().

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

◆ _getOriginalId()

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

Returns the original id of a question.

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

871 : int {
872 global $DIC;
873
874 $ilDB = $DIC->database();
875 $result = $ilDB->queryF(
876 "SELECT * FROM svy_question WHERE question_id = %s",
877 array('integer'),
878 array($question_id)
879 );
880 if ($result->numRows() > 0) {
881 $row = $ilDB->fetchAssoc($result);
882 if ($row["original_id"] > 0) {
883 return (int) $row["original_id"];
884 } elseif ($a_return_question_id_if_no_original) { // #12419
885 return (int) $row["question_id"];
886 }
887 }
888 return 0;
889 }

References $ilDB.

◆ _getQuestionType()

static SurveyQuestion::_getQuestionType ( int  $question_id)
static

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

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

821 : string
822 {
823 global $DIC;
824
825 $ilDB = $DIC->database();
826
827 if ($question_id < 1) {
828 return "";
829 }
830
831 $result = $ilDB->queryF(
832 "SELECT type_tag FROM svy_question, svy_qtype WHERE svy_question.question_id = %s AND svy_question.questiontype_fi = svy_qtype.questiontype_id",
833 array('integer'),
834 array($question_id)
835 );
836 if ($result->numRows() === 1) {
837 $data = $ilDB->fetchAssoc($result);
838 return $data["type_tag"];
839 } else {
840 return "";
841 }
842 }

References $data, $DIC, and $ilDB.

Referenced by SurveyQuestionGUI\_getGUIClassNameForId(), SurveyQuestionGUI\_getQuestionGUI(), ilObjSurveyGUI\addLocatorItems(), ilObjSurveyQuestionPoolGUI\addLocatorItems(), ilSurveyConstraintsGUI\confirmDeleteConstraintsObject(), and ilObjSurvey\getUserSpecificResults().

+ Here is the caller graph for this function:

◆ _getQuestionTypeName()

static SurveyQuestion::_getQuestionTypeName ( string  $type_tag)
static

Return the translation for a given question type.

Parameters
string$type_tagtype of the question type

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

1328 : string {
1329 global $DIC;
1330
1331 if (file_exists("./Modules/SurveyQuestionPool/Questions/class." . $type_tag . ".php")) {
1332 $lng = $DIC->language();
1333 return $lng->txt($type_tag);
1334 } else {
1335 $component_factory = $DIC["component.factory"];
1336 foreach ($component_factory->getActivePluginsInSlot("svyq") as $pl) {
1337 if (strcmp($pl->getQuestionType(), $type_tag) === 0) {
1338 return $pl->getQuestionTypeTranslation();
1339 }
1340 }
1341 }
1342 return "";
1343 }
txt(string $a_topic, string $a_default_lang_fallback_mod="")
gets the text for a given topic if the topic is not in the list, the topic itself with "-" will be re...

References $DIC, and $lng.

Referenced by ilObjSurveyQuestionPoolGUI\deleteQuestionsObject(), ilSurveyQuestionsTableGUI\fillRow(), ilSurveyResultsCumulatedTableGUI\getItems(), and ilSurveyEditorGUI\removeQuestionsForm().

+ Here is the caller graph for this function:

◆ _getTitle()

static SurveyQuestion::_getTitle ( int  $question_id)
static

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

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

847 : string
848 {
849 global $DIC;
850
851 $ilDB = $DIC->database();
852
853 $result = $ilDB->queryF(
854 "SELECT title FROM svy_question WHERE svy_question.question_id = %s",
855 array('integer'),
856 array($question_id)
857 );
858
859 if ($data = $ilDB->fetchAssoc($result)) {
860 return (string) $data["title"];
861 }
862 return "";
863 }

References $data, $DIC, and $ilDB.

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

+ Here is the caller graph for this function:

◆ _includeClass()

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

Include the php class file for a given question type.

Parameters
int$gui0 if the class should be included, 1 if the GUI class should be included

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

1300 : bool {
1301 $type = $question_type;
1302 if ($gui === 1) {
1303 $type .= "GUI";
1304 } elseif ($gui === 2) {
1305 $type .= "Evaluation";
1306 }
1307 if (file_exists("./Modules/SurveyQuestionPool/Questions/class." . $type . ".php")) {
1308 return true;
1309 } else {
1310 global $DIC;
1311
1312 $component_factory = $DIC["component.factory"];
1313 foreach ($component_factory->getActivePluginsInSlot("svyq") as $pl) {
1314 if (strcmp($pl->getQuestionType(), $question_type) === 0) {
1315 return true;
1316 }
1317 }
1318 }
1319 return false;
1320 }

References $type.

Referenced by ilSurveyConstraintsGUI\confirmDeleteConstraintsObject(), ilObjSurvey\getUserSpecificResults(), SurveyImportParser\handlerBeginTag(), and ilObjSurveyQuestionPool\toXML().

+ Here is the caller graph for this function:

◆ _instanciateQuestion()

static SurveyQuestion::_instanciateQuestion ( int  $question_id)
static

Get question object.

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

1350 {
1351 $question_type = self::_getQuestionType($question_id);
1352 if ($question_type) {
1353 self::_includeClass($question_type);
1354 $question = new $question_type();
1355 $question->loadFromDb($question_id);
1356 return $question;
1357 }
1358 return null;
1359 }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static _includeClass(string $question_type, int $gui=0)
Include the php class file for a given question type.
static _getQuestionType(int $question_id)
Returns the question type of a question with a given id.

Referenced by ilSurveySkill\determineMaxScale(), ilObjSurveyQuestionPool\removeQuestion(), and ilSurveyExecutionGUI\saveActiveQuestionData().

+ Here is the caller graph for this function:

◆ _instanciateQuestionEvaluation()

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

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

1381 $question = self::_instanciateQuestion($question_id);
1382 if (is_null($a_finished_ids)) {
1383 $a_finished_ids = [];
1384 }
1385 if ($question) {
1386 $question_type = self::_getQuestionType($question_id);
1387 self::_includeClass($question_type, 2);
1388 $class = $question_type . "Evaluation";
1389 $ev = new $class($question, $a_finished_ids);
1390 return $ev;
1391 }
1392 return null;
1393 }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static _instanciateQuestion(int $question_id)
Get question object.

Referenced by ilSurveyEvaluationGUI\exportEvaluationUser(), ILIAS\Survey\PrintView\ResultsDetailsPrintViewProviderGUI\getPages(), ILIAS\Survey\Evaluation\EvaluationManager\getUserSpecificResults(), and ilObjSurvey\getUserSpecificResults().

+ Here is the caller graph for this function:

◆ _instanciateQuestionGUI()

static SurveyQuestion::_instanciateQuestionGUI ( int  $question_id)
static

Get question gui object.

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

1367 $question_type = self::_getQuestionType($question_id);
1368 if ($question_type) {
1369 self::_includeClass($question_type, 1);
1370 $guitype = $question_type . "GUI";
1371 $question = new $guitype($question_id);
1372 return $question;
1373 }
1374 return null;
1375 }
Basic class for all survey question types The SurveyQuestionGUI class defines and encapsulates basic ...

◆ _isComplete()

static SurveyQuestion::_isComplete ( int  $question_id)
static

Checks whether the question is complete or not.

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

431 : bool
432 {
433 global $DIC;
434
435 $ilDB = $DIC->database();
436
437 $result = $ilDB->queryF(
438 "SELECT complete FROM svy_question WHERE question_id = %s",
439 array('integer'),
440 array($question_id)
441 );
442 if ($result->numRows()) {
443 $row = $ilDB->fetchAssoc($result);
444 if ((int) $row["complete"] === 1) {
445 return true;
446 }
447 }
448 return false;
449 }

References $DIC, and $ilDB.

Referenced by SurveyQuestionGUI\save().

+ Here is the caller graph for this function:

◆ _isWriteable()

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

is question writeable by a certain user

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

1249 : bool {
1250 global $DIC;
1251
1252 $ilDB = $DIC->database();
1253
1254 if (($question_id < 1) || ($user_id < 1)) {
1255 return false;
1256 }
1257
1258 $result = $ilDB->queryF(
1259 "SELECT obj_fi FROM svy_question WHERE question_id = %s",
1260 array('integer'),
1261 array($question_id)
1262 );
1263 if ($result->numRows() === 1) {
1264 $row = $ilDB->fetchAssoc($result);
1265 $qpl_object_id = $row["obj_fi"];
1266 return ilObjSurveyQuestionPool::_isWriteable($qpl_object_id);
1267 }
1268
1269 return false;
1270 }
static _isWriteable(int $object_id)
Returns true, if the question pool is writeable for the current user.

Referenced by SurveyQuestionGUI\save().

+ Here is the caller graph for this function:

◆ _lookupSurveyObjId()

static SurveyQuestion::_lookupSurveyObjId ( int  $a_question_id)
static

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

1681 : ?int {
1682 global $DIC;
1683
1684 $ilDB = $DIC->database();
1685
1686 $set = $ilDB->query("SELECT svy_svy.obj_fi FROM svy_svy_qst" .
1687 " JOIN svy_svy ON (svy_svy.survey_id = svy_svy_qst.survey_fi)" .
1688 " WHERE svy_svy_qst.question_fi = " . $ilDB->quote($a_question_id, "integer"));
1689 $row = $ilDB->fetchAssoc($set);
1690 if ($ilDB->numRows($set)) {
1691 return (int) $row["obj_fi"];
1692 }
1693 return null;
1694 }

◆ _questionExists()

static SurveyQuestion::_questionExists ( int  $question_id)
static

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

965 : bool
966 {
967 global $DIC;
968
969 $ilDB = $DIC->database();
970
971 if ($question_id < 1) {
972 return false;
973 }
974
975 $result = $ilDB->queryF(
976 "SELECT question_id FROM svy_question WHERE question_id = %s",
977 array('integer'),
978 array($question_id)
979 );
980 return $result->numRows() === 1;
981 }

References $DIC, and $ilDB.

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

+ Here is the caller graph for this function:

◆ _resolveInternalLink()

static SurveyQuestion::_resolveInternalLink ( string  $internal_link)
static

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

1134 : string {
1135 $resolved_link = "";
1136 if (preg_match("/il_(\d+)_(\w+)_(\d+)/", $internal_link, $matches)) {
1137 switch ($matches[2]) {
1138 case "lm":
1139 $resolved_link = ilLMObject::_getIdForImportId($internal_link);
1140 break;
1141 case "pg":
1142 $resolved_link = ilInternalLink::_getIdForImportId("PageObject", $internal_link);
1143 break;
1144 case "st":
1145 $resolved_link = ilInternalLink::_getIdForImportId("StructureObject", $internal_link);
1146 break;
1147 case "git":
1148 $resolved_link = ilInternalLink::_getIdForImportId("GlossaryItem", $internal_link);
1149 break;
1150 case "mob":
1151 $resolved_link = ilInternalLink::_getIdForImportId("MediaObject", $internal_link);
1152 break;
1153 }
1154 if (strcmp($resolved_link, "") === 0) {
1155 $resolved_link = $internal_link;
1156 }
1157 } else {
1158 $resolved_link = $internal_link;
1159 }
1160 return $resolved_link;
1161 }
static _getIdForImportId(string $a_import_id)
get current object id for import id (static)

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

+ Here is the call graph for this function:

◆ _resolveIntLinks()

static SurveyQuestion::_resolveIntLinks ( int  $question_id)
static

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

1165 : void {
1166 global $DIC;
1167
1168 $ilDB = $DIC->database();
1169 $resolvedlinks = 0;
1170 $result = $ilDB->queryF(
1171 "SELECT * FROM svy_material WHERE question_fi = %s",
1172 array('integer'),
1173 array($question_id)
1174 );
1175 if ($result->numRows()) {
1176 while ($row = $ilDB->fetchAssoc($result)) {
1177 $internal_link = $row["internal_link"];
1178 $resolved_link = self::_resolveInternalLink($internal_link);
1179 if (strcmp($internal_link, $resolved_link) !== 0) {
1180 // internal link was resolved successfully
1181 $affectedRows = $ilDB->manipulateF(
1182 "UPDATE svy_material SET internal_link = %s, tstamp = %s WHERE material_id = %s",
1183 array('text', 'integer', 'integer'),
1184 array($resolved_link, time(), $row["material_id"])
1185 );
1186 $resolvedlinks++;
1187 }
1188 }
1189 }
1190 if ($resolvedlinks) {
1191 // there are resolved links -> reenter theses links to the database
1192
1193 // delete all internal links from the database
1194 ilInternalLink::_deleteAllLinksOfSource("sqst", $question_id);
1195
1196 $result = $ilDB->queryF(
1197 "SELECT * FROM svy_material WHERE question_fi = %s",
1198 array('integer'),
1199 array($question_id)
1200 );
1201 if ($result->numRows()) {
1202 while ($row = $ilDB->fetchAssoc($result)) {
1203 if (preg_match("/il_(\d*?)_(\w+)_(\d+)/", $row["internal_link"], $matches)) {
1204 ilInternalLink::_saveLink("sqst", $question_id, $matches[2], $matches[3], $matches[1]);
1205 }
1206 }
1207 }
1208 }
1209 }
static _resolveInternalLink(string $internal_link)

References $ilDB.

Referenced by ilQuestionPageParser\processPagesToParse().

+ Here is the caller graph for this function:

◆ addMaterial()

SurveyQuestion::addMaterial ( ilSurveyMaterial  $obj_material)

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

1064 : void
1065 {
1066 $this->material[] = $obj_material;
1067 }

◆ addMaterials()

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

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

164 : void {
165 if (empty($materials_name)) {
166 $materials_name = $materials_file;
167 }
168 if ((!empty($materials_name)) && (!array_key_exists($materials_name, $this->materials))) {
169 $this->materials[$materials_name] = $materials_file;
170 }
171 }

◆ addMaterialTag()

SurveyQuestion::addMaterialTag ( ilXmlWriter  $a_xml_writer,
string  $a_material,
bool  $close_material_tag = true,
bool  $add_mobs = true,
?array  $a_attrs = null 
)

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

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

1444 : void {
1445 $a_xml_writer->xmlStartTag("material");
1446 $attrs = array(
1447 "type" => "text/plain"
1448 );
1449 if ($this->isHTML($a_material)) {
1450 $attrs["type"] = "text/xhtml";
1451 }
1452 if (is_array($a_attrs)) {
1453 $attrs = array_merge($attrs, $a_attrs);
1454 }
1455 $a_xml_writer->xmlElement("mattext", $attrs, ilRTE::_replaceMediaObjectImageSrc($a_material, 0));
1456
1457 if ($add_mobs) {
1458 $mobs = ilObjMediaObject::_getMobsOfObject("spl:html", $this->getId());
1459 foreach ($mobs as $mob) {
1460 $mob_obj = new ilObjMediaObject($mob);
1461 $imgattrs = array(
1462 "label" => "il_" . IL_INST_ID . "_mob_" . $mob,
1463 "uri" => "objects/" . "il_" . IL_INST_ID . "_mob_" . $mob . "/" . $mob_obj->getTitle(),
1464 "type" => "spl:html",
1465 "id" => $this->getId()
1466 );
1467 $a_xml_writer->xmlElement("matimage", $imgattrs, null);
1468 }
1469 }
1470 if ($close_material_tag) {
1471 $a_xml_writer->xmlEndTag("material");
1472 }
1473 }
isHTML(string $a_text)
static _getMobsOfObject(string $a_type, int $a_id, int $a_usage_hist_nr=0, string $a_lang="-")
static _replaceMediaObjectImageSrc(string $a_text, int $a_direction=0, string $nic='')
Replaces image source from mob image urls with the mob id or replaces mob id with the correct image s...
xmlElement(string $tag, $attrs=null, $data=null, $encode=true, $escape=true)
Writes a basic element (no children, just textual content)
xmlEndTag(string $tag)
Writes an endtag.
xmlStartTag(string $tag, ?array $attrs=null, bool $empty=false, bool $encode=true, bool $escape=true)
Writes a starttag.
const IL_INST_ID
Definition: constants.php:40
$mobs
Definition: imgupload.php:70

◆ copyObject()

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

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

364 : ?int {
365 if ($this->getId() <= 0) {
366 // The question has not been saved. It cannot be copied
367 return null;
368 }
369 $clone = $this;
370 $original_id = self::_getOriginalId($this->getId(), false);
371 $clone->setId(-1);
372 $source_questionpool = $this->getObjId();
373 $clone->setObjId($target_questionpool);
374 if ($title) {
375 $clone->setTitle($title);
376 }
377
378 $clone->saveToDb();
379
380 // duplicate the materials
381 $clone->duplicateMaterials($original_id);
382 // copy XHTML media objects
383 $clone->copyXHTMLMediaObjectsOfQuestion($original_id);
384 return $clone->getId();
385 }
static _getOriginalId(int $question_id, bool $a_return_question_id_if_no_original=true)
Returns the original id of a question.
getObjId()
Get the reference(?) id of the container object.

◆ copyXHTMLMediaObjectsOfQuestion()

SurveyQuestion::copyXHTMLMediaObjectsOfQuestion ( int  $a_q_id)

Copy media object usages from other question.

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

392 : void {
393 $mobs = ilObjMediaObject::_getMobsOfObject("spl:html", $a_q_id);
394 foreach ($mobs as $mob) {
395 ilObjMediaObject::_saveUsage($mob, "spl:html", $this->getId());
396 }
397 }
static _saveUsage(int $a_mob_id, string $a_type, int $a_id, int $a_usage_hist_nr=0, string $a_lang="-")
Save usage of mob within another container (e.g.

References ilObjMediaObject\_saveUsage(), and ILIAS\Survey\Mode\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
int ID of the new question

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

569 : int
570 {
572
573 $obj_id = $this->getObjId();
574 if ($obj_id > 0) {
575 $next_id = $ilDB->nextId('svy_question');
576 $affectedRows = $ilDB->manipulateF(
577 "INSERT INTO svy_question (question_id, questiontype_fi, " .
578 "obj_fi, owner_fi, title, description, author, questiontext, obligatory, complete, " .
579 "created, original_id, tstamp) VALUES " .
580 "(%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)",
581 array('integer', 'integer', 'integer', 'integer', 'text', 'text', 'text', 'text',
582 'text', 'text', 'integer', 'integer', 'integer'),
583 array(
584 $next_id,
585 $this->getQuestionTypeID(),
586 $obj_id,
587 $this->getOwner(),
588 null,
589 null,
590 $this->getAuthor(),
591 null,
592 "1",
593 "0",
594 time(),
595 null,
596 0
597 )
598 );
599 $this->log->debug("INSERT INTO svy_question question_id= " . $next_id . " questiontype_fi= " . $this->getQuestionTypeID());
600
601 $this->setId($next_id);
602 }
603 return $this->getId();
604 }

References $ilDB, and ILIAS\Survey\Mode\getId().

+ Here is the call graph for this function:

◆ delete()

SurveyQuestion::delete ( int  $question_id)

Deletes a question and all materials from the database.

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

708 : void
709 {
711 $this->log->debug("Question Delete... " . $question_id);
712 if ($question_id < 1) {
713 return;
714 }
715
716 $result = $ilDB->queryF(
717 "SELECT obj_fi FROM svy_question WHERE question_id = %s",
718 array('integer'),
719 array($question_id)
720 );
721 if ($result->numRows() === 1) {
722 $row = $ilDB->fetchAssoc($result);
723 $obj_id = $row["obj_fi"];
724 } else {
725 return;
726 }
727
728 $affectedRows = $ilDB->manipulateF(
729 "DELETE FROM svy_answer WHERE question_fi = %s",
730 array('integer'),
731 array($question_id)
732 );
733
734 $affectedRows = $ilDB->manipulateF(
735 "DELETE FROM svy_constraint WHERE question_fi = %s",
736 array('integer'),
737 array($question_id)
738 );
739
740 $result = $ilDB->queryF(
741 "SELECT constraint_fi FROM svy_qst_constraint WHERE question_fi = %s",
742 array('integer'),
743 array($question_id)
744 );
745 while ($row = $ilDB->fetchObject($result)) {
746 $affectedRows = $ilDB->manipulateF(
747 "DELETE FROM svy_constraint WHERE constraint_id = %s",
748 array('integer'),
749 array($row->constraint_fi)
750 );
751 }
752
753 $affectedRows = $ilDB->manipulateF(
754 "DELETE FROM svy_qst_constraint WHERE question_fi = %s",
755 array('integer'),
756 array($question_id)
757 );
758 $affectedRows = $ilDB->manipulateF(
759 "DELETE FROM svy_qblk_qst WHERE question_fi = %s",
760 array('integer'),
761 array($question_id)
762 );
763 $affectedRows = $ilDB->manipulateF(
764 "DELETE FROM svy_svy_qst WHERE question_fi = %s",
765 array('integer'),
766 array($question_id)
767 );
768 $affectedRows = $ilDB->manipulateF(
769 "DELETE FROM svy_variable WHERE question_fi = %s",
770 array('integer'),
771 array($question_id)
772 );
773 $affectedRows = $ilDB->manipulateF(
774 "DELETE FROM svy_question WHERE question_id = %s",
775 array('integer'),
776 array($question_id)
777 );
778
779 $this->deleteAdditionalTableData($question_id);
780
781 $affectedRows = $ilDB->manipulateF(
782 "DELETE FROM svy_material WHERE question_fi = %s",
783 array('integer'),
784 array($question_id)
785 );
786
787 $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);
788
789 ilInternalLink::_deleteAllLinksOfSource("sqst", $question_id);
790
791 $directory = CLIENT_WEB_DIR . "/survey/" . $obj_id . "/$question_id";
792 if (preg_match("/\d+/", $obj_id) and preg_match("/\d+/", $question_id) and is_dir($directory)) {
793 ilFileUtils::delDir($directory);
794 }
795
796 $mobs = ilObjMediaObject::_getMobsOfObject("spl:html", $question_id);
797 // remaining usages are not in text anymore -> delete them
798 // and media objects (note: delete method of ilObjMediaObject
799 // checks whether object is used in another context; if yes,
800 // the object is not deleted!)
801 foreach ($mobs as $mob) {
802 ilObjMediaObject::_removeUsage($mob, "spl:html", $question_id);
803 $mob_obj = new ilObjMediaObject($mob);
804 $mob_obj->delete();
805 }
806 $this->log->debug("Call ilSurveySkill::handleQuestionDeletion, q id: " . $question_id .
807 ", obj id: " . $obj_id);
809
810 $this->log->debug("UPDATE svy_question");
811
812 // #12772 - untie question copies from pool question
813 $ilDB->manipulate("UPDATE svy_question" .
814 " SET original_id = NULL" .
815 " WHERE original_id = " . $ilDB->quote($question_id, "integer"));
816 }
deleteAdditionalTableData(int $question_id)
Deletes datasets from the additional question table in the database.
static delDir(string $a_dir, bool $a_clean_only=false)
removes a dir and all its content (subdirs and files) recursively
static _removeUsage(int $a_mob_id, string $a_type, int $a_id, int $a_usage_hist_nr=0, string $a_lang="-")
Remove usage of mob in another container.
static handleQuestionDeletion(int $a_question_id, int $a_obj_id)
Remove question skill assignment.
const CLIENT_WEB_DIR
Definition: constants.php:47

References $ilDB, $mobs, ilInternalLink\_deleteAllLinksOfSource(), ilObjMediaObject\_getMobsOfObject(), ilObjMediaObject\_removeUsage(), CLIENT_WEB_DIR, ilFileUtils\delDir(), and ilSurveySkill\handleQuestionDeletion().

+ Here is the call graph for this function:

◆ deleteAdditionalTableData()

SurveyQuestion::deleteAdditionalTableData ( int  $question_id)

Deletes datasets from the additional question table in the database.

Reimplemented in SurveyMatrixQuestion.

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

692 : void
693 {
695
696 $this->log->debug("DELETE FROM " . $this->getAdditionalTableName());
697
698 $ilDB->manipulateF(
699 "DELETE FROM " . $this->getAdditionalTableName() . " WHERE question_fi = %s",
700 array('integer'),
701 array($question_id)
702 );
703 }

References $ilDB.

◆ deleteMaterial()

SurveyQuestion::deleteMaterial ( string  $materials_name = "")

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

200 : void {
201 foreach ($this->materials as $key => $value) {
202 if (strcmp($key, $materials_name) === 0) {
203 if (file_exists($this->getMaterialsPath() . $value)) {
204 unlink($this->getMaterialsPath() . $value);
205 }
206 unset($this->materials[$key]);
207 }
208 }
209 }
getMaterialsPath()
Returns the materials path for web accessible materials of a question.

References ILIAS\LTI\ToolProvider\$key.

◆ deleteMaterials()

SurveyQuestion::deleteMaterials ( array  $a_array)
Parameters
array$a_arrayArray with indexes of the materials to delete

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

1036 : void
1037 {
1038 foreach ($a_array as $idx) {
1039 unset($this->material[$idx]);
1040 }
1041 $this->material = array_values($this->material);
1042 $this->saveMaterial();
1043 }

◆ duplicate()

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

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

328 : ?int {
329 if ($this->getId() <= 0) {
330 // The question has not been saved. It cannot be duplicated
331 return null;
332 }
333 // duplicate the question in database
334 $clone = $this;
335 $original_id = $this->getId();
336 $clone->setId(-1);
337 if ($a_survey_id > 0) {
338 $clone->setObjId($a_survey_id);
339 }
340 if ($title) {
341 $clone->setTitle($title);
342 }
343 if ($author) {
344 $clone->setAuthor($author);
345 }
346 if ($owner) {
347 $clone->setOwner($owner);
348 }
349 if ($for_survey) {
350 $clone->saveToDb($original_id);
351 } else {
352 $clone->saveToDb();
353 }
354 // duplicate the materials
355 $clone->duplicateMaterials($original_id);
356 // copy XHTML media objects
357 $clone->copyXHTMLMediaObjectsOfQuestion($original_id);
358 return $clone->getId();
359 }

◆ duplicateMaterials()

SurveyQuestion::duplicateMaterials ( int  $question_id)

Duplicates the materials of a question.

Parameters
int$question_id
Exceptions
ilSurveyException

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

1050 : void
1051 {
1052 foreach ($this->materials as $filename) {
1053 $materialspath = $this->getMaterialsPath();
1054 $materialspath_original = preg_replace("/([^\d])$this->id([^\d])/", "\${1}$question_id\${2}", $materialspath);
1055 if (!file_exists($materialspath)) {
1056 ilFileUtils::makeDirParents($materialspath);
1057 }
1058 if (!copy($materialspath_original . $filename, $materialspath . $filename)) {
1059 throw new ilSurveyException("Unable to duplicate materials.");
1060 }
1061 }
1062 }
$filename
Definition: buildRTE.php:78
static makeDirParents(string $a_dir)
Create a new directory and all parent directories.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...

References $filename, and ilFileUtils\makeDirParents().

+ Here is the call graph for this function:

◆ flushMaterials()

SurveyQuestion::flushMaterials ( )

Deletes all materials uris.

Todo:
check if unlink is necessary

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

215 : void
216 {
217 $this->materials = array();
218 }

◆ getAuthor()

SurveyQuestion::getAuthor ( )

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

291 : string
292 {
293 return $this->author;
294 }

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

+ Here is the caller graph for this function:

◆ getAvailableRelations()

SurveyQuestion::getAvailableRelations ( )

Returns the available relations for the question.

Reimplemented in SurveyMetricQuestion, SurveyMultipleChoiceQuestion, and SurveySingleChoiceQuestion.

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

1550 : array
1551 {
1552 // overwrite in inherited classes
1553 return array();
1554 }

◆ getCopyIds()

SurveyQuestion::getCopyIds ( bool  $a_group_by_survey = false)

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

1655 : array {
1656 $ilDB = $this->db;
1657
1658 $set = $ilDB->query("SELECT q.question_id,s.obj_fi" .
1659 " FROM svy_question q" .
1660 " JOIN svy_svy_qst sq ON (sq.question_fi = q.question_id)" .
1661 " JOIN svy_svy s ON (s.survey_id = sq.survey_fi)" .
1662 " WHERE original_id = " . $ilDB->quote($this->getId(), "integer"));
1663 $res = array();
1664 while ($row = $ilDB->fetchAssoc($set)) {
1665 if (!$a_group_by_survey) {
1666 $res[] = (int) $row["question_id"];
1667 } else {
1668 $res[$row["obj_fi"]][] = (int) $row["question_id"];
1669 }
1670 }
1671 return $res;
1672 }
$res
Definition: ltiservices.php:69

◆ getDescription()

SurveyQuestion::getDescription ( )

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

286 : string
287 {
288 return $this->description;
289 }

◆ getId()

◆ getImagePath()

SurveyQuestion::getImagePath ( )

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

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

609 : string
610 {
611 return CLIENT_WEB_DIR . "/survey/$this->obj_id/$this->id/images/";
612 }

References CLIENT_WEB_DIR.

◆ getImagePathWeb()

SurveyQuestion::getImagePathWeb ( )

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

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

625 : string
626 {
627 $webdir = ilFileUtils::removeTrailingPathSeparators(CLIENT_WEB_DIR) . "/survey/$this->obj_id/$this->id/images/";
628 return str_replace(
631 $webdir
632 );
633 }

References CLIENT_WEB_DIR, and ilFileUtils\removeTrailingPathSeparators().

+ Here is the call graph for this function:

◆ getLabel()

SurveyQuestion::getLabel ( )

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

248 : string
249 {
250 return $this->label;
251 }

◆ getMaterial()

SurveyQuestion::getMaterial ( )

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

1598 : array
1599 {
1600 return $this->material;
1601 }

◆ getMaterialsPath()

SurveyQuestion::getMaterialsPath ( )

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

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

617 : string
618 {
619 return CLIENT_WEB_DIR . "/survey/$this->obj_id/$this->id/materials/";
620 }

References CLIENT_WEB_DIR.

◆ getMaterialsPathWeb()

SurveyQuestion::getMaterialsPathWeb ( )

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

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

638 : string
639 {
640 $webdir = ilFileUtils::removeTrailingPathSeparators(CLIENT_WEB_DIR) . "/survey/$this->obj_id/$this->id/materials/";
641 return str_replace(
644 $webdir
645 );
646 }

References CLIENT_WEB_DIR, and ilFileUtils\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)

Reimplemented in SurveyMatrixQuestion, SurveyMultipleChoiceQuestion, and SurveySingleChoiceQuestion.

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

1729 : int
1730 {
1731 return 0;
1732 }

◆ getObjId()

SurveyQuestion::getObjId ( )

Get the reference(?) id of the container object.

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

309 : int
310 {
311 return $this->obj_id;
312 }

◆ getObligatory()

SurveyQuestion::getObligatory ( )

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

258 : bool
259 {
260 return $this->obligatory;
261 }

◆ getOrientation()

SurveyQuestion::getOrientation ( )
Returns
int 0 = vertical, 1 = horizontal

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

271 : int
272 {
273 switch ($this->orientation) {
274 case 0:
275 case 1:
276 case 2:
277 break;
278 default:
279 $this->orientation = 0;
280 break;
281 }
282 return $this->orientation;
283 }

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

+ Here is the caller graph for this function:

◆ getOriginalId()

SurveyQuestion::getOriginalId ( )

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

1593 : ?int
1594 {
1595 return $this->original_id;
1596 }

◆ getOwner()

SurveyQuestion::getOwner ( )

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

296 : int
297 {
298 return $this->owner;
299 }

◆ getPhrase()

SurveyQuestion::getPhrase ( int  $phrase_id)

Returns a phrase title for phrase id.

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

934 : string
935 {
937
938 $result = $ilDB->queryF(
939 "SELECT title FROM svy_phrase WHERE phrase_id = %s",
940 array('integer'),
941 array($phrase_id)
942 );
943 if ($row = $ilDB->fetchAssoc($result)) {
944 return $row["title"];
945 }
946 return "";
947 }

References $ilDB.

◆ getPreconditionOptions()

SurveyQuestion::getPreconditionOptions ( )

Returns the options for preconditions.

Reimplemented in SurveyMultipleChoiceQuestion, and SurveySingleChoiceQuestion.

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

1559 : array
1560 {
1561 // overwrite in inherited classes
1562 return [];
1563 }

◆ getPreconditionSelectValue()

SurveyQuestion::getPreconditionSelectValue ( string  $default,
string  $title,
string  $variable 
)

Creates a form property for the precondition value.

Reimplemented in SurveyMatrixQuestion, SurveyMetricQuestion, SurveyMultipleChoiceQuestion, and SurveySingleChoiceQuestion.

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

1584 // overwrite in inherited classes
1585 return null;
1586 }
This class represents a property in a property form.

◆ getPreconditionValueOutput()

SurveyQuestion::getPreconditionValueOutput ( string  $value)

Returns the output for a precondition value.

Parameters
string$valueThe precondition value
Returns
string The output of the precondition value

Reimplemented in SurveyMatrixQuestion, SurveyMultipleChoiceQuestion, and SurveySingleChoiceQuestion.

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

1570 : string
1571 {
1572 // overwrite in inherited classes
1573 return $value;
1574 }

◆ getQuestionDataArray()

SurveyQuestion::getQuestionDataArray ( int  $id)

Returns the question data.

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

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

1488 : array
1489 {
1490 return array();
1491 }

◆ getQuestiontext()

SurveyQuestion::getQuestiontext ( )

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

301 : string
302 {
303 return $this->questiontext;
304 }

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

+ Here is the caller graph for this function:

◆ getQuestionType()

SurveyQuestion::getQuestionType ( )

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

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

1288 : string
1289 {
1290 return "";
1291 }

◆ getQuestionTypeID()

SurveyQuestion::getQuestionTypeID ( )

Reimplemented in SurveyMetricQuestion.

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

1272 : int
1273 {
1274 $ilDB = $this->db;
1275 $result = $ilDB->queryF(
1276 "SELECT questiontype_id FROM svy_qtype WHERE type_tag = %s",
1277 array('text'),
1278 array($this->getQuestionType())
1279 );
1280 if ($result->numRows() === 1) {
1281 $row = $ilDB->fetchAssoc($result);
1282 return (int) $row["questiontype_id"];
1283 }
1284
1285 return 0;
1286 }

References $ilDB.

◆ getSubtype()

SurveyQuestion::getSubtype ( )

Reimplemented in SurveyMatrixQuestion, and SurveyMetricQuestion.

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

1608 : ?int
1609 {
1610 // do nothing
1611 return null;
1612 }

◆ getSurveyId()

SurveyQuestion::getSurveyId ( )

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

263 : int
264 {
265 return $this->survey_id;
266 }

◆ getTitle()

SurveyQuestion::getTitle ( )

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

243 : string
244 {
245 return $this->title;
246 }

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

+ Here is the caller graph for this function:

◆ getWorkingDataFromUserInput()

SurveyQuestion::getWorkingDataFromUserInput ( array  $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

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

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

1497 : array
1498 {
1499 // overwrite in inherited classes
1500 $data = array();
1501 return $data;
1502 }

References $data.

◆ hasCopies()

SurveyQuestion::hasCopies ( )

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

1674 : bool
1675 {
1676 return (bool) count($this->getCopyIds());
1677 }
getCopyIds(bool $a_group_by_survey=false)

◆ importAdditionalMetadata()

SurveyQuestion::importAdditionalMetadata ( array  $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.

Reimplemented in SurveyMatrixQuestion, SurveyMultipleChoiceQuestion, and SurveySingleChoiceQuestion.

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

1509 : void
1510 {
1511 // overwrite in inherited classes
1512 }

◆ importAdjectives()

SurveyQuestion::importAdjectives ( array  $a_data)

Import bipolar adjectives from the question import file.

Reimplemented in SurveyMatrixQuestion.

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

1525 : void
1526 {
1527 // overwrite in inherited classes
1528 }

◆ importMatrix()

SurveyQuestion::importMatrix ( array  $a_data)

Import matrix rows from the question import file.

Reimplemented in SurveyMatrixQuestion.

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

1533 : void
1534 {
1535 // overwrite in inherited classes
1536 }

◆ importResponses()

SurveyQuestion::importResponses ( array  $a_data)

Import response data from the question import file.

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

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

1517 : void
1518 {
1519 // overwrite in inherited classes
1520 }

◆ isComplete()

SurveyQuestion::isComplete ( )

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

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

105 : bool
106 {
107 return false;
108 }

◆ isHTML()

SurveyQuestion::isHTML ( string  $a_text)
Todo:
move to manager

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

1398 : bool
1399 {
1400 if (preg_match("/<[^>]*?>/", $a_text)) {
1401 return true;
1402 }
1403
1404 return false;
1405 }

◆ loadFromDb()

SurveyQuestion::loadFromDb ( int  $question_id)

load question data into object note: this base implementation only loads the material data

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

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

403 : void
404 {
406
407 $result = $ilDB->queryF(
408 "SELECT * FROM svy_material WHERE question_fi = %s",
409 array('integer'),
410 array($this->getId())
411 );
412 $this->material = array();
413 if ($result->numRows()) {
414 while ($row = $ilDB->fetchAssoc($result)) {
415 $mat = new ilSurveyMaterial();
416 $mat->type = (string) $row['material_type'];
417 $mat->internal_link = (string) $row['internal_link'];
418 $mat->title = (string) $row['material_title'];
419 $mat->import_id = (string) $row['import_id'];
420 $mat->text_material = (string) $row['text_material'];
421 $mat->external_link = (string) $row['external_link'];
422 $mat->file_material = (string) $row['file_material'];
423 $this->material[] = $mat;
424 }
425 }
426 }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...

References $ilDB, and ILIAS\Survey\Mode\getId().

+ Here is the call graph for this function:

◆ lookupObjFi()

static SurveyQuestion::lookupObjFi ( int  $a_qid)
static

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

1698 : ?int {
1699 global $DIC;
1700
1701 $ilDB = $DIC->database();
1702
1703 $set = $ilDB->query(
1704 "SELECT obj_fi FROM svy_question " .
1705 " WHERE question_id = " . $ilDB->quote($a_qid, "integer")
1706 );
1707 if ($rec = $ilDB->fetchAssoc($set)) {
1708 return (int) $rec["obj_fi"];
1709 }
1710 return null;
1711 }

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

+ Here is the caller graph for this function:

◆ phraseExists()

SurveyQuestion::phraseExists ( string  $title)

Returns true if the phrase title already exists for the current user(!)

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

952 : bool
953 {
956
957 $result = $ilDB->queryF(
958 "SELECT phrase_id FROM svy_phrase WHERE title = %s AND owner_fi = %s",
959 array('text', 'integer'),
960 array($title, $ilUser->getId())
961 );
962 return $result->numRows() > 0;
963 }

References $ilDB, and $ilUser.

◆ prepareTextareaOutput()

SurveyQuestion::prepareTextareaOutput ( string  $txt_output,
bool  $prepare_for_latex_output = false 
)

Prepares string for a text area output in surveys.

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

1481 : string {
1482 return ilLegacyFormElementsUtil::prepareTextareaOutput($txt_output, $prepare_for_latex_output);
1483 }
static prepareTextareaOutput(string $txt_output, bool $prepare_for_latex_output=false, bool $omitNl2BrWhenTextArea=false)
Prepares a string for a text area output where latex code may be in it If the text is HTML-free,...

◆ QTIMaterialToString()

SurveyQuestion::QTIMaterialToString ( ilQTIMaterial  $a_material)

Reads an QTI material tag an creates a text string.

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

1410 : string
1411 {
1412 $svy_log = ilLoggerFactory::getLogger("svy");
1413 $svy_log->debug("material count: " . $a_material->getMaterialCount());
1414
1415 $result = "";
1416 for ($i = 0; $i < $a_material->getMaterialCount(); $i++) {
1417 $material = $a_material->getMaterial($i);
1418 if (strcmp($material["type"], "mattext") === 0) {
1419 $result .= $material["material"]->getContent();
1420 }
1421 if (strcmp($material["type"], "matimage") === 0) {
1422 $matimage = $material["material"];
1423 if (preg_match("/(il_([0-9]+)_mob_([0-9]+))/", $matimage->getLabel(), $matches)) {
1424 // import an mediaobject which was inserted using tiny mce
1425 $this->import_manager->addMob(
1426 $matimage->getLabel(),
1427 $matimage->getUri()
1428 );
1429 }
1430 }
1431 }
1432 return $result;
1433 }
getMaterial(int $a_index)
$i
Definition: metadata.php:41

References $i, ilLoggerFactory\getLogger(), ilQTIMaterial\getMaterial(), and ilQTIMaterial\getMaterialCount().

+ Here is the call graph for this function:

◆ questionTitleExists()

SurveyQuestion::questionTitleExists ( string  $title,
int  $questionpool_object = 0 
)

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

113 : bool {
115
116 $refwhere = "";
117 if ($questionpool_object > 0) {
118 $refwhere = sprintf(
119 " AND obj_fi = %s",
120 $ilDB->quote($questionpool_object, 'integer')
121 );
122 }
123 $result = $ilDB->queryF(
124 "SELECT question_id FROM svy_question WHERE title = %s$refwhere",
125 array('text'),
126 array($title)
127 );
128 return $result->numRows() > 0;
129 }

References $ilDB.

◆ saveCategoryToDb()

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

Saves a category to the database.

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

654 : int {
657
658 $result = $ilDB->queryF(
659 "SELECT title, category_id FROM svy_category WHERE title = %s AND neutral = %s AND owner_fi = %s",
660 array('text','text','integer'),
661 array($categorytext, $neutral, $ilUser->getId())
662 );
663 $insert = false;
664 $returnvalue = "";
665 $insert = true;
666 if ($result->numRows()) {
667 while ($row = $ilDB->fetchAssoc($result)) {
668 if (strcmp($row["title"], $categorytext) === 0) {
669 $returnvalue = $row["category_id"];
670 $insert = false;
671 }
672 }
673 }
674 if ($insert) {
675 $next_id = $ilDB->nextId('svy_category');
676 $affectedRows = $ilDB->manipulateF(
677 "INSERT INTO svy_category (category_id, title, neutral, owner_fi, tstamp) VALUES (%s, %s, %s, %s, %s)",
678 array('integer','text','text','integer','integer'),
679 array($next_id, $categorytext, $neutral, $ilUser->getId(), time())
680 );
681
682 $this->log->debug("INSERT INTO svy_category id=" . $next_id);
683
684 $returnvalue = $next_id;
685 }
686 return $returnvalue;
687 }

References $ilDB.

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

+ Here is the caller graph for this function:

◆ saveCompletionStatus()

SurveyQuestion::saveCompletionStatus ( int  $original_id = 0)

Saves the complete flag to the database.

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

456 : void {
458
459 $question_id = $this->getId();
460 if ($original_id > 0) {
461 $question_id = $original_id;
462 }
463
464 if ($this->getId() > 0) {
465 $this->log->debug("UPDATE svy_question question_id=" . $question_id);
466
467 // update existing dataset
468 $affectedRows = $ilDB->manipulateF(
469 "UPDATE svy_question SET complete = %s, tstamp = %s WHERE question_id = %s",
470 array('text', 'integer', 'integer'),
471 array($this->isComplete(), time(), $question_id)
472 );
473 }
474 }

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

+ Here is the caller graph for this function:

◆ saveMaterial()

SurveyQuestion::saveMaterial ( )

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

529 : void
530 {
532
533 $this->log->debug("DELETE: svy_material question_fi=" . $this->getId());
534
535 $affectedRows = $ilDB->manipulateF(
536 "DELETE FROM svy_material WHERE question_fi = %s",
537 array('integer'),
538 array($this->getId())
539 );
541
542 foreach ($this->material as $material) {
543 $next_id = $ilDB->nextId('svy_material');
544
545 $this->log->debug("INSERT: svy_material question_fi=" . $this->getId());
546
547 $affectedRows = $ilDB->manipulateF(
548 "INSERT INTO svy_material " .
549 "(material_id, question_fi, internal_link, import_id, material_title, tstamp," .
550 "text_material, external_link, file_material, material_type) " .
551 "VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s)",
552 array('integer','integer','text','text','text','integer','text','text','text','integer'),
553 array(
554 $next_id, $this->getId(), $material->internal_link, $material->import_id,
555 $material->title, time(), $material->text_material, $material->external_link,
556 $material->file_material, $material->type)
557 );
558 if (preg_match("/il_(\d*?)_(\w+)_(\d+)/", $material->internal_link, $matches)) {
559 ilInternalLink::_saveLink("sqst", $this->getId(), $matches[2], (int) $matches[3], (int) $matches[1]);
560 }
561 }
562 }

References $ilDB, ilInternalLink\_deleteAllLinksOfSource(), ilInternalLink\_saveLink(), and ILIAS\Survey\Mode\getId().

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

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

◆ saveToDb()

SurveyQuestion::saveToDb ( int  $original_id = 0)

Saves a SurveyQuestion object to a database.

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

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

479 : int
480 {
482
483 // cleanup RTE images which are not inserted into the question text
484 ilRTE::_cleanupMediaObjectUsage($this->getQuestiontext(), "spl:html", $this->getId());
485 $affectedRows = 0;
486 if ($this->getId() === -1) {
487 // Write new dataset
488 $next_id = $ilDB->nextId('svy_question');
489 $affectedRows = $ilDB->insert("svy_question", array(
490 "question_id" => array("integer", $next_id),
491 "questiontype_fi" => array("integer", $this->getQuestionTypeID()),
492 "obj_fi" => array("integer", $this->getObjId()),
493 "owner_fi" => array("integer", $this->getOwner()),
494 "title" => array("text", $this->getTitle()),
495 "label" => array("text", (strlen($this->label)) ? $this->label : null),
496 "description" => array("text", $this->getDescription()),
497 "author" => array("text", $this->getAuthor()),
498 "questiontext" => array("clob", ilRTE::_replaceMediaObjectImageSrc($this->getQuestiontext(), 0)),
499 "obligatory" => array("text", $this->getObligatory()),
500 "complete" => array("text", $this->isComplete()),
501 "created" => array("integer", time()),
502 "original_id" => array("integer", ($original_id) ?: null),
503 "tstamp" => array("integer", time())
504 ));
505
506 //$this->log->debug("INSERT: svy_question id=".$next_id." questiontype_fi=".$this->getQuestionTypeID()." obj_fi".$this->getObjId()." title=".$this->getTitle()." ...");
507
508 $this->setId($next_id);
509 } else {
510 // update existing dataset
511 $affectedRows = $ilDB->update("svy_question", array(
512 "title" => array("text", $this->getTitle()),
513 "label" => array("text", (strlen($this->label)) ? $this->label : null),
514 "description" => array("text", $this->getDescription()),
515 "author" => array("text", $this->getAuthor()),
516 "questiontext" => array("clob", ilRTE::_replaceMediaObjectImageSrc($this->getQuestiontext(), 0)),
517 "obligatory" => array("text", $this->getObligatory()),
518 "complete" => array("text", $this->isComplete()),
519 "tstamp" => array("integer", time())
520 ), array(
521 "question_id" => array("integer", $this->getId())
522 ));
523
524 $this->log->debug("UPDATE svy_question id=" . $this->getId() . " SET: title=" . $this->getTitle() . " ...");
525 }
526 return $affectedRows;
527 }
static _cleanupMediaObjectUsage(string $a_text, string $a_usage_type, int $a_usage_id)
Synchronises appearances of media objects in $a_text with media object usage table.

References $ilDB, ilRTE\_cleanupMediaObjectUsage(), ilRTE\_replaceMediaObjectImageSrc(), and ILIAS\Survey\Mode\getId().

+ Here is the call graph for this function:

◆ setAuthor()

SurveyQuestion::setAuthor ( string  $author = "")

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

220 : void
221 {
223
224 if (!$author) {
225 $author = $ilUser->fullname;
226 }
227 $this->author = $author;
228 }

References $ilUser.

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

+ Here is the caller graph for this function:

◆ setComplete()

SurveyQuestion::setComplete ( bool  $a_complete)

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

100 : void
101 {
102 $this->complete = $a_complete;
103 }

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

+ Here is the caller graph for this function:

◆ setDescription()

SurveyQuestion::setDescription ( string  $description = "")

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

156 : void
157 {
158 $this->description = $description;
159 }

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

+ Here is the caller graph for this function:

◆ setId()

SurveyQuestion::setId ( int  $id = -1)

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

146 : void
147 {
148 $this->id = $id;
149 }

References $id.

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

+ Here is the caller graph for this function:

◆ setMaterialsfile()

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

Uploads and adds a material.

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

180 : void {
181 if (!empty($materials_filename)) {
182 $materialspath = $this->getMaterialsPath();
183 if (!file_exists($materialspath)) {
184 ilFileUtils::makeDirParents($materialspath);
185 }
187 $materials_tempfilename,
188 $materials_filename,
189 $materialspath . $materials_filename
190 )) {
191 print "image not uploaded!!!! ";
192 } else {
193 $this->addMaterials($materials_filename, $materials_name);
194 }
195 }
196 }
addMaterials(string $materials_file, string $materials_name="")
static moveUploadedFile(string $a_file, string $a_name, string $a_target, bool $a_raise_errors=true, string $a_mode="move_uploaded")
move uploaded file

References ilFileUtils\makeDirParents(), and ilFileUtils\moveUploadedFile().

+ Here is the call graph for this function:

◆ setObjId()

SurveyQuestion::setObjId ( int  $obj_id = 0)

Set the reference(?) id of the container object.

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

317 : void
318 {
319 $this->obj_id = $obj_id;
320 }

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

+ Here is the caller graph for this function:

◆ setObligatory()

SurveyQuestion::setObligatory ( bool  $obligatory = true)

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

136 : void
137 {
138 $this->obligatory = $obligatory;
139 }

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

+ Here is the caller graph for this function:

◆ setOrientation()

SurveyQuestion::setOrientation ( int  $orientation = 0)

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

141 : void
142 {
143 $this->orientation = $orientation;
144 }

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

+ Here is the caller graph for this function:

◆ setOriginalId()

SurveyQuestion::setOriginalId ( ?int  $original_id)

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

1588 : void
1589 {
1590 $this->original_id = $original_id;
1591 }

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

+ Here is the caller graph for this function:

◆ setOwner()

SurveyQuestion::setOwner ( int  $owner = 0)
Parameters
int$owneruser id of owner

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

238 : void
239 {
240 $this->owner = $owner;
241 }

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

+ Here is the caller graph for this function:

◆ setQuestiontext()

SurveyQuestion::setQuestiontext ( string  $questiontext = "")

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

230 : void
231 {
232 $this->questiontext = $questiontext;
233 }

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

+ Here is the caller graph for this function:

◆ setSubtype()

SurveyQuestion::setSubtype ( int  $a_subtype)

Reimplemented in SurveyMatrixQuestion, and SurveyMetricQuestion.

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

1603 : void
1604 {
1605 // do nothing
1606 }

◆ setSurveyId()

SurveyQuestion::setSurveyId ( int  $id = -1)

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

151 : void
152 {
153 $this->survey_id = $id;
154 }

References $id.

◆ setTitle()

SurveyQuestion::setTitle ( string  $title = "")

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

131 : void
132 {
133 $this->title = $title;
134 }

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

+ Here is the caller graph for this function:

◆ stripSlashesAddSpaceFallback()

SurveyQuestion::stripSlashesAddSpaceFallback ( string  $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.

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

1717 : string
1718 {
1719 $str = ilUtil::stripSlashes($a_str);
1720 if ($str !== $a_str) {
1721 $str = ilUtil::stripSlashes(str_replace("<", "< ", $a_str));
1722 }
1723 return $str;
1724 }
static stripSlashes(string $a_str, bool $a_strip_html=true, string $a_allow="")

References ilUtil\stripSlashes().

+ Here is the call graph for this function:

◆ syncWithOriginal()

SurveyQuestion::syncWithOriginal ( )

Reimplemented in SurveyMatrixQuestion.

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

891 : void
892 {
894
895 if ($this->getOriginalId()) {
896 $id = $this->getId();
897 $original = $this->getOriginalId();
898
899 $this->setId($this->getOriginalId());
900 $this->setOriginalId(null);
901 $this->saveToDb();
902
903 $this->setId($id);
904 $this->setOriginalId($original);
905
906 $this->log->debug("DELETE FROM svy_material WHERE question_fi = " . $this->getOriginalId());
907
908 $affectedRows = $ilDB->manipulateF(
909 "DELETE FROM svy_material WHERE question_fi = %s",
910 array('integer'),
911 array($this->getOriginalId())
912 );
913 ilInternalLink::_deleteAllLinksOfSource("sqst", $this->original_id);
914 if (strlen($this->material["internal_link"])) {
915 $next_id = $ilDB->nextId('svy_material');
916 $affectedRows = $ilDB->manipulateF(
917 "INSERT INTO svy_material (material_id, question_fi, internal_link, import_id, material_title, tstamp) VALUES (%s, %s, %s, %s, %s, %s)",
918 array('integer', 'integer', 'text', 'text', 'text', 'integer'),
919 array($next_id, $this->getOriginalId(), $this->material["internal_link"], $this->material["import_id"], $this->material["title"], time())
920 );
921
922 $this->log->debug("INSERT svy_material material_id=" . $next_id . " question_fi=" . $this->getOriginalId());
923
924 if (preg_match("/il_(\d*?)_(\w+)_(\d+)/", $this->material["internal_link"], $matches)) {
925 ilInternalLink::_saveLink("sqst", $this->getOriginalId(), $matches[2], $matches[3], $matches[1]);
926 }
927 }
928 }
929 }
saveToDb(int $original_id=0)
Saves a SurveyQuestion object to a database.
setOriginalId(?int $original_id)

References $id, $ilDB, ilInternalLink\_deleteAllLinksOfSource(), ilInternalLink\_saveLink(), and ILIAS\Survey\Mode\getId().

+ Here is the call graph for this function:

◆ usableForPrecondition()

SurveyQuestion::usableForPrecondition ( )

Returns if the question is usable for preconditions.

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

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

1541 : bool
1542 {
1543 // overwrite in inherited classes
1544 return false;
1545 }

Field Documentation

◆ $arrData

array SurveyQuestion::$arrData
private

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

◆ $author

◆ $complete

bool SurveyQuestion::$complete

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

◆ $cumulated

array SurveyQuestion::$cumulated
protected

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

◆ $db

◆ $description

◆ $edit_manager

ILIAS SurveyQuestionPool Editing EditSessionRepository SurveyQuestion::$edit_manager
protected

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

◆ $id

◆ $import_manager

ILIAS SurveyQuestionPool Export ImportSessionRepository SurveyQuestion::$import_manager
protected

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

◆ $lng

ilLanguage SurveyQuestion::$lng

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

Referenced by __construct().

◆ $log

ilLogger SurveyQuestion::$log
protected

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

◆ $material

array SurveyQuestion::$material

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

◆ $materials

array SurveyQuestion::$materials

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

◆ $obj_id

int SurveyQuestion::$obj_id

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

◆ $obligatory

bool SurveyQuestion::$obligatory

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

◆ $orientation

int SurveyQuestion::$orientation

◆ $original_id

◆ $owner

◆ $questiontext

◆ $survey_id

int SurveyQuestion::$survey_id

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

◆ $title

◆ $user

ilObjUser SurveyQuestion::$user
protected

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

Referenced by SurveySingleChoiceQuestion\addPhrase().


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