ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
SurveyQuestion Class Reference

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

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

Public Member Functions

 SurveyQuestion ( $title="", $description="", $author="", $questiontext="", $owner=-1)
 SurveyQuestion constructor The constructor takes possible arguments an creates an instance of the SurveyQuestion object. More...
 
 _SurveyQuestion ()
 
 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="")
 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...
 
 _isComplete ($question_id)
 Checks whether the question is complete or not. 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...
 
 _getQuestionType ($question_id)
 Returns the question type of a question with a given id. More...
 
 _getTitle ($question_id)
 Returns the question title of a question with a given id. More...
 
 _getOriginalId ($question_id, $a_return_question_id_if_no_original=true)
 Returns the original id of a question. 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...
 
 _questionExists ($question_id)
 Returns true if the question already exists in the database. 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...
 
 _resolveInternalLink ($internal_link)
 
 _resolveIntLinks ($question_id)
 
 _getInternalLinkHref ($target="", $a_parent_ref_id=null)
 
 _isWriteable ($question_id, $user_id)
 Returns true if the question is writeable by a certain user. More...
 
 getQuestionTypeID ()
 Returns the question type ID of the question. More...
 
 getQuestionType ()
 Returns the question type of the question. More...
 
_instanciateQuestion ($question_id)
 Creates an instance of a question with a given question id. More...
 
_instanciateQuestionGUI ($question_id)
 Creates an instance of a question GUI with a given question id. 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...
 
 addUserSpecificResultsExportTitles (&$a_array, $a_use_label=false, $a_substitute=true)
 Adds the entries for the title row of the user specific results. More...
 
 addUserSpecificResultsData (&$a_array, &$resultset)
 Adds the values for the user specific results export for a given user. More...
 
getUserAnswers ($survey_id)
 Returns an array containing all answers to this question in a given survey. 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...
 
 setExportCumulatedXLS (&$worksheet, &$format_title, &$format_bold, &$eval_data, $row, $export_label)
 Creates the Excel output for the cumulated results of this question. More...
 
setExportCumulatedCVS (&$eval_data, $export_label)
 Creates the CSV output for the cumulated results of this question. More...
 
 setExportDetailsXLS (&$workbook, &$format_title, &$format_bold, &$eval_data, $export_label)
 Creates an Excel worksheet for the detailed cumulated results of this question. 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...
 
 outChart ($survey_id, $type="")
 Creates an image visualising the results of the question. More...
 
 setOriginalId ($original_id)
 
 getOriginalId ()
 
 saveRandomData ($active_id)
 Saves random answers for a given active user in the database. More...
 
 getMaterial ()
 
 setSubtype ($a_subtype)
 
 getSubtype ()
 
 getCumulatedResultData ($survey_id, $counter, $finished_ids)
 Creates a the cumulated results data for the question. More...
 
 __get ($value)
 Object getter. More...
 
 __set ($key, $value)
 Object setter. More...
 
 getCopyIds ($a_group_by_survey=false)
 
 hasCopies ()
 
 getSkippedValue ()
 

Static Public Member Functions

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 _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
 
 $ilias
 
 $tpl
 
 $lng
 
 $orientation
 
 $material
 
 $complete
 

Protected Member Functions

calculateCumulatedResults ($survey_id, $finished_ids)
 

Protected Attributes

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

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.

Member Function Documentation

◆ __get()

SurveyQuestion::__get (   $value)

Object getter.

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

2346  {
2347  switch ($value)
2348  {
2349  default:
2350  if (array_key_exists($value, $this->arrData))
2351  {
2352  return $this->arrData[$value];
2353  }
2354  else
2355  {
2356  return null;
2357  }
2358  break;
2359  }
2360  }

◆ __set()

SurveyQuestion::__set (   $key,
  $value 
)

Object setter.

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

2366  {
2367  switch ($key)
2368  {
2369  default:
2370  $this->arrData[$key] = $value;
2371  break;
2372  }
2373  }

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

References $ilDB.

Referenced by ilSurveyEditorGUI\executeCopyQuestionsToPoolObject().

2383  {
2384  global $ilDB;
2385 
2386  $ilDB->manipulate("UPDATE svy_question".
2387  " SET original_id = ".$ilDB->quote($a_original_id, "integer").",".
2388  " obj_fi = ".$ilDB->quote($a_object_id, "integer").
2389  " WHERE question_id = ".$ilDB->quote($a_question_id, "integer"));
2390  }
global $ilDB
+ Here is the caller graph for this function:

◆ _getInternalLinkHref()

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

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

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

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

1640  {
1641  global $ilDB;
1642  $linktypes = array(
1643  "lm" => "LearningModule",
1644  "pg" => "PageObject",
1645  "st" => "StructureObject",
1646  "git" => "GlossaryItem",
1647  "mob" => "MediaObject"
1648  );
1649  $href = "";
1650  if (preg_match("/il__(\w+)_(\d+)/", $target, $matches))
1651  {
1652  $type = $matches[1];
1653  $target_id = $matches[2];
1654  include_once "./Services/Utilities/classes/class.ilUtil.php";
1655  switch($linktypes[$matches[1]])
1656  {
1657  case "LearningModule":
1658  $href = ilUtil::removeTrailingPathSeparators(ILIAS_HTTP_PATH) ."/goto.php?target=" . $type . "_" . $target_id;
1659  break;
1660  case "PageObject":
1661  case "StructureObject":
1662  $href = ilUtil::removeTrailingPathSeparators(ILIAS_HTTP_PATH) ."/goto.php?target=" . $type . "_" . $target_id;
1663  break;
1664  case "GlossaryItem":
1665  $href = ilUtil::removeTrailingPathSeparators(ILIAS_HTTP_PATH) ."/goto.php?target=" . $type . "_" . $target_id;
1666  break;
1667  case "MediaObject":
1668  $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;
1669  break;
1670  }
1671  }
1672  return $href;
1673  }
$target_id
Definition: goto.php:88
static removeTrailingPathSeparators($path)
global $ilDB
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _getOriginalId()

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

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

References $ilDB, $result, and $row.

Referenced by ilObjSurvey\cloneObject(), and copyObject().

1256  {
1257  global $ilDB;
1258  $result = $ilDB->queryF("SELECT * FROM svy_question WHERE question_id = %s",
1259  array('integer'),
1260  array($question_id)
1261  );
1262  if ($result->numRows() > 0)
1263  {
1264  $row = $ilDB->fetchAssoc($result);
1265  if ($row["original_id"] > 0)
1266  {
1267  return $row["original_id"];
1268  }
1269  else if((bool)$a_return_question_id_if_no_original) // #12419
1270  {
1271  return $row["question_id"];
1272  }
1273  }
1274  else
1275  {
1276  return "";
1277  }
1278  }
$result
global $ilDB
+ Here is the caller graph for this function:

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

1961  {
1962  return array();
1963  }

◆ _getQuestionType()

SurveyQuestion::_getQuestionType (   $question_id)

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

References $data, $ilDB, and $result.

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

1200  {
1201  global $ilDB;
1202 
1203  if ($question_id < 1) return "";
1204 
1205  $result = $ilDB->queryF("SELECT type_tag FROM svy_question, svy_qtype WHERE svy_question.question_id = %s AND svy_question.questiontype_fi = svy_qtype.questiontype_id",
1206  array('integer'),
1207  array($question_id)
1208  );
1209  if ($result->numRows() == 1)
1210  {
1211  $data = $ilDB->fetchAssoc($result);
1212  return $data["type_tag"];
1213  }
1214  else
1215  {
1216  return "";
1217  }
1218  }
$result
$data
global $ilDB
+ 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 1783 of file class.SurveyQuestion.php.

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

Referenced by ilSurveyConstraintsGUI\constraintForm(), ilObjSurveyQuestionPoolGUI\deleteQuestionsObject(), ilSurveyQuestionsTableGUI\fillRow(), and ilSurveyEditorGUI\removeQuestionsForm().

1784  {
1785  if (file_exists("./Modules/SurveyQuestionPool/classes/class.".$type_tag.".php"))
1786  {
1787  global $lng;
1788  return $lng->txt($type_tag);
1789  }
1790  else
1791  {
1792  global $ilPluginAdmin;
1793  $pl_names = $ilPluginAdmin->getActivePluginsForSlot(IL_COMP_MODULE, "SurveyQuestionPool", "svyq");
1794  foreach ($pl_names as $pl_name)
1795  {
1796  $pl = ilPlugin::getPluginObject(IL_COMP_MODULE, "SurveyQuestionPool", "svyq", $pl_name);
1797  if (strcmp($pl->getQuestionType(), $type_tag) == 0)
1798  {
1799  return $pl->getQuestionTypeTranslation();
1800  }
1801  }
1802  }
1803  return "";
1804  }
static getPluginObject($a_ctype, $a_cname, $a_slot_id, $a_pname)
Get plugin object.
const IL_COMP_MODULE
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _getTitle()

SurveyQuestion::_getTitle (   $question_id)

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

References $data, $ilDB, and $result.

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

1228  {
1229  global $ilDB;
1230 
1231  if ($question_id < 1) return "";
1232 
1233  $result = $ilDB->queryF("SELECT title FROM svy_question WHERE svy_question.question_id = %s",
1234  array('integer'),
1235  array($question_id)
1236  );
1237  if ($result->numRows() == 1)
1238  {
1239  $data = $ilDB->fetchAssoc($result);
1240  return $data["title"];
1241  }
1242  else
1243  {
1244  return "";
1245  }
1246  }
$result
$data
global $ilDB
+ 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 1751 of file class.SurveyQuestion.php.

References ilPlugin\getPluginObject(), and IL_COMP_MODULE.

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

1752  {
1753  $type = $question_type;
1754  if ($gui) $type .= "GUI";
1755  if (file_exists("./Modules/SurveyQuestionPool/classes/class.".$type.".php"))
1756  {
1757  include_once "./Modules/SurveyQuestionPool/classes/class.".$type.".php";
1758  return true;
1759  }
1760  else
1761  {
1762  global $ilPluginAdmin;
1763  $pl_names = $ilPluginAdmin->getActivePluginsForSlot(IL_COMP_MODULE, "SurveyQuestionPool", "svyq");
1764  foreach ($pl_names as $pl_name)
1765  {
1766  $pl = ilPlugin::getPluginObject(IL_COMP_MODULE, "SurveyQuestionPool", "svyq", $pl_name);
1767  if (strcmp($pl->getQuestionType(), $question_type) == 0)
1768  {
1769  $pl->includeClass("class.".$type.".php");
1770  return true;
1771  }
1772  }
1773  }
1774  return false;
1775  }
static getPluginObject($a_ctype, $a_cname, $a_slot_id, $a_pname)
Get plugin object.
const IL_COMP_MODULE
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _instanciateQuestion()

& SurveyQuestion::_instanciateQuestion (   $question_id)

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

References _getQuestionType(), and _includeClass().

Referenced by ilSurveySkill\determineMaxScale(), ilObjSurveyQuestionPool\duplicateQuestion(), ilSurveyEvaluationGUI\exportCumulatedResults(), ilSurveyEvaluationGUI\exportUserSpecificResults(), ilObjSurvey\fillSurveyForUser(), ilObjSurvey\getDetailedParticipantResultsAsText(), ilObjMediaObject\getParentObjectIdForUsage(), ilObjSurvey\importObject(), ilObjSurveyQuestionPool\removeQuestion(), and ilSurveyExecutionGUI\saveActiveQuestionData().

1815  {
1816  $question_type = SurveyQuestion::_getQuestionType($question_id);
1817  if($question_type)
1818  {
1819  SurveyQuestion::_includeClass($question_type);
1820  $question = new $question_type();
1821  $question->loadFromDb($question_id);
1822  return $question;
1823  }
1824  }
static _includeClass($question_type, $gui=0)
Include the php class file for a given question type.
_getQuestionType($question_id)
Returns the question type of a question with a given id.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _instanciateQuestionGUI()

& SurveyQuestion::_instanciateQuestionGUI (   $question_id)

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

References _getQuestionType(), and _includeClass().

Referenced by ilSurveyEvaluationGUI\evaluation().

1834  {
1835  $question_type = SurveyQuestion::_getQuestionType($question_id);
1836  if($question_type)
1837  {
1838  SurveyQuestion::_includeClass($question_type, 1);
1839  $guitype = $question_type . "GUI";
1840  $question = new $guitype($question_id);
1841  return $question;
1842  }
1843  }
static _includeClass($question_type, $gui=0)
Include the php class file for a given question type.
_getQuestionType($question_id)
Returns the question type of a question with a given id.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _isComplete()

SurveyQuestion::_isComplete (   $question_id)

Checks whether the question is complete or not.

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

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

References $ilDB, $result, and $row.

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

742  {
743  global $ilDB;
744 
745  $result = $ilDB->queryF("SELECT complete FROM svy_question WHERE question_id = %s",
746  array('integer'),
747  array($question_id)
748  );
749  if ($result->numRows())
750  {
751  $row = $ilDB->fetchAssoc($result);
752  if ($row["complete"] == 1)
753  {
754  return TRUE;
755  }
756  }
757  return FALSE;
758  }
$result
global $ilDB
+ Here is the caller graph for this function:

◆ _isWriteable()

SurveyQuestion::_isWriteable (   $question_id,
  $user_id 
)

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

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

Referenced by SurveyQuestionGUI\save().

1684  {
1685  global $ilDB;
1686 
1687  if (($question_id < 1) || ($user_id < 1))
1688  {
1689  return false;
1690  }
1691 
1692  $result = $ilDB->queryF("SELECT obj_fi FROM svy_question WHERE question_id = %s",
1693  array('integer'),
1694  array($question_id)
1695  );
1696  if ($result->numRows() == 1)
1697  {
1698  $row = $ilDB->fetchAssoc($result);
1699  $qpl_object_id = $row["obj_fi"];
1700  include_once "./Modules/SurveyQuestionPool/classes/class.ilObjSurveyQuestionPool.php";
1701  return ilObjSurveyQuestionPool::_isWriteable($qpl_object_id, $user_id);
1702  }
1703  else
1704  {
1705  return false;
1706  }
1707  }
_isWriteable($object_id, $user_id)
Returns true, if the question pool is writeable by a given user.
$result
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 2427 of file class.SurveyQuestion.php.

References $ilDB, and $row.

Referenced by ilObjMediaObject\getParentObjectIdForUsage().

2428  {
2429  global $ilDB;
2430 
2431  $set = $ilDB->query("SELECT svy_svy.obj_fi FROM svy_svy_qst".
2432  " JOIN svy_svy ON (svy_svy.survey_id = svy_svy_qst.survey_fi)".
2433  " WHERE svy_svy_qst.question_fi = ".$ilDB->quote($a_question_id, "integer"));
2434  $row = $ilDB->fetchAssoc($set);
2435  if($ilDB->numRows($set))
2436  {
2437  return $row["obj_fi"];
2438  }
2439  }
global $ilDB
+ Here is the caller graph for this function:

◆ _questionExists()

SurveyQuestion::_questionExists (   $question_id)

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

References $ilDB, and $result.

Referenced by ilSurveySkill\read().

1364  {
1365  global $ilDB;
1366 
1367  if ($question_id < 1)
1368  {
1369  return false;
1370  }
1371 
1372  $result = $ilDB->queryF("SELECT question_id FROM svy_question WHERE question_id = %s",
1373  array('integer'),
1374  array($question_id)
1375  );
1376  return ($result->numRows() == 1) ? true : false;
1377  }
$result
global $ilDB
+ Here is the caller graph for this function:

◆ _resolveInternalLink()

SurveyQuestion::_resolveInternalLink (   $internal_link)

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

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

Referenced by _resolveIntLinks(), and setMaterial().

1552  {
1553  if (preg_match("/il_(\d+)_(\w+)_(\d+)/", $internal_link, $matches))
1554  {
1555  include_once "./Services/Link/classes/class.ilInternalLink.php";
1556  include_once "./Modules/LearningModule/classes/class.ilLMObject.php";
1557  include_once "./Modules/Glossary/classes/class.ilGlossaryTerm.php";
1558  switch ($matches[2])
1559  {
1560  case "lm":
1561  $resolved_link = ilLMObject::_getIdForImportId($internal_link);
1562  break;
1563  case "pg":
1564  $resolved_link = ilInternalLink::_getIdForImportId("PageObject", $internal_link);
1565  break;
1566  case "st":
1567  $resolved_link = ilInternalLink::_getIdForImportId("StructureObject", $internal_link);
1568  break;
1569  case "git":
1570  $resolved_link = ilInternalLink::_getIdForImportId("GlossaryItem", $internal_link);
1571  break;
1572  case "mob":
1573  $resolved_link = ilInternalLink::_getIdForImportId("MediaObject", $internal_link);
1574  break;
1575  }
1576  if (strcmp($resolved_link, "") == 0)
1577  {
1578  $resolved_link = $internal_link;
1579  }
1580  }
1581  else
1582  {
1583  $resolved_link = $internal_link;
1584  }
1585  return $resolved_link;
1586  }
_getIdForImportId($a_import_id)
get current object id for import id (static)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _resolveIntLinks()

SurveyQuestion::_resolveIntLinks (   $question_id)

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

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

Referenced by ilContObjParser\processPagesToParse().

1589  {
1590  global $ilDB;
1591  $resolvedlinks = 0;
1592  $result = $ilDB->queryF("SELECT * FROM svy_material WHERE question_fi = %s",
1593  array('integer'),
1594  array($question_id)
1595  );
1596  if ($result->numRows())
1597  {
1598  while ($row = $ilDB->fetchAssoc($result))
1599  {
1600  $internal_link = $row["internal_link"];
1601  include_once "./Modules/SurveyQuestionPool/classes/class.SurveyQuestion.php";
1602  $resolved_link = SurveyQuestion::_resolveInternalLink($internal_link);
1603  if (strcmp($internal_link, $resolved_link) != 0)
1604  {
1605  // internal link was resolved successfully
1606  $affectedRows = $ilDB->manipulateF("UPDATE svy_material SET internal_link = %s, tstamp = %s WHERE material_id = %s",
1607  array('text', 'integer', 'integer'),
1608  array($resolved_link, time(), $row["material_id"])
1609  );
1610  $resolvedlinks++;
1611  }
1612  }
1613  }
1614  if ($resolvedlinks)
1615  {
1616  // there are resolved links -> reenter theses links to the database
1617 
1618  // delete all internal links from the database
1619  include_once "./Services/Link/classes/class.ilInternalLink.php";
1620  ilInternalLink::_deleteAllLinksOfSource("sqst", $question_id);
1621 
1622  $result = $ilDB->queryF("SELECT * FROM svy_material WHERE question_fi = %s",
1623  array('integer'),
1624  array($question_id)
1625  );
1626  if ($result->numRows())
1627  {
1628  while ($row = $ilDB->fetchAssoc($result))
1629  {
1630  if (preg_match("/il_(\d*?)_(\w+)_(\d+)/", $row["internal_link"], $matches))
1631  {
1632  ilInternalLink::_saveLink("sqst", $question_id, $matches[2], $matches[3], $matches[1]);
1633  }
1634  }
1635  }
1636  }
1637  }
$result
_resolveInternalLink($internal_link)
global $ilDB
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _SurveyQuestion()

SurveyQuestion::_SurveyQuestion ( )

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

199  {
200  }

◆ addInternalLink()

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

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

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

1380  {
1381  if (strlen($material_id))
1382  {
1383  if (strcmp($material_title, "") == 0)
1384  {
1385  if (preg_match("/il__(\w+)_(\d+)/", $material_id, $matches))
1386  {
1387  $type = $matches[1];
1388  $target_id = $matches[2];
1389  $material_title = $this->lng->txt("obj_$type") . ": ";
1390  switch ($type)
1391  {
1392  case "lm":
1393  include_once("./Modules/LearningModule/classes/class.ilObjContentObjectGUI.php");
1394  $cont_obj_gui =& new ilObjContentObjectGUI("", $target_id, true);
1395  $cont_obj = $cont_obj_gui->object;
1396  $material_title .= $cont_obj->getTitle();
1397  break;
1398  case "pg":
1399  include_once("./Modules/LearningModule/classes/class.ilLMPageObject.php");
1400  include_once("./Modules/LearningModule/classes/class.ilLMObject.php");
1402  include_once("./Modules/LearningModule/classes/class.ilObjContentObjectGUI.php");
1403  $cont_obj_gui =& new ilObjContentObjectGUI("", $lm_id, FALSE);
1404  $cont_obj = $cont_obj_gui->object;
1405  $pg_obj =& new ilLMPageObject($cont_obj, $target_id);
1406  $material_title .= $pg_obj->getTitle();
1407  break;
1408  case "st":
1409  include_once("./Modules/LearningModule/classes/class.ilStructureObject.php");
1410  include_once("./Modules/LearningModule/classes/class.ilLMObject.php");
1412  include_once("./Modules/LearningModule/classes/class.ilObjContentObjectGUI.php");
1413  $cont_obj_gui =& new ilObjContentObjectGUI("", $lm_id, FALSE);
1414  $cont_obj = $cont_obj_gui->object;
1415  $st_obj =& new ilStructureObject($cont_obj, $target_id);
1416  $material_title .= $st_obj->getTitle();
1417  break;
1418  case "git":
1419  include_once "./Modules/Glossary/classes/class.ilGlossaryTerm.php";
1420  $material_title = $this->lng->txt("glossary_term") . ": " . ilGlossaryTerm::_lookGlossaryTerm($target_id);
1421  break;
1422  case "mob":
1423  break;
1424  }
1425  }
1426  }
1427  include_once "./Modules/SurveyQuestionPool/classes/class.ilSurveyMaterial.php";
1428  $mat = new ilSurveyMaterial();
1429  $mat->type = 0;
1430  $mat->internal_link = $material_id;
1431  $mat->title = $material_title;
1432  $this->addMaterial($mat);
1433  $this->saveMaterial();
1434  }
1435  }
$target_id
Definition: goto.php:88
Survey material class.
addMaterial($obj_material)
Class ilLMPageObject.
saveMaterial()
save material to db
_lookupContObjID($a_id)
get learning module / digibook id for lm object
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 1476 of file class.SurveyQuestion.php.

Referenced by addInternalLink().

1477  {
1478  array_push($this->material, $obj_material);
1479  }
+ 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 331 of file class.SurveyQuestion.php.

Referenced by setMaterialsfile().

332  {
333  if (empty($materials_name))
334  {
335  $materials_name = $materials_file;
336  }
337  if ((!empty($materials_name))&&(!array_key_exists($materials_name, $this->materials)))
338  {
339  $this->materials[$materials_name] = $materials_file;
340  }
341  }
+ 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 1904 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().

1905  {
1906  include_once "./Services/RTE/classes/class.ilRTE.php";
1907  include_once("./Services/MediaObjects/classes/class.ilObjMediaObject.php");
1908 
1909  $a_xml_writer->xmlStartTag("material");
1910  $attrs = array(
1911  "type" => "text/plain"
1912  );
1913  if ($this->isHTML($a_material))
1914  {
1915  $attrs["type"] = "text/xhtml";
1916  }
1917  if (is_array($a_attrs))
1918  {
1919  $attrs = array_merge($attrs, $a_attrs);
1920  }
1921  $a_xml_writer->xmlElement("mattext", $attrs, ilRTE::_replaceMediaObjectImageSrc($a_material, 0));
1922 
1923  if ($add_mobs)
1924  {
1925  $mobs = ilObjMediaObject::_getMobsOfObject("spl:html", $this->getId());
1926  foreach ($mobs as $mob)
1927  {
1928  $mob_obj =& new ilObjMediaObject($mob);
1929  $imgattrs = array(
1930  "label" => "il_" . IL_INST_ID . "_mob_" . $mob,
1931  "uri" => "objects/" . "il_" . IL_INST_ID . "_mob_" . $mob . "/" . $mob_obj->getTitle(),
1932  "type" => "spl:html",
1933  "id" => $this->getId()
1934  );
1935  $a_xml_writer->xmlElement("matimage", $imgattrs, NULL);
1936  }
1937  }
1938  if ($close_material_tag) $a_xml_writer->xmlEndTag("material");
1939  }
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.
_getMobsOfObject($a_type, $a_id, $a_usage_hist_nr=0, $a_lang="-")
get mobs of object
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:

◆ addUserSpecificResultsData()

SurveyQuestion::addUserSpecificResultsData ( $a_array,
$resultset 
)

Adds the values for the user specific results export for a given user.

Parameters
array$a_arrayAn array which is used to append the values
array$resultsetThe evaluation data for a given user public

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

2001  {
2002  // overwrite in inherited classes
2003  }

◆ addUserSpecificResultsExportTitles()

SurveyQuestion::addUserSpecificResultsExportTitles ( $a_array,
  $a_use_label = false,
  $a_substitute = true 
)

Adds the entries for the title row of the user specific results.

Parameters
array$a_arrayAn array which is used to append the title row entries public

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

References $title.

1972  {
1973  if(!$a_use_label)
1974  {
1975  $title = $this->title;
1976  }
1977  else
1978  {
1979  if($a_substitute)
1980  {
1981  $title = $this->label ? $this->label : $this->title;
1982  }
1983  else
1984  {
1985  $title = $this->label;
1986  }
1987  }
1988 
1989  array_push($a_array, $title);
1990  return $title;
1991  }

◆ calculateCumulatedResults()

& SurveyQuestion::calculateCumulatedResults (   $survey_id,
  $finished_ids 
)
protected

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

References $cumulated, and ilObjSurvey\_getNrOfParticipants().

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

2290  {
2291  if (count($this->cumulated) == 0)
2292  {
2293  if(!$finished_ids)
2294  {
2295  include_once "./Modules/Survey/classes/class.ilObjSurvey.php";
2297  }
2298  else
2299  {
2300  $nr_of_users = sizeof($finished_ids);
2301  }
2302  if($nr_of_users)
2303  {
2304  $this->cumulated =& $this->getCumulatedResults($survey_id, $nr_of_users, $finished_ids);
2305  }
2306  }
2307  return $this->cumulated;
2308  }
$cumulated
An array containing the cumulated results of the question for a given survey.
_getNrOfParticipants($survey_id)
Returns the number of participants for a survey.
+ 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 660 of file class.SurveyQuestion.php.

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

661  {
662  if ($this->getId() <= 0)
663  {
664  // The question has not been saved. It cannot be copied
665  return;
666  }
667  $clone = $this;
668  $original_id = SurveyQuestion::_getOriginalId($this->getId(), false);
669  $clone->setId(-1);
670  $source_questionpool = $this->getObjId();
671  $clone->setObjId($target_questionpool);
672  if ($title)
673  {
674  $clone->setTitle($title);
675  }
676 
677  $clone->saveToDb();
678 
679  // duplicate the materials
680  $clone->duplicateMaterials($original_id);
681  // copy XHTML media objects
682  $clone->copyXHTMLMediaObjectsOfQuestion($original_id);
683  return $clone->getId();
684  }
getId()
Gets the id of the SurveyQuestion object.
_getOriginalId($question_id, $a_return_question_id_if_no_original=true)
Returns the original id of a question.
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 692 of file class.SurveyQuestion.php.

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

693  {
694  include_once("./Services/MediaObjects/classes/class.ilObjMediaObject.php");
695  $mobs = ilObjMediaObject::_getMobsOfObject("spl:html", $a_q_id);
696  foreach ($mobs as $mob)
697  {
698  ilObjMediaObject::_saveUsage($mob, "spl:html", $this->getId());
699  }
700  }
_saveUsage($a_mob_id, $a_type, $a_id, $a_usage_hist_nr=0, $a_lang="-")
Save usage of mob within another container (e.g.
$mobs
getId()
Gets the id of the SurveyQuestion object.
_getMobsOfObject($a_type, $a_id, $a_usage_hist_nr=0, $a_lang="-")
get mobs of object
+ 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 926 of file class.SurveyQuestion.php.

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

927  {
928  global $ilDB;
929 
930  $obj_id = $this->getObjId();
931  if ($obj_id > 0)
932  {
933  $next_id = $ilDB->nextId('svy_question');
934  $affectedRows = $ilDB->manipulateF("INSERT INTO svy_question (question_id, questiontype_fi, " .
935  "obj_fi, owner_fi, title, description, author, questiontext, obligatory, complete, " .
936  "created, original_id, tstamp) VALUES " .
937  "(%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)",
938  array('integer', 'integer', 'integer', 'integer', 'text', 'text', 'text', 'text',
939  'text', 'text', 'integer', 'integer', 'integer'),
940  array(
941  $next_id,
942  $this->getQuestionTypeID(),
943  $obj_id,
944  $this->getOwner(),
945  NULL,
946  NULL,
947  $this->getAuthor(),
948  NULL,
949  "1",
950  "0",
951  time(),
952  NULL,
953  0
954  )
955  );
956  $this->setId($next_id);
957  }
958  return $this->getId();
959  }
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 1086 of file class.SurveyQuestion.php.

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

1087  {
1088  global $ilDB;
1089 
1090  if ($question_id < 1) return;
1091 
1092  $result = $ilDB->queryF("SELECT obj_fi FROM svy_question WHERE question_id = %s",
1093  array('integer'),
1094  array($question_id)
1095  );
1096  if ($result->numRows() == 1)
1097  {
1098  $row = $ilDB->fetchAssoc($result);
1099  $obj_id = $row["obj_fi"];
1100  }
1101  else
1102  {
1103  return;
1104  }
1105 
1106  $affectedRows = $ilDB->manipulateF("DELETE FROM svy_answer WHERE question_fi = %s",
1107  array('integer'),
1108  array($question_id)
1109  );
1110 
1111  $affectedRows = $ilDB->manipulateF("DELETE FROM svy_constraint WHERE question_fi = %s",
1112  array('integer'),
1113  array($question_id)
1114  );
1115 
1116  $result = $ilDB->queryF("SELECT constraint_fi FROM svy_qst_constraint WHERE question_fi = %s",
1117  array('integer'),
1118  array($question_id)
1119  );
1120  while ($row = $ilDB->fetchObject($result))
1121  {
1122  $affectedRows = $ilDB->manipulateF("DELETE FROM svy_constraint WHERE constraint_id = %s",
1123  array('integer'),
1124  array($row->constraint_fi)
1125  );
1126  }
1127 
1128  $affectedRows = $ilDB->manipulateF("DELETE FROM svy_qst_constraint WHERE question_fi = %s",
1129  array('integer'),
1130  array($question_id)
1131  );
1132 
1133  $affectedRows = $ilDB->manipulateF("DELETE FROM svy_qblk_qst WHERE question_fi = %s",
1134  array('integer'),
1135  array($question_id)
1136  );
1137  $affectedRows = $ilDB->manipulateF("DELETE FROM svy_qst_oblig WHERE question_fi = %s",
1138  array('integer'),
1139  array($question_id)
1140  );
1141  $affectedRows = $ilDB->manipulateF("DELETE FROM svy_svy_qst WHERE question_fi = %s",
1142  array('integer'),
1143  array($question_id)
1144  );
1145  $affectedRows = $ilDB->manipulateF("DELETE FROM svy_variable WHERE question_fi = %s",
1146  array('integer'),
1147  array($question_id)
1148  );
1149  $affectedRows = $ilDB->manipulateF("DELETE FROM svy_question WHERE question_id = %s",
1150  array('integer'),
1151  array($question_id)
1152  );
1153 
1154  $this->deleteAdditionalTableData($question_id);
1155 
1156  $affectedRows = $ilDB->manipulateF("DELETE FROM svy_material WHERE question_fi = %s",
1157  array('integer'),
1158  array($question_id)
1159  );
1160  include_once "./Services/Link/classes/class.ilInternalLink.php";
1161  ilInternalLink::_deleteAllLinksOfSource("sqst", $question_id);
1162 
1163  $directory = CLIENT_WEB_DIR . "/survey/" . $obj_id . "/$question_id";
1164  if (preg_match("/\d+/", $obj_id) and preg_match("/\d+/", $question_id) and is_dir($directory))
1165  {
1166  include_once "./Services/Utilities/classes/class.ilUtil.php";
1167  ilUtil::delDir($directory);
1168  }
1169 
1170  include_once("./Services/MediaObjects/classes/class.ilObjMediaObject.php");
1171  $mobs = ilObjMediaObject::_getMobsOfObject("spl:html", $question_id);
1172  // remaining usages are not in text anymore -> delete them
1173  // and media objects (note: delete method of ilObjMediaObject
1174  // checks whether object is used in another context; if yes,
1175  // the object is not deleted!)
1176  foreach($mobs as $mob)
1177  {
1178  ilObjMediaObject::_removeUsage($mob, "spl:html", $question_id);
1179  $mob_obj =& new ilObjMediaObject($mob);
1180  $mob_obj->delete();
1181  }
1182 
1183  include_once("./Modules/Survey/classes/class.ilSurveySkill.php");
1185 
1186  // #12772 - untie question copies from pool question
1187  $ilDB->manipulate("UPDATE svy_question".
1188  " SET original_id = NULL".
1189  " WHERE original_id = ".$ilDB->quote($question_id, "integer"));
1190  }
static handleQuestionDeletion($a_question_id, $a_obj_id)
Remove question skill assignment.
$result
_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.
_getMobsOfObject($a_type, $a_id, $a_usage_hist_nr=0, $a_lang="-")
get mobs of object
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 1071 of file class.SurveyQuestion.php.

References $ilDB.

Referenced by delete().

1072  {
1073  global $ilDB;
1074  $affectedRows = $ilDB->manipulateF("DELETE FROM " . $this->getAdditionalTableName() . " WHERE question_fi = %s",
1075  array('integer'),
1076  array($question_id)
1077  );
1078  }
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 379 of file class.SurveyQuestion.php.

References getMaterialsPath().

380  {
381  foreach ($this->materials as $key => $value)
382  {
383  if (strcmp($key, $materials_name)==0)
384  {
385  if (file_exists($this->getMaterialsPath().$value))
386  {
387  unlink($this->getMaterialsPath().$value);
388  }
389  unset($this->materials[$key]);
390  }
391  }
392  }
getMaterialsPath()
Returns the materials path for web accessable materials of a question.
+ 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 1442 of file class.SurveyQuestion.php.

References saveMaterial().

1443  {
1444  foreach ($a_array as $idx)
1445  {
1446  unset($this->material[$idx]);
1447  }
1448  $this->material = array_values($this->material);
1449  $this->saveMaterial();
1450  }
saveMaterial()
save material to db
+ Here is the call graph for this function:

◆ duplicate()

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

Duplicates a survey question.

public

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

References getId().

618  {
619  if ($this->getId() <= 0)
620  {
621  // The question has not been saved. It cannot be duplicated
622  return;
623  }
624  // duplicate the question in database
625  $clone = $this;
626  $original_id = $this->getId();
627  $clone->setId(-1);
628  if ($title)
629  {
630  $clone->setTitle($title);
631  }
632  if ($author)
633  {
634  $clone->setAuthor($author);
635  }
636  if ($owner)
637  {
638  $clone->setOwner($owner);
639  }
640  if ($for_survey)
641  {
642  $clone->saveToDb($original_id);
643  }
644  else
645  {
646  $clone->saveToDb();
647  }
648  // duplicate the materials
649  $clone->duplicateMaterials($original_id);
650  // copy XHTML media objects
651  $clone->copyXHTMLMediaObjectsOfQuestion($original_id);
652  return $clone->getId();
653  }
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 1458 of file class.SurveyQuestion.php.

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

1459  {
1460  foreach ($this->materials as $filename)
1461  {
1462  $materialspath = $this->getMaterialsPath();
1463  $materialspath_original = preg_replace("/([^\d])$this->id([^\d])/", "\${1}$question_id\${2}", $materialspath);
1464  if (!file_exists($materialspath))
1465  {
1466  include_once "./Services/Utilities/classes/class.ilUtil.php";
1467  ilUtil::makeDirParents($materialspath);
1468  }
1469  if (!copy($materialspath_original . $filename, $materialspath . $filename))
1470  {
1471  print "material could not be duplicated!!!! ";
1472  }
1473  }
1474  }
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 400 of file class.SurveyQuestion.php.

401  {
402  $this->materials = array();
403  }

◆ 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 560 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().

561  {
562  return (strlen($this->author)) ? $this->author : NULL;
563  }
+ 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 2199 of file class.SurveyQuestion.php.

2200  {
2201  // overwrite in inherited classes
2202  return array();
2203  }

◆ getCopyIds()

SurveyQuestion::getCopyIds (   $a_group_by_survey = false)

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

References $ilDB, $res, and $row.

Referenced by hasCopies().

2393  {
2394  global $ilDB;
2395 
2396  $set = $ilDB->query("SELECT q.question_id,s.obj_fi".
2397  " FROM svy_question q".
2398  " JOIN svy_svy_qst sq ON (sq.question_fi = q.question_id)".
2399  " JOIN svy_svy s ON (s.survey_id = sq.survey_fi)".
2400  " WHERE original_id = ".$ilDB->quote($this->getId(), "integer"));
2401  $res = array();
2402  while($row = $ilDB->fetchAssoc($set))
2403  {
2404  if(!$a_group_by_survey)
2405  {
2406  $res[] = $row["question_id"];
2407  }
2408  else
2409  {
2410  $res[$row["obj_fi"]][] = $row["question_id"];
2411  }
2412  }
2413  return $res;
2414  }
global $ilDB
+ Here is the caller graph for this function:

◆ getCumulatedResultData()

SurveyQuestion::getCumulatedResultData (   $survey_id,
  $counter,
  $finished_ids 
)

Creates a the cumulated results data for the question.

Returns
array Data

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

References $cumulated, $questiontext, $result, calculateCumulatedResults(), and getQuestiontext().

2316  {
2317  $cumulated =& $this->calculateCumulatedResults($survey_id, $finished_ids);
2318  $questiontext = preg_replace("/<[^>]+?>/ims", "", $this->getQuestiontext());
2319 
2320  $maxlen = 75;
2321  include_once "./Services/Utilities/classes/class.ilStr.php";
2322  if (ilStr::strlen($questiontext) > $maxlen + 3)
2323  {
2324  $questiontext = ilStr::substr($questiontext, 0, $maxlen) . "...";
2325  }
2326 
2327  $result = array(
2328  'counter' => $counter,
2329  'title' => $counter.'. '.$this->getTitle(),
2330  'question' => $questiontext,
2331  'users_answered' => $cumulated['USERS_ANSWERED'],
2332  'users_skipped' => $cumulated['USERS_SKIPPED'],
2333  'question_type' => $this->lng->txt($cumulated["QUESTION_TYPE"]),
2334  'mode' => $cumulated["MODE"],
2335  'mode_nr_of_selections' => $cumulated["MODE_NR_OF_SELECTIONS"],
2336  'median' => $cumulated["MEDIAN"],
2337  'arithmetic_mean' => $cumulated["ARITHMETIC_MEAN"]
2338  );
2339  return $result;
2340  }
$cumulated
An array containing the cumulated results of the question for a given survey.
$result
getQuestiontext()
Gets the questiontext of the SurveyQuestion object.
& calculateCumulatedResults($survey_id, $finished_ids)
+ Here is the call 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 548 of file class.SurveyQuestion.php.

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

549  {
550  return (strlen($this->description)) ? $this->description : NULL;
551  }
+ 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 469 of file class.SurveyQuestion.php.

References $id.

Referenced by addMaterialTag(), SurveyTextQuestion\addUserSpecificResultsData(), SurveyMultipleChoiceQuestion\addUserSpecificResultsData(), SurveyMetricQuestion\addUserSpecificResultsData(), SurveySingleChoiceQuestion\addUserSpecificResultsData(), SurveyMatrixQuestion\addUserSpecificResultsData(), SurveyTextQuestion\checkUserInput(), SurveyMultipleChoiceQuestion\checkUserInput(), SurveySingleChoiceQuestion\checkUserInput(), SurveyMetricQuestion\checkUserInput(), SurveyMatrixQuestion\checkUserInput(), copyObject(), copyXHTMLMediaObjectsOfQuestion(), createNewQuestion(), duplicate(), SurveyTextQuestion\getCumulatedResults(), SurveyMultipleChoiceQuestion\getCumulatedResults(), SurveySingleChoiceQuestion\getCumulatedResults(), SurveyMetricQuestion\getCumulatedResults(), SurveyMatrixQuestion\getCumulatedResults(), SurveyMatrixQuestion\getCumulatedResultsForRow(), SurveyMatrixQuestion\getNrOfUsersAnswered(), getObligatory(), SurveyTextQuestion\getUserAnswers(), SurveyMultipleChoiceQuestion\getUserAnswers(), SurveyMetricQuestion\getUserAnswers(), SurveySingleChoiceQuestion\getUserAnswers(), SurveyMatrixQuestion\getUserAnswers(), 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(), SurveyTextQuestion\saveRandomData(), SurveyMultipleChoiceQuestion\saveRandomData(), SurveySingleChoiceQuestion\saveRandomData(), SurveyMetricQuestion\saveRandomData(), SurveyMatrixQuestion\saveRandomData(), SurveyMatrixQuestion\saveRowsToDb(), SurveyMultipleChoiceQuestion\saveToDb(), SurveyTextQuestion\saveToDb(), SurveySingleChoiceQuestion\saveToDb(), SurveyMetricQuestion\saveToDb(), SurveyMatrixQuestion\saveToDb(), saveToDb(), SurveyTextQuestion\saveUserInput(), SurveyMultipleChoiceQuestion\saveUserInput(), SurveySingleChoiceQuestion\saveUserInput(), SurveyMetricQuestion\saveUserInput(), SurveyMatrixQuestion\saveUserInput(), and syncWithOriginal().

470  {
471  return $this->id;
472  }
+ 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 977 of file class.SurveyQuestion.php.

978  {
979  return CLIENT_WEB_DIR . "/survey/$this->obj_id/$this->id/images/";
980  }

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

References ILIAS_ABSOLUTE_PATH, and ilUtil\removeTrailingPathSeparators().

1000  {
1001  include_once "./Services/Utilities/classes/class.ilUtil.php";
1002  $webdir = ilUtil::removeTrailingPathSeparators(CLIENT_WEB_DIR) . "/survey/$this->obj_id/$this->id/images/";
1004  }
const ILIAS_ABSOLUTE_PATH
static removeTrailingPathSeparators($path)
+ Here is the call graph for this function:

◆ getLabel()

SurveyQuestion::getLabel ( )

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

458  {
459  return $this->label;
460  }

◆ getMaterial()

SurveyQuestion::getMaterial ( )

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

References $material.

2274  {
2275  return $this->material;
2276  }

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

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

989  {
990  return CLIENT_WEB_DIR . "/survey/$this->obj_id/$this->id/materials/";
991  }
+ 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 1012 of file class.SurveyQuestion.php.

References ILIAS_ABSOLUTE_PATH, and ilUtil\removeTrailingPathSeparators().

1013  {
1014  include_once "./Services/Utilities/classes/class.ilUtil.php";
1015  $webdir = ilUtil::removeTrailingPathSeparators(CLIENT_WEB_DIR) . "/survey/$this->obj_id/$this->id/materials/";
1017  }
const ILIAS_ABSOLUTE_PATH
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 596 of file class.SurveyQuestion.php.

References $obj_id.

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

596  {
597  return $this->obj_id;
598  }
+ 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 480 of file class.SurveyQuestion.php.

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

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

481  {
482  if ($survey_id > 0)
483  {
484  global $ilDB;
485 
486  $result = $ilDB->queryF("SELECT * FROM svy_qst_oblig WHERE survey_fi = %s AND question_fi = %s",
487  array('integer', 'integer'),
488  array($survey_id, $this->getId())
489  );
490  if ($result->numRows())
491  {
492  $row = $ilDB->fetchAssoc($result);
493  return ($row["obligatory"]) ? 1 : 0;
494  }
495  else
496  {
497  return ($this->obligatory) ? 1 : 0;
498  }
499  }
500  else
501  {
502  return ($this->obligatory) ? 1 : 0;
503  }
504  }
$result
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:

◆ getOrientation()

SurveyQuestion::getOrientation ( )

Gets the orientation of the question output.

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

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

References $orientation.

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

526  {
527  switch ($this->orientation)
528  {
529  case 0:
530  case 1:
531  case 2:
532  break;
533  default:
534  $this->orientation = 0;
535  break;
536  }
537  return $this->orientation;
538  }
+ Here is the caller graph for this function:

◆ getOriginalId()

SurveyQuestion::getOriginalId ( )

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

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

2259  {
2260  return $this->original_id;
2261  }
+ 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 572 of file class.SurveyQuestion.php.

References $owner.

Referenced by createNewQuestion(), and saveToDb().

573  {
574  return $this->owner;
575  }
+ 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 1323 of file class.SurveyQuestion.php.

References $ilDB, $result, and $row.

1324  {
1325  global $ilDB;
1326 
1327  $result = $ilDB->queryF("SELECT title FROM svy_phrase WHERE phrase_id = %s",
1328  array('integer'),
1329  array($phrase_id)
1330  );
1331  if ($row = $ilDB->fetchAssoc($result))
1332  {
1333  return $row["title"];
1334  }
1335  return "";
1336  }
$result
global $ilDB

◆ getPreconditionOptions()

SurveyQuestion::getPreconditionOptions ( )

Returns the options for preconditions.

Returns
array

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

Referenced by SurveyMatrixQuestion\getPreconditionSelectValue().

2211  {
2212  // overwrite in inherited classes
2213  }
+ 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 2234 of file class.SurveyQuestion.php.

2235  {
2236  // overwrite in inherited classes
2237  return null;
2238  }

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

2223  {
2224  // overwrite in inherited classes
2225  return $value;
2226  }

◆ getQuestiontext()

◆ getQuestionType()

SurveyQuestion::getQuestionType ( )

Returns the question type of the question.

Returns
integer The question type of the question public

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

Referenced by getQuestionTypeID().

1740  {
1741  return "";
1742  }
+ 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 1715 of file class.SurveyQuestion.php.

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

Referenced by createNewQuestion(), and saveToDb().

1716  {
1717  global $ilDB;
1718  $result = $ilDB->queryF("SELECT questiontype_id FROM svy_qtype WHERE type_tag = %s",
1719  array('text'),
1720  array($this->getQuestionType())
1721  );
1722  if ($result->numRows() == 1)
1723  {
1724  $row = $ilDB->fetchAssoc($result);
1725  return $row["questiontype_id"];
1726  }
1727  else
1728  {
1729  return 0;
1730  }
1731  }
$result
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:

◆ getSkippedValue()

SurveyQuestion::getSkippedValue ( )

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

References ilObjSurvey\getSurveySkippedValue().

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

2422  {
2423  include_once "Modules/Survey/classes/class.ilObjSurvey.php";
2425  }
static getSurveySkippedValue()
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getSubtype()

SurveyQuestion::getSubtype ( )

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

2284  {
2285  // do nothing
2286  return null;
2287  }

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

References $survey_id.

514  {
515  return $this->survey_id;
516  }

◆ getTitle()

◆ getUserAnswers()

& SurveyQuestion::getUserAnswers (   $survey_id)

Returns an array containing all answers to this question in a given survey.

Parameters
integer$survey_idThe database ID of the survey
Returns
array An array containing the answers to the question. The keys are either the user id or the anonymous id public

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

2013  {
2014  // overwrite in inherited classes
2015  return array();
2016  }

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

References $data.

2025  {
2026  // overwrite in inherited classes
2027  $data = array();
2028  return $data;
2029  }
$data

◆ hasCopies()

SurveyQuestion::hasCopies ( )

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

References getCopyIds().

2417  {
2418  return (bool)sizeof($this->getCopyIds());
2419  }
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 2039 of file class.SurveyQuestion.php.

2040  {
2041  // overwrite in inherited classes
2042  }

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

2062  {
2063  // overwrite in inherited classes
2064  }

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

2073  {
2074  // overwrite in inherited classes
2075  }

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

2051  {
2052  // overwrite in inherited classes
2053  }

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

Referenced by saveCompletionStatus(), and saveToDb().

220  {
221  return 0;
222  }
+ 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 1853 of file class.SurveyQuestion.php.

Referenced by addMaterialTag().

1854  {
1855  if (preg_match("/<[^>]*?>/", $a_text))
1856  {
1857  return TRUE;
1858  }
1859  else
1860  {
1861  return FALSE;
1862  }
1863  }
+ 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 708 of file class.SurveyQuestion.php.

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

709  {
710  global $ilDB;
711 
712  $result = $ilDB->queryF("SELECT * FROM svy_material WHERE question_fi = %s",
713  array('integer'),
714  array($this->getId())
715  );
716  $this->material = array();
717  if ($result->numRows())
718  {
719  include_once "./Modules/SurveyQuestionPool/classes/class.ilSurveyMaterial.php";
720  while ($row = $ilDB->fetchAssoc($result))
721  {
722  $mat = new ilSurveyMaterial();
723  $mat->type = $row['material_type'];
724  $mat->internal_link = $row['internal_link'];
725  $mat->title = $row['material_title'];
726  $mat->import_id = $row['import_id'];
727  $mat->text_material = $row['text_material'];
728  $mat->external_link = $row['external_link'];
729  $mat->file_material = $row['file_material'];
730  array_push($this->material, $mat);
731  }
732  }
733  }
$result
Survey material class.
getId()
Gets the id of the SurveyQuestion object.
global $ilDB
+ Here is the call graph for this function:

◆ lookupObjFi()

static SurveyQuestion::lookupObjFi (   $a_qid)
static

Lookip obj fi.

Parameters

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

References $ilDB.

Referenced by ilTermUsagesTableGUI\fillRow().

2448  {
2449  global $ilDB;
2450 
2451  $set = $ilDB->query("SELECT obj_fi FROM svy_question ".
2452  " WHERE question_id = ".$ilDB->quote($a_qid, "integer")
2453  );
2454  $rec = $ilDB->fetchAssoc($set);
2455  return $rec["obj_fi"];
2456  }
global $ilDB
+ Here is the caller graph for this function:

◆ outChart()

SurveyQuestion::outChart (   $survey_id,
  $type = "" 
)

Creates an image visualising the results of the question.

Parameters
integer$survey_idThe database ID of the survey
string$typeAn additional parameter to allow to draw more than one chart per question. Must be interpreted by the question. Default is an empty string
Returns
binary Image with the visualisation private

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

2249  {
2250  // overwrite in inherited classes
2251  }

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

References $ilDB, $ilUser, and $result.

1346  {
1347  global $ilUser, $ilDB;
1348 
1349  $result = $ilDB->queryF("SELECT phrase_id FROM svy_phrase WHERE title = %s AND owner_fi = %s",
1350  array('text', 'integer'),
1351  array($title, $ilUser->getId())
1352  );
1353  return ($result->numRows() == 0) ? false : true;
1354  }
$result
global $ilUser
Definition: imgupload.php:15
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 1947 of file class.SurveyQuestion.php.

References ilUtil\prepareTextareaOutput().

1948  {
1949  include_once "./Services/Utilities/classes/class.ilUtil.php";
1950  return ilUtil::prepareTextareaOutput($txt_output, $prepare_for_latex_output);
1951  }
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 1872 of file class.SurveyQuestion.php.

References $_SESSION, and $result.

1873  {
1874  $result = "";
1875  for ($i = 0; $i < $a_material->getMaterialCount(); $i++)
1876  {
1877  $material = $a_material->getMaterial($i);
1878  if (strcmp($material["type"], "mattext") == 0)
1879  {
1880  $result .= $material["material"]->getContent();
1881  }
1882  if (strcmp($material["type"], "matimage") == 0)
1883  {
1884  $matimage = $material["material"];
1885  if (preg_match("/(il_([0-9]+)_mob_([0-9]+))/", $matimage->getLabel(), $matches))
1886  {
1887  // import an mediaobject which was inserted using tiny mce
1888  if (!is_array($_SESSION["import_mob_xhtml"])) $_SESSION["import_mob_xhtml"] = array();
1889  array_push($_SESSION["import_mob_xhtml"], array("mob" => $matimage->getLabel(), "uri" => $matimage->getUri()));
1890  }
1891  }
1892  }
1893  return $result;
1894  }
$_SESSION["AccountId"]
$result

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

References $ilDB, and $result.

233  {
234  global $ilDB;
235 
236  $refwhere = "";
237  if (strcmp($questionpool_object, "") != 0)
238  {
239  $refwhere = sprintf(" AND obj_fi = %s",
240  $ilDB->quote($questionpool_object, 'integer')
241  );
242  }
243  $result = $ilDB->queryF("SELECT question_id FROM svy_question WHERE title = %s$refwhere",
244  array('text'),
245  array($title)
246  );
247  return ($result->numRows() > 0) ? true : false;
248  }
$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 1027 of file class.SurveyQuestion.php.

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

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

1028  {
1029  global $ilUser, $ilDB;
1030 
1031  $result = $ilDB->queryF("SELECT title, category_id FROM svy_category WHERE title = %s AND neutral = %s AND owner_fi = %s",
1032  array('text','text','integer'),
1033  array($categorytext, $neutral, $ilUser->getId())
1034  );
1035  $insert = FALSE;
1036  $returnvalue = "";
1037  if ($result->numRows())
1038  {
1039  $insert = TRUE;
1040  while ($row = $ilDB->fetchAssoc($result))
1041  {
1042  if (strcmp($row["title"], $categorytext) == 0)
1043  {
1044  $returnvalue = $row["category_id"];
1045  $insert = FALSE;
1046  }
1047  }
1048  }
1049  else
1050  {
1051  $insert = TRUE;
1052  }
1053  if ($insert)
1054  {
1055  $next_id = $ilDB->nextId('svy_category');
1056  $affectedRows = $ilDB->manipulateF("INSERT INTO svy_category (category_id, title, neutral, owner_fi, tstamp) VALUES (%s, %s, %s, %s, %s)",
1057  array('integer','text','text','integer','integer'),
1058  array($next_id, $categorytext, $neutral, $ilUser->getId(), time())
1059  );
1060  $returnvalue = $next_id;
1061  }
1062  return $returnvalue;
1063  }
$result
global $ilUser
Definition: imgupload.php:15
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 765 of file class.SurveyQuestion.php.

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

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

766  {
767  global $ilDB;
768 
769  $question_id = $this->getId();
770  if (strlen($original_id))
771  {
772  $question_id = $original_id;
773  }
774 
775  if ($this->getId() > 0)
776  {
777  // update existing dataset
778  $affectedRows = $ilDB->manipulateF("UPDATE svy_question SET complete = %s, tstamp = %s WHERE question_id = %s",
779  array('text', 'integer', 'integer'),
780  array($this->isComplete(), time(), $question_id)
781  );
782  }
783  }
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 889 of file class.SurveyQuestion.php.

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

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

890  {
891  global $ilDB;
892 
893  include_once "./Services/Link/classes/class.ilInternalLink.php";
894  $affectedRows = $ilDB->manipulateF("DELETE FROM svy_material WHERE question_fi = %s",
895  array('integer'),
896  array($this->getId())
897  );
899 
900  foreach ($this->material as $material)
901  {
902  $next_id = $ilDB->nextId('svy_material');
903  $affectedRows = $ilDB->manipulateF("INSERT INTO svy_material " .
904  "(material_id, question_fi, internal_link, import_id, material_title, tstamp," .
905  "text_material, external_link, file_material, material_type) ".
906  "VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s)",
907  array('integer','integer','text','text','text','integer','text','text','text','integer'),
908  array(
909  $next_id, $this->getId(), $material->internal_link, $material->import_id,
910  $material->title, time(), $material->text_material, $material->external_link,
911  $material->file_material, $material->type)
912  );
913  if (preg_match("/il_(\d*?)_(\w+)_(\d+)/", $material->internal_link, $matches))
914  {
915  ilInternalLink::_saveLink("sqst", $this->getId(), $matches[2], $matches[3], $matches[1]);
916  }
917  }
918  }
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:

◆ saveRandomData()

SurveyQuestion::saveRandomData (   $active_id)

Saves random answers for a given active user in the database.

Parameters
integer$active_idThe database ID of the active user

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

2269  {
2270  // do nothing, overwrite in parent classes
2271  }

◆ saveToDb()

SurveyQuestion::saveToDb (   $original_id = "")

Saves a SurveyQuestion object to a database.

Parameters
integer$original_idpublic

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

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

Referenced by syncWithOriginal().

792  {
793  global $ilDB;
794 
795  // cleanup RTE images which are not inserted into the question text
796  include_once("./Services/RTE/classes/class.ilRTE.php");
797  ilRTE::_cleanupMediaObjectUsage($this->getQuestiontext(), "spl:html", $this->getId());
798  $affectedRows = 0;
799  if ($this->getId() == -1)
800  {
801  // Write new dataset
802  $next_id = $ilDB->nextId('svy_question');
803  $affectedRows = $ilDB->insert("svy_question", array(
804  "question_id" => array("integer", $next_id),
805  "questiontype_fi" => array("integer", $this->getQuestionTypeID()),
806  "obj_fi" => array("integer", $this->getObjId()),
807  "owner_fi" => array("integer", $this->getOwner()),
808  "title" => array("text", $this->getTitle()),
809  "label" => array("text", (strlen($this->label)) ? $this->label : null),
810  "description" => array("text", $this->getDescription()),
811  "author" => array("text", $this->getAuthor()),
812  "questiontext" => array("clob", ilRTE::_replaceMediaObjectImageSrc($this->getQuestiontext(), 0)),
813  "obligatory" => array("text", $this->getObligatory()),
814  "complete" => array("text", $this->isComplete()),
815  "created" => array("integer", time()),
816  "original_id" => array("integer", ($original_id) ? $original_id : NULL),
817  "tstamp" => array("integer", time())
818  ));
819  $this->setId($next_id);
820  }
821  else
822  {
823  // update existing dataset
824  $affectedRows = $ilDB->update("svy_question", array(
825  "title" => array("text", $this->getTitle()),
826  "label" => array("text", (strlen($this->label)) ? $this->label : null),
827  "description" => array("text", $this->getDescription()),
828  "author" => array("text", $this->getAuthor()),
829  "questiontext" => array("clob", ilRTE::_replaceMediaObjectImageSrc($this->getQuestiontext(), 0)),
830  "obligatory" => array("text", $this->getObligatory()),
831  "complete" => array("text", $this->isComplete()),
832  "tstamp" => array("integer", time())
833  ), array(
834  "question_id" => array("integer", $this->getId())
835  ));
836  }
837 
838  $set = $ilDB->query("SELECT survey_fi FROM svy_svy_qst".
839  " WHERE question_fi = ".$ilDB->quote($this->getId(), "integer"));
840  $survey_fi = $ilDB->fetchAssoc($set);
841  $survey_fi = $survey_fi["survey_fi"];
842 
843  if($survey_fi)
844  {
845  $set = $ilDB->query("SELECT obligatory FROM svy_qst_oblig".
846  " WHERE survey_fi = ".$ilDB->quote($survey_fi, "integer").
847  " AND question_fi = ".$ilDB->quote($this->getId(), "integer"));
848  $has_obligatory_states_entry = (bool)$ilDB->numRows($set);
849  $is_obligatory = $ilDB->fetchAssoc($set);
850  $is_obligatory = (bool)$is_obligatory["obligatory"];
851 
852  if(!$this->getObligatory())
853  {
854  if($has_obligatory_states_entry)
855  {
856  $ilDB->manipulate("DELETE FROM svy_qst_oblig".
857  " WHERE survey_fi = ".$ilDB->quote($survey_fi, "integer").
858  " AND question_fi = ".$ilDB->quote($this->getId(), "integer"));
859  }
860  }
861  else if($this->getObligatory())
862  {
863  if(!$has_obligatory_states_entry)
864  {
865  // ilObjSurvey::setObligatoryStates()
866  $next_id = $ilDB->nextId('svy_qst_oblig');
867  $affectedRows = $ilDB->manipulateF("INSERT INTO svy_qst_oblig (question_obligatory_id, survey_fi, question_fi, " .
868  "obligatory, tstamp) VALUES (%s, %s, %s, %s, %s)",
869  array('integer','integer','integer','text','integer'),
870  array($next_id, $survey_fi, $this->getId(), 1, time())
871  );
872  }
873  else if(!$is_obligatory)
874  {
875  $ilDB->manipulate("UPDATE svy_qst_oblig".
876  " SET obligatory = ".$ilDB->quote(1, "integer").
877  " WHERE survey_fi = ".$ilDB->quote($survey_fi, "integer").
878  " AND question_fi = ".$ilDB->quote($this->getId(), "integer"));
879  }
880  }
881  }
882 
883  return $affectedRows;
884  }
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.
_cleanupMediaObjectUsage($a_text, $a_usage_type, $a_usage_id)
synchronises appearances of media objects in $a_text with media object usage table ...
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
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 967 of file class.SurveyQuestion.php.

968  {
969  }

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

References $author.

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

413  {
414  if (!$author)
415  {
416  $author = $this->ilias->account->fullname;
417  }
418  $this->author = $author;
419  }
redirection script todo: (a better solution should control the processing via a xml file) ...
+ 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 208 of file class.SurveyQuestion.php.

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

209  {
210  $this->complete = ($a_complete) ? 1 : 0;
211  }
+ 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 317 of file class.SurveyQuestion.php.

References $description.

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

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

◆ setExportCumulatedCVS()

& SurveyQuestion::setExportCumulatedCVS ( $eval_data,
  $export_label 
)

Creates the CSV output for the cumulated results of this question.

Parameters
object$worksheetReference to the excel worksheet
object$format_titleExcel title format
object$format_boldExcel bold format
array$eval_dataCumulated evaluation data
integer$rowActual row in the worksheet
Returns
integer The next row which should be used for the export public

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

References $result, getQuestiontext(), and getTitle().

2139  {
2140  $csvrow = array();
2141  switch ($export_label)
2142  {
2143  case 'label_only':
2144  array_push($csvrow, $this->label);
2145  break;
2146  case 'title_only':
2147  array_push($csvrow, $this->getTitle());
2148  break;
2149  default:
2150  array_push($csvrow, $this->getTitle());
2151  array_push($csvrow, $this->label);
2152  break;
2153  }
2154  array_push($csvrow, strip_tags($this->getQuestiontext())); // #12942
2155  array_push($csvrow, $this->lng->txt($eval_data["QUESTION_TYPE"]));
2156  array_push($csvrow, $eval_data["USERS_ANSWERED"]);
2157  array_push($csvrow, $eval_data["USERS_SKIPPED"]);
2158  array_push($csvrow, $eval_data["MODE"]);
2159  array_push($csvrow, $eval_data["MODE_NR_OF_SELECTIONS"]);
2160  array_push($csvrow, str_replace("<br />", " ", $eval_data["MEDIAN"])); // #17214
2161  array_push($csvrow, $eval_data["ARITHMETIC_MEAN"]);
2162  $result = array();
2163  array_push($result, $csvrow);
2164  return $result;
2165  }
getTitle()
Gets the title string of the SurveyQuestion object.
$result
getQuestiontext()
Gets the questiontext of the SurveyQuestion object.
+ Here is the call graph for this function:

◆ setExportCumulatedXLS()

SurveyQuestion::setExportCumulatedXLS ( $worksheet,
$format_title,
$format_bold,
$eval_data,
  $row,
  $export_label 
)

Creates the Excel output for the cumulated results of this question.

Parameters
object$worksheetReference to the excel worksheet
object$format_titleExcel title format
object$format_boldExcel bold format
array$eval_dataCumulated evaluation data
integer$rowActual row in the worksheet
Returns
integer The next row which should be used for the export public

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

References $row, ilExcelUtils\_convert_text(), getQuestiontext(), and getTitle().

2089  {
2090  include_once ("./Services/Excel/classes/class.ilExcelUtils.php");
2091  $column = 0;
2092  switch ($export_label)
2093  {
2094  case 'label_only':
2095  $worksheet->writeString($row, $column, ilExcelUtils::_convert_text($this->label));
2096  break;
2097  case 'title_only':
2098  $worksheet->writeString($row, $column, ilExcelUtils::_convert_text($this->getTitle()));
2099  break;
2100  default:
2101  $worksheet->writeString($row, $column, ilExcelUtils::_convert_text($this->getTitle()));
2102  $column++;
2103  $worksheet->writeString($row, $column, ilExcelUtils::_convert_text($this->label));
2104  break;
2105  }
2106  $column++;
2107  $worksheet->writeString($row, $column, ilExcelUtils::_convert_text(strip_tags($this->getQuestiontext()))); // #12942
2108  $column++;
2109  $worksheet->writeString($row, $column, ilExcelUtils::_convert_text($this->lng->txt($eval_data["QUESTION_TYPE"])));
2110  $column++;
2111  $worksheet->write($row, $column, $eval_data["USERS_ANSWERED"]);
2112  $column++;
2113  $worksheet->write($row, $column, $eval_data["USERS_SKIPPED"]);
2114  $column++;
2115  $worksheet->write($row, $column, ilExcelUtils::_convert_text($eval_data["MODE_VALUE"]));
2116  $column++;
2117  $worksheet->write($row, $column, ilExcelUtils::_convert_text($eval_data["MODE"]));
2118  $column++;
2119  $worksheet->write($row, $column, $eval_data["MODE_NR_OF_SELECTIONS"]);
2120  $column++;
2121  $worksheet->write($row, $column, ilExcelUtils::_convert_text(str_replace("<br />", " ", $eval_data["MEDIAN"])));
2122  $column++;
2123  $worksheet->write($row, $column, $eval_data["ARITHMETIC_MEAN"]);
2124  return $row + 1;
2125  }
getTitle()
Gets the title string of the SurveyQuestion object.
_convert_text($a_text, $a_target="has been removed")
getQuestiontext()
Gets the questiontext of the SurveyQuestion object.
+ Here is the call graph for this function:

◆ setExportDetailsXLS()

SurveyQuestion::setExportDetailsXLS ( $workbook,
$format_title,
$format_bold,
$eval_data,
  $export_label 
)

Creates an Excel worksheet for the detailed cumulated results of this question.

Parameters
object$workbookReference to the parent excel workbook
object$format_titleExcel title format
object$format_boldExcel bold format
array$eval_dataCumulated evaluation data public

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

2177  {
2178  // overwrite in inherited classes
2179  }

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

References $id.

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

294  {
295  $this->id = $id;
296  }
+ 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 1488 of file class.SurveyQuestion.php.

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

1489  {
1490  if (strcmp($material_id, "") != 0)
1491  {
1492  $import_id = "";
1493  if ($is_import)
1494  {
1495  $import_id = $material_id;
1496  $material_id = $this->_resolveInternalLink($import_id);
1497  }
1498  if (strcmp($material_title, "") == 0)
1499  {
1500  if (preg_match("/il__(\w+)_(\d+)/", $material_id, $matches))
1501  {
1502  $type = $matches[1];
1503  $target_id = $matches[2];
1504  $material_title = $this->lng->txt("obj_$type") . ": ";
1505  switch ($type)
1506  {
1507  case "lm":
1508  include_once("./Modules/LearningModule/classes/class.ilObjContentObjectGUI.php");
1509  $cont_obj_gui =& new ilObjContentObjectGUI("", $target_id, true);
1510  $cont_obj = $cont_obj_gui->object;
1511  $material_title .= $cont_obj->getTitle();
1512  break;
1513  case "pg":
1514  include_once("./Modules/LearningModule/classes/class.ilLMPageObject.php");
1515  include_once("./Modules/LearningModule/classes/class.ilLMObject.php");
1517  include_once("./Modules/LearningModule/classes/class.ilObjContentObjectGUI.php");
1518  $cont_obj_gui =& new ilObjContentObjectGUI("", $lm_id, FALSE);
1519  $cont_obj = $cont_obj_gui->object;
1520  $pg_obj =& new ilLMPageObject($cont_obj, $target_id);
1521  $material_title .= $pg_obj->getTitle();
1522  break;
1523  case "st":
1524  include_once("./Modules/LearningModule/classes/class.ilStructureObject.php");
1525  include_once("./Modules/LearningModule/classes/class.ilLMObject.php");
1527  include_once("./Modules/LearningModule/classes/class.ilObjContentObjectGUI.php");
1528  $cont_obj_gui =& new ilObjContentObjectGUI("", $lm_id, FALSE);
1529  $cont_obj = $cont_obj_gui->object;
1530  $st_obj =& new ilStructureObject($cont_obj, $target_id);
1531  $material_title .= $st_obj->getTitle();
1532  break;
1533  case "git":
1534  include_once "./Modules/Glossary/classes/class.ilGlossaryTerm.php";
1535  $material_title = $this->lng->txt("glossary_term") . ": " . ilGlossaryTerm::_lookGlossaryTerm($target_id);
1536  break;
1537  case "mob":
1538  break;
1539  }
1540  }
1541  }
1542  $this->material = array(
1543  "internal_link" => $material_id,
1544  "import_id" => $import_id,
1545  "title" => $material_title
1546  );
1547  }
1548  $this->saveMaterial();
1549  }
_resolveInternalLink($internal_link)
$target_id
Definition: goto.php:88
Class ilLMPageObject.
saveMaterial()
save material to db
_lookupContObjID($a_id)
get learning module / digibook id for lm object
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 350 of file class.SurveyQuestion.php.

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

351  {
352  if (!empty($materials_filename))
353  {
354  include_once "./Services/Utilities/classes/class.ilUtil.php";
355  $materialspath = $this->getMaterialsPath();
356  if (!file_exists($materialspath))
357  {
358  ilUtil::makeDirParents($materialspath);
359  }
360  if (ilUtil::moveUploadedFile($materials_tempfilename, $materials_filename,
361  $materialspath.$materials_filename))
362  {
363  print "image not uploaded!!!! ";
364  }
365  else
366  {
367  $this->addMaterials($materials_filename, $materials_name);
368  }
369  }
370  }
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.
static moveUploadedFile($a_file, $a_name, $a_target, $a_raise_errors=true, $a_mode="move_uploaded")
move uploaded file
+ 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 607 of file class.SurveyQuestion.php.

References $obj_id.

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

608  {
609  $this->obj_id = $obj_id;
610  }
+ 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 269 of file class.SurveyQuestion.php.

References $obligatory.

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

270  {
271  $this->obligatory = ($obligatory) ? 1 : 0;
272  }
+ 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 281 of file class.SurveyQuestion.php.

References $orientation.

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

282  {
283  $this->orientation = ($orientation) ? $orientation : 0;
284  }
+ Here is the caller graph for this function:

◆ setOriginalId()

SurveyQuestion::setOriginalId (   $original_id)

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

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

2254  {
2255  $this->original_id = $original_id;
2256  }
+ 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 440 of file class.SurveyQuestion.php.

References $owner.

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

441  {
442  $this->owner = $owner;
443  }
+ 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 428 of file class.SurveyQuestion.php.

References $questiontext.

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

429  {
430  $this->questiontext = $questiontext;
431  }
+ Here is the caller graph for this function:

◆ setSubtype()

SurveyQuestion::setSubtype (   $a_subtype)

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

2279  {
2280  // do nothing
2281  }

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

References $id.

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

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

References $title.

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

258  {
259  $this->title = $title;
260  }
+ Here is the caller graph for this function:

◆ SurveyQuestion()

SurveyQuestion::SurveyQuestion (   $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, $ilias, $lng, $owner, $questiontext, $title, and $tpl.

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

165  {
166  global $ilias;
167  global $lng;
168  global $tpl;
169 
170  $this->ilias =& $ilias;
171  $this->lng =& $lng;
172  $this->tpl =& $tpl;
173  $this->complete =
174  $this->title = $title;
175  $this->description = $description;
176  $this->questiontext = $questiontext;
177  $this->author = $author;
178  $this->cumulated = array();
179  if (!$this->author)
180  {
181  $this->author = $this->ilias->account->fullname;
182  }
183  $this->owner = $owner;
184  if ($this->owner == -1)
185  {
186  $this->owner = $this->ilias->account->id;
187  }
188  $this->id = -1;
189  $this->survey_id = -1;
190  $this->obligatory = 1;
191  $this->orientation = 0;
192  $this->materials = array();
193  $this->material = array();
194  $this->arrData = array();
195  register_shutdown_function(array(&$this, '_SurveyQuestion'));
196  }
redirection script todo: (a better solution should control the processing via a xml file) ...
+ Here is the caller graph for this function:

◆ syncWithOriginal()

SurveyQuestion::syncWithOriginal ( )

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

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

1281  {
1282  global $ilDB;
1283 
1284  if ($this->getOriginalId())
1285  {
1286  $id = $this->getId();
1287  $original = $this->getOriginalId();
1288 
1289  $this->setId($this->getOriginalId());
1290  $this->setOriginalId(NULL);
1291  $this->saveToDb();
1292 
1293  $this->setId($id);
1294  $this->setOriginalId($original);
1295 
1296  include_once "./Services/Link/classes/class.ilInternalLink.php";
1297  $affectedRows = $ilDB->manipulateF("DELETE FROM svy_material WHERE question_fi = %s",
1298  array('integer'),
1299  array($this->getOriginalId())
1300  );
1301  ilInternalLink::_deleteAllLinksOfSource("sqst", $this->original_id);
1302  if (strlen($this->material["internal_link"]))
1303  {
1304  $next_id = $ilDB->nextId('svy_material');
1305  $affectedRows = $ilDB->manipulateF("INSERT INTO svy_material (material_id, question_fi, internal_link, import_id, material_title, tstamp) VALUES (%s, %s, %s, %s, %s, %s)",
1306  array('integer', 'integer', 'text', 'text', 'text', 'integer'),
1307  array($next_id, $this->getOriginalId(), $this->material["internal_link"], $this->material["import_id"], $this->material["title"], time())
1308  );
1309  if (preg_match("/il_(\d*?)_(\w+)_(\d+)/", $this->material["internal_link"], $matches))
1310  {
1311  ilInternalLink::_saveLink("sqst", $this->getOriginalId(), $matches[2], $matches[3], $matches[1]);
1312  }
1313  }
1314  }
1315  }
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 2187 of file class.SurveyQuestion.php.

2188  {
2189  // overwrite in inherited classes
2190  return FALSE;
2191  }

Field Documentation

◆ $arrData

SurveyQuestion::$arrData
private

data array containing the question data

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

◆ $author

◆ $complete

SurveyQuestion::$complete

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

◆ $cumulated

◆ $description

◆ $id

◆ $ilias

SurveyQuestion::$ilias

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

Referenced by SurveyQuestion().

◆ $lng

◆ $material

◆ $materials

SurveyQuestion::$materials

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

◆ $obj_id

SurveyQuestion::$obj_id

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

Referenced by getObjId(), and setObjId().

◆ $obligatory

SurveyQuestion::$obligatory

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

Referenced by setObligatory().

◆ $orientation

◆ $owner

◆ $questiontext

◆ $survey_id

◆ $title

◆ $tpl

SurveyQuestion::$tpl

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

Referenced by SurveyQuestion().


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