ILIAS  trunk Revision v11.0_alpha-2638-g80c1d007f79
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...
 
 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 ()
 
 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 
)

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

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

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: shib_login.php:26
+ Here is the call graph for this function:

Member Function Documentation

◆ __get()

SurveyQuestion::__get ( string  $value)

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

References null.

1353  : ?string
1354  {
1355  switch ($value) {
1356  default:
1357  if (array_key_exists($value, $this->arrData)) {
1358  return (string) $this->arrData[$value];
1359  }
1360 
1361  return null;
1362  }
1363  }
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null

◆ __set()

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

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

1365  : void
1366  {
1367  switch ($key) {
1368  default:
1369  $this->arrData[$key] = $value;
1370  break;
1371  }
1372  }

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

References $DIC, and $ilDB.

Referenced by ilSurveyEditorGUI\executeCopyQuestionsToPoolObject().

1381  : void {
1382  global $DIC;
1383 
1384  $ilDB = $DIC->database();
1385 
1386  $ilDB->manipulate("UPDATE svy_question" .
1387  " SET original_id = " . $ilDB->quote($a_original_id, "integer") . "," .
1388  " obj_fi = " . $ilDB->quote($a_object_id, "integer") .
1389  " WHERE question_id = " . $ilDB->quote($a_question_id, "integer"));
1390  }
global $DIC
Definition: shib_login.php:26
+ Here is the caller graph for this function:

◆ _getInternalLinkHref()

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

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

References ilFileUtils\removeTrailingPathSeparators().

973  : string {
974  $linktypes = array(
975  "lm" => "LearningModule",
976  "pg" => "PageObject",
977  "st" => "StructureObject",
978  "git" => "GlossaryItem",
979  "mob" => "MediaObject"
980  );
981  $href = "";
982  if (preg_match("/il__(\w+)_(\d+)/", $target, $matches)) {
983  $type = $matches[1];
984  $target_id = $matches[2];
985  switch ($linktypes[$matches[1]]) {
986  case "StructureObject":
987  case "PageObject":
988  case "GlossaryItem":
989  case "LearningModule":
990  $href = ilFileUtils::removeTrailingPathSeparators(ILIAS_HTTP_PATH) . "/goto.php?target=" . $type . "_" . $target_id;
991  break;
992  case "MediaObject":
994  ILIAS_HTTP_PATH
995  ) . "/ilias.php?baseClass=ilLMPresentationGUI&obj_type=" . $linktypes[$type] . "&cmd=media&ref_id=" . $a_parent_ref_id . "&mob_id=" . $target_id;
996  break;
997  }
998  }
999  return $href;
1000  }
static removeTrailingPathSeparators(string $path)
+ Here is the call 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 809 of file class.SurveyQuestion.php.

References $DIC, and $ilDB.

Referenced by ilObjSurvey\importObject().

812  : int {
813  global $DIC;
814 
815  $ilDB = $DIC->database();
816  $result = $ilDB->queryF(
817  "SELECT * FROM svy_question WHERE question_id = %s",
818  array('integer'),
819  array($question_id)
820  );
821  if ($result->numRows() > 0) {
822  $row = $ilDB->fetchAssoc($result);
823  if ($row["original_id"] > 0) {
824  return (int) $row["original_id"];
825  } elseif ($a_return_question_id_if_no_original) { // #12419
826  return (int) $row["question_id"];
827  }
828  }
829  return 0;
830  }
global $DIC
Definition: shib_login.php:26
+ Here is the caller graph for this function:

◆ _getQuestionType()

static SurveyQuestion::_getQuestionType ( int  $question_id)
static

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

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

References $data, $DIC, and $ilDB.

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

762  : string
763  {
764  global $DIC;
765 
766  $ilDB = $DIC->database();
767 
768  if ($question_id < 1) {
769  return "";
770  }
771 
772  $result = $ilDB->queryF(
773  "SELECT type_tag FROM svy_question, svy_qtype WHERE svy_question.question_id = %s AND svy_question.questiontype_fi = svy_qtype.questiontype_id",
774  array('integer'),
775  array($question_id)
776  );
777  if ($result->numRows() === 1) {
778  $data = $ilDB->fetchAssoc($result);
779  return $data["type_tag"];
780  } else {
781  return "";
782  }
783  }
global $DIC
Definition: shib_login.php:26
+ 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 1076 of file class.SurveyQuestion.php.

References $DIC, and ilLanguage\txt().

Referenced by ilSurveyConstraintsGUI\constraintForm(), ilObjSurveyQuestionPoolGUI\deleteQuestionsObject(), SurveyMatrixQuestionEvaluation\exportResults(), SurveyQuestionEvaluation\exportResults(), ilSurveyEvaluationGUI\exportResultsDetailsExcel(), ilSurveyQuestionsTableGUI\fillRow(), ilSurveyResultsCumulatedTableGUI\getItems(), ILIAS\Survey\Mode\AbstractUIModifier\getPanelCard(), and ilSurveyEditorGUI\removeQuestionsForm().

1078  : string {
1079  global $DIC;
1080  $lng = $DIC->language();
1081  return $lng->txt($type_tag);
1082  }
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...
global $DIC
Definition: shib_login.php:26
+ Here is the call graph for this function:
+ 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 788 of file class.SurveyQuestion.php.

References $data, $DIC, and $ilDB.

Referenced by ilObjSurveyQuestionPoolGUI\addLocatorItems(), ilObjSurveyGUI\addLocatorItems(), ILIAS\components\ILIAS\Glossary\Table\TermUsagesTable\getDataRetrieval(), and ilSurveySyncTableGUI\importData().

788  : string
789  {
790  global $DIC;
791 
792  $ilDB = $DIC->database();
793 
794  $result = $ilDB->queryF(
795  "SELECT title FROM svy_question WHERE svy_question.question_id = %s",
796  array('integer'),
797  array($question_id)
798  );
799 
800  if ($data = $ilDB->fetchAssoc($result)) {
801  return (string) $data["title"];
802  }
803  return "";
804  }
global $DIC
Definition: shib_login.php:26
+ 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 1056 of file class.SurveyQuestion.php.

Referenced by SurveyQuestionGUI\_getQuestionGUI(), ilObjSurvey\_instanciateQuestion(), ilSurveyConstraintsGUI\confirmDeleteConstraintsObject(), ilSurveyConstraintsGUI\constraintForm(), ilObjSurvey\getConstraints(), ilObjSurvey\getUserSpecificResults(), ilObjSurveyQuestionPool\toXML(), and ilObjSurveyQuestionPool\toXmlForExport().

1059  : bool {
1060  $type = $question_type;
1061  if ($gui === 1) {
1062  $type .= "GUI";
1063  } elseif ($gui === 2) {
1064  $type .= "Evaluation";
1065  }
1066  if (file_exists("./components/ILIAS/SurveyQuestionPool/Questions/class." . $type . ".php")) {
1067  return true;
1068  }
1069  return false;
1070  }
+ Here is the caller graph for this function:

◆ _instanciateQuestion()

static SurveyQuestion::_instanciateQuestion ( int  $question_id)
static

Get question object.

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

References null.

Referenced by ilSurveySkill\determineMaxScale(), ilObjSurveyQuestionPool\duplicateQuestion(), ilObjMediaObject\getParentObjectIdForUsage(), SurveySingleChoiceQuestion\isSumScoreValid(), ilObjSurveyQuestionPool\removeQuestion(), and ilSurveyExecutionGUI\saveActiveQuestionData().

1088  : ?SurveyQuestion
1089  {
1090  $question_type = self::_getQuestionType($question_id);
1091  if ($question_type) {
1092  self::_includeClass($question_type);
1093  $question = new $question_type();
1094  $question->loadFromDb($question_id);
1095  return $question;
1096  }
1097  return null;
1098  }
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
+ Here is the caller graph for this function:

◆ _instanciateQuestionEvaluation()

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

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

References null.

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

1120  $question = self::_instanciateQuestion($question_id);
1121  if (is_null($a_finished_ids)) {
1122  $a_finished_ids = [];
1123  }
1124  if ($question) {
1125  $question_type = self::_getQuestionType($question_id);
1126  self::_includeClass($question_type, 2);
1127  $class = $question_type . "Evaluation";
1128  $ev = new $class($question, $a_finished_ids);
1129  return $ev;
1130  }
1131  return null;
1132  }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
+ Here is the caller graph for this function:

◆ _instanciateQuestionGUI()

static SurveyQuestion::_instanciateQuestionGUI ( int  $question_id)
static

Get question gui object.

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

References null.

1105  : ?SurveyQuestionGUI {
1106  $question_type = self::_getQuestionType($question_id);
1107  if ($question_type) {
1108  self::_includeClass($question_type, 1);
1109  $guitype = $question_type . "GUI";
1110  $question = new $guitype($question_id);
1111  return $question;
1112  }
1113  return null;
1114  }
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
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 407 of file class.SurveyQuestion.php.

References $DIC, and $ilDB.

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

407  : bool
408  {
409  global $DIC;
410 
411  $ilDB = $DIC->database();
412 
413  $result = $ilDB->queryF(
414  "SELECT complete FROM svy_question WHERE question_id = %s",
415  array('integer'),
416  array($question_id)
417  );
418  if ($result->numRows()) {
419  $row = $ilDB->fetchAssoc($result);
420  if ((int) $row["complete"] === 1) {
421  return true;
422  }
423  }
424  return false;
425  }
global $DIC
Definition: shib_login.php:26
+ 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 1005 of file class.SurveyQuestion.php.

References $DIC, $ilDB, and ilObjSurveyQuestionPool\_isWriteable().

Referenced by SurveyQuestionGUI\save().

1008  : bool {
1009  global $DIC;
1010 
1011  $ilDB = $DIC->database();
1012 
1013  if (($question_id < 1) || ($user_id < 1)) {
1014  return false;
1015  }
1016 
1017  $result = $ilDB->queryF(
1018  "SELECT obj_fi FROM svy_question WHERE question_id = %s",
1019  array('integer'),
1020  array($question_id)
1021  );
1022  if ($result->numRows() === 1) {
1023  $row = $ilDB->fetchAssoc($result);
1024  $qpl_object_id = $row["obj_fi"];
1025  return ilObjSurveyQuestionPool::_isWriteable($qpl_object_id);
1026  }
1027 
1028  return false;
1029  }
static _isWriteable(int $object_id)
Returns true, if the question pool is writeable for the current user.
global $DIC
Definition: shib_login.php:26
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _lookupSurveyObjId()

static SurveyQuestion::_lookupSurveyObjId ( int  $a_question_id)
static

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

References $DIC, $ilDB, and null.

Referenced by ilObjMediaObject\getParentObjectIdForUsage().

1420  : ?int {
1421  global $DIC;
1422 
1423  $ilDB = $DIC->database();
1424 
1425  $set = $ilDB->query("SELECT svy_svy.obj_fi FROM svy_svy_qst" .
1426  " JOIN svy_svy ON (svy_svy.survey_id = svy_svy_qst.survey_fi)" .
1427  " WHERE svy_svy_qst.question_fi = " . $ilDB->quote($a_question_id, "integer"));
1428  $row = $ilDB->fetchAssoc($set);
1429  if ($ilDB->numRows($set)) {
1430  return (int) $row["obj_fi"];
1431  }
1432  return null;
1433  }
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
global $DIC
Definition: shib_login.php:26
+ Here is the caller graph for this function:

◆ _questionExists()

static SurveyQuestion::_questionExists ( int  $question_id)
static

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

References $DIC, and $ilDB.

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

872  : bool
873  {
874  global $DIC;
875 
876  $ilDB = $DIC->database();
877 
878  if ($question_id < 1) {
879  return false;
880  }
881 
882  $result = $ilDB->queryF(
883  "SELECT question_id FROM svy_question WHERE question_id = %s",
884  array('integer'),
885  array($question_id)
886  );
887  return $result->numRows() === 1;
888  }
global $DIC
Definition: shib_login.php:26
+ Here is the caller graph for this function:

◆ _resolveInternalLink()

static SurveyQuestion::_resolveInternalLink ( string  $internal_link)
static

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

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

893  : string {
894  $resolved_link = "";
895  if (preg_match("/il_(\d+)_(\w+)_(\d+)/", $internal_link, $matches)) {
896  switch ($matches[2]) {
897  case "lm":
898  $resolved_link = ilLMObject::_getIdForImportId($internal_link);
899  break;
900  case "pg":
901  $resolved_link = ilInternalLink::_getIdForImportId("PageObject", $internal_link);
902  break;
903  case "st":
904  $resolved_link = ilInternalLink::_getIdForImportId("StructureObject", $internal_link);
905  break;
906  case "git":
907  $resolved_link = ilInternalLink::_getIdForImportId("GlossaryItem", $internal_link);
908  break;
909  case "mob":
910  $resolved_link = ilInternalLink::_getIdForImportId("MediaObject", $internal_link);
911  break;
912  }
913  if (strcmp($resolved_link, "") === 0) {
914  $resolved_link = $internal_link;
915  }
916  } else {
917  $resolved_link = $internal_link;
918  }
919  return $resolved_link;
920  }
static _getIdForImportId(string $a_import_id)
get current object id for import id (static)
+ Here is the call graph for this function:

◆ _resolveIntLinks()

static SurveyQuestion::_resolveIntLinks ( int  $question_id)
static

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

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

924  : void {
925  global $DIC;
926 
927  $ilDB = $DIC->database();
928  $resolvedlinks = 0;
929  $result = $ilDB->queryF(
930  "SELECT * FROM svy_material WHERE question_fi = %s",
931  array('integer'),
932  array($question_id)
933  );
934  if ($result->numRows()) {
935  while ($row = $ilDB->fetchAssoc($result)) {
936  $internal_link = $row["internal_link"];
937  $resolved_link = self::_resolveInternalLink($internal_link);
938  if (strcmp($internal_link, $resolved_link) !== 0) {
939  // internal link was resolved successfully
940  $affectedRows = $ilDB->manipulateF(
941  "UPDATE svy_material SET internal_link = %s, tstamp = %s WHERE material_id = %s",
942  array('text', 'integer', 'integer'),
943  array($resolved_link, time(), $row["material_id"])
944  );
945  $resolvedlinks++;
946  }
947  }
948  }
949  if ($resolvedlinks) {
950  // there are resolved links -> reenter theses links to the database
951 
952  // delete all internal links from the database
953  ilInternalLink::_deleteAllLinksOfSource("sqst", $question_id);
954 
955  $result = $ilDB->queryF(
956  "SELECT * FROM svy_material WHERE question_fi = %s",
957  array('integer'),
958  array($question_id)
959  );
960  if ($result->numRows()) {
961  while ($row = $ilDB->fetchAssoc($result)) {
962  if (preg_match("/il_(\d*?)_(\w+)_(\d+)/", $row["internal_link"], $matches)) {
963  ilInternalLink::_saveLink("sqst", $question_id, $matches[2], $matches[3], $matches[1]);
964  }
965  }
966  }
967  }
968  }
global $DIC
Definition: shib_login.php:26
+ Here is the call graph for this function:

◆ addMaterials()

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

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

Referenced by setMaterialsfile().

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  }
+ Here is the caller graph for this function:

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

References ilObjMediaObject\_getMobsOfObject(), ilRTE\_replaceMediaObjectImageSrc(), getId(), IL_INST_ID, isHTML(), null, ilXmlWriter\xmlElement(), ilXmlWriter\xmlEndTag(), and ilXmlWriter\xmlStartTag().

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

1183  : void {
1184  $a_xml_writer->xmlStartTag("material");
1185  $attrs = array(
1186  "type" => "text/plain"
1187  );
1188  if ($this->isHTML($a_material)) {
1189  $attrs["type"] = "text/xhtml";
1190  }
1191  if (is_array($a_attrs)) {
1192  $attrs = array_merge($attrs, $a_attrs);
1193  }
1194  $a_xml_writer->xmlElement("mattext", $attrs, ilRTE::_replaceMediaObjectImageSrc($a_material, 0));
1195 
1196  if ($add_mobs) {
1197  $mobs = ilObjMediaObject::_getMobsOfObject("spl:html", $this->getId());
1198  foreach ($mobs as $mob) {
1199  $mob_obj = new ilObjMediaObject($mob);
1200  $imgattrs = array(
1201  "label" => "il_" . IL_INST_ID . "_mob_" . $mob,
1202  "uri" => "objects/" . "il_" . IL_INST_ID . "_mob_" . $mob . "/" . $mob_obj->getTitle(),
1203  "type" => "spl:html",
1204  "id" => $this->getId()
1205  );
1206  $a_xml_writer->xmlElement("matimage", $imgattrs, null);
1207  }
1208  }
1209  if ($close_material_tag) {
1210  $a_xml_writer->xmlEndTag("material");
1211  }
1212  }
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...
isHTML(string $a_text)
const IL_INST_ID
Definition: constants.php:40
xmlEndTag(string $tag)
Writes an endtag.
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
static _getMobsOfObject(string $a_type, int $a_id, int $a_usage_hist_nr=0, string $a_lang="-")
xmlStartTag(string $tag, ?array $attrs=null, bool $empty=false, bool $encode=true, bool $escape=true)
Writes a starttag.
xmlElement(string $tag, $attrs=null, $data=null, $encode=true, $escape=true)
Writes a basic element (no children, just textual content)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ copyObject()

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

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

References getId(), getObjId(), and null.

362  : ?int {
363  if ($this->getId() <= 0) {
364  // The question has not been saved. It cannot be copied
365  return null;
366  }
367  $clone = $this;
368  $original_id = self::_getOriginalId($this->getId(), false);
369  $clone->setId(-1);
370  $source_questionpool = $this->getObjId();
371  $clone->setObjId($target_questionpool);
372  if ($title) {
373  $clone->setTitle($title);
374  }
375 
376  $clone->saveToDb();
377 
378  // copy XHTML media objects
379  $clone->copyXHTMLMediaObjectsOfQuestion($original_id);
380  return $clone->getId();
381  }
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
getObjId()
Get the reference(?) id of the container object.
+ Here is the call graph for this function:

◆ copyXHTMLMediaObjectsOfQuestion()

SurveyQuestion::copyXHTMLMediaObjectsOfQuestion ( int  $a_q_id)

Copy media object usages from other question.

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

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

388  : void {
389  $mobs = ilObjMediaObject::_getMobsOfObject("spl:html", $a_q_id);
390  foreach ($mobs as $mob) {
391  ilObjMediaObject::_saveUsage($mob, "spl:html", $this->getId());
392  }
393  }
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.
static _getMobsOfObject(string $a_type, int $a_id, int $a_usage_hist_nr=0, string $a_lang="-")
+ 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 510 of file class.SurveyQuestion.php.

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

510  : int
511  {
512  $ilDB = $this->db;
513 
514  $obj_id = $this->getObjId();
515  if ($obj_id > 0) {
516  $next_id = $ilDB->nextId('svy_question');
517  $affectedRows = $ilDB->manipulateF(
518  "INSERT INTO svy_question (question_id, questiontype_fi, " .
519  "obj_fi, owner_fi, title, description, author, questiontext, obligatory, complete, " .
520  "created, original_id, tstamp) VALUES " .
521  "(%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)",
522  array('integer', 'integer', 'integer', 'integer', 'text', 'text', 'text', 'text',
523  'text', 'text', 'integer', 'integer', 'integer'),
524  array(
525  $next_id,
526  $this->getQuestionTypeID(),
527  $obj_id,
528  $this->getOwner(),
529  null,
530  null,
531  $this->getAuthor(),
532  null,
533  "1",
534  "0",
535  time(),
536  null,
537  0
538  )
539  );
540  $this->log->debug("INSERT INTO svy_question question_id= " . $next_id . " questiontype_fi= " . $this->getQuestionTypeID());
541 
542  $this->setId($next_id);
543  }
544  return $this->getId();
545  }
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
getObjId()
Get the reference(?) id of the container object.
+ 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 649 of file class.SurveyQuestion.php.

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

649  : void
650  {
651  $ilDB = $this->db;
652  $this->log->debug("Question Delete... " . $question_id);
653  if ($question_id < 1) {
654  return;
655  }
656 
657  $result = $ilDB->queryF(
658  "SELECT obj_fi FROM svy_question WHERE question_id = %s",
659  array('integer'),
660  array($question_id)
661  );
662  if ($result->numRows() === 1) {
663  $row = $ilDB->fetchAssoc($result);
664  $obj_id = $row["obj_fi"];
665  } else {
666  return;
667  }
668 
669  $affectedRows = $ilDB->manipulateF(
670  "DELETE FROM svy_answer WHERE question_fi = %s",
671  array('integer'),
672  array($question_id)
673  );
674 
675  $affectedRows = $ilDB->manipulateF(
676  "DELETE FROM svy_constraint WHERE question_fi = %s",
677  array('integer'),
678  array($question_id)
679  );
680 
681  $result = $ilDB->queryF(
682  "SELECT constraint_fi FROM svy_qst_constraint WHERE question_fi = %s",
683  array('integer'),
684  array($question_id)
685  );
686  while ($row = $ilDB->fetchObject($result)) {
687  $affectedRows = $ilDB->manipulateF(
688  "DELETE FROM svy_constraint WHERE constraint_id = %s",
689  array('integer'),
690  array($row->constraint_fi)
691  );
692  }
693 
694  $affectedRows = $ilDB->manipulateF(
695  "DELETE FROM svy_qst_constraint WHERE question_fi = %s",
696  array('integer'),
697  array($question_id)
698  );
699  $affectedRows = $ilDB->manipulateF(
700  "DELETE FROM svy_qblk_qst WHERE question_fi = %s",
701  array('integer'),
702  array($question_id)
703  );
704  $affectedRows = $ilDB->manipulateF(
705  "DELETE FROM svy_svy_qst WHERE question_fi = %s",
706  array('integer'),
707  array($question_id)
708  );
709  $affectedRows = $ilDB->manipulateF(
710  "DELETE FROM svy_variable WHERE question_fi = %s",
711  array('integer'),
712  array($question_id)
713  );
714  $affectedRows = $ilDB->manipulateF(
715  "DELETE FROM svy_question WHERE question_id = %s",
716  array('integer'),
717  array($question_id)
718  );
719 
720  $this->deleteAdditionalTableData($question_id);
721 
722  $affectedRows = $ilDB->manipulateF(
723  "DELETE FROM svy_material WHERE question_fi = %s",
724  array('integer'),
725  array($question_id)
726  );
727 
728  $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);
729 
730  ilInternalLink::_deleteAllLinksOfSource("sqst", $question_id);
731 
732  $directory = CLIENT_WEB_DIR . "/survey/" . $obj_id . "/$question_id";
733  if (preg_match("/\d+/", $obj_id) and preg_match("/\d+/", $question_id) and is_dir($directory)) {
734  ilFileUtils::delDir($directory);
735  }
736 
737  $mobs = ilObjMediaObject::_getMobsOfObject("spl:html", $question_id);
738  // remaining usages are not in text anymore -> delete them
739  // and media objects (note: delete method of ilObjMediaObject
740  // checks whether object is used in another context; if yes,
741  // the object is not deleted!)
742  foreach ($mobs as $mob) {
743  ilObjMediaObject::_removeUsage($mob, "spl:html", $question_id);
744  $mob_obj = new ilObjMediaObject($mob);
745  $mob_obj->delete();
746  }
747  $this->log->debug("Call ilSurveySkill::handleQuestionDeletion, q id: " . $question_id .
748  ", obj id: " . $obj_id);
749  ilSurveySkill::handleQuestionDeletion($question_id, $obj_id);
750 
751  $this->log->debug("UPDATE svy_question");
752 
753  // #12772 - untie question copies from pool question
754  $ilDB->manipulate("UPDATE svy_question" .
755  " SET original_id = NULL" .
756  " WHERE original_id = " . $ilDB->quote($question_id, "integer"));
757  }
deleteAdditionalTableData(int $question_id)
Deletes datasets from the additional question table in the database.
static handleQuestionDeletion(int $a_question_id, int $a_obj_id)
Remove question skill assignment.
static delDir(string $a_dir, bool $a_clean_only=false)
removes a dir and all its content (subdirs and files) recursively
const CLIENT_WEB_DIR
Definition: constants.php:47
static _getMobsOfObject(string $a_type, int $a_id, int $a_usage_hist_nr=0, string $a_lang="-")
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.
+ Here is the call graph for this function:

◆ deleteAdditionalTableData()

SurveyQuestion::deleteAdditionalTableData ( int  $question_id)

Deletes datasets from the additional question table in the database.

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

References $db, and $ilDB.

Referenced by delete().

633  : void
634  {
635  $ilDB = $this->db;
636 
637  $this->log->debug("DELETE FROM " . $this->getAdditionalTableName());
638 
639  $ilDB->manipulateF(
640  "DELETE FROM " . $this->getAdditionalTableName() . " WHERE question_fi = %s",
641  array('integer'),
642  array($question_id)
643  );
644  }
+ Here is the caller graph for this function:

◆ deleteMaterial()

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

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

References getMaterialsPath().

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.
+ Here is the call graph for this function:

◆ 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.

References getId(), and null.

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  // copy XHTML media objects
355  $clone->copyXHTMLMediaObjectsOfQuestion($original_id);
356  return $clone->getId();
357  }
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
+ 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()

◆ getAvailableRelations()

SurveyQuestion::getAvailableRelations ( )

Returns the available relations for the question.

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

1289  : array
1290  {
1291  // overwrite in inherited classes
1292  return array();
1293  }

◆ getCopyIds()

SurveyQuestion::getCopyIds ( bool  $a_group_by_survey = false)

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

References $db, $ilDB, $res, and ILIAS\Repository\int().

Referenced by hasCopies().

1394  : array {
1395  $ilDB = $this->db;
1396 
1397  $set = $ilDB->query("SELECT q.question_id,s.obj_fi" .
1398  " FROM svy_question q" .
1399  " JOIN svy_svy_qst sq ON (sq.question_fi = q.question_id)" .
1400  " JOIN svy_svy s ON (s.survey_id = sq.survey_fi)" .
1401  " WHERE original_id = " . $ilDB->quote($this->getId(), "integer"));
1402  $res = array();
1403  while ($row = $ilDB->fetchAssoc($set)) {
1404  if (!$a_group_by_survey) {
1405  $res[] = (int) $row["question_id"];
1406  } else {
1407  $res[$row["obj_fi"]][] = (int) $row["question_id"];
1408  }
1409  }
1410  return $res;
1411  }
$res
Definition: ltiservices.php:66
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getDescription()

SurveyQuestion::getDescription ( )

◆ getId()

SurveyQuestion::getId ( )

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

References $id.

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

253  : int
254  {
255  return $this->id;
256  }
+ Here is the caller graph for this function:

◆ getImagePath()

SurveyQuestion::getImagePath ( )

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

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

References CLIENT_WEB_DIR.

550  : string
551  {
552  return CLIENT_WEB_DIR . "/survey/$this->obj_id/$this->id/images/";
553  }
const CLIENT_WEB_DIR
Definition: constants.php:47

◆ getImagePathWeb()

SurveyQuestion::getImagePathWeb ( )

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

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

References CLIENT_WEB_DIR, and ilFileUtils\removeTrailingPathSeparators().

566  : string
567  {
568  $webdir = ilFileUtils::removeTrailingPathSeparators(CLIENT_WEB_DIR) . "/survey/$this->obj_id/$this->id/images/";
569  return str_replace(
570  ilFileUtils::removeTrailingPathSeparators(ILIAS_ABSOLUTE_PATH),
572  $webdir
573  );
574  }
static removeTrailingPathSeparators(string $path)
const CLIENT_WEB_DIR
Definition: constants.php:47
+ 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 1337 of file class.SurveyQuestion.php.

References $material.

1337  : array
1338  {
1339  return $this->material;
1340  }

◆ getMaterialsPath()

SurveyQuestion::getMaterialsPath ( )

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

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

References CLIENT_WEB_DIR.

Referenced by deleteMaterial(), and setMaterialsfile().

558  : string
559  {
560  return CLIENT_WEB_DIR . "/survey/$this->obj_id/$this->id/materials/";
561  }
const CLIENT_WEB_DIR
Definition: constants.php:47
+ Here is the caller graph for this function:

◆ getMaterialsPathWeb()

SurveyQuestion::getMaterialsPathWeb ( )

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

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

References CLIENT_WEB_DIR, and ilFileUtils\removeTrailingPathSeparators().

579  : string
580  {
581  $webdir = ilFileUtils::removeTrailingPathSeparators(CLIENT_WEB_DIR) . "/survey/$this->obj_id/$this->id/materials/";
582  return str_replace(
583  ilFileUtils::removeTrailingPathSeparators(ILIAS_ABSOLUTE_PATH),
585  $webdir
586  );
587  }
static removeTrailingPathSeparators(string $path)
const CLIENT_WEB_DIR
Definition: constants.php:47
+ 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)

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

1468  : int
1469  {
1470  return 0;
1471  }

◆ getObjId()

SurveyQuestion::getObjId ( )

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

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

References $obj_id.

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

309  : int
310  {
311  return $this->obj_id;
312  }
+ Here is the caller graph for this function:

◆ getObligatory()

◆ getOrientation()

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

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

References $orientation.

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

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  }
+ Here is the caller graph for this function:

◆ getOriginalId()

SurveyQuestion::getOriginalId ( )

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

References $original_id.

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

1332  : ?int
1333  {
1334  return $this->original_id;
1335  }
+ Here is the caller graph for this function:

◆ getOwner()

SurveyQuestion::getOwner ( )

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

References $owner.

Referenced by createNewQuestion(), and saveToDb().

296  : int
297  {
298  return $this->owner;
299  }
+ Here is the caller graph for this function:

◆ getPreconditionOptions()

SurveyQuestion::getPreconditionOptions ( )

Returns the options for preconditions.

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

Referenced by SurveyMatrixQuestion\getPreconditionSelectValue().

1298  : array
1299  {
1300  // overwrite in inherited classes
1301  return [];
1302  }
+ Here is the caller graph for this function:

◆ getPreconditionSelectValue()

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

Creates a form property for the precondition value.

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

References null.

1322  : ?ilFormPropertyGUI {
1323  // overwrite in inherited classes
1324  return null;
1325  }
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null

◆ 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

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

1309  : string
1310  {
1311  // overwrite in inherited classes
1312  return $value;
1313  }

◆ getQuestionDataArray()

SurveyQuestion::getQuestionDataArray ( int  $id)

Returns the question data.

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

1227  : array
1228  {
1229  return array();
1230  }

◆ getQuestiontext()

◆ getQuestionType()

SurveyQuestion::getQuestionType ( )

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

Referenced by SurveyMatrixQuestionEvaluation\exportResults(), SurveyQuestionEvaluation\exportResults(), and getQuestionTypeID().

1047  : string
1048  {
1049  return "";
1050  }
+ Here is the caller graph for this function:

◆ getQuestionTypeID()

SurveyQuestion::getQuestionTypeID ( )

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

References $db, $ilDB, and getQuestionType().

Referenced by createNewQuestion(), and saveToDb().

1031  : int
1032  {
1033  $ilDB = $this->db;
1034  $result = $ilDB->queryF(
1035  "SELECT questiontype_id FROM svy_qtype WHERE type_tag = %s",
1036  array('text'),
1037  array($this->getQuestionType())
1038  );
1039  if ($result->numRows() === 1) {
1040  $row = $ilDB->fetchAssoc($result);
1041  return (int) $row["questiontype_id"];
1042  }
1043 
1044  return 0;
1045  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getSubtype()

SurveyQuestion::getSubtype ( )

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

References null.

1347  : ?int
1348  {
1349  // do nothing
1350  return null;
1351  }
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null

◆ getSurveyId()

SurveyQuestion::getSurveyId ( )

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

References $survey_id.

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

◆ getTitle()

◆ 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

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

References $data.

1236  : array
1237  {
1238  // overwrite in inherited classes
1239  $data = array();
1240  return $data;
1241  }

◆ hasCopies()

SurveyQuestion::hasCopies ( )

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

References getCopyIds().

1413  : bool
1414  {
1415  return (bool) count($this->getCopyIds());
1416  }
getCopyIds(bool $a_group_by_survey=false)
+ Here is the call graph for this function:

◆ 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.

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

1248  : void
1249  {
1250  // overwrite in inherited classes
1251  }

◆ importAdjectives()

SurveyQuestion::importAdjectives ( array  $a_data)

Import bipolar adjectives from the question import file.

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

1264  : void
1265  {
1266  // overwrite in inherited classes
1267  }

◆ importMatrix()

SurveyQuestion::importMatrix ( array  $a_data)

Import matrix rows from the question import file.

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

1272  : void
1273  {
1274  // overwrite in inherited classes
1275  }

◆ importResponses()

SurveyQuestion::importResponses ( array  $a_data)

Import response data from the question import file.

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

1256  : void
1257  {
1258  // overwrite in inherited classes
1259  }

◆ isComplete()

SurveyQuestion::isComplete ( )

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

Referenced by saveCompletionStatus(), and saveToDb().

105  : bool
106  {
107  return false;
108  }
+ Here is the caller graph for this function:

◆ isHTML()

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

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

Referenced by addMaterialTag().

1137  : bool
1138  {
1139  if (preg_match("/<[^>]*?>/", $a_text)) {
1140  return true;
1141  }
1142 
1143  return false;
1144  }
+ Here is the caller graph for this function:

◆ loadFromDb()

SurveyQuestion::loadFromDb ( int  $question_id)

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

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

399  : void
400  {
401  $this->material = [];
402  }

◆ lookupObjFi()

static SurveyQuestion::lookupObjFi ( int  $a_qid)
static

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

References $DIC, $ilDB, and null.

Referenced by ILIAS\components\ILIAS\Glossary\Table\TermUsagesTable\getDataRetrieval(), and ilSurveyQuestionTableGUI\importData().

1437  : ?int {
1438  global $DIC;
1439 
1440  $ilDB = $DIC->database();
1441 
1442  $set = $ilDB->query(
1443  "SELECT obj_fi FROM svy_question " .
1444  " WHERE question_id = " . $ilDB->quote($a_qid, "integer")
1445  );
1446  if ($rec = $ilDB->fetchAssoc($set)) {
1447  return (int) $rec["obj_fi"];
1448  }
1449  return null;
1450  }
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
global $DIC
Definition: shib_login.php:26
+ Here is the caller graph for this function:

◆ prepareTextareaOutput()

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

Prepares string for a text area output in surveys.

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

References ilLegacyFormElementsUtil\prepareTextareaOutput().

1220  : string {
1221  return ilLegacyFormElementsUtil::prepareTextareaOutput($txt_output, $prepare_for_latex_output);
1222  }
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...
+ Here is the call graph for this function:

◆ QTIMaterialToString()

SurveyQuestion::QTIMaterialToString ( ilQTIMaterial  $a_material)

Reads an QTI material tag an creates a text string.

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

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

1149  : string
1150  {
1151  $svy_log = ilLoggerFactory::getLogger("svy");
1152  $svy_log->debug("material count: " . $a_material->getMaterialCount());
1153 
1154  $result = "";
1155  for ($i = 0; $i < $a_material->getMaterialCount(); $i++) {
1156  $material = $a_material->getMaterial($i);
1157  if (strcmp($material["type"], "mattext") === 0) {
1158  $result .= $material["material"]->getContent();
1159  }
1160  if (strcmp($material["type"], "matimage") === 0) {
1161  $matimage = $material["material"];
1162  if (preg_match("/(il_([0-9]+)_mob_([0-9]+))/", $matimage->getLabel(), $matches)) {
1163  // import an mediaobject which was inserted using tiny mce
1164  $this->import_manager->addMob(
1165  $matimage->getLabel(),
1166  $matimage->getUri()
1167  );
1168  }
1169  }
1170  }
1171  return $result;
1172  }
static getLogger(string $a_component_id)
Get component logger.
getMaterial(int $a_index)
+ 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.

References $db, and $ilDB.

113  : bool {
114  $ilDB = $this->db;
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  }

◆ saveCategoryToDb()

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

Saves a category to the database.

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

References $db, $ilDB, and $user.

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

595  : int {
596  $ilUser = $this->user;
597  $ilDB = $this->db;
598 
599  $result = $ilDB->queryF(
600  "SELECT title, category_id FROM svy_category WHERE title = %s AND neutral = %s AND owner_fi = %s",
601  array('text','text','integer'),
602  array($categorytext, $neutral, $ilUser->getId())
603  );
604  $insert = false;
605  $returnvalue = "";
606  $insert = true;
607  if ($result->numRows()) {
608  while ($row = $ilDB->fetchAssoc($result)) {
609  if (strcmp($row["title"], $categorytext) === 0) {
610  $returnvalue = $row["category_id"];
611  $insert = false;
612  }
613  }
614  }
615  if ($insert) {
616  $next_id = $ilDB->nextId('svy_category');
617  $affectedRows = $ilDB->manipulateF(
618  "INSERT INTO svy_category (category_id, title, neutral, owner_fi, tstamp) VALUES (%s, %s, %s, %s, %s)",
619  array('integer','text','text','integer','integer'),
620  array($next_id, $categorytext, $neutral, $ilUser->getId(), time())
621  );
622 
623  $this->log->debug("INSERT INTO svy_category id=" . $next_id);
624 
625  $returnvalue = $next_id;
626  }
627  return $returnvalue;
628  }
+ 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 430 of file class.SurveyQuestion.php.

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

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

432  : void {
433  $ilDB = $this->db;
434 
435  $question_id = $this->getId();
436  if ($original_id > 0) {
437  $question_id = $original_id;
438  }
439 
440  if ($this->getId() > 0) {
441  $this->log->debug("UPDATE svy_question question_id=" . $question_id);
442 
443  // update existing dataset
444  $affectedRows = $ilDB->manipulateF(
445  "UPDATE svy_question SET complete = %s, tstamp = %s WHERE question_id = %s",
446  array('text', 'integer', 'integer'),
447  array($this->isComplete(), time(), $question_id)
448  );
449  }
450  }
+ 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.

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

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

Referenced by syncWithOriginal().

455  : int
456  {
457  $ilDB = $this->db;
458 
459  // cleanup RTE images which are not inserted into the question text
460  ilRTE::_cleanupMediaObjectUsage($this->getQuestiontext(), "spl:html", $this->getId());
461  $affectedRows = 0;
462  if ($this->getId() === -1) {
463  // Write new dataset
464  $next_id = $ilDB->nextId('svy_question');
465  $affectedRows = $ilDB->insert("svy_question", array(
466  "question_id" => array("integer", $next_id),
467  "questiontype_fi" => array("integer", $this->getQuestionTypeID()),
468  "obj_fi" => array("integer", $this->getObjId()),
469  "owner_fi" => array("integer", $this->getOwner()),
470  "title" => array("text", $this->getTitle()),
471  "label" => array("text", (strlen($this->label ?? "")) ? $this->label : null),
472  "description" => array("text", $this->getDescription()),
473  "author" => array("text", $this->getAuthor()),
474  "questiontext" => array("clob", ilRTE::_replaceMediaObjectImageSrc($this->getQuestiontext(), 0)),
475  "obligatory" => array("text", $this->getObligatory()),
476  "complete" => array("text", $this->isComplete()),
477  "created" => array("integer", time()),
478  "original_id" => array("integer", ($original_id) ?: null),
479  "tstamp" => array("integer", time())
480  ));
481 
482  //$this->log->debug("INSERT: svy_question id=".$next_id." questiontype_fi=".$this->getQuestionTypeID()." obj_fi".$this->getObjId()." title=".$this->getTitle()." ...");
483 
484  $this->setId($next_id);
485  } else {
486  // update existing dataset
487  $affectedRows = $ilDB->update("svy_question", array(
488  "title" => array("text", $this->getTitle()),
489  "label" => array("text", (strlen($this->label ?? "")) ? $this->label : null),
490  "description" => array("text", $this->getDescription()),
491  "author" => array("text", $this->getAuthor()),
492  "questiontext" => array("clob", ilRTE::_replaceMediaObjectImageSrc($this->getQuestiontext(), 0)),
493  "obligatory" => array("text", $this->getObligatory()),
494  "complete" => array("text", $this->isComplete()),
495  "tstamp" => array("integer", time())
496  ), array(
497  "question_id" => array("integer", $this->getId())
498  ));
499 
500  $this->log->debug("UPDATE svy_question id=" . $this->getId() . " SET: title=" . $this->getTitle() . " ...");
501  }
502  return $affectedRows;
503  }
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...
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.
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
getObjId()
Get the reference(?) id of the container object.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setAuthor()

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

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

References $author, and $user.

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

220  : void
221  {
222  $ilUser = $this->user;
223 
224  if (!$author) {
225  $author = $ilUser->fullname;
226  }
227  $this->author = $author;
228  }
+ Here is the caller graph for this function:

◆ setComplete()

SurveyQuestion::setComplete ( bool  $a_complete)

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

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

100  : void
101  {
102  $this->complete = $a_complete;
103  }
+ Here is the caller graph for this function:

◆ setDescription()

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

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

References $description.

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

156  : void
157  {
158  $this->description = $description;
159  }
+ Here is the caller graph for this function:

◆ setId()

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

◆ 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.

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

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="")
getMaterialsPath()
Returns the materials path for web accessible materials of a question.
static makeDirParents(string $a_dir)
Create a new directory and all parent directories.
static moveUploadedFile(string $a_file, string $a_name, string $a_target, bool $a_raise_errors=true, string $a_mode="move_uploaded")
move uploaded file
+ 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.

References $obj_id.

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

317  : void
318  {
319  $this->obj_id = $obj_id;
320  }
+ Here is the caller graph for this function:

◆ setObligatory()

SurveyQuestion::setObligatory ( bool  $obligatory = true)

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

References $obligatory.

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

136  : void
137  {
138  $this->obligatory = $obligatory;
139  }
+ Here is the caller graph for this function:

◆ setOrientation()

SurveyQuestion::setOrientation ( int  $orientation = 0)

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

References $orientation.

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

141  : void
142  {
143  $this->orientation = $orientation;
144  }
+ Here is the caller graph for this function:

◆ setOriginalId()

SurveyQuestion::setOriginalId ( ?int  $original_id)

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

References $original_id.

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

1327  : void
1328  {
1329  $this->original_id = $original_id;
1330  }
+ 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.

References $owner.

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

238  : void
239  {
240  $this->owner = $owner;
241  }
+ Here is the caller graph for this function:

◆ setQuestiontext()

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

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

References $questiontext.

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

230  : void
231  {
232  $this->questiontext = $questiontext;
233  }
+ Here is the caller graph for this function:

◆ setSubtype()

SurveyQuestion::setSubtype ( int  $a_subtype)

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

1342  : void
1343  {
1344  // do nothing
1345  }

◆ setSurveyId()

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

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

References $id.

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

◆ setTitle()

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

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

References $title.

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

131  : void
132  {
133  $this->title = $title;
134  }
+ 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 1456 of file class.SurveyQuestion.php.

References ilUtil\stripSlashes().

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

1456  : string
1457  {
1458  $str = ilUtil::stripSlashes($a_str);
1459  if ($str !== $a_str) {
1460  $str = ilUtil::stripSlashes(str_replace("<", "< ", $a_str));
1461  }
1462  return $str;
1463  }
static stripSlashes(string $a_str, bool $a_strip_html=true, string $a_allow="")
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ syncWithOriginal()

SurveyQuestion::syncWithOriginal ( )

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

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

832  : void
833  {
834  $ilDB = $this->db;
835 
836  if ($this->getOriginalId()) {
837  $id = $this->getId();
838  $original = $this->getOriginalId();
839 
840  $this->setId($this->getOriginalId());
841  $this->setOriginalId(null);
842  $this->saveToDb();
843 
844  $this->setId($id);
845  $this->setOriginalId($original);
846 
847  $this->log->debug("DELETE FROM svy_material WHERE question_fi = " . $this->getOriginalId());
848 
849  $affectedRows = $ilDB->manipulateF(
850  "DELETE FROM svy_material WHERE question_fi = %s",
851  array('integer'),
852  array($this->getOriginalId())
853  );
854  ilInternalLink::_deleteAllLinksOfSource("sqst", $this->original_id);
855  if (strlen($this->material["internal_link"] ?? "")) {
856  $next_id = $ilDB->nextId('svy_material');
857  $affectedRows = $ilDB->manipulateF(
858  "INSERT INTO svy_material (material_id, question_fi, internal_link, import_id, material_title, tstamp) VALUES (%s, %s, %s, %s, %s, %s)",
859  array('integer', 'integer', 'text', 'text', 'text', 'integer'),
860  array($next_id, $this->getOriginalId(), $this->material["internal_link"], $this->material["import_id"], $this->material["title"], time())
861  );
862 
863  $this->log->debug("INSERT svy_material material_id=" . $next_id . " question_fi=" . $this->getOriginalId());
864 
865  if (preg_match("/il_(\d*?)_(\w+)_(\d+)/", $this->material["internal_link"], $matches)) {
866  ilInternalLink::_saveLink("sqst", $this->getOriginalId(), $matches[2], $matches[3], $matches[1]);
867  }
868  }
869  }
870  }
saveToDb(int $original_id=0)
Saves a SurveyQuestion object to a database.
setOriginalId(?int $original_id)
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
+ Here is the call graph for this function:

◆ usableForPrecondition()

SurveyQuestion::usableForPrecondition ( )

Returns if the question is usable for preconditions.

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

1280  : bool
1281  {
1282  // overwrite in inherited classes
1283  return false;
1284  }

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

ilDBInterface SurveyQuestion::$db
protected

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

Referenced by createNewQuestion(), delete(), deleteAdditionalTableData(), SurveyMatrixQuestion\deleteAdditionalTableData(), getCopyIds(), SurveySingleChoiceQuestion\getMaxSumScore(), SurveyMultipleChoiceQuestion\getMaxSumScore(), SurveyMatrixQuestion\getMaxSumScore(), SurveyTextQuestion\getQuestionDataArray(), SurveyMultipleChoiceQuestion\getQuestionDataArray(), SurveySingleChoiceQuestion\getQuestionDataArray(), SurveyMetricQuestion\getQuestionDataArray(), SurveyMatrixQuestion\getQuestionDataArray(), SurveyMetricQuestion\getQuestionTypeID(), getQuestionTypeID(), SurveyTextQuestion\loadFromDb(), SurveyMultipleChoiceQuestion\loadFromDb(), SurveySingleChoiceQuestion\loadFromDb(), SurveyMetricQuestion\loadFromDb(), SurveyMatrixQuestion\loadFromDb(), questionTitleExists(), SurveyMatrixQuestion\saveBipolarAdjectives(), SurveyMultipleChoiceQuestion\saveCategoriesToDb(), SurveySingleChoiceQuestion\saveCategoriesToDb(), saveCategoryToDb(), SurveyMatrixQuestion\saveColumnsToDb(), SurveyMatrixQuestion\saveColumnToDb(), saveCompletionStatus(), SurveyMatrixQuestion\saveLayout(), SurveyMatrixQuestion\saveRowsToDb(), SurveyTextQuestion\saveToDb(), SurveyMultipleChoiceQuestion\saveToDb(), SurveySingleChoiceQuestion\saveToDb(), SurveyMetricQuestion\saveToDb(), SurveyMatrixQuestion\saveToDb(), saveToDb(), SurveyTextQuestion\saveUserInput(), SurveyMultipleChoiceQuestion\saveUserInput(), SurveySingleChoiceQuestion\saveUserInput(), SurveyMetricQuestion\saveUserInput(), SurveyMatrixQuestion\saveUserInput(), and syncWithOriginal().

◆ $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

◆ $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.

Referenced by getObjId(), and setObjId().

◆ $obligatory

bool SurveyQuestion::$obligatory

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

Referenced by getObligatory(), and setObligatory().

◆ $orientation

◆ $original_id

◆ $owner

◆ $questiontext

◆ $survey_id

int SurveyQuestion::$survey_id

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

Referenced by getSurveyId().

◆ $title

◆ $user

ilObjUser SurveyQuestion::$user
protected

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