ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
SurveyQuestion Class Reference

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

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

Public Member Functions

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

Static Public Member Functions

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

Data Fields

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

Protected Attributes

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

Private Attributes

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

Detailed Description

Basic class for all survey question types.

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

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

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

Constructor & Destructor Documentation

◆ __construct()

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

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

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

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

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

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

Member Function Documentation

◆ __get()

SurveyQuestion::__get (   $value)

Object getter.

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

2038  {
2039  switch ($value) {
2040  default:
2041  if (array_key_exists($value, $this->arrData)) {
2042  return $this->arrData[$value];
2043  } else {
2044  return null;
2045  }
2046  break;
2047  }
2048  }

◆ __set()

SurveyQuestion::__set (   $key,
  $value 
)

Object setter.

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

References $key.

2054  {
2055  switch ($key) {
2056  default:
2057  $this->arrData[$key] = $value;
2058  break;
2059  }
2060  }
$key
Definition: croninfo.php:18

◆ _changeOriginalId()

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

Change original id of existing question in db.

Parameters
int$a_question_id
int$a_original_id
int$a_object_id

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

References $DIC, and $ilDB.

Referenced by ilSurveyEditorGUI\executeCopyQuestionsToPoolObject().

2070  {
2071  global $DIC;
2072 
2073  $ilDB = $DIC->database();
2074 
2075  $ilDB->manipulate("UPDATE svy_question" .
2076  " SET original_id = " . $ilDB->quote($a_original_id, "integer") . "," .
2077  " obj_fi = " . $ilDB->quote($a_object_id, "integer") .
2078  " WHERE question_id = " . $ilDB->quote($a_question_id, "integer"));
2079  }
global $DIC
Definition: saml.php:7
global $ilDB
+ Here is the caller graph for this function:

◆ _getInternalLinkHref()

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

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

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

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

1557  {
1558  global $DIC;
1559 
1560  $ilDB = $DIC->database();
1561  $linktypes = array(
1562  "lm" => "LearningModule",
1563  "pg" => "PageObject",
1564  "st" => "StructureObject",
1565  "git" => "GlossaryItem",
1566  "mob" => "MediaObject"
1567  );
1568  $href = "";
1569  if (preg_match("/il__(\w+)_(\d+)/", $target, $matches)) {
1570  $type = $matches[1];
1571  $target_id = $matches[2];
1572  switch ($linktypes[$matches[1]]) {
1573  case "LearningModule":
1574  $href = ilUtil::removeTrailingPathSeparators(ILIAS_HTTP_PATH) . "/goto.php?target=" . $type . "_" . $target_id;
1575  break;
1576  case "PageObject":
1577  case "StructureObject":
1578  $href = ilUtil::removeTrailingPathSeparators(ILIAS_HTTP_PATH) . "/goto.php?target=" . $type . "_" . $target_id;
1579  break;
1580  case "GlossaryItem":
1581  $href = ilUtil::removeTrailingPathSeparators(ILIAS_HTTP_PATH) . "/goto.php?target=" . $type . "_" . $target_id;
1582  break;
1583  case "MediaObject":
1584  $href = ilUtil::removeTrailingPathSeparators(ILIAS_HTTP_PATH) . "/ilias.php?baseClass=ilLMPresentationGUI&obj_type=" . $linktypes[$type] . "&cmd=media&ref_id=" . $a_parent_ref_id . "&mob_id=" . $target_id;
1585  break;
1586  }
1587  }
1588  return $href;
1589  }
$type
global $DIC
Definition: saml.php:7
$target_id
Definition: goto.php:49
static removeTrailingPathSeparators($path)
global $ilDB
$target
Definition: test.php:19
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _getOriginalId()

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

Returns the original id of a question.

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

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

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

Referenced by ilObjSurvey\importObject().

1189  {
1190  global $DIC;
1191 
1192  $ilDB = $DIC->database();
1193  $result = $ilDB->queryF(
1194  "SELECT * FROM svy_question WHERE question_id = %s",
1195  array('integer'),
1196  array($question_id)
1197  );
1198  if ($result->numRows() > 0) {
1199  $row = $ilDB->fetchAssoc($result);
1200  if ($row["original_id"] > 0) {
1201  return $row["original_id"];
1202  } elseif ((bool) $a_return_question_id_if_no_original) { // #12419
1203  return $row["question_id"];
1204  }
1205  } else {
1206  return "";
1207  }
1208  }
$result
global $DIC
Definition: saml.php:7
$row
global $ilDB
+ Here is the caller graph for this function:

◆ _getQuestionType()

static SurveyQuestion::_getQuestionType (   $question_id)
static

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

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

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

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

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

1129  {
1130  global $DIC;
1131 
1132  $ilDB = $DIC->database();
1133 
1134  if ($question_id < 1) {
1135  return "";
1136  }
1137 
1138  $result = $ilDB->queryF(
1139  "SELECT type_tag FROM svy_question, svy_qtype WHERE svy_question.question_id = %s AND svy_question.questiontype_fi = svy_qtype.questiontype_id",
1140  array('integer'),
1141  array($question_id)
1142  );
1143  if ($result->numRows() == 1) {
1144  $data = $ilDB->fetchAssoc($result);
1145  return $data["type_tag"];
1146  } else {
1147  return "";
1148  }
1149  }
$result
global $DIC
Definition: saml.php:7
global $ilDB
$data
Definition: bench.php:6
+ Here is the caller graph for this function:

◆ _getQuestionTypeName()

static SurveyQuestion::_getQuestionTypeName (   $type_tag)
static

Return the translation for a given question type tag.

Parameters
string$type_tagThe type tag of the question type public

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

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

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

1698  {
1699  if (file_exists("./Modules/SurveyQuestionPool/classes/class." . $type_tag . ".php")) {
1700  global $DIC;
1701 
1702  $lng = $DIC->language();
1703  return $lng->txt($type_tag);
1704  } else {
1705  global $DIC;
1706 
1707  $ilPluginAdmin = $DIC["ilPluginAdmin"];
1708  $pl_names = $ilPluginAdmin->getActivePluginsForSlot(IL_COMP_MODULE, "SurveyQuestionPool", "svyq");
1709  foreach ($pl_names as $pl_name) {
1710  $pl = ilPlugin::getPluginObject(IL_COMP_MODULE, "SurveyQuestionPool", "svyq", $pl_name);
1711  if (strcmp($pl->getQuestionType(), $type_tag) == 0) {
1712  return $pl->getQuestionTypeTranslation();
1713  }
1714  }
1715  }
1716  return "";
1717  }
static getPluginObject(string $a_ctype, string $a_cname, string $a_slot_id, string $a_pname)
global $DIC
Definition: saml.php:7
const IL_COMP_MODULE
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _getTitle()

static SurveyQuestion::_getTitle (   $question_id)
static

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

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

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

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

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

1159  {
1160  global $DIC;
1161 
1162  $ilDB = $DIC->database();
1163 
1164  if ($question_id < 1) {
1165  return "";
1166  }
1167 
1168  $result = $ilDB->queryF(
1169  "SELECT title FROM svy_question WHERE svy_question.question_id = %s",
1170  array('integer'),
1171  array($question_id)
1172  );
1173  if ($result->numRows() == 1) {
1174  $data = $ilDB->fetchAssoc($result);
1175  return $data["title"];
1176  } else {
1177  return "";
1178  }
1179  }
$result
global $DIC
Definition: saml.php:7
global $ilDB
$data
Definition: bench.php:6
+ Here is the caller graph for this function:

◆ _includeClass()

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

Include the php class file for a given question type.

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

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

References $DIC, $type, ilPlugin\getPluginObject(), and IL_COMP_MODULE.

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

1665  {
1666  $type = $question_type;
1667  if ($gui == 1) {
1668  $type .= "GUI";
1669  } elseif ($gui == 2) {
1670  $type .= "Evaluation";
1671  }
1672  if (file_exists("./Modules/SurveyQuestionPool/classes/class." . $type . ".php")) {
1673  include_once "./Modules/SurveyQuestionPool/classes/class." . $type . ".php";
1674  return true;
1675  } else {
1676  global $DIC;
1677 
1678  $ilPluginAdmin = $DIC["ilPluginAdmin"];
1679  $pl_names = $ilPluginAdmin->getActivePluginsForSlot(IL_COMP_MODULE, "SurveyQuestionPool", "svyq");
1680  foreach ($pl_names as $pl_name) {
1681  $pl = ilPlugin::getPluginObject(IL_COMP_MODULE, "SurveyQuestionPool", "svyq", $pl_name);
1682  if (strcmp($pl->getQuestionType(), $question_type) == 0) {
1683  $pl->includeClass("class." . $type . ".php");
1684  return true;
1685  }
1686  }
1687  }
1688  return false;
1689  }
static getPluginObject(string $a_ctype, string $a_cname, string $a_slot_id, string $a_pname)
$type
global $DIC
Definition: saml.php:7
const IL_COMP_MODULE
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _instanciateQuestion()

static SurveyQuestion::_instanciateQuestion (   $question_id)
static

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

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

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

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

1728  {
1729  $question_type = self::_getQuestionType($question_id);
1730  if ($question_type) {
1731  self::_includeClass($question_type);
1732  $question = new $question_type();
1733  $question->loadFromDb($question_id);
1734  return $question;
1735  }
1736  }
+ Here is the caller graph for this function:

◆ _instanciateQuestionEvaluation()

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

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

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

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

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

1764  {
1765  $question = self::_instanciateQuestion($question_id);
1766  if ($question) {
1767  $question_type = self::_getQuestionType($question_id);
1768  self::_includeClass($question_type, 2);
1769  $class = $question_type . "Evaluation";
1770  $ev = new $class($question, $a_finished_ids);
1771  return $ev;
1772  }
1773  }
+ Here is the caller graph for this function:

◆ _instanciateQuestionGUI()

static SurveyQuestion::_instanciateQuestionGUI (   $question_id)
static

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

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

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

1746  {
1747  $question_type = self::_getQuestionType($question_id);
1748  if ($question_type) {
1749  self::_includeClass($question_type, 1);
1750  $guitype = $question_type . "GUI";
1751  $question = new $guitype($question_id);
1752  return $question;
1753  }
1754  }

◆ _isComplete()

static SurveyQuestion::_isComplete (   $question_id)
static

Checks whether the question is complete or not.

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

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

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

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

696  {
697  global $DIC;
698 
699  $ilDB = $DIC->database();
700 
701  $result = $ilDB->queryF(
702  "SELECT complete FROM svy_question WHERE question_id = %s",
703  array('integer'),
704  array($question_id)
705  );
706  if ($result->numRows()) {
707  $row = $ilDB->fetchAssoc($result);
708  if ($row["complete"] == 1) {
709  return true;
710  }
711  }
712  return false;
713  }
$result
global $DIC
Definition: saml.php:7
$row
global $ilDB
+ Here is the caller graph for this function:

◆ _isWriteable()

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

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

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

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

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

Referenced by SurveyQuestionGUI\save().

1600  {
1601  global $DIC;
1602 
1603  $ilDB = $DIC->database();
1604 
1605  if (($question_id < 1) || ($user_id < 1)) {
1606  return false;
1607  }
1608 
1609  $result = $ilDB->queryF(
1610  "SELECT obj_fi FROM svy_question WHERE question_id = %s",
1611  array('integer'),
1612  array($question_id)
1613  );
1614  if ($result->numRows() == 1) {
1615  $row = $ilDB->fetchAssoc($result);
1616  $qpl_object_id = $row["obj_fi"];
1617  include_once "./Modules/SurveyQuestionPool/classes/class.ilObjSurveyQuestionPool.php";
1618  return ilObjSurveyQuestionPool::_isWriteable($qpl_object_id, $user_id);
1619  } else {
1620  return false;
1621  }
1622  }
$result
global $DIC
Definition: saml.php:7
static _isWriteable($object_id, $user_id)
Returns true, if the question pool is writeable by a given user.
$row
global $ilDB
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _lookupSurveyObjId()

static SurveyQuestion::_lookupSurveyObjId (   $a_question_id)
static

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

References $DIC, $ilDB, and $row.

Referenced by ilObjMediaObject\getParentObjectIdForUsage().

2107  {
2108  global $DIC;
2109 
2110  $ilDB = $DIC->database();
2111 
2112  $set = $ilDB->query("SELECT svy_svy.obj_fi FROM svy_svy_qst" .
2113  " JOIN svy_svy ON (svy_svy.survey_id = svy_svy_qst.survey_fi)" .
2114  " WHERE svy_svy_qst.question_fi = " . $ilDB->quote($a_question_id, "integer"));
2115  $row = $ilDB->fetchAssoc($set);
2116  if ($ilDB->numRows($set)) {
2117  return $row["obj_fi"];
2118  }
2119  }
global $DIC
Definition: saml.php:7
$row
global $ilDB
+ Here is the caller graph for this function:

◆ _questionExists()

static SurveyQuestion::_questionExists (   $question_id)
static

Returns true if the question already exists in the database.

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

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

References $DIC, $ilDB, and $result.

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

1300  {
1301  global $DIC;
1302 
1303  $ilDB = $DIC->database();
1304 
1305  if ($question_id < 1) {
1306  return false;
1307  }
1308 
1309  $result = $ilDB->queryF(
1310  "SELECT question_id FROM svy_question WHERE question_id = %s",
1311  array('integer'),
1312  array($question_id)
1313  );
1314  return ($result->numRows() == 1) ? true : false;
1315  }
$result
global $DIC
Definition: saml.php:7
global $ilDB
+ Here is the caller graph for this function:

◆ _resolveInternalLink()

static SurveyQuestion::_resolveInternalLink (   $internal_link)
static

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

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

1476  {
1477  if (preg_match("/il_(\d+)_(\w+)_(\d+)/", $internal_link, $matches)) {
1478  include_once "./Services/Link/classes/class.ilInternalLink.php";
1479  include_once "./Modules/LearningModule/classes/class.ilLMObject.php";
1480  include_once "./Modules/Glossary/classes/class.ilGlossaryTerm.php";
1481  switch ($matches[2]) {
1482  case "lm":
1483  $resolved_link = ilLMObject::_getIdForImportId($internal_link);
1484  break;
1485  case "pg":
1486  $resolved_link = ilInternalLink::_getIdForImportId("PageObject", $internal_link);
1487  break;
1488  case "st":
1489  $resolved_link = ilInternalLink::_getIdForImportId("StructureObject", $internal_link);
1490  break;
1491  case "git":
1492  $resolved_link = ilInternalLink::_getIdForImportId("GlossaryItem", $internal_link);
1493  break;
1494  case "mob":
1495  $resolved_link = ilInternalLink::_getIdForImportId("MediaObject", $internal_link);
1496  break;
1497  }
1498  if (strcmp($resolved_link, "") == 0) {
1499  $resolved_link = $internal_link;
1500  }
1501  } else {
1502  $resolved_link = $internal_link;
1503  }
1504  return $resolved_link;
1505  }
static _getIdForImportId($a_import_id)
get current object id for import id (static)
+ Here is the call graph for this function:

◆ _resolveIntLinks()

static SurveyQuestion::_resolveIntLinks (   $question_id)
static

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

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

Referenced by ilContObjParser\processPagesToParse().

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

◆ addInternalLink()

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

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

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

1318  {
1319  if (strlen($material_id)) {
1320  if (strcmp($material_title, "") == 0) {
1321  if (preg_match("/il__(\w+)_(\d+)/", $material_id, $matches)) {
1322  $type = $matches[1];
1323  $target_id = $matches[2];
1324  $material_title = $this->lng->txt("obj_$type") . ": ";
1325  switch ($type) {
1326  case "lm":
1327  include_once("./Modules/LearningModule/classes/class.ilObjContentObjectGUI.php");
1328  $cont_obj_gui = new ilObjContentObjectGUI("", $target_id, true);
1329  $cont_obj = $cont_obj_gui->object;
1330  $material_title .= $cont_obj->getTitle();
1331  break;
1332  case "pg":
1333  include_once("./Modules/LearningModule/classes/class.ilLMPageObject.php");
1334  include_once("./Modules/LearningModule/classes/class.ilLMObject.php");
1336  include_once("./Modules/LearningModule/classes/class.ilObjContentObjectGUI.php");
1337  $cont_obj_gui = new ilObjContentObjectGUI("", $lm_id, false);
1338  $cont_obj = $cont_obj_gui->object;
1339  $pg_obj = new ilLMPageObject($cont_obj, $target_id);
1340  $material_title .= $pg_obj->getTitle();
1341  break;
1342  case "st":
1343  include_once("./Modules/LearningModule/classes/class.ilStructureObject.php");
1344  include_once("./Modules/LearningModule/classes/class.ilLMObject.php");
1346  include_once("./Modules/LearningModule/classes/class.ilObjContentObjectGUI.php");
1347  $cont_obj_gui = new ilObjContentObjectGUI("", $lm_id, false);
1348  $cont_obj = $cont_obj_gui->object;
1349  $st_obj = new ilStructureObject($cont_obj, $target_id);
1350  $material_title .= $st_obj->getTitle();
1351  break;
1352  case "git":
1353  include_once "./Modules/Glossary/classes/class.ilGlossaryTerm.php";
1354  $material_title = $this->lng->txt("glossary_term") . ": " . ilGlossaryTerm::_lookGlossaryTerm($target_id);
1355  break;
1356  case "mob":
1357  break;
1358  }
1359  }
1360  }
1361  include_once "./Modules/SurveyQuestionPool/classes/class.ilSurveyMaterial.php";
1362  $mat = new ilSurveyMaterial();
1363  $mat->type = 0;
1364  $mat->internal_link = $material_id;
1365  $mat->title = $material_title;
1366  $this->addMaterial($mat);
1367  $this->saveMaterial();
1368  }
1369  }
$type
$target_id
Definition: goto.php:49
Survey material class.
static _lookupContObjID($a_id)
get learning module / digibook id for lm object
addMaterial($obj_material)
Class ilLMPageObject.
saveMaterial()
save material to db
Class ilStructreObject.
Class ilObjContentObjectGUI.
static _lookGlossaryTerm($term_id)
get glossary term
+ Here is the call graph for this function:

◆ addMaterial()

SurveyQuestion::addMaterial (   $obj_material)

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

Referenced by addInternalLink().

1406  {
1407  array_push($this->material, $obj_material);
1408  }
+ Here is the caller graph for this function:

◆ addMaterials()

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

Sets the materials uri.

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

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

Referenced by setMaterialsfile().

322  {
323  if (empty($materials_name)) {
324  $materials_name = $materials_file;
325  }
326  if ((!empty($materials_name)) && (!array_key_exists($materials_name, $this->materials))) {
327  $this->materials[$materials_name] = $materials_file;
328  }
329  }
+ Here is the caller graph for this function:

◆ addMaterialTag()

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

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

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

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

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

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

1833  {
1834  include_once "./Services/RTE/classes/class.ilRTE.php";
1835  include_once("./Services/MediaObjects/classes/class.ilObjMediaObject.php");
1836 
1837  $a_xml_writer->xmlStartTag("material");
1838  $attrs = array(
1839  "type" => "text/plain"
1840  );
1841  if ($this->isHTML($a_material)) {
1842  $attrs["type"] = "text/xhtml";
1843  }
1844  if (is_array($a_attrs)) {
1845  $attrs = array_merge($attrs, $a_attrs);
1846  }
1847  $a_xml_writer->xmlElement("mattext", $attrs, ilRTE::_replaceMediaObjectImageSrc($a_material, 0));
1848 
1849  if ($add_mobs) {
1850  $mobs = ilObjMediaObject::_getMobsOfObject("spl:html", $this->getId());
1851  foreach ($mobs as $mob) {
1852  $mob_obj = new ilObjMediaObject($mob);
1853  $imgattrs = array(
1854  "label" => "il_" . IL_INST_ID . "_mob_" . $mob,
1855  "uri" => "objects/" . "il_" . IL_INST_ID . "_mob_" . $mob . "/" . $mob_obj->getTitle(),
1856  "type" => "spl:html",
1857  "id" => $this->getId()
1858  );
1859  $a_xml_writer->xmlElement("matimage", $imgattrs, null);
1860  }
1861  }
1862  if ($close_material_tag) {
1863  $a_xml_writer->xmlEndTag("material");
1864  }
1865  }
static _getMobsOfObject($a_type, $a_id, $a_usage_hist_nr=0, $a_lang="-")
get mobs of object
static _replaceMediaObjectImageSrc($a_text, $a_direction=0, $nic=IL_INST_ID)
Replaces image source from mob image urls with the mob id or replaces mob id with the correct image s...
$mobs
getId()
Gets the id of the SurveyQuestion object.
Class ilObjMediaObject.
isHTML($a_text)
Checks if a given string contains HTML or not.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ copyObject()

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

Copies an assOrderingQuestion object.

public

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

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

619  {
620  if ($this->getId() <= 0) {
621  // The question has not been saved. It cannot be copied
622  return;
623  }
624  $clone = $this;
625  $original_id = self::_getOriginalId($this->getId(), false);
626  $clone->setId(-1);
627  $source_questionpool = $this->getObjId();
628  $clone->setObjId($target_questionpool);
629  if ($title) {
630  $clone->setTitle($title);
631  }
632 
633  $clone->saveToDb();
634 
635  // duplicate the materials
636  $clone->duplicateMaterials($original_id);
637  // copy XHTML media objects
638  $clone->copyXHTMLMediaObjectsOfQuestion($original_id);
639  return $clone->getId();
640  }
getId()
Gets the id of the SurveyQuestion object.
getObjId()
Get the reference id of the container object.
+ Here is the call graph for this function:

◆ copyXHTMLMediaObjectsOfQuestion()

SurveyQuestion::copyXHTMLMediaObjectsOfQuestion (   $a_q_id)

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

Parameters
integer$a_q_idThe question id of the original question public

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

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

649  {
650  include_once("./Services/MediaObjects/classes/class.ilObjMediaObject.php");
651  $mobs = ilObjMediaObject::_getMobsOfObject("spl:html", $a_q_id);
652  foreach ($mobs as $mob) {
653  ilObjMediaObject::_saveUsage($mob, "spl:html", $this->getId());
654  }
655  }
static _getMobsOfObject($a_type, $a_id, $a_usage_hist_nr=0, $a_lang="-")
get mobs of object
$mobs
getId()
Gets the id of the SurveyQuestion object.
static _saveUsage($a_mob_id, $a_type, $a_id, $a_usage_hist_nr=0, $a_lang="-")
Save usage of mob within another container (e.g.
+ Here is the call graph for this function:

◆ createNewQuestion()

SurveyQuestion::createNewQuestion ( )

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

Returns
integer ID of the new question

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

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

846  {
847  $ilDB = $this->db;
848 
849  $obj_id = $this->getObjId();
850  if ($obj_id > 0) {
851  $next_id = $ilDB->nextId('svy_question');
852  $affectedRows = $ilDB->manipulateF(
853  "INSERT INTO svy_question (question_id, questiontype_fi, " .
854  "obj_fi, owner_fi, title, description, author, questiontext, obligatory, complete, " .
855  "created, original_id, tstamp) VALUES " .
856  "(%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)",
857  array('integer', 'integer', 'integer', 'integer', 'text', 'text', 'text', 'text',
858  'text', 'text', 'integer', 'integer', 'integer'),
859  array(
860  $next_id,
861  $this->getQuestionTypeID(),
862  $obj_id,
863  $this->getOwner(),
864  null,
865  null,
866  $this->getAuthor(),
867  null,
868  "1",
869  "0",
870  time(),
871  null,
872  0
873  )
874  );
875  $this->log->debug("INSERT INTO svy_question question_id= " . $next_id . " questiontype_fi= " . $this->getQuestionTypeID());
876 
877  $this->setId($next_id);
878  }
879  return $this->getId();
880  }
getAuthor()
Gets the authors name of the SurveyQuestion object.
setId($id=-1)
Sets the id of the SurveyQuestion object.
getQuestionTypeID()
Returns the question type ID of the question.
getOwner()
Gets the creator/owner ID of the SurveyQuestion object.
getId()
Gets the id of the SurveyQuestion object.
global $ilDB
getObjId()
Get the reference id of the container object.
+ Here is the call graph for this function:

◆ delete()

SurveyQuestion::delete (   $question_id)

Deletes a question and all materials from the database.

Parameters
integer$question_idThe database id of the question private

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

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

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

◆ deleteAdditionalTableData()

SurveyQuestion::deleteAdditionalTableData (   $question_id)

Deletes datasets from the additional question table in the database.

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

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

References $db, and $ilDB.

Referenced by delete().

991  {
992  $ilDB = $this->db;
993 
994  $this->log->debug("DELETE FROM " . $this->getAdditionalTableName());
995 
996  $affectedRows = $ilDB->manipulateF(
997  "DELETE FROM " . $this->getAdditionalTableName() . " WHERE question_fi = %s",
998  array('integer'),
999  array($question_id)
1000  );
1001  }
global $ilDB
+ Here is the caller graph for this function:

◆ deleteMaterial()

SurveyQuestion::deleteMaterial (   $materials_name = "")

Deletes a materials uri with a given name.

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

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

References $key, and getMaterialsPath().

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

◆ deleteMaterials()

SurveyQuestion::deleteMaterials (   $a_array)

Deletes materials.

Parameters
array$a_arrayArray with indexes of the materials to delete

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

References saveMaterial().

1377  {
1378  foreach ($a_array as $idx) {
1379  unset($this->material[$idx]);
1380  }
1381  $this->material = array_values($this->material);
1382  $this->saveMaterial();
1383  }
saveMaterial()
save material to db
+ Here is the call graph for this function:

◆ duplicate()

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

Duplicates a survey question.

public

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

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

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

◆ duplicateMaterials()

SurveyQuestion::duplicateMaterials (   $question_id)

Duplicates the materials of a question.

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

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

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

1392  {
1393  foreach ($this->materials as $filename) {
1394  $materialspath = $this->getMaterialsPath();
1395  $materialspath_original = preg_replace("/([^\d])$this->id([^\d])/", "\${1}$question_id\${2}", $materialspath);
1396  if (!file_exists($materialspath)) {
1397  ilUtil::makeDirParents($materialspath);
1398  }
1399  if (!copy($materialspath_original . $filename, $materialspath . $filename)) {
1400  print "material could not be duplicated!!!! ";
1401  }
1402  }
1403  }
static makeDirParents($a_dir)
Create a new directory and all parent directories.
getMaterialsPath()
Returns the materials path for web accessable materials of a question.
$filename
Definition: buildRTE.php:89
+ Here is the call graph for this function:

◆ flushMaterials()

SurveyQuestion::flushMaterials ( )

Deletes all materials uris.

public

See also
$materials

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

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

◆ getAuthor()

SurveyQuestion::getAuthor ( )

Gets the authors name of the SurveyQuestion object.

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

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

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

522  {
523  return (strlen($this->author)) ? $this->author : null;
524  }
+ Here is the caller graph for this function:

◆ getAvailableRelations()

SurveyQuestion::getAvailableRelations ( )

Returns the available relations for the question.

Returns
array An array containing the available relations public

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

1968  {
1969  // overwrite in inherited classes
1970  return array();
1971  }

◆ getCopyIds()

SurveyQuestion::getCopyIds (   $a_group_by_survey = false)

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

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

Referenced by hasCopies().

2082  {
2083  $ilDB = $this->db;
2084 
2085  $set = $ilDB->query("SELECT q.question_id,s.obj_fi" .
2086  " FROM svy_question q" .
2087  " JOIN svy_svy_qst sq ON (sq.question_fi = q.question_id)" .
2088  " JOIN svy_svy s ON (s.survey_id = sq.survey_fi)" .
2089  " WHERE original_id = " . $ilDB->quote($this->getId(), "integer"));
2090  $res = array();
2091  while ($row = $ilDB->fetchAssoc($set)) {
2092  if (!$a_group_by_survey) {
2093  $res[] = $row["question_id"];
2094  } else {
2095  $res[$row["obj_fi"]][] = $row["question_id"];
2096  }
2097  }
2098  return $res;
2099  }
foreach($_POST as $key=> $value) $res
$row
global $ilDB
+ Here is the caller graph for this function:

◆ getDescription()

SurveyQuestion::getDescription ( )

Gets the description string of the SurveyQuestion object.

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

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

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

510  {
511  return (strlen($this->description)) ? $this->description : null;
512  }
+ Here is the caller graph for this function:

◆ getId()

SurveyQuestion::getId ( )

Gets the id of the SurveyQuestion object.

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

Definition at line 452 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(), loadFromDb(), SurveyMatrixQuestion\saveBipolarAdjectives(), SurveyMultipleChoiceQuestion\saveCategoriesToDb(), SurveySingleChoiceQuestion\saveCategoriesToDb(), SurveyMatrixQuestion\saveColumnsToDb(), saveCompletionStatus(), SurveyMatrixQuestion\saveLayout(), saveMaterial(), SurveyMatrixQuestion\saveRowsToDb(), SurveyTextQuestion\saveToDb(), SurveyMultipleChoiceQuestion\saveToDb(), SurveySingleChoiceQuestion\saveToDb(), SurveyMetricQuestion\saveToDb(), SurveyMatrixQuestion\saveToDb(), saveToDb(), SurveyTextQuestion\saveUserInput(), SurveyMultipleChoiceQuestion\saveUserInput(), SurveyMetricQuestion\saveUserInput(), SurveySingleChoiceQuestion\saveUserInput(), SurveyMatrixQuestion\saveUserInput(), and syncWithOriginal().

453  {
454  return $this->id;
455  }
+ Here is the caller graph for this function:

◆ getImagePath()

SurveyQuestion::getImagePath ( )

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

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

public

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

899  {
900  return CLIENT_WEB_DIR . "/survey/$this->obj_id/$this->id/images/";
901  }

◆ getImagePathWeb()

SurveyQuestion::getImagePathWeb ( )

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

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

public

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

References ilUtil\removeTrailingPathSeparators().

921  {
922  $webdir = ilUtil::removeTrailingPathSeparators(CLIENT_WEB_DIR) . "/survey/$this->obj_id/$this->id/images/";
923  return str_replace(ilUtil::removeTrailingPathSeparators(ILIAS_ABSOLUTE_PATH), ilUtil::removeTrailingPathSeparators(ILIAS_HTTP_PATH), $webdir);
924  }
static removeTrailingPathSeparators($path)
+ Here is the call graph for this function:

◆ getLabel()

SurveyQuestion::getLabel ( )

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

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

◆ getMaterial()

SurveyQuestion::getMaterial ( )

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

References $material.

2019  {
2020  return $this->material;
2021  }

◆ getMaterialsPath()

SurveyQuestion::getMaterialsPath ( )

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

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

public

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

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

910  {
911  return CLIENT_WEB_DIR . "/survey/$this->obj_id/$this->id/materials/";
912  }
+ Here is the caller graph for this function:

◆ getMaterialsPathWeb()

SurveyQuestion::getMaterialsPathWeb ( )

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

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

public

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

References ilUtil\removeTrailingPathSeparators().

933  {
934  $webdir = ilUtil::removeTrailingPathSeparators(CLIENT_WEB_DIR) . "/survey/$this->obj_id/$this->id/materials/";
935  return str_replace(ilUtil::removeTrailingPathSeparators(ILIAS_ABSOLUTE_PATH), ilUtil::removeTrailingPathSeparators(ILIAS_HTTP_PATH), $webdir);
936  }
static removeTrailingPathSeparators($path)
+ Here is the call graph for this function:

◆ getObjId()

SurveyQuestion::getObjId ( )

Get the reference id of the container object.

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

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

References $obj_id.

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

558  {
559  return $this->obj_id;
560  }
+ Here is the caller graph for this function:

◆ getObligatory()

SurveyQuestion::getObligatory (   $survey_id = "")

Gets the obligatory state of the question.

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

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

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

464  {
465  return ($this->obligatory) ? 1 : 0;
466  }
+ Here is the caller graph for this function:

◆ getOrientation()

SurveyQuestion::getOrientation ( )

Gets the orientation of the question output.

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

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

References $orientation.

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

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

◆ getOriginalId()

SurveyQuestion::getOriginalId ( )

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

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

2014  {
2015  return $this->original_id;
2016  }
+ Here is the caller graph for this function:

◆ getOwner()

SurveyQuestion::getOwner ( )

Gets the creator/owner ID of the SurveyQuestion object.

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

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

References $owner.

Referenced by createNewQuestion(), and saveToDb().

534  {
535  return $this->owner;
536  }
+ Here is the caller graph for this function:

◆ getPhrase()

SurveyQuestion::getPhrase (   $phrase_id)

Returns a phrase for a given database id.

Returns
String The title of the phrase public

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

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

1258  {
1259  $ilDB = $this->db;
1260 
1261  $result = $ilDB->queryF(
1262  "SELECT title FROM svy_phrase WHERE phrase_id = %s",
1263  array('integer'),
1264  array($phrase_id)
1265  );
1266  if ($row = $ilDB->fetchAssoc($result)) {
1267  return $row["title"];
1268  }
1269  return "";
1270  }
$result
$row
global $ilDB

◆ getPreconditionOptions()

SurveyQuestion::getPreconditionOptions ( )

Returns the options for preconditions.

Returns
array

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

Referenced by SurveyMatrixQuestion\getPreconditionSelectValue().

1979  {
1980  // overwrite in inherited classes
1981  }
+ Here is the caller graph for this function:

◆ getPreconditionSelectValue()

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

Creates a form property for the precondition value.

Returns
The ILIAS form element public

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

2003  {
2004  // overwrite in inherited classes
2005  return null;
2006  }

◆ getPreconditionValueOutput()

SurveyQuestion::getPreconditionValueOutput (   $value)

Returns the output for a precondition value.

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

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

1991  {
1992  // overwrite in inherited classes
1993  return $value;
1994  }

◆ getQuestionDataArray()

SurveyQuestion::getQuestionDataArray (   $id)

Returns the question data fields from the database.

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

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

1886  {
1887  return array();
1888  }

◆ getQuestiontext()

SurveyQuestion::getQuestiontext ( )

Gets the questiontext of the SurveyQuestion object.

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

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

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

546  {
547  return (strlen($this->questiontext)) ? $this->questiontext : null;
548  }
+ Here is the caller graph for this function:

◆ getQuestionType()

SurveyQuestion::getQuestionType ( )

Returns the question type of the question.

Returns
integer The question type of the question public

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

Referenced by getQuestionTypeID().

1653  {
1654  return "";
1655  }
+ Here is the caller graph for this function:

◆ getQuestionTypeID()

SurveyQuestion::getQuestionTypeID ( )

Returns the question type ID of the question.

Returns
integer The question type of the question public

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

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

Referenced by createNewQuestion(), and saveToDb().

1631  {
1632  $ilDB = $this->db;
1633  $result = $ilDB->queryF(
1634  "SELECT questiontype_id FROM svy_qtype WHERE type_tag = %s",
1635  array('text'),
1636  array($this->getQuestionType())
1637  );
1638  if ($result->numRows() == 1) {
1639  $row = $ilDB->fetchAssoc($result);
1640  return $row["questiontype_id"];
1641  } else {
1642  return 0;
1643  }
1644  }
$result
$row
global $ilDB
getQuestionType()
Returns the question type of the question.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getSubtype()

SurveyQuestion::getSubtype ( )

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

2029  {
2030  // do nothing
2031  return null;
2032  }

◆ getSurveyId()

SurveyQuestion::getSurveyId ( )

Gets the survey id of the SurveyQuestion object.

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

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

References $survey_id.

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

◆ getTitle()

SurveyQuestion::getTitle ( )

◆ getWorkingDataFromUserInput()

& SurveyQuestion::getWorkingDataFromUserInput (   $post_data)

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

Returns
array User data according to the svy_answer table public

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

References $data.

1897  {
1898  // overwrite in inherited classes
1899  $data = array();
1900  return $data;
1901  }
$data
Definition: bench.php:6

◆ hasCopies()

SurveyQuestion::hasCopies ( )

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

References getCopyIds().

2102  {
2103  return (bool) sizeof($this->getCopyIds());
2104  }
getCopyIds($a_group_by_survey=false)
+ Here is the call graph for this function:

◆ importAdditionalMetadata()

SurveyQuestion::importAdditionalMetadata (   $a_meta)

Import additional meta data from the question import file.

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

Returns
array $a_meta Array containing the additional meta data public

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

1912  {
1913  // overwrite in inherited classes
1914  }

◆ importAdjectives()

SurveyQuestion::importAdjectives (   $a_data)

Import bipolar adjectives from the question import file.

Returns
array $a_data Array containing the adjectives public

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

1934  {
1935  // overwrite in inherited classes
1936  }

◆ importMatrix()

SurveyQuestion::importMatrix (   $a_data)

Import matrix rows from the question import file.

Returns
array $a_data Array containing the matrix rows public

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

1945  {
1946  // overwrite in inherited classes
1947  }

◆ importResponses()

SurveyQuestion::importResponses (   $a_data)

Import response data from the question import file.

Returns
array $a_data Array containing the response data public

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

1923  {
1924  // overwrite in inherited classes
1925  }

◆ isComplete()

SurveyQuestion::isComplete ( )

Returns 1, if a question is complete for use.

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

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

Referenced by saveCompletionStatus(), and saveToDb().

210  {
211  return 0;
212  }
+ Here is the caller graph for this function:

◆ isHTML()

SurveyQuestion::isHTML (   $a_text)

Checks if a given string contains HTML or not.

Parameters
string$a_textText which should be checked
Returns
boolean public

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

Referenced by addMaterialTag().

1784  {
1785  if (preg_match("/<[^>]*?>/", $a_text)) {
1786  return true;
1787  } else {
1788  return false;
1789  }
1790  }
+ Here is the caller graph for this function:

◆ loadFromDb()

SurveyQuestion::loadFromDb (   $question_id)

Loads a SurveyQuestion object from the database.

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

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

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

664  {
665  $ilDB = $this->db;
666 
667  $result = $ilDB->queryF(
668  "SELECT * FROM svy_material WHERE question_fi = %s",
669  array('integer'),
670  array($this->getId())
671  );
672  $this->material = array();
673  if ($result->numRows()) {
674  include_once "./Modules/SurveyQuestionPool/classes/class.ilSurveyMaterial.php";
675  while ($row = $ilDB->fetchAssoc($result)) {
676  $mat = new ilSurveyMaterial();
677  $mat->type = $row['material_type'];
678  $mat->internal_link = $row['internal_link'];
679  $mat->title = $row['material_title'];
680  $mat->import_id = $row['import_id'];
681  $mat->text_material = $row['text_material'];
682  $mat->external_link = $row['external_link'];
683  $mat->file_material = $row['file_material'];
684  array_push($this->material, $mat);
685  }
686  }
687  }
$result
Survey material class.
getId()
Gets the id of the SurveyQuestion object.
$row
global $ilDB
+ Here is the call graph for this function:

◆ lookupObjFi()

static SurveyQuestion::lookupObjFi (   $a_qid)
static

Lookip obj fi.

Parameters

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

References $DIC, and $ilDB.

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

2128  {
2129  global $DIC;
2130 
2131  $ilDB = $DIC->database();
2132 
2133  $set = $ilDB->query(
2134  "SELECT obj_fi FROM svy_question " .
2135  " WHERE question_id = " . $ilDB->quote($a_qid, "integer")
2136  );
2137  $rec = $ilDB->fetchAssoc($set);
2138  return $rec["obj_fi"];
2139  }
global $DIC
Definition: saml.php:7
global $ilDB
+ Here is the caller graph for this function:

◆ phraseExists()

SurveyQuestion::phraseExists (   $title)

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

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

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

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

1280  {
1281  $ilUser = $this->user;
1282  $ilDB = $this->db;
1283 
1284  $result = $ilDB->queryF(
1285  "SELECT phrase_id FROM svy_phrase WHERE title = %s AND owner_fi = %s",
1286  array('text', 'integer'),
1287  array($title, $ilUser->getId())
1288  );
1289  return ($result->numRows() == 0) ? false : true;
1290  }
$result
$ilUser
Definition: imgupload.php:18
global $ilDB

◆ prepareTextareaOutput()

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

Prepares a string for a text area output in surveys.

Parameters
string$txt_outputString which should be prepared for output public

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

References ilUtil\prepareTextareaOutput().

1874  {
1875  return ilUtil::prepareTextareaOutput($txt_output, $prepare_for_latex_output);
1876  }
static prepareTextareaOutput($txt_output, $prepare_for_latex_output=false, $omitNl2BrWhenTextArea=false)
Prepares a string for a text area output where latex code may be in it If the text is HTML-free...
+ Here is the call graph for this function:

◆ QTIMaterialToString()

SurveyQuestion::QTIMaterialToString (   $a_material)

Reads an QTI material tag an creates a text string.

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

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

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

1800  {
1801  $svy_log = ilLoggerFactory::getLogger("svy");
1802  $svy_log->debug("material count: " . $a_material->getMaterialCount());
1803 
1804  $result = "";
1805  for ($i = 0; $i < $a_material->getMaterialCount(); $i++) {
1806  $material = $a_material->getMaterial($i);
1807  if (strcmp($material["type"], "mattext") == 0) {
1808  $result .= $material["material"]->getContent();
1809  }
1810  if (strcmp($material["type"], "matimage") == 0) {
1811  $matimage = $material["material"];
1812  if (preg_match("/(il_([0-9]+)_mob_([0-9]+))/", $matimage->getLabel(), $matches)) {
1813  // import an mediaobject which was inserted using tiny mce
1814  if (!is_array($_SESSION["import_mob_xhtml"])) {
1815  $_SESSION["import_mob_xhtml"] = array();
1816  }
1817  array_push($_SESSION["import_mob_xhtml"], array("mob" => $matimage->getLabel(), "uri" => $matimage->getUri()));
1818  }
1819  }
1820  }
1821  return $result;
1822  }
$_SESSION["AccountId"]
$result
$i
Definition: disco.tpl.php:19
static getLogger($a_component_id)
Get component logger.
+ Here is the call graph for this function:

◆ questionTitleExists()

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

Returns TRUE if the question title exists in the database.

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

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

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

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

◆ saveCategoryToDb()

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

Saves a category to the database.

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

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

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

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

947  {
949  $ilDB = $this->db;
950 
951  $result = $ilDB->queryF(
952  "SELECT title, category_id FROM svy_category WHERE title = %s AND neutral = %s AND owner_fi = %s",
953  array('text','text','integer'),
954  array($categorytext, $neutral, $ilUser->getId())
955  );
956  $insert = false;
957  $returnvalue = "";
958  if ($result->numRows()) {
959  $insert = true;
960  while ($row = $ilDB->fetchAssoc($result)) {
961  if (strcmp($row["title"], $categorytext) == 0) {
962  $returnvalue = $row["category_id"];
963  $insert = false;
964  }
965  }
966  } else {
967  $insert = true;
968  }
969  if ($insert) {
970  $next_id = $ilDB->nextId('svy_category');
971  $affectedRows = $ilDB->manipulateF(
972  "INSERT INTO svy_category (category_id, title, neutral, owner_fi, tstamp) VALUES (%s, %s, %s, %s, %s)",
973  array('integer','text','text','integer','integer'),
974  array($next_id, $categorytext, $neutral, $ilUser->getId(), time())
975  );
976 
977  $this->log->debug("INSERT INTO svy_category id=" . $next_id);
978 
979  $returnvalue = $next_id;
980  }
981  return $returnvalue;
982  }
$result
$ilUser
Definition: imgupload.php:18
$row
global $ilDB
+ Here is the caller graph for this function:

◆ saveCompletionStatus()

SurveyQuestion::saveCompletionStatus (   $original_id = "")

Saves the complete flag to the database.

public

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

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

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

721  {
722  $ilDB = $this->db;
723 
724  $question_id = $this->getId();
725  if (strlen($original_id)) {
726  $question_id = $original_id;
727  }
728 
729  if ($this->getId() > 0) {
730  $this->log->debug("UPDATE svy_question question_id=" . $question_id);
731 
732  // update existing dataset
733  $affectedRows = $ilDB->manipulateF(
734  "UPDATE svy_question SET complete = %s, tstamp = %s WHERE question_id = %s",
735  array('text', 'integer', 'integer'),
736  array($this->isComplete(), time(), $question_id)
737  );
738  }
739  }
getId()
Gets the id of the SurveyQuestion object.
isComplete()
Returns 1, if a question is complete for use.
global $ilDB
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ saveMaterial()

SurveyQuestion::saveMaterial ( )

save material to db

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

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

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

803  {
804  $ilDB = $this->db;
805 
806  include_once "./Services/Link/classes/class.ilInternalLink.php";
807 
808  $this->log->debug("DELETE: svy_material question_fi=" . $this->getId());
809 
810  $affectedRows = $ilDB->manipulateF(
811  "DELETE FROM svy_material WHERE question_fi = %s",
812  array('integer'),
813  array($this->getId())
814  );
816 
817  foreach ($this->material as $material) {
818  $next_id = $ilDB->nextId('svy_material');
819 
820  $this->log->debug("INSERT: svy_material question_fi=" . $this->getId());
821 
822  $affectedRows = $ilDB->manipulateF(
823  "INSERT INTO svy_material " .
824  "(material_id, question_fi, internal_link, import_id, material_title, tstamp," .
825  "text_material, external_link, file_material, material_type) " .
826  "VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s)",
827  array('integer','integer','text','text','text','integer','text','text','text','integer'),
828  array(
829  $next_id, $this->getId(), $material->internal_link, $material->import_id,
830  $material->title, time(), $material->text_material, $material->external_link,
831  $material->file_material, $material->type)
832  );
833  if (preg_match("/il_(\d*?)_(\w+)_(\d+)/", $material->internal_link, $matches)) {
834  ilInternalLink::_saveLink("sqst", $this->getId(), $matches[2], $matches[3], $matches[1]);
835  }
836  }
837  }
getId()
Gets the id of the SurveyQuestion object.
global $ilDB
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ saveToDb()

SurveyQuestion::saveToDb (   $original_id = "")

Saves a SurveyQuestion object to a database.

Parameters
integer$original_idpublic

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

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

Referenced by syncWithOriginal().

748  {
749  $ilDB = $this->db;
750 
751  // cleanup RTE images which are not inserted into the question text
752  include_once("./Services/RTE/classes/class.ilRTE.php");
753  ilRTE::_cleanupMediaObjectUsage($this->getQuestiontext(), "spl:html", $this->getId());
754  $affectedRows = 0;
755  if ($this->getId() == -1) {
756  // Write new dataset
757  $next_id = $ilDB->nextId('svy_question');
758  $affectedRows = $ilDB->insert("svy_question", array(
759  "question_id" => array("integer", $next_id),
760  "questiontype_fi" => array("integer", $this->getQuestionTypeID()),
761  "obj_fi" => array("integer", $this->getObjId()),
762  "owner_fi" => array("integer", $this->getOwner()),
763  "title" => array("text", $this->getTitle()),
764  "label" => array("text", (strlen($this->label)) ? $this->label : null),
765  "description" => array("text", $this->getDescription()),
766  "author" => array("text", $this->getAuthor()),
767  "questiontext" => array("clob", ilRTE::_replaceMediaObjectImageSrc($this->getQuestiontext(), 0)),
768  "obligatory" => array("text", $this->getObligatory()),
769  "complete" => array("text", $this->isComplete()),
770  "created" => array("integer", time()),
771  "original_id" => array("integer", ($original_id) ? $original_id : null),
772  "tstamp" => array("integer", time())
773  ));
774 
775  //$this->log->debug("INSERT: svy_question id=".$next_id." questiontype_fi=".$this->getQuestionTypeID()." obj_fi".$this->getObjId()." title=".$this->getTitle()." ...");
776 
777  $this->setId($next_id);
778  } else {
779  // update existing dataset
780  $affectedRows = $ilDB->update("svy_question", array(
781  "title" => array("text", $this->getTitle()),
782  "label" => array("text", (strlen($this->label)) ? $this->label : null),
783  "description" => array("text", $this->getDescription()),
784  "author" => array("text", $this->getAuthor()),
785  "questiontext" => array("clob", ilRTE::_replaceMediaObjectImageSrc($this->getQuestiontext(), 0)),
786  "obligatory" => array("text", $this->getObligatory()),
787  "complete" => array("text", $this->isComplete()),
788  "tstamp" => array("integer", time())
789  ), array(
790  "question_id" => array("integer", $this->getId())
791  ));
792 
793  $this->log->debug("UPDATE svy_question id=" . $this->getId() . " SET: title=" . $this->getTitle() . " ...");
794  }
795 
796  return $affectedRows;
797  }
getAuthor()
Gets the authors name of the SurveyQuestion object.
getTitle()
Gets the title string of the SurveyQuestion object.
getObligatory($survey_id="")
Gets the obligatory state of the question.
setId($id=-1)
Sets the id of the SurveyQuestion object.
getQuestiontext()
Gets the questiontext of the SurveyQuestion object.
static _replaceMediaObjectImageSrc($a_text, $a_direction=0, $nic=IL_INST_ID)
Replaces image source from mob image urls with the mob id or replaces mob id with the correct image s...
getQuestionTypeID()
Returns the question type ID of the question.
getOwner()
Gets the creator/owner ID of the SurveyQuestion object.
getId()
Gets the id of the SurveyQuestion object.
isComplete()
Returns 1, if a question is complete for use.
global $ilDB
static _cleanupMediaObjectUsage($a_text, $a_usage_type, $a_usage_id)
Synchronises appearances of media objects in $a_text with media object usage table.
getDescription()
Gets the description string of the SurveyQuestion object.
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:

◆ saveWorkingData()

SurveyQuestion::saveWorkingData (   $limit_to = LIMIT_NO_LIMIT)

Saves the learners input of the question to the database.

public

See also
$answers

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

889  {
890  }

◆ setAuthor()

SurveyQuestion::setAuthor (   $author = "")

Sets the authors name of the SurveyQuestion object.

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

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

References $author, $ilUser, and $user.

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

395  {
397 
398  if (!$author) {
399  $author = $ilUser->fullname;
400  }
401  $this->author = $author;
402  }
$ilUser
Definition: imgupload.php:18
+ Here is the caller graph for this function:

◆ setComplete()

SurveyQuestion::setComplete (   $a_complete)

Sets the complete state of the question.

Parameters
integer$a_complete1 if complete, 0 otherwise public

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

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

199  {
200  $this->complete = ($a_complete) ? 1 : 0;
201  }
+ Here is the caller graph for this function:

◆ setDescription()

SurveyQuestion::setDescription (   $description = "")

Sets the description string of the SurveyQuestion object.

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

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

References $description.

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

309  {
310  $this->description = $description;
311  }
+ Here is the caller graph for this function:

◆ setId()

SurveyQuestion::setId (   $id = -1)

Sets the id of the SurveyQuestion object.

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

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

References $id.

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

285  {
286  $this->id = $id;
287  }
+ Here is the caller graph for this function:

◆ setMaterial()

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

Sets a material link for the question.

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

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

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

1418  {
1419  if (strcmp($material_id, "") != 0) {
1420  $import_id = "";
1421  if ($is_import) {
1422  $import_id = $material_id;
1423  $material_id = self::_resolveInternalLink($import_id);
1424  }
1425  if (strcmp($material_title, "") == 0) {
1426  if (preg_match("/il__(\w+)_(\d+)/", $material_id, $matches)) {
1427  $type = $matches[1];
1428  $target_id = $matches[2];
1429  $material_title = $this->lng->txt("obj_$type") . ": ";
1430  switch ($type) {
1431  case "lm":
1432  include_once("./Modules/LearningModule/classes/class.ilObjContentObjectGUI.php");
1433  $cont_obj_gui = new ilObjContentObjectGUI("", $target_id, true);
1434  $cont_obj = $cont_obj_gui->object;
1435  $material_title .= $cont_obj->getTitle();
1436  break;
1437  case "pg":
1438  include_once("./Modules/LearningModule/classes/class.ilLMPageObject.php");
1439  include_once("./Modules/LearningModule/classes/class.ilLMObject.php");
1441  include_once("./Modules/LearningModule/classes/class.ilObjContentObjectGUI.php");
1442  $cont_obj_gui = new ilObjContentObjectGUI("", $lm_id, false);
1443  $cont_obj = $cont_obj_gui->object;
1444  $pg_obj = new ilLMPageObject($cont_obj, $target_id);
1445  $material_title .= $pg_obj->getTitle();
1446  break;
1447  case "st":
1448  include_once("./Modules/LearningModule/classes/class.ilStructureObject.php");
1449  include_once("./Modules/LearningModule/classes/class.ilLMObject.php");
1451  include_once("./Modules/LearningModule/classes/class.ilObjContentObjectGUI.php");
1452  $cont_obj_gui = new ilObjContentObjectGUI("", $lm_id, false);
1453  $cont_obj = $cont_obj_gui->object;
1454  $st_obj = new ilStructureObject($cont_obj, $target_id);
1455  $material_title .= $st_obj->getTitle();
1456  break;
1457  case "git":
1458  include_once "./Modules/Glossary/classes/class.ilGlossaryTerm.php";
1459  $material_title = $this->lng->txt("glossary_term") . ": " . ilGlossaryTerm::_lookGlossaryTerm($target_id);
1460  break;
1461  case "mob":
1462  break;
1463  }
1464  }
1465  }
1466  $this->material = array(
1467  "internal_link" => $material_id,
1468  "import_id" => $import_id,
1469  "title" => $material_title
1470  );
1471  }
1472  $this->saveMaterial();
1473  }
$type
$target_id
Definition: goto.php:49
static _lookupContObjID($a_id)
get learning module / digibook id for lm object
Class ilLMPageObject.
saveMaterial()
save material to db
Class ilStructreObject.
Class ilObjContentObjectGUI.
static _lookGlossaryTerm($term_id)
get glossary term
+ Here is the call graph for this function:

◆ setMaterialsfile()

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

Sets and uploads the materials uri.

Parameters
string | string | string$materials_filename,$materials_tempfilename,$materialspublic
See also
$materials

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

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

339  {
340  if (!empty($materials_filename)) {
341  $materialspath = $this->getMaterialsPath();
342  if (!file_exists($materialspath)) {
343  ilUtil::makeDirParents($materialspath);
344  }
345  if (ilUtil::moveUploadedFile(
346  $materials_tempfilename,
347  $materials_filename,
348  $materialspath . $materials_filename
349  )) {
350  print "image not uploaded!!!! ";
351  } else {
352  $this->addMaterials($materials_filename, $materials_name);
353  }
354  }
355  }
static makeDirParents($a_dir)
Create a new directory and all parent directories.
addMaterials($materials_file, $materials_name="")
Sets the materials uri.
getMaterialsPath()
Returns the materials path for web accessable materials of a question.
+ Here is the call graph for this function:

◆ setObjId()

SurveyQuestion::setObjId (   $obj_id = 0)

Set the reference id of the container object.

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

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

References $obj_id.

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

570  {
571  $this->obj_id = $obj_id;
572  }
+ Here is the caller graph for this function:

◆ setObligatory()

SurveyQuestion::setObligatory (   $obligatory = 1)

Sets the obligatory state of the question.

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

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

References $obligatory.

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

261  {
262  $this->obligatory = ($obligatory) ? 1 : 0;
263  }
+ Here is the caller graph for this function:

◆ setOrientation()

SurveyQuestion::setOrientation (   $orientation = 0)

Sets the orientation of the question output.

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

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

References $orientation.

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

273  {
274  $this->orientation = ($orientation) ? $orientation : 0;
275  }
+ Here is the caller graph for this function:

◆ setOriginalId()

SurveyQuestion::setOriginalId (   $original_id)

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

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

2009  {
2010  $this->original_id = $original_id;
2011  }
+ Here is the caller graph for this function:

◆ setOwner()

SurveyQuestion::setOwner (   $owner = "")

Sets the creator/owner ID of the SurveyQuestion object.

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

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

References $owner.

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

424  {
425  $this->owner = $owner;
426  }
+ Here is the caller graph for this function:

◆ setQuestiontext()

SurveyQuestion::setQuestiontext (   $questiontext = "")

Sets the questiontext of the SurveyQuestion object.

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

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

References $questiontext.

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

412  {
413  $this->questiontext = $questiontext;
414  }
+ Here is the caller graph for this function:

◆ setSubtype()

SurveyQuestion::setSubtype (   $a_subtype)

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

2024  {
2025  // do nothing
2026  }

◆ setSurveyId()

SurveyQuestion::setSurveyId (   $id = -1)

Sets the survey id of the SurveyQuestion object.

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

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

References $id.

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

◆ setTitle()

SurveyQuestion::setTitle (   $title = "")

Sets the title string of the SurveyQuestion object.

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

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

References $title.

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

249  {
250  $this->title = $title;
251  }
+ Here is the caller graph for this function:

◆ stripSlashesAddSpaceFallback()

SurveyQuestion::stripSlashesAddSpaceFallback (   $a_str)

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

Parameters
string$a_strstring
Returns
string

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

References ilUtil\stripSlashes().

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

2149  {
2150  $str = ilUtil::stripSlashes($a_str);
2151  if ($str != $a_str) {
2152  $str = ilUtil::stripSlashes(str_replace("<", "< ", $a_str));
2153  }
2154  return $str;
2155  }
static stripSlashes($a_str, $a_strip_html=true, $a_allow="")
strip slashes if magic qoutes is enabled
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ syncWithOriginal()

SurveyQuestion::syncWithOriginal ( )

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

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

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

◆ usableForPrecondition()

SurveyQuestion::usableForPrecondition ( )

Returns if the question is usable for preconditions.

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

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

1956  {
1957  // overwrite in inherited classes
1958  return false;
1959  }

Field Documentation

◆ $arrData

SurveyQuestion::$arrData
private

data array containing the question data

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

◆ $author

◆ $complete

SurveyQuestion::$complete

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

◆ $cumulated

SurveyQuestion::$cumulated
protected

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

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

◆ $db

◆ $description

◆ $id

◆ $lng

◆ $log

SurveyQuestion::$log
protected

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

◆ $material

◆ $materials

SurveyQuestion::$materials

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

◆ $obj_id

SurveyQuestion::$obj_id

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

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

◆ $obligatory

SurveyQuestion::$obligatory

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

Referenced by setObligatory().

◆ $orientation

◆ $owner

◆ $questiontext

◆ $survey_id

◆ $title

◆ $user


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