ILIAS  release_5-0 Revision 5.0.0-1144-gc4397b1f870
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...
 
 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 2343 of file class.SurveyQuestion.php.

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

◆ __set()

SurveyQuestion::__set (   $key,
  $value 
)

Object setter.

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

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

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

2381 {
2382 global $ilDB;
2383
2384 $ilDB->manipulate("UPDATE svy_question".
2385 " SET original_id = ".$ilDB->quote($a_original_id, "integer").",".
2386 " obj_fi = ".$ilDB->quote($a_object_id, "integer").
2387 " WHERE question_id = ".$ilDB->quote($a_question_id, "integer"));
2388 }
global $ilDB

References $ilDB.

Referenced by ilSurveyEditorGUI\executeCopyQuestionsToPoolObject().

+ Here is the caller graph for this function:

◆ _getInternalLinkHref()

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

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

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

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

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

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

◆ _getOriginalId()

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 @access public

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

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

References $ilDB, $result, and $row.

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

+ 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 @access public

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

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

1959 {
1960 return array();
1961 }

◆ _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 @access private

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

1198 {
1199 global $ilDB;
1200
1201 if ($question_id < 1) return "";
1202
1203 $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",
1204 array('integer'),
1205 array($question_id)
1206 );
1207 if ($result->numRows() == 1)
1208 {
1209 $data = $ilDB->fetchAssoc($result);
1210 return $data["type_tag"];
1211 }
1212 else
1213 {
1214 return "";
1215 }
1216 }

References $data, $ilDB, and $result.

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

+ Here is the caller graph for this function:

◆ _getQuestionTypeName()

static SurveyQuestion::_getQuestionTypeName (   $type_tag)
static

Return the translation for a given question type tag.

Parameters
string$type_tagThe type tag of the question type @access public

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

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

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

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

+ 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 @access private

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

1226 {
1227 global $ilDB;
1228
1229 if ($question_id < 1) return "";
1230
1231 $result = $ilDB->queryF("SELECT title FROM svy_question WHERE svy_question.question_id = %s",
1232 array('integer'),
1233 array($question_id)
1234 );
1235 if ($result->numRows() == 1)
1236 {
1237 $data = $ilDB->fetchAssoc($result);
1238 return $data["title"];
1239 }
1240 else
1241 {
1242 return "";
1243 }
1244 }

References $data, $ilDB, and $result.

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

+ Here is the caller graph for this function:

◆ _includeClass()

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

Include the php class file for a given question type.

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

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

1750 {
1751 $type = $question_type;
1752 if ($gui) $type .= "GUI";
1753 if (file_exists("./Modules/SurveyQuestionPool/classes/class.".$type.".php"))
1754 {
1755 include_once "./Modules/SurveyQuestionPool/classes/class.".$type.".php";
1756 return true;
1757 }
1758 else
1759 {
1760 global $ilPluginAdmin;
1761 $pl_names = $ilPluginAdmin->getActivePluginsForSlot(IL_COMP_MODULE, "SurveyQuestionPool", "svyq");
1762 foreach ($pl_names as $pl_name)
1763 {
1764 $pl = ilPlugin::getPluginObject(IL_COMP_MODULE, "SurveyQuestionPool", "svyq", $pl_name);
1765 if (strcmp($pl->getQuestionType(), $question_type) == 0)
1766 {
1767 $pl->includeClass("class.".$type.".php");
1768 return true;
1769 }
1770 }
1771 }
1772 return false;
1773 }

References ilPlugin\getPluginObject(), and IL_COMP_MODULE.

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

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

◆ _instanciateQuestion()

& 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 @access public

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

1813 {
1814 $question_type = SurveyQuestion::_getQuestionType($question_id);
1815 if($question_type)
1816 {
1817 SurveyQuestion::_includeClass($question_type);
1818 $question = new $question_type();
1819 $question->loadFromDb($question_id);
1820 return $question;
1821 }
1822 }
_getQuestionType($question_id)
Returns the question type of a question with a given id.
static _includeClass($question_type, $gui=0)
Include the php class file for a given question type.

References _getQuestionType(), and _includeClass().

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

+ 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 @access public

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

1832 {
1833 $question_type = SurveyQuestion::_getQuestionType($question_id);
1834 if($question_type)
1835 {
1836 SurveyQuestion::_includeClass($question_type, 1);
1837 $guitype = $question_type . "GUI";
1838 $question = new $guitype($question_id);
1839 return $question;
1840 }
1841 }

References _getQuestionType(), and _includeClass().

Referenced by ilSurveyEvaluationGUI\evaluation().

+ 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 @access public

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

738 {
739 global $ilDB;
740
741 $result = $ilDB->queryF("SELECT complete FROM svy_question WHERE question_id = %s",
742 array('integer'),
743 array($question_id)
744 );
745 if ($result->numRows())
746 {
747 $row = $ilDB->fetchAssoc($result);
748 if ($row["complete"] == 1)
749 {
750 return TRUE;
751 }
752 }
753 return FALSE;
754 }

References $ilDB, $result, and $row.

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

+ 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 @access public

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

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

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

Referenced by SurveyQuestionGUI\save().

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

◆ _lookupSurveyObjId()

static SurveyQuestion::_lookupSurveyObjId (   $a_question_id)
static

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

2426 {
2427 global $ilDB;
2428
2429 $set = $ilDB->query("SELECT svy_svy.obj_fi FROM svy_svy_qst".
2430 " JOIN svy_svy ON (svy_svy.survey_id = svy_svy_qst.survey_fi)".
2431 " WHERE svy_svy_qst.question_fi = ".$ilDB->quote($a_question_id, "integer"));
2432 $row = $ilDB->fetchAssoc($set);
2433 if($ilDB->numRows($set))
2434 {
2435 return $row["obj_fi"];
2436 }
2437 }

References $ilDB, and $row.

Referenced by ilObjMediaObject\getParentObjectIdForUsage().

+ 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 @access public

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

1362 {
1363 global $ilDB;
1364
1365 if ($question_id < 1)
1366 {
1367 return false;
1368 }
1369
1370 $result = $ilDB->queryF("SELECT question_id FROM svy_question WHERE question_id = %s",
1371 array('integer'),
1372 array($question_id)
1373 );
1374 return ($result->numRows() == 1) ? true : false;
1375 }

References $ilDB, and $result.

Referenced by ilSurveySkill\read().

+ Here is the caller graph for this function:

◆ _resolveInternalLink()

SurveyQuestion::_resolveInternalLink (   $internal_link)

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

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

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

Referenced by _resolveIntLinks(), and setMaterial().

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

◆ _resolveIntLinks()

SurveyQuestion::_resolveIntLinks (   $question_id)

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

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

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

Referenced by ilContObjParser\processPagesToParse().

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

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

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

+ Here is the call graph for this function:

◆ addMaterial()

SurveyQuestion::addMaterial (   $obj_material)

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

1475 {
1476 array_push($this->material, $obj_material);
1477 }

Referenced by addInternalLink().

+ Here is the caller graph for this function:

◆ addMaterials()

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

Sets the materials uri.

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

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

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 }

Referenced by setMaterialsfile().

+ Here is the caller graph for this function:

◆ addMaterialTag()

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

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

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

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

1903 {
1904 include_once "./Services/RTE/classes/class.ilRTE.php";
1905 include_once("./Services/MediaObjects/classes/class.ilObjMediaObject.php");
1906
1907 $a_xml_writer->xmlStartTag("material");
1908 $attrs = array(
1909 "type" => "text/plain"
1910 );
1911 if ($this->isHTML($a_material))
1912 {
1913 $attrs["type"] = "text/xhtml";
1914 }
1915 if (is_array($a_attrs))
1916 {
1917 $attrs = array_merge($attrs, $a_attrs);
1918 }
1919 $a_xml_writer->xmlElement("mattext", $attrs, ilRTE::_replaceMediaObjectImageSrc($a_material, 0));
1920
1921 if ($add_mobs)
1922 {
1923 $mobs = ilObjMediaObject::_getMobsOfObject("spl:html", $this->getId());
1924 foreach ($mobs as $mob)
1925 {
1926 $mob_obj =& new ilObjMediaObject($mob);
1927 $imgattrs = array(
1928 "label" => "il_" . IL_INST_ID . "_mob_" . $mob,
1929 "uri" => "objects/" . "il_" . IL_INST_ID . "_mob_" . $mob . "/" . $mob_obj->getTitle(),
1930 "type" => "spl:html",
1931 "id" => $this->getId()
1932 );
1933 $a_xml_writer->xmlElement("matimage", $imgattrs, NULL);
1934 }
1935 }
1936 if ($close_material_tag) $a_xml_writer->xmlEndTag("material");
1937 }
getId()
Gets the id of the SurveyQuestion object.
isHTML($a_text)
Checks if a given string contains HTML or not.
Class ilObjMediaObject.
_getMobsOfObject($a_type, $a_id, $a_usage_hist_nr=0, $a_lang="-")
get mobs of object
static _replaceMediaObjectImageSrc($a_text, $a_direction=0, $nic=IL_INST_ID)
replaces image source from mob image urls with the mob id or replaces mob id with the correct image s...
$mobs

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

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

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

◆ 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 @access public

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

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

1999 {
2000 // overwrite in inherited classes
2001 }

◆ 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 @access public

Reimplemented in SurveyMatrixQuestion, SurveyMultipleChoiceQuestion, and SurveySingleChoiceQuestion.

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

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

References $title.

◆ calculateCumulatedResults()

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

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

2288 {
2289 if (count($this->cumulated) == 0)
2290 {
2291 if(!$finished_ids)
2292 {
2293 include_once "./Modules/Survey/classes/class.ilObjSurvey.php";
2295 }
2296 else
2297 {
2298 $nr_of_users = sizeof($finished_ids);
2299 }
2300 if($nr_of_users)
2301 {
2302 $this->cumulated =& $this->getCumulatedResults($survey_id, $nr_of_users, $finished_ids);
2303 }
2304 }
2305 return $this->cumulated;
2306 }
$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.

References $cumulated, $survey_id, and ilObjSurvey\_getNrOfParticipants().

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

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

◆ copyObject()

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

Copies an assOrderingQuestion object.

@access public

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

657 {
658 if ($this->getId() <= 0)
659 {
660 // The question has not been saved. It cannot be copied
661 return;
662 }
663 $clone = $this;
664 $original_id = SurveyQuestion::_getOriginalId($this->getId(), false);
665 $clone->setId(-1);
666 $source_questionpool = $this->getObjId();
667 $clone->setObjId($target_questionpool);
668 if ($title)
669 {
670 $clone->setTitle($title);
671 }
672
673 $clone->saveToDb();
674
675 // duplicate the materials
676 $clone->duplicateMaterials($original_id);
677 // copy XHTML media objects
678 $clone->copyXHTMLMediaObjectsOfQuestion($original_id);
679 return $clone->getId();
680 }
getObjId()
Get the reference id of the container object.
_getOriginalId($question_id, $a_return_question_id_if_no_original=true)
Returns the original id of a question.

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

+ Here is the call graph for this function:

◆ copyXHTMLMediaObjectsOfQuestion()

SurveyQuestion::copyXHTMLMediaObjectsOfQuestion (   $a_q_id)

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

Parameters
integer$a_q_idThe question id of the original question @access public

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

689 {
690 include_once("./Services/MediaObjects/classes/class.ilObjMediaObject.php");
691 $mobs = ilObjMediaObject::_getMobsOfObject("spl:html", $a_q_id);
692 foreach ($mobs as $mob)
693 {
694 ilObjMediaObject::_saveUsage($mob, "spl:html", $this->getId());
695 }
696 }
_saveUsage($a_mob_id, $a_type, $a_id, $a_usage_hist_nr=0, $a_lang="-")
Save usage of mob within another container (e.g.

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

+ Here is the call graph for this function:

◆ createNewQuestion()

SurveyQuestion::createNewQuestion ( )

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

Returns
integer ID of the new question

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

925 {
926 global $ilDB;
927
928 $obj_id = $this->getObjId();
929 if ($obj_id > 0)
930 {
931 $next_id = $ilDB->nextId('svy_question');
932 $affectedRows = $ilDB->manipulateF("INSERT INTO svy_question (question_id, questiontype_fi, " .
933 "obj_fi, owner_fi, title, description, author, questiontext, obligatory, complete, " .
934 "created, original_id, tstamp) VALUES " .
935 "(%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)",
936 array('integer', 'integer', 'integer', 'integer', 'text', 'text', 'text', 'text',
937 'text', 'text', 'integer', 'integer', 'integer'),
938 array(
939 $next_id,
940 $this->getQuestionTypeID(),
941 $obj_id,
942 $this->getOwner(),
943 NULL,
944 NULL,
945 $this->getAuthor(),
946 NULL,
947 "1",
948 "0",
949 time(),
950 NULL,
951 0
952 )
953 );
954 $this->setId($next_id);
955 }
956 return $this->getId();
957 }
setId($id=-1)
Sets the id of the SurveyQuestion object.
getOwner()
Gets the creator/owner ID of the SurveyQuestion object.
getQuestionTypeID()
Returns the question type ID of the question.
getAuthor()
Gets the authors name of the SurveyQuestion object.

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

+ Here is the call graph for this function:

◆ delete()

SurveyQuestion::delete (   $question_id)

Deletes a question and all materials from the database.

Parameters
integer$question_idThe database id of the question @access private

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

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

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

+ Here is the call graph for this function:

◆ deleteAdditionalTableData()

SurveyQuestion::deleteAdditionalTableData (   $question_id)

Deletes datasets from the additional question table in the database.

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

Reimplemented in SurveyMatrixQuestion.

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

1070 {
1071 global $ilDB;
1072 $affectedRows = $ilDB->manipulateF("DELETE FROM " . $this->getAdditionalTableName() . " WHERE question_fi = %s",
1073 array('integer'),
1074 array($question_id)
1075 );
1076 }

References $ilDB.

Referenced by delete().

+ Here is the caller graph for this function:

◆ deleteMaterial()

SurveyQuestion::deleteMaterial (   $materials_name = "")

Deletes a materials uri with a given name.

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

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

381 {
382 foreach ($this->materials as $key => $value)
383 {
384 if (strcmp($key, $materials_name)==0)
385 {
386 if (file_exists($this->getMaterialsPath().$value))
387 {
388 unlink($this->getMaterialsPath().$value);
389 }
390 unset($this->materials[$key]);
391 }
392 }
393 }
getMaterialsPath()
Returns the materials path for web accessable materials of a question.

References getMaterialsPath().

+ Here is the call graph for this function:

◆ deleteMaterials()

SurveyQuestion::deleteMaterials (   $a_array)

Deletes materials.

Parameters
array$a_arrayArray with indexes of the materials to delete

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

1441 {
1442 foreach ($a_array as $idx)
1443 {
1444 unset($this->material[$idx]);
1445 }
1446 $this->material = array_values($this->material);
1447 $this->saveMaterial();
1448 }

References saveMaterial().

+ Here is the call graph for this function:

◆ duplicate()

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

Duplicates a survey question.

@access public

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

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

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

+ Here is the call graph for this function:

◆ duplicateMaterials()

SurveyQuestion::duplicateMaterials (   $question_id)

Duplicates the materials of a question.

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

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

1457 {
1458 foreach ($this->materials as $filename)
1459 {
1460 $materialspath = $this->getMaterialsPath();
1461 $materialspath_original = preg_replace("/([^\d])$this->id([^\d])/", "\${1}$question_id\${2}", $materialspath);
1462 if (!file_exists($materialspath))
1463 {
1464 include_once "./Services/Utilities/classes/class.ilUtil.php";
1465 ilUtil::makeDirParents($materialspath);
1466 }
1467 if (!copy($materialspath_original . $filename, $materialspath . $filename))
1468 {
1469 print "material could not be duplicated!!!! ";
1470 }
1471 }
1472 }
$filename
Definition: buildRTE.php:89
static makeDirParents($a_dir)
Create a new directory and all parent directories.
if(! $in) print

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

+ Here is the call graph for this function:

◆ flushMaterials()

SurveyQuestion::flushMaterials ( )

Deletes all materials uris.

@access public

See also
$materials

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

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

◆ getAuthor()

SurveyQuestion::getAuthor ( )

Gets the authors name of the SurveyQuestion object.

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

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

557 {
558 return (strlen($this->author)) ? $this->author : NULL;
559 }

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

+ Here is the caller graph for this function:

◆ getAvailableRelations()

SurveyQuestion::getAvailableRelations ( )

Returns the available relations for the question.

Returns
array An array containing the available relations @access public

Reimplemented in SurveyMetricQuestion, SurveyMultipleChoiceQuestion, and SurveySingleChoiceQuestion.

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

2198 {
2199 // overwrite in inherited classes
2200 return array();
2201 }

◆ getCopyIds()

SurveyQuestion::getCopyIds (   $a_group_by_survey = false)

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

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

References $ilDB, $res, and $row.

Referenced by hasCopies().

+ 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

Reimplemented in SurveyMatrixQuestion.

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

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

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

+ 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 @access public
See also
$description

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

545 {
546 return (strlen($this->description)) ? $this->description : NULL;
547 }

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

+ Here is the caller graph for this function:

◆ getId()

SurveyQuestion::getId ( )

Gets the id of the SurveyQuestion object.

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

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

466 {
467 return $this->id;
468 }

References $id.

Referenced by addMaterialTag(), SurveyMatrixQuestion\addUserSpecificResultsData(), SurveyMetricQuestion\addUserSpecificResultsData(), SurveyMultipleChoiceQuestion\addUserSpecificResultsData(), SurveySingleChoiceQuestion\addUserSpecificResultsData(), SurveyTextQuestion\addUserSpecificResultsData(), SurveyMatrixQuestion\checkUserInput(), SurveyMetricQuestion\checkUserInput(), SurveyMultipleChoiceQuestion\checkUserInput(), SurveySingleChoiceQuestion\checkUserInput(), SurveyTextQuestion\checkUserInput(), copyObject(), copyXHTMLMediaObjectsOfQuestion(), createNewQuestion(), duplicate(), SurveyMatrixQuestion\getCumulatedResults(), SurveyMetricQuestion\getCumulatedResults(), SurveyMultipleChoiceQuestion\getCumulatedResults(), SurveySingleChoiceQuestion\getCumulatedResults(), SurveyTextQuestion\getCumulatedResults(), SurveyMatrixQuestion\getCumulatedResultsForRow(), SurveyMatrixQuestion\getNrOfUsersAnswered(), getObligatory(), SurveyMatrixQuestion\getUserAnswers(), SurveyMetricQuestion\getUserAnswers(), SurveyMultipleChoiceQuestion\getUserAnswers(), SurveySingleChoiceQuestion\getUserAnswers(), SurveyTextQuestion\getUserAnswers(), SurveyMatrixQuestion\getWorkingDataFromUserInput(), SurveyMetricQuestion\getWorkingDataFromUserInput(), SurveyMultipleChoiceQuestion\getWorkingDataFromUserInput(), SurveySingleChoiceQuestion\getWorkingDataFromUserInput(), SurveyTextQuestion\getWorkingDataFromUserInput(), SurveyMatrixQuestion\insertXML(), SurveyMetricQuestion\insertXML(), SurveyMultipleChoiceQuestion\insertXML(), SurveySingleChoiceQuestion\insertXML(), SurveyTextQuestion\insertXML(), loadFromDb(), SurveyMatrixQuestion\saveBipolarAdjectives(), SurveyMultipleChoiceQuestion\saveCategoriesToDb(), SurveySingleChoiceQuestion\saveCategoriesToDb(), SurveyMatrixQuestion\saveColumnsToDb(), saveCompletionStatus(), SurveyMatrixQuestion\saveLayout(), saveMaterial(), SurveyMatrixQuestion\saveRandomData(), SurveyMetricQuestion\saveRandomData(), SurveyMultipleChoiceQuestion\saveRandomData(), SurveySingleChoiceQuestion\saveRandomData(), SurveyTextQuestion\saveRandomData(), SurveyMatrixQuestion\saveRowsToDb(), SurveyMetricQuestion\saveToDb(), SurveyMultipleChoiceQuestion\saveToDb(), saveToDb(), SurveySingleChoiceQuestion\saveToDb(), SurveyTextQuestion\saveToDb(), SurveyMatrixQuestion\saveToDb(), SurveyMatrixQuestion\saveUserInput(), SurveyMetricQuestion\saveUserInput(), SurveyMultipleChoiceQuestion\saveUserInput(), SurveySingleChoiceQuestion\saveUserInput(), SurveyTextQuestion\saveUserInput(), and syncWithOriginal().

+ Here is the caller graph for this function:

◆ getImagePath()

SurveyQuestion::getImagePath ( )

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

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

@access public

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

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

◆ getImagePathWeb()

SurveyQuestion::getImagePathWeb ( )

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

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

@access public

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

998 {
999 include_once "./Services/Utilities/classes/class.ilUtil.php";
1000 $webdir = ilUtil::removeTrailingPathSeparators(CLIENT_WEB_DIR) . "/survey/$this->obj_id/$this->id/images/";
1002 }
const ILIAS_ABSOLUTE_PATH

References ILIAS_ABSOLUTE_PATH, and ilUtil\removeTrailingPathSeparators().

+ Here is the call graph for this function:

◆ getMaterial()

SurveyQuestion::getMaterial ( )

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

2272 {
2273 return $this->material;
2274 }

References $material.

◆ getMaterialsPath()

SurveyQuestion::getMaterialsPath ( )

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

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

@access public

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

987 {
988 return CLIENT_WEB_DIR . "/survey/$this->obj_id/$this->id/materials/";
989 }

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

+ Here is the caller graph for this function:

◆ getMaterialsPathWeb()

SurveyQuestion::getMaterialsPathWeb ( )

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

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

@access public

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

1011 {
1012 include_once "./Services/Utilities/classes/class.ilUtil.php";
1013 $webdir = ilUtil::removeTrailingPathSeparators(CLIENT_WEB_DIR) . "/survey/$this->obj_id/$this->id/materials/";
1015 }

References ILIAS_ABSOLUTE_PATH, and ilUtil\removeTrailingPathSeparators().

+ 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 @access public
See also
$obj_id

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

592 {
593 return $this->obj_id;
594 }

References $obj_id.

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

+ Here is the caller graph for this function:

◆ getObligatory()

SurveyQuestion::getObligatory (   $survey_id = "")

Gets the obligatory state of the question.

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

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

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

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

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

+ Here is the 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 @access public
See also
$orientation

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

522 {
523 switch ($this->orientation)
524 {
525 case 0:
526 case 1:
527 case 2:
528 break;
529 default:
530 $this->orientation = 0;
531 break;
532 }
533 return $this->orientation;
534 }

References $orientation.

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

+ Here is the caller graph for this function:

◆ getOriginalId()

SurveyQuestion::getOriginalId ( )

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

2257 {
2258 return $this->original_id;
2259 }

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

+ Here is the caller graph for this function:

◆ getOwner()

SurveyQuestion::getOwner ( )

Gets the creator/owner ID of the SurveyQuestion object.

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

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

569 {
570 return $this->owner;
571 }

References $owner.

Referenced by createNewQuestion(), and saveToDb().

+ Here is the caller graph for this function:

◆ getPhrase()

SurveyQuestion::getPhrase (   $phrase_id)

Returns a phrase for a given database id.

Returns
String The title of the phrase @access public

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

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

References $ilDB, $result, and $row.

◆ getPreconditionOptions()

SurveyQuestion::getPreconditionOptions ( )

Returns the options for preconditions.

Returns
array

Reimplemented in SurveyMultipleChoiceQuestion, and SurveySingleChoiceQuestion.

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

2209 {
2210 // overwrite in inherited classes
2211 }

Referenced by SurveyMatrixQuestion\getPreconditionSelectValue().

+ Here is the caller graph for this function:

◆ getPreconditionSelectValue()

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

Creates a form property for the precondition value.

Returns
The ILIAS form element @access public

Reimplemented in SurveyMatrixQuestion, SurveyMetricQuestion, SurveyMultipleChoiceQuestion, and SurveySingleChoiceQuestion.

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

2233 {
2234 // overwrite in inherited classes
2235 return null;
2236 }

◆ getPreconditionValueOutput()

SurveyQuestion::getPreconditionValueOutput (   $value)

Returns the output for a precondition value.

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

Reimplemented in SurveyMatrixQuestion, SurveyMultipleChoiceQuestion, and SurveySingleChoiceQuestion.

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

2221 {
2222 // overwrite in inherited classes
2223 return $value;
2224 }

◆ getQuestiontext()

◆ getQuestionType()

SurveyQuestion::getQuestionType ( )

Returns the question type of the question.

Returns
integer The question type of the question @access public

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

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

1738 {
1739 return "";
1740 }

Referenced by getQuestionTypeID().

+ Here is the caller graph for this function:

◆ getQuestionTypeID()

SurveyQuestion::getQuestionTypeID ( )

Returns the question type ID of the question.

Returns
integer The question type of the question @access public

Reimplemented in SurveyMetricQuestion.

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

1714 {
1715 global $ilDB;
1716 $result = $ilDB->queryF("SELECT questiontype_id FROM svy_qtype WHERE type_tag = %s",
1717 array('text'),
1718 array($this->getQuestionType())
1719 );
1720 if ($result->numRows() == 1)
1721 {
1722 $row = $ilDB->fetchAssoc($result);
1723 return $row["questiontype_id"];
1724 }
1725 else
1726 {
1727 return 0;
1728 }
1729 }
getQuestionType()
Returns the question type of the question.

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

Referenced by createNewQuestion(), and saveToDb().

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

◆ getSkippedValue()

SurveyQuestion::getSkippedValue ( )

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

2420 {
2421 include_once "Modules/Survey/classes/class.ilObjSurvey.php";
2423 }
static getSurveySkippedValue()

References ilObjSurvey\getSurveySkippedValue().

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

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

◆ getSubtype()

SurveyQuestion::getSubtype ( )

Reimplemented in SurveyMatrixQuestion, and SurveyMetricQuestion.

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

2282 {
2283 // do nothing
2284 return null;
2285 }

◆ getSurveyId()

SurveyQuestion::getSurveyId ( )

Gets the survey id of the SurveyQuestion object.

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

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

510 {
511 return $this->survey_id;
512 }

References $survey_id.

◆ 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 @access public

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

2011 {
2012 // overwrite in inherited classes
2013 return array();
2014 }

◆ getWorkingDataFromUserInput()

& SurveyQuestion::getWorkingDataFromUserInput (   $post_data)

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

Returns
array User data according to the svy_answer table @access public

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

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

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

References $data.

◆ hasCopies()

SurveyQuestion::hasCopies ( )

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

2415 {
2416 return (bool)sizeof($this->getCopyIds());
2417 }
getCopyIds($a_group_by_survey=false)

References getCopyIds().

+ Here is the call graph for this function:

◆ importAdditionalMetadata()

SurveyQuestion::importAdditionalMetadata (   $a_meta)

Import additional meta data from the question import file.

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

Returns
array $a_meta Array containing the additional meta data @access public

Reimplemented in SurveyMatrixQuestion, SurveyMultipleChoiceQuestion, and SurveySingleChoiceQuestion.

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

2038 {
2039 // overwrite in inherited classes
2040 }

◆ importAdjectives()

SurveyQuestion::importAdjectives (   $a_data)

Import bipolar adjectives from the question import file.

Returns
array $a_data Array containing the adjectives @access public

Reimplemented in SurveyMatrixQuestion.

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

2060 {
2061 // overwrite in inherited classes
2062 }

◆ importMatrix()

SurveyQuestion::importMatrix (   $a_data)

Import matrix rows from the question import file.

Returns
array $a_data Array containing the matrix rows @access public

Reimplemented in SurveyMatrixQuestion.

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

2071 {
2072 // overwrite in inherited classes
2073 }

◆ importResponses()

SurveyQuestion::importResponses (   $a_data)

Import response data from the question import file.

Returns
array $a_data Array containing the response data @access public

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

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

2049 {
2050 // overwrite in inherited classes
2051 }

◆ isComplete()

SurveyQuestion::isComplete ( )

Returns 1, if a question is complete for use.

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

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

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

220 {
221 return 0;
222 }

Referenced by saveCompletionStatus(), and saveToDb().

+ Here is the caller graph for this function:

◆ isHTML()

SurveyQuestion::isHTML (   $a_text)

Checks if a given string contains HTML or not.

Parameters
string$a_textText which should be checked
Returns
boolean @access public

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

1852 {
1853 if (preg_match("/<[^>]*?>/", $a_text))
1854 {
1855 return TRUE;
1856 }
1857 else
1858 {
1859 return FALSE;
1860 }
1861 }

Referenced by addMaterialTag().

+ Here is the caller graph for this function:

◆ loadFromDb()

SurveyQuestion::loadFromDb (   $question_id)

Loads a SurveyQuestion object from the database.

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

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

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

705 {
706 global $ilDB;
707
708 $result = $ilDB->queryF("SELECT * FROM svy_material WHERE question_fi = %s",
709 array('integer'),
710 array($this->getId())
711 );
712 $this->material = array();
713 if ($result->numRows())
714 {
715 include_once "./Modules/SurveyQuestionPool/classes/class.ilSurveyMaterial.php";
716 while ($row = $ilDB->fetchAssoc($result))
717 {
718 $mat = new ilSurveyMaterial();
719 $mat->type = $row['material_type'];
720 $mat->internal_link = $row['internal_link'];
721 $mat->title = $row['material_title'];
722 $mat->import_id = $row['import_id'];
723 $mat->text_material = $row['text_material'];
724 $mat->external_link = $row['external_link'];
725 $mat->file_material = $row['file_material'];
726 array_push($this->material, $mat);
727 }
728 }
729 }

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

+ Here is the call graph for this function:

◆ lookupObjFi()

static SurveyQuestion::lookupObjFi (   $a_qid)
static

Lookip obj fi.

Parameters

return

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

2446 {
2447 global $ilDB;
2448
2449 $set = $ilDB->query("SELECT obj_fi FROM svy_question ".
2450 " WHERE question_id = ".$ilDB->quote($a_qid, "integer")
2451 );
2452 $rec = $ilDB->fetchAssoc($set);
2453 return $rec["obj_fi"];
2454 }

References $ilDB.

Referenced by ilTermUsagesTableGUI\fillRow().

+ 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 @access private

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

2247 {
2248 // overwrite in inherited classes
2249 }

◆ phraseExists()

SurveyQuestion::phraseExists (   $title)

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

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

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

1344 {
1345 global $ilUser, $ilDB;
1346
1347 $result = $ilDB->queryF("SELECT phrase_id FROM svy_phrase WHERE title = %s AND owner_fi = %s",
1348 array('text', 'integer'),
1349 array($title, $ilUser->getId())
1350 );
1351 return ($result->numRows() == 0) ? false : true;
1352 }
global $ilUser
Definition: imgupload.php:15

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

◆ prepareTextareaOutput()

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

Prepares a string for a text area output in surveys.

Parameters
string$txt_outputString which should be prepared for output @access public

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

1946 {
1947 include_once "./Services/Utilities/classes/class.ilUtil.php";
1948 return ilUtil::prepareTextareaOutput($txt_output, $prepare_for_latex_output);
1949 }
static prepareTextareaOutput($txt_output, $prepare_for_latex_output=FALSE, $omitNl2BrWhenTextArea=false)
Prepares a string for a text area output where latex code may be in it If the text is HTML-free,...

References ilUtil\prepareTextareaOutput().

+ Here is the call graph for this function:

◆ QTIMaterialToString()

SurveyQuestion::QTIMaterialToString (   $a_material)

Reads an QTI material tag an creates a text string.

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

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

1871 {
1872 $result = "";
1873 for ($i = 0; $i < $a_material->getMaterialCount(); $i++)
1874 {
1875 $material = $a_material->getMaterial($i);
1876 if (strcmp($material["type"], "mattext") == 0)
1877 {
1878 $result .= $material["material"]->getContent();
1879 }
1880 if (strcmp($material["type"], "matimage") == 0)
1881 {
1882 $matimage = $material["material"];
1883 if (preg_match("/(il_([0-9]+)_mob_([0-9]+))/", $matimage->getLabel(), $matches))
1884 {
1885 // import an mediaobject which was inserted using tiny mce
1886 if (!is_array($_SESSION["import_mob_xhtml"])) $_SESSION["import_mob_xhtml"] = array();
1887 array_push($_SESSION["import_mob_xhtml"], array("mob" => $matimage->getLabel(), "uri" => $matimage->getUri()));
1888 }
1889 }
1890 }
1891 return $result;
1892 }
< a tabindex="-1" style="border-style: none;" href="#" title="Refresh Image" onclick="document.getElementById('siimage').src = './securimage_show.php?sid=' + Math.random(); this.blur(); return false">< img src="./images/refresh.png" alt="Reload Image" height="32" width="32" onclick="this.blur()" align="bottom" border="0"/></a >< br/>< strong > Enter Code *if($_SERVER['REQUEST_METHOD']=='POST' &&@ $_POST['do']=='contact') $_SESSION['ctform']['success']

References $_SESSION, $material, and $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 @access public

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

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 }

References $ilDB, $result, and $title.

◆ saveCategoryToDb()

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

Saves a category to the database.

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

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

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

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

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

+ Here is the caller graph for this function:

◆ saveCompletionStatus()

SurveyQuestion::saveCompletionStatus (   $original_id = "")

Saves the complete flag to the database.

@access public

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

762 {
763 global $ilDB;
764
765 $question_id = $this->getId();
766 if (strlen($original_id))
767 {
768 $question_id = $original_id;
769 }
770
771 if ($this->getId() > 0)
772 {
773 // update existing dataset
774 $affectedRows = $ilDB->manipulateF("UPDATE svy_question SET complete = %s, tstamp = %s WHERE question_id = %s",
775 array('text', 'integer', 'integer'),
776 array($this->isComplete(), time(), $question_id)
777 );
778 }
779 }
isComplete()
Returns 1, if a question is complete for use.

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

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

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

◆ saveMaterial()

SurveyQuestion::saveMaterial ( )

save material to db

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

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

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

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

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

◆ 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

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

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

2267 {
2268 // do nothing, overwrite in parent classes
2269 }

◆ saveToDb()

SurveyQuestion::saveToDb (   $original_id = "")

Saves a SurveyQuestion object to a database.

Parameters
integer$original_id@access public

Reimplemented in SurveyMetricQuestion, SurveyMultipleChoiceQuestion, SurveySingleChoiceQuestion, and SurveyTextQuestion.

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

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

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

Referenced by syncWithOriginal().

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

◆ saveWorkingData()

SurveyQuestion::saveWorkingData (   $limit_to = LIMIT_NO_LIMIT)

Saves the learners input of the question to the database.

@access public

See also
$answers

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

966 {
967 }

◆ setAuthor()

SurveyQuestion::setAuthor (   $author = "")

Sets the authors name of the SurveyQuestion object.

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

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

414 {
415 if (!$author)
416 {
417 $author = $this->ilias->account->fullname;
418 }
419 $this->author = $author;
420 }
redirection script todo: (a better solution should control the processing via a xml file)

References $author.

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

+ Here is the caller graph for this function:

◆ setComplete()

SurveyQuestion::setComplete (   $a_complete)

Sets the complete state of the question.

Parameters
integer$a_complete1 if complete, 0 otherwise @access public

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

209 {
210 $this->complete = ($a_complete) ? 1 : 0;
211 }

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

+ Here is the caller graph for this function:

◆ setDescription()

SurveyQuestion::setDescription (   $description = "")

Sets the description string of the SurveyQuestion object.

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

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

318 {
319 $this->description = $description;
320 }

References $description.

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

+ 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 @access public

Reimplemented in SurveyMatrixQuestion.

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

2137 {
2138 $csvrow = array();
2139 switch ($export_label)
2140 {
2141 case 'label_only':
2142 array_push($csvrow, $this->label);
2143 break;
2144 case 'title_only':
2145 array_push($csvrow, $this->getTitle());
2146 break;
2147 default:
2148 array_push($csvrow, $this->getTitle());
2149 array_push($csvrow, $this->label);
2150 break;
2151 }
2152 array_push($csvrow, strip_tags($this->getQuestiontext())); // #12942
2153 array_push($csvrow, $this->lng->txt($eval_data["QUESTION_TYPE"]));
2154 array_push($csvrow, $eval_data["USERS_ANSWERED"]);
2155 array_push($csvrow, $eval_data["USERS_SKIPPED"]);
2156 array_push($csvrow, $eval_data["MODE"]);
2157 array_push($csvrow, $eval_data["MODE_NR_OF_SELECTIONS"]);
2158 array_push($csvrow, $eval_data["MEDIAN"]);
2159 array_push($csvrow, $eval_data["ARITHMETIC_MEAN"]);
2160 $result = array();
2161 array_push($result, $csvrow);
2162 return $result;
2163 }

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

+ 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 @access public

Reimplemented in SurveyMatrixQuestion.

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

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

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

+ 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 @access public

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

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

2175 {
2176 // overwrite in inherited classes
2177 }

◆ setId()

SurveyQuestion::setId (   $id = -1)

Sets the id of the SurveyQuestion object.

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

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

294 {
295 $this->id = $id;
296 }

References $id.

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

+ Here is the caller graph for this function:

◆ setMaterial()

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

Sets a material link for the question.

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

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

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

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

+ Here is the call graph for this function:

◆ setMaterialsfile()

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

Sets and uploads the materials uri.

Parameters
stringstringstring$materials_filename,$materials_tempfilename,$materials@access public
See also
$materials

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

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 (!move_uploaded_file($materials_tempfilename, $materialspath . $materials_filename))
361 if (ilUtil::moveUploadedFile($materials_tempfilename, $materials_filename,
362 $materialspath.$materials_filename))
363 {
364 print "image not uploaded!!!! ";
365 }
366 else
367 {
368 $this->addMaterials($materials_filename, $materials_name);
369 }
370 }
371 }
addMaterials($materials_file, $materials_name="")
Sets the materials uri.
static moveUploadedFile($a_file, $a_name, $a_target, $a_raise_errors=true, $a_mode="move_uploaded")
move uploaded file

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

+ Here is the call graph for this function:

◆ setObjId()

SurveyQuestion::setObjId (   $obj_id = 0)

Set the reference id of the container object.

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

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

604 {
605 $this->obj_id = $obj_id;
606 }

References $obj_id.

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

+ Here is the caller graph for this function:

◆ setObligatory()

SurveyQuestion::setObligatory (   $obligatory = 1)

Sets the obligatory state of the question.

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

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

270 {
271 $this->obligatory = ($obligatory) ? 1 : 0;
272 }

References $obligatory.

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

+ Here is the caller graph for this function:

◆ setOrientation()

SurveyQuestion::setOrientation (   $orientation = 0)

Sets the orientation of the question output.

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

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

282 {
283 $this->orientation = ($orientation) ? $orientation : 0;
284 }

References $orientation.

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

+ Here is the caller graph for this function:

◆ setOriginalId()

SurveyQuestion::setOriginalId (   $original_id)

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

2252 {
2253 $this->original_id = $original_id;
2254 }

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

+ Here is the caller graph for this function:

◆ setOwner()

SurveyQuestion::setOwner (   $owner = "")

Sets the creator/owner ID of the SurveyQuestion object.

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

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

442 {
443 $this->owner = $owner;
444 }

References $owner.

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

+ Here is the caller graph for this function:

◆ setQuestiontext()

SurveyQuestion::setQuestiontext (   $questiontext = "")

Sets the questiontext of the SurveyQuestion object.

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

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

430 {
431 $this->questiontext = $questiontext;
432 }

References $questiontext.

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

+ Here is the caller graph for this function:

◆ setSubtype()

SurveyQuestion::setSubtype (   $a_subtype)

Reimplemented in SurveyMatrixQuestion, and SurveyMetricQuestion.

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

2277 {
2278 // do nothing
2279 }

◆ setSurveyId()

SurveyQuestion::setSurveyId (   $id = -1)

Sets the survey id of the SurveyQuestion object.

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

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

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

References $id.

◆ setTitle()

SurveyQuestion::setTitle (   $title = "")

Sets the title string of the SurveyQuestion object.

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

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

258 {
259 $this->title = $title;
260 }

References $title.

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

+ 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 @access public

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

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 }

References $author, $description, $ilias, $lng, $owner, $questiontext, $title, and $tpl.

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

+ Here is the caller graph for this function:

◆ syncWithOriginal()

SurveyQuestion::syncWithOriginal ( )

Reimplemented in SurveyMatrixQuestion.

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

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

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

+ Here is the call graph for this function:

◆ usableForPrecondition()

SurveyQuestion::usableForPrecondition ( )

Returns if the question is usable for preconditions.

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

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

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

2186 {
2187 // overwrite in inherited classes
2188 return FALSE;
2189 }

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 createNewQuestion(), delete(), 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: