ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
ilObjSurveyQuestionPool Class Reference
+ Inheritance diagram for ilObjSurveyQuestionPool:
+ Collaboration diagram for ilObjSurveyQuestionPool:

Public Member Functions

 ilObjSurveyQuestionPool ($a_id=0, $a_call_by_reference=true)
 Constructor @access public. More...
 
 create ($a_upload=false)
 create question pool object More...
 
 update ()
 update object data More...
 
 read ($a_force_db=false)
 read object data from db into object More...
 
 cloneObject ($a_target_id, $a_copy_id=0)
 Creates a 1:1 copy of the object and places the copy in a given repository. More...
 
createQuestion ($question_type, $question_id=-1)
 
 copyQuestion ($question_id, $questionpool_to)
 Copies a question into another question pool. More...
 
 loadFromDb ()
 Loads a ilObjQuestionpool object from a database. More...
 
 saveToDb ()
 Saves a ilObjSurveyQuestionPool object to a database. More...
 
 delete ()
 delete object and all related data More...
 
 deleteAllData ()
 
 notify ($a_event, $a_ref_id, $a_parent_non_rbac_id, $a_node_id, $a_params=0)
 notifys an object about an event occured Based on the event happend, each object may decide how it reacts. More...
 
 removeQuestion ($question_id)
 Removes a question from the question pool. More...
 
 getQuestiontype ($question_id)
 Returns the question type of a question with a given id. More...
 
 isInUse ($question_id)
 Checks if a question is in use by a survey. More...
 
 paste ($question_id)
 Pastes a question in the question pool. More...
 
getQuestionsInfo ($question_array)
 Retrieves the datase entries for questions from a given array. More...
 
 duplicateQuestion ($question_id, $obj_id="")
 Duplicates a question for a questionpool. More...
 
 getQuestionsData ($arrFilter)
 Calculates the data for the output of the questionpool. More...
 
 createExportDirectory ()
 creates data directory for export files (data_dir/spl_data/spl_<id>/export, depending on data directory that is set in ILIAS setup/ini) More...
 
 getExportDirectory ()
 get export directory of survey More...
 
 getExportFiles ($dir)
 get export files More...
 
 createImportDirectory ()
 creates data directory for import files (data_dir/spl_data/spl_<id>/import, depending on data directory that is set in ILIAS setup/ini) More...
 
 getImportDirectory ()
 get import directory of survey More...
 
 toXML ($questions)
 export questions to xml More...
 
getQuestions ()
 
 importObject ($source, $spl_exists=FALSE)
 Imports survey questions into ILIAS. More...
 
 setOnline ($a_online_status)
 Sets the questionpool online status. More...
 
 getOnline ()
 
 _lookupOnline ($a_obj_id)
 
 _isWriteable ($object_id, $user_id)
 Returns true, if the question pool is writeable by a given user. More...
 
_getQuestiontypes ()
 Creates a list of all available question types. More...
 
 _getAvailableQuestionpools ($use_object_id=FALSE, $could_be_offline=FALSE, $showPath=FALSE, $permission="read")
 Returns the available question pools for the active user. More...
 
 isPluginActive ($a_pname)
 Checks whether or not a question plugin with a given name is active. More...
 
 getQuestionInfos ($question_ids)
 Returns title, description and type for an array of question id's. More...
 
 purgeQuestions ()
 
 copyToClipboard ($question_id)
 Copies a question to the clipboard. More...
 
 moveToClipboard ($question_id)
 Moves a question to the clipboard. More...
 
 pasteFromClipboard ()
 Copies/Moves a question from the clipboard. More...
 
 setObligatoryStates ($obligatory_questions)
 Sets the obligatory states for questions in a survey from the questions form. More...
 
- Public Member Functions inherited from ilObject
 ilObject ($a_id=0, $a_reference=true)
 Constructor @access public. More...
 
 withReferences ()
 determines wehter objects are referenced or not (got ref ids or not) More...
 
 read ($a_force_db=false)
 read object data from db into object More...
 
 getId ()
 get object id @access public More...
 
 setId ($a_id)
 set object id @access public More...
 
 setRefId ($a_id)
 set reference id @access public More...
 
 getRefId ()
 get reference id @access public More...
 
 getType ()
 get object type @access public More...
 
 setType ($a_type)
 set object type @access public More...
 
 getPresentationTitle ()
 get presentation title Normally same as title Overwritten for sessions More...
 
 getTitle ()
 get object title @access public More...
 
 getUntranslatedTitle ()
 get untranslated object title @access public More...
 
 setTitle ($a_title)
 set object title More...
 
 getDescription ()
 get object description More...
 
 setDescription ($a_desc)
 set object description More...
 
 getLongDescription ()
 get object long description (stored in object_description) More...
 
 getImportId ()
 get import id More...
 
 setImportId ($a_import_id)
 set import id More...
 
 getOwner ()
 get object owner More...
 
 getOwnerName ()
 
 _lookupOwnerName ($a_owner_id)
 lookup owner name for owner id More...
 
 setOwner ($a_owner)
 set object owner More...
 
 getCreateDate ()
 get create date @access public More...
 
 getLastUpdateDate ()
 get last update date @access public More...
 
 getDiskUsage ()
 
 setObjDataRecord ($a_record)
 set object_data record (note: this method should only be called from the ilObjectFactory class) More...
 
 create ()
 create More...
 
 update ()
 update object in db More...
 
 MDUpdateListener ($a_element)
 Meta data update listener. More...
 
 createMetaData ()
 create meta data entry More...
 
 updateMetaData ()
 update meta data entry More...
 
 deleteMetaData ()
 delete meta data entry More...
 
 updateOwner ()
 update owner of object in db More...
 
 _getIdForImportId ($a_import_id)
 get current object id for import id (static) More...
 
 _lookupOwner ($a_id)
 lookup object owner More...
 
 _lookupLastUpdate ($a_id, $a_as_string=false)
 lookup last update More...
 
 _getLastUpdateOfObjects ($a_objs)
 Get last update for a set of media objects. More...
 
 _setDeletedDate ($a_ref_id)
 only called in ilTree::saveSubTree More...
 
 _resetDeletedDate ($a_ref_id)
 only called in ilObjectGUI::insertSavedNodes More...
 
 _lookupDeletedDate ($a_ref_id)
 only called in ilObjectGUI::insertSavedNodes More...
 
 _writeTitle ($a_obj_id, $a_title)
 write title to db (static) More...
 
 _writeDescription ($a_obj_id, $a_desc)
 write description to db (static) More...
 
 _writeImportId ($a_obj_id, $a_import_id)
 write import id to db (static) More...
 
 _isInTrash ($a_ref_id)
 checks wether object is in trash More...
 
 _hasUntrashedReference ($a_obj_id)
 checks wether an object has at least one reference that is not in trash More...
 
 _getObjectsDataForType ($a_type, $a_omit_trash=false)
 get all objects of a certain type More...
 
 putInTree ($a_parent_ref)
 maybe this method should be in tree object!? More...
 
 setPermissions ($a_parent_ref)
 set permissions of object More...
 
 setParentRolePermissions ($a_parent_ref)
 Initialize the permissions of parent roles (local roles of categories, global roles...) This method is overwritten in e.g courses, groups for building permission intersections with non_member templates. More...
 
 createReference ()
 creates reference for object More...
 
 countReferences ()
 count references of object More...
 
 delete ()
 delete object or referenced object (in the case of a referenced object, object data is only deleted if last reference is deleted) This function removes an object entirely from system!! More...
 
 initDefaultRoles ()
 init default roles settings Purpose of this function is to create a local role folder and local roles, that are needed depending on the object type If you want to setup default local roles you MUST overwrite this method in derived object classes (see ilObjForum for an example) @access public More...
 
 applyDidacticTemplate ($a_tpl_id)
 Apply template. More...
 
 notify ($a_event, $a_ref_id, $a_parent_non_rbac_id, $a_node_id, $a_params=0)
 notifys an object about an event occured Based on the event passed, each object may decide how it reacts. More...
 
 setRegisterMode ($a_bool)
 
 isUserRegistered ($a_user_id=0)
 
 requireRegistration ()
 
 getXMLZip ()
 
 getHTMLDirectory ()
 
 cloneObject ($a_target_id, $a_copy_id=0, $a_omit_tree=false)
 Clone object permissions, put in tree ... More...
 
 appendCopyInfo ($a_target_id, $a_copy_id)
 Prepend Copy info if object with same name exists in that container. More...
 
 cloneDependencies ($a_target_id, $a_copy_id)
 Clone object dependencies. More...
 
 cloneMetaData ($target_obj)
 Copy meta data. More...
 
 _lookupCreationDate ($a_id)
 Lookup creation date. More...
 
 getPossibleSubObjects ($a_filter=true)
 get all possible subobjects of this type the object can decide which types of subobjects are possible jut in time overwrite if the decision distinguish from standard model More...
 

Static Public Member Functions

static _setOnline ($a_obj_id, $a_online_status)
 
static & _getQuestionTypeTranslations ()
 
- Static Public Member Functions inherited from ilObject
static _lookupObjIdByImportId ($a_import_id)
 
static _lookupImportId ($a_obj_id)
 
static _getAllReferences ($a_id)
 get all reference ids of object More...
 
static _lookupTitle ($a_id)
 lookup object title More...
 
static _getIdsForTitle ($title, $type='', $partialmatch=false)
 
static _lookupDescription ($a_id)
 lookup object description More...
 
static _lookupObjId ($a_id)
 
static setDeletedDates ($a_ref_ids)
 Set deleted date @global type $ilDB. More...
 
static _lookupType ($a_id, $a_reference=false)
 lookup object type More...
 
static _lookupObjectId ($a_ref_id)
 lookup object id More...
 
static _exists ($a_id, $a_reference=false, $a_type=null)
 checks if an object exists in object_data@access public More...
 
static _getObjectsByType ($a_obj_type="", $a_owner="")
 Get objects by type. More...
 
static _prepareCloneSelection ($a_ref_ids, $new_type, $show_path=true)
 Prepare copy wizard object selection. More...
 
static _getIcon ($a_obj_id="", $a_size="big", $a_type="", $a_offline=false)
 Get icon for repository item. More...
 
static collectDeletionDependencies (&$deps, $a_ref_id, $a_obj_id, $a_type, $a_depth=0)
 Collect deletion dependencies. More...
 
static getDeletionDependencies ($a_obj_id)
 Get deletion dependencies. More...
 
static getLongDescriptions (array $a_obj_ids)
 Get long description data. More...
 
static getAllOwnedRepositoryObjects ($a_user_id)
 Get all ids of objects user owns. More...
 
static fixMissingTitles ($a_type, array &$a_obj_title_map)
 Try to fix missing object titles. More...
 
static hasAutoRating ($a_type, $a_ref_id)
 Check if auto rating is active for parent group/course. More...
 

Data Fields

 $online
 
- Data Fields inherited from ilObject
const TITLE_LENGTH = 255
 max length of object title More...
 
const DESC_LENGTH = 128
 
 $ilias
 
 $lng
 
 $id
 
 $ref_id
 
 $type
 
 $title
 
 $untranslatedTitle
 
 $desc
 
 $long_desc
 
 $owner
 
 $create_date
 
 $last_update
 
 $import_id
 
 $register = false
 
 $referenced
 
 $objectList
 
 $max_title
 
 $max_desc
 
 $add_dots
 
 $obj_data_record
 object_data record More...
 

Detailed Description

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

Member Function Documentation

◆ _getAvailableQuestionpools()

ilObjSurveyQuestionPool::_getAvailableQuestionpools (   $use_object_id = FALSE,
  $could_be_offline = FALSE,
  $showPath = FALSE,
  $permission = "read" 
)

Returns the available question pools for the active user.

Returns
array The available question pools @access public

Definition at line 1030 of file class.ilObjSurveyQuestionPool.php.

1031 {
1032 global $ilUser;
1033 global $ilDB;
1034
1035 $result_array = array();
1036 $qpls = ilUtil::_getObjectsByOperations("spl", $permission, $ilUser->getId(), -1);
1037 $titles = ilObject::_prepareCloneSelection($qpls, "spl", $showPath);
1038 $allqpls = array();
1039 $result = $ilDB->query("SELECT obj_fi, isonline FROM svy_qpl");
1040 while ($row = $ilDB->fetchAssoc($result))
1041 {
1042 $allqpls[$row['obj_fi']] = $row['isonline'];
1043 }
1044 foreach ($qpls as $ref_id)
1045 {
1047 if ($could_be_offline || $allqpls[$obj_id] == 1)
1048 {
1049 if ($use_object_id)
1050 {
1051 $result_array[$obj_id] = $titles[$ref_id];
1052 }
1053 else
1054 {
1055 $result_array[$ref_id] = $titles[$ref_id];
1056 }
1057 }
1058 }
1059 return $result_array;
1060 }
$result
static _lookupObjectId($a_ref_id)
lookup object id
static _prepareCloneSelection($a_ref_ids, $new_type, $show_path=true)
Prepare copy wizard object selection.
static _getObjectsByOperations($a_obj_type, $a_operation, $a_usr_id=0, $limit=0)
Get all objects of a specific type and check access This function is not recursive,...
global $ilDB
global $ilUser
Definition: imgupload.php:15

References $ilDB, $ilUser, ilObject\$ref_id, $result, $row, ilUtil\_getObjectsByOperations(), ilObject\_lookupObjectId(), and ilObject\_prepareCloneSelection().

Referenced by ilSurveyQuestionbrowserTableGUI\__construct(), ilObjSurvey\getAvailableQuestionpools(), and ilObjSurvey\getQuestionpoolTitles().

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

◆ _getQuestiontypes()

& ilObjSurveyQuestionPool::_getQuestiontypes ( )

Creates a list of all available question types.

Returns
array An array containing the available questiontypes @access public

Definition at line 918 of file class.ilObjSurveyQuestionPool.php.

919 {
920 global $ilDB;
921 global $lng;
922
923 $lng->loadLanguageModule("survey");
924 $types = array();
925 $query_result = $ilDB->query("SELECT * FROM svy_qtype ORDER BY type_tag");
926 while ($row = $ilDB->fetchAssoc($query_result))
927 {
928 //array_push($questiontypes, $row["type_tag"]);
929 if ($row["plugin"] == 0)
930 {
931 $types[$lng->txt($row["type_tag"])] = $row;
932 }
933 else
934 {
935 global $ilPluginAdmin;
936 $pl_names = $ilPluginAdmin->getActivePluginsForSlot(IL_COMP_MODULE, "SurveyQuestionPool", "svyq");
937 foreach ($pl_names as $pl_name)
938 {
939 $pl = ilPlugin::getPluginObject(IL_COMP_MODULE, "SurveyQuestionPool", "svyq", $pl_name);
940 if (strcmp($pl->getQuestionType(), $row["type_tag"]) == 0)
941 {
942 $types[$pl->getQuestionTypeTranslation()] = $row;
943 }
944 }
945 }
946 }
947 ksort($types);
948
949
950 // #14263 - default sorting
951
952 $default_sorting = array_flip(array(
953 "SurveySingleChoiceQuestion",
954 "SurveyMultipleChoiceQuestion",
955 "SurveyMatrixQuestion",
956 "SurveyMetricQuestion",
957 "SurveyTextQuestion"
958 ));
959
960 $sorted = array();
961 $idx = sizeof($default_sorting);
962 foreach($types as $caption => $item)
963 {
964 $type = $item["type_tag"];
965 $item["caption"] = $caption;
966
967 // default
968 if(array_key_exists($type, $default_sorting))
969 {
970 $sorted[$default_sorting[$type]] = $item;
971 }
972 // plugin (append alphabetically sorted)
973 else
974 {
975 $sorted[$idx] = $item;
976 $idx++;
977 }
978 }
979 ksort($sorted);
980
981 // redo captions as index
982 $types = array();
983 foreach($sorted as $item)
984 {
985 $types[$item["caption"]] = $item;
986 }
987
988 return $types;
989 }
const IL_COMP_MODULE
static getPluginObject($a_ctype, $a_cname, $a_slot_id, $a_pname)
Get plugin object.

References $ilDB, ilObject\$lng, $row, ilObject\$type, ilPlugin\getPluginObject(), and IL_COMP_MODULE.

Referenced by ilSurveyPageGUI\addQuestion(), ilSurveyPageGUI\addQuestionToolbarForm(), ilSurveyPageGUI\getPageNodes(), ilSurveyQuestionTableGUI\importData(), and ilSurveyEditorGUI\questionsObject().

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

◆ _getQuestionTypeTranslations()

static & ilObjSurveyQuestionPool::_getQuestionTypeTranslations ( )
static

Definition at line 991 of file class.ilObjSurveyQuestionPool.php.

992 {
993 global $ilDB;
994 global $lng;
995 global $ilLog;
996 global $ilPluginAdmin;
997
998 $lng->loadLanguageModule("survey");
999 $result = $ilDB->query("SELECT * FROM svy_qtype");
1000 $types = array();
1001 while ($row = $ilDB->fetchAssoc($result))
1002 {
1003 if ($row["plugin"] == 0)
1004 {
1005 $types[$row['type_tag']] = $lng->txt($row["type_tag"]);
1006 }
1007 else
1008 {
1009 $pl_names = $ilPluginAdmin->getActivePluginsForSlot(IL_COMP_MODULE, "SurveyQuestionPool", "svyq");
1010 foreach ($pl_names as $pl_name)
1011 {
1012 $pl = ilPlugin::getPluginObject(IL_COMP_MODULE, "SurveyQuestionPool", "svyq", $pl_name);
1013 if (strcmp($pl->getQuestionType(), $row["type_tag"]) == 0)
1014 {
1015 $types[$row['type_tag']] = $pl->getQuestionTypeTranslation();
1016 }
1017 }
1018 }
1019 }
1020 ksort($types);
1021 return $types;
1022 }

References $ilDB, $ilLog, ilObject\$lng, $result, $row, ilPlugin\getPluginObject(), and IL_COMP_MODULE.

Referenced by ilObjSurvey\getQuestionsTable().

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

◆ _isWriteable()

ilObjSurveyQuestionPool::_isWriteable (   $object_id,
  $user_id 
)

Returns true, if the question pool is writeable by a given user.

Parameters
integer$object_idThe object id of the question pool
integer$user_idThe database id of the user @access public

Definition at line 895 of file class.ilObjSurveyQuestionPool.php.

896 {
897 global $rbacsystem;
898 global $ilDB;
899
900 $refs = ilObject::_getAllReferences($object_id);
901 $result = false;
902 foreach ($refs as $ref)
903 {
904 if ($rbacsystem->checkAccess("write", $ref) && (ilObject::_hasUntrashedReference($object_id)))
905 {
906 $result = true;
907 }
908 }
909 return $result;
910 }
_hasUntrashedReference($a_obj_id)
checks wether an object has at least one reference that is not in trash
static _getAllReferences($a_id)
get all reference ids of object

References $ilDB, $result, ilObject\_getAllReferences(), and ilObject\_hasUntrashedReference().

Referenced by SurveyQuestion\_isWriteable().

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

◆ _lookupOnline()

ilObjSurveyQuestionPool::_lookupOnline (   $a_obj_id)

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

873 {
874 global $ilDB;
875
876 $result = $ilDB->queryF("SELECT isonline FROM svy_qpl WHERE obj_fi = %s",
877 array('integer'),
878 array($a_obj_id)
879 );
880 if ($result->numRows() == 1)
881 {
882 $row = $ilDB->fetchAssoc($result);
883 return $row["isonline"];
884 }
885 return 0;
886 }

References $ilDB, $result, and $row.

Referenced by ilObjSurveyQuestionPoolListGUI\getProperties().

+ Here is the caller graph for this function:

◆ _setOnline()

static ilObjSurveyQuestionPool::_setOnline (   $a_obj_id,
  $a_online_status 
)
static

Definition at line 827 of file class.ilObjSurveyQuestionPool.php.

828 {
829 global $ilDB;
830
831 $status = "0";
832 switch ($a_online_status)
833 {
834 case 0:
835 case 1:
836 $status = "$a_online_status";
837 break;
838 }
839 $affectedRows = $ilDB->manipulateF("UPDATE svy_qpl SET isonline = %s WHERE obj_fi = %s",
840 array('text','integer'),
841 array($status, $a_obj_id)
842 );
843 }

References $ilDB.

◆ cloneObject()

ilObjSurveyQuestionPool::cloneObject (   $a_target_id,
  $a_copy_id = 0 
)

Creates a 1:1 copy of the object and places the copy in a given repository.

@access public

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

105 {
106 global $ilLog;
107 $newObj = parent::cloneObject($a_target_id,$a_copy_id);
108
109 //copy online status if object is not the root copy object
110 $cp_options = ilCopyWizardOptions::_getInstance($a_copy_id);
111
112 if(!$cp_options->isRootNode($this->getRefId()))
113 {
114 $newObj->setOnline($this->getOnline());
115 }
116
117 $newObj->saveToDb();
118 // clone the questions in the question pool
119 $questions =& $this->getQuestions();
120 foreach ($questions as $question_id)
121 {
122 $newObj->copyQuestion($question_id, $newObj->getId());
123 }
124
125 // clone meta data
126 include_once "./Services/MetaData/classes/class.ilMD.php";
127 $md = new ilMD($this->getId(),0,$this->getType());
128 $new_md =& $md->cloneMD($newObj->getId(),0,$newObj->getType());
129
130 // update the metadata with the new title of the question pool
131 $newObj->updateMetaData();
132 return $newObj;
133 }
static _getInstance($a_copy_id)
Get instance of copy wizard options.
getType()
get object type @access public
getId()
get object id @access public

References $ilLog, ilCopyWizardOptions\_getInstance(), ilObject\getId(), getOnline(), getQuestions(), and ilObject\getType().

+ Here is the call graph for this function:

◆ copyQuestion()

ilObjSurveyQuestionPool::copyQuestion (   $question_id,
  $questionpool_to 
)

Copies a question into another question pool.

Parameters
integer$question_idDatabase id of the question
integer$questionpool_toDatabase id of the target questionpool @access public

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

162 {
163 $question_gui =& $this->createQuestion("", $question_id);
164 if ($question_gui->object->getObjId() == $questionpool_to)
165 {
166 // the question is copied into the same question pool
167 $this->duplicateQuestion($question_id);
168 }
169 else
170 {
171 // the question is copied into another question pool
172 $newtitle = $question_gui->object->getTitle();
173 if ($question_gui->object->questionTitleExists($question_gui->object->getTitle(), $questionpool_to))
174 {
175 $counter = 2;
176 while ($question_gui->object->questionTitleExists($question_gui->object->getTitle() . " ($counter)", $questionpool_to))
177 {
178 $counter++;
179 }
180 $newtitle = $question_gui->object->getTitle() . " ($counter)";
181 }
182 $question_gui->object->copyObject($this->getId(), $newtitle);
183 }
184 }
& createQuestion($question_type, $question_id=-1)
duplicateQuestion($question_id, $obj_id="")
Duplicates a question for a questionpool.

References createQuestion(), duplicateQuestion(), and ilObject\getId().

Referenced by pasteFromClipboard().

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

◆ copyToClipboard()

ilObjSurveyQuestionPool::copyToClipboard (   $question_id)

Copies a question to the clipboard.

Parameters
integer$question_idObject id of the question

Definition at line 1134 of file class.ilObjSurveyQuestionPool.php.

1135 {
1136 if (!array_key_exists("spl_clipboard", $_SESSION))
1137 {
1138 $_SESSION["spl_clipboard"] = array();
1139 }
1140 $_SESSION["spl_clipboard"][$question_id] = array("question_id" => $question_id, "action" => "copy");
1141 }
$_SESSION["AccountId"]

References $_SESSION.

◆ create()

ilObjSurveyQuestionPool::create (   $a_upload = false)

create question pool object

Definition at line 60 of file class.ilObjSurveyQuestionPool.php.

61 {
62 parent::create();
63 if(!$a_upload)
64 {
65 $this->createMetaData();
66 }
67 }
createMetaData()
create meta data entry

References ilObject\createMetaData().

+ Here is the call graph for this function:

◆ createExportDirectory()

ilObjSurveyQuestionPool::createExportDirectory ( )

creates data directory for export files (data_dir/spl_data/spl_<id>/export, depending on data directory that is set in ILIAS setup/ini)

Definition at line 563 of file class.ilObjSurveyQuestionPool.php.

564 {
565 include_once "./Services/Utilities/classes/class.ilUtil.php";
566 $spl_data_dir = ilUtil::getDataDir()."/spl_data";
567 ilUtil::makeDir($spl_data_dir);
568 if(!is_writable($spl_data_dir))
569 {
570 $this->ilias->raiseError("Survey Questionpool Data Directory (".$spl_data_dir
571 .") not writeable.",$this->ilias->error_obj->FATAL);
572 }
573
574 // create learning module directory (data_dir/lm_data/lm_<id>)
575 $spl_dir = $spl_data_dir."/spl_".$this->getId();
576 ilUtil::makeDir($spl_dir);
577 if(!@is_dir($spl_dir))
578 {
579 $this->ilias->raiseError("Creation of Survey Questionpool Directory failed.",$this->ilias->error_obj->FATAL);
580 }
581 // create Export subdirectory (data_dir/lm_data/lm_<id>/Export)
582 $export_dir = $spl_dir."/export";
583 ilUtil::makeDir($export_dir);
584 if(!@is_dir($export_dir))
585 {
586 $this->ilias->raiseError("Creation of Export Directory failed.",$this->ilias->error_obj->FATAL);
587 }
588 }
static getDataDir()
get data directory (outside webspace)
static makeDir($a_dir)
creates a new directory and inherits all filesystem permissions of the parent directory You may pass ...
redirection script todo: (a better solution should control the processing via a xml file)

References ilUtil\getDataDir(), ilObject\getId(), and ilUtil\makeDir().

+ Here is the call graph for this function:

◆ createImportDirectory()

ilObjSurveyQuestionPool::createImportDirectory ( )

creates data directory for import files (data_dir/spl_data/spl_<id>/import, depending on data directory that is set in ILIAS setup/ini)

Definition at line 643 of file class.ilObjSurveyQuestionPool.php.

644 {
645 include_once "./Services/Utilities/classes/class.ilUtil.php";
646 $spl_data_dir = ilUtil::getDataDir()."/spl_data";
647 ilUtil::makeDir($spl_data_dir);
648
649 if(!is_writable($spl_data_dir))
650 {
651 $this->ilias->raiseError("Survey Questionpool Data Directory (".$spl_data_dir
652 .") not writeable.",$this->ilias->error_obj->FATAL);
653 }
654
655 // create test directory (data_dir/spl_data/spl_<id>)
656 $spl_dir = $spl_data_dir."/spl_".$this->getId();
657 ilUtil::makeDir($spl_dir);
658 if(!@is_dir($spl_dir))
659 {
660 $this->ilias->raiseError("Creation of Survey Questionpool Directory failed.",$this->ilias->error_obj->FATAL);
661 }
662
663 // create import subdirectory (data_dir/spl_data/spl_<id>/import)
664 $import_dir = $spl_dir."/import";
665 ilUtil::makeDir($import_dir);
666 if(!@is_dir($import_dir))
667 {
668 $this->ilias->raiseError("Creation of Import Directory failed.",$this->ilias->error_obj->FATAL);
669 }
670 }

References ilUtil\getDataDir(), ilObject\getId(), and ilUtil\makeDir().

+ Here is the call graph for this function:

◆ createQuestion()

& ilObjSurveyQuestionPool::createQuestion (   $question_type,
  $question_id = -1 
)

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

136 {
137 if ((!$question_type) and ($question_id > 0))
138 {
139 $question_type = $this->getQuestiontype($question_id);
140 }
141
142 include_once "./Modules/SurveyQuestionPool/classes/class.".$question_type."GUI.php";
143 $question_type_gui = $question_type . "GUI";
144 $question =& new $question_type_gui();
145
146 if ($question_id > 0)
147 {
148 $question->object->loadFromDb($question_id);
149 }
150
151 return $question;
152 }
getQuestiontype($question_id)
Returns the question type of a question with a given id.

References getQuestiontype().

Referenced by copyQuestion().

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

◆ delete()

ilObjSurveyQuestionPool::delete ( )

delete object and all related data

@access public

Returns
boolean true if all object data were removed; false if only a references were removed

Reimplemented from ilObject.

Definition at line 244 of file class.ilObjSurveyQuestionPool.php.

245 {
246 $remove = parent::delete();
247 // always call parent delete function first!!
248 if (!$remove)
249 {
250 return false;
251 }
252
253 // delete all related questions
254 $this->deleteAllData();
255
256 // delete meta data
257 $this->deleteMetaData();
258
259 return true;
260 }
deleteMetaData()
delete meta data entry

References deleteAllData(), and ilObject\deleteMetaData().

+ Here is the call graph for this function:

◆ deleteAllData()

ilObjSurveyQuestionPool::deleteAllData ( )

Definition at line 262 of file class.ilObjSurveyQuestionPool.php.

263 {
264 global $ilDB;
265 $result = $ilDB->queryF("SELECT question_id FROM svy_question WHERE obj_fi = %s AND original_id IS NULL",
266 array('integer'),
267 array($this->getId())
268 );
269 $found_questions = array();
270 while ($row = $ilDB->fetchAssoc($result))
271 {
272 $this->removeQuestion($row["question_id"]);
273 }
274
275 // delete export files
276 include_once "./Services/Utilities/classes/class.ilUtil.php";
277 $spl_data_dir = ilUtil::getDataDir()."/spl_data";
278 $directory = $spl_data_dir."/spl_".$this->getId();
279 if (is_dir($directory))
280 {
281 include_once "./Services/Utilities/classes/class.ilUtil.php";
282 ilUtil::delDir($directory);
283 }
284 }
removeQuestion($question_id)
Removes a question from the question pool.
static delDir($a_dir, $a_clean_only=false)
removes a dir and all its content (subdirs and files) recursively

References $ilDB, $result, $row, ilUtil\delDir(), ilUtil\getDataDir(), ilObject\getId(), and removeQuestion().

Referenced by delete().

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

◆ duplicateQuestion()

ilObjSurveyQuestionPool::duplicateQuestion (   $question_id,
  $obj_id = "" 
)

Duplicates a question for a questionpool.

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

Definition at line 473 of file class.ilObjSurveyQuestionPool.php.

474 {
475 global $ilUser;
476 include_once "./Modules/SurveyQuestionPool/classes/class.SurveyQuestion.php";
477 $question = SurveyQuestion::_instanciateQuestion($question_id);
478 $suffix = "";
479 $counter = 1;
480 while ($question->questionTitleExists($question->getTitle().$suffix, $obj_id))
481 {
482 $counter++;
483 if ($counter > 1) $suffix = " ($counter)";
484 }
485 if ($obj_id)
486 {
487 $question->setObjId($obj_id);
488 }
489 $question->duplicate(false, $question->getTitle() . $suffix, $ilUser->fullname, $ilUser->id);
490 }
& _instanciateQuestion($question_id)
Creates an instance of a question with a given question id.

References $ilUser, and SurveyQuestion\_instanciateQuestion().

Referenced by copyQuestion(), and paste().

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

◆ getExportDirectory()

ilObjSurveyQuestionPool::getExportDirectory ( )

get export directory of survey

Definition at line 593 of file class.ilObjSurveyQuestionPool.php.

594 {
595 include_once "./Services/Utilities/classes/class.ilUtil.php";
596 $export_dir = ilUtil::getDataDir()."/spl_data"."/spl_".$this->getId()."/export";
597 return $export_dir;
598 }

References ilUtil\getDataDir().

+ Here is the call graph for this function:

◆ getExportFiles()

ilObjSurveyQuestionPool::getExportFiles (   $dir)

get export files

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

604 {
605 // quit if import dir not available
606 if (!@is_dir($dir) or
607 !is_writeable($dir))
608 {
609 return array();
610 }
611
612 // open directory
613 $dir = dir($dir);
614
615 // initialize array
616 $file = array();
617
618 // get files and save the in the array
619 while ($entry = $dir->read())
620 {
621 if ($entry != "." &&
622 $entry != ".." &&
623 ereg("^[0-9]{10}_{2}[0-9]+_{2}(spl_)*[0-9]+\.[A-Za-z]{3}\$", $entry))
624 {
625 $file[] = $entry;
626 }
627 }
628
629 // close import directory
630 $dir->close();
631 // sort files
632 sort ($file);
633 reset ($file);
634
635 return $file;
636 }
print $file

References $file.

◆ getImportDirectory()

ilObjSurveyQuestionPool::getImportDirectory ( )

get import directory of survey

Definition at line 675 of file class.ilObjSurveyQuestionPool.php.

676 {
677 include_once "./Services/Utilities/classes/class.ilUtil.php";
678 $import_dir = ilUtil::getDataDir()."/spl_data".
679 "/spl_".$this->getId()."/import";
680 if(@is_dir($import_dir))
681 {
682 return $import_dir;
683 }
684 else
685 {
686 return false;
687 }
688 }

References ilUtil\getDataDir().

+ Here is the call graph for this function:

◆ getOnline()

ilObjSurveyQuestionPool::getOnline ( )

Definition at line 866 of file class.ilObjSurveyQuestionPool.php.

867 {
868 if (strcmp($this->online, "") == 0) $this->online = "0";
869 return $this->online;
870 }

References $online.

Referenced by cloneObject(), saveToDb(), and toXML().

+ Here is the caller graph for this function:

◆ getQuestionInfos()

ilObjSurveyQuestionPool::getQuestionInfos (   $question_ids)

Returns title, description and type for an array of question id's.

Parameters
array$question_idsAn array of question id's
Returns
array Array of associated arrays with title, description, type_tag

Definition at line 1087 of file class.ilObjSurveyQuestionPool.php.

1088 {
1089 global $ilDB;
1090
1091 $found = array();
1092 $query_result = $ilDB->query("SELECT svy_question.*, svy_qtype.type_tag FROM svy_question, svy_qtype " .
1093 "WHERE svy_question.questiontype_fi = svy_qtype.questiontype_id " .
1094 "AND svy_question.tstamp > 0 AND " . $ilDB->in('svy_question.question_id', $question_ids, false, 'integer') . " " .
1095 "ORDER BY svy_question.title");
1096 if ($query_result->numRows() > 0)
1097 {
1098 while ($data = $ilDB->fetchAssoc($query_result))
1099 {
1100 if (in_array($data["question_id"], $question_ids))
1101 {
1102 array_push($found, array('id' => $data["question_id"],
1103 'title' => $data["title"],
1104 'description' => $data["description"],
1105 'type_tag' => $data["type_tag"]));
1106 }
1107 }
1108 }
1109 return $found;
1110 }
$data

References $data, and $ilDB.

◆ getQuestions()

& ilObjSurveyQuestionPool::getQuestions ( )

Definition at line 754 of file class.ilObjSurveyQuestionPool.php.

755 {
756 global $ilDB;
757 $questions = array();
758 $result = $ilDB->queryF("SELECT question_id FROM svy_question WHERE obj_fi = %s AND svy_question.tstamp > 0 AND original_id IS NULL",
759 array('integer'),
760 array($this->getId())
761 );
762 if ($result->numRows())
763 {
764 while ($row = $ilDB->fetchAssoc($result))
765 {
766 array_push($questions, $row["question_id"]);
767 }
768 }
769 return $questions;
770 }

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

Referenced by cloneObject(), setObligatoryStates(), and toXML().

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

◆ getQuestionsData()

ilObjSurveyQuestionPool::getQuestionsData (   $arrFilter)

Calculates the data for the output of the questionpool.

@access public

Definition at line 497 of file class.ilObjSurveyQuestionPool.php.

498 {
499 global $ilUser;
500 global $ilDB;
501 $where = "";
502 if (is_array($arrFilter))
503 {
504 foreach ($arrFilter as $key => $value)
505 {
506 $arrFilter[$key] = str_replace('%', '', $arrFilter[$key]);
507 }
508 if (array_key_exists('title', $arrFilter) && strlen($arrFilter['title']))
509 {
510 $where .= " AND " . $ilDB->like('svy_question.title', 'text', "%%" . $arrFilter['title'] . "%%");
511 }
512 if (array_key_exists('description', $arrFilter) && strlen($arrFilter['description']))
513 {
514 $where .= " AND " . $ilDB->like('svy_question.description', 'text', "%%" . $arrFilter['description'] . "%%");
515 }
516 if (array_key_exists('author', $arrFilter) && strlen($arrFilter['author']))
517 {
518 $where .= " AND " . $ilDB->like('svy_question.author', 'text', "%%" . $arrFilter['author'] . "%%");
519 }
520 if (array_key_exists('type', $arrFilter) && strlen($arrFilter['type']))
521 {
522 $where .= " AND svy_qtype.type_tag = " . $ilDB->quote($arrFilter['type'], 'text');
523 }
524 }
525 $query_result = $ilDB->queryF("SELECT svy_question.*, svy_qtype.type_tag, svy_qtype.plugin FROM svy_question, svy_qtype WHERE svy_question.original_id IS NULL AND svy_question.tstamp > 0 AND svy_question.questiontype_fi = svy_qtype.questiontype_id AND svy_question.obj_fi = %s" . $where,
526 array('integer'),
527 array($this->getId())
528 );
529 $rows = array();
530 if ($query_result->numRows())
531 {
532 while ($row = $ilDB->fetchAssoc($query_result))
533 {
534 // first part fix #19469
535 $set = $ilDB->query("SELECT question_fi FROM svy_svy_qst ".
536 " WHERE question_fi = ".$ilDB->quote($row["question_id"], "integer")
537 );
538 if ($temp = $ilDB->fetchAssoc($set))
539 {
540 continue;
541 }
542 if ($row["plugin"])
543 {
544 if ($this->isPluginActive($row["type_tag"]))
545 {
546 array_push($rows, $row);
547 }
548 }
549 else
550 {
551 array_push($rows, $row);
552 }
553 }
554 }
555 return $rows;
556 }
isPluginActive($a_pname)
Checks whether or not a question plugin with a given name is active.

References $ilDB, $ilUser, $row, ilObject\getId(), and isPluginActive().

+ Here is the call graph for this function:

◆ getQuestionsInfo()

& ilObjSurveyQuestionPool::getQuestionsInfo (   $question_array)

Retrieves the datase entries for questions from a given array.

Parameters
array$question_arrayAn array containing the id's of the questions
Returns
array An array containing the database rows of the given question id's @access public

Definition at line 445 of file class.ilObjSurveyQuestionPool.php.

446 {
447 global $ilDB;
448 $result_array = array();
449 $result = $ilDB->query("SELECT svy_question.*, svy_qtype.type_tag, svy_qtype.plugin FROM svy_question, svy_qtype WHERE svy_question.questiontype_fi = svy_qtype.questiontype_id AND svy_question.tstamp > 0 AND " . $ilDB->in('svy_question.question_id', $question_array, false, 'integer'));
450 while ($row = $ilDB->fetchAssoc($result))
451 {
452 if ($row["plugin"])
453 {
454 if ($this->isPluginActive($row["type_tag"]))
455 {
456 array_push($result_array, $row);
457 }
458 }
459 else
460 {
461 array_push($result_array, $row);
462 }
463 }
464 return $result_array;
465 }

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

+ Here is the call graph for this function:

◆ getQuestiontype()

ilObjSurveyQuestionPool::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 373 of file class.ilObjSurveyQuestionPool.php.

374 {
375 global $ilDB;
376 if ($question_id < 1) return;
377 $result = $ilDB->queryF("SELECT svy_qtype.type_tag FROM svy_question, svy_qtype WHERE svy_question.questiontype_fi = svy_qtype.questiontype_id AND svy_question.question_id = %s",
378 array('integer'),
379 array($question_id)
380 );
381 if ($result->numRows() == 1)
382 {
383 $data = $ilDB->fetchAssoc($result);
384 return $data["type_tag"];
385 }
386 else
387 {
388 return;
389 }
390 }

References $data, $ilDB, and $result.

Referenced by createQuestion(), and toXML().

+ Here is the caller graph for this function:

◆ ilObjSurveyQuestionPool()

ilObjSurveyQuestionPool::ilObjSurveyQuestionPool (   $a_id = 0,
  $a_call_by_reference = true 
)

Constructor @access public.

Parameters
integerreference_id or object_id
booleantreat the id as reference_id (true) or object_id (false)

Definition at line 51 of file class.ilObjSurveyQuestionPool.php.

52 {
53 $this->type = "spl";
54 $this->ilObject($a_id,$a_call_by_reference);
55 }
ilObject($a_id=0, $a_reference=true)
Constructor @access public.

References ilObject\ilObject().

+ Here is the call graph for this function:

◆ importObject()

ilObjSurveyQuestionPool::importObject (   $source,
  $spl_exists = FALSE 
)

Imports survey questions into ILIAS.

Parameters
string$sourceThe filename of an XML import file @access public

Definition at line 778 of file class.ilObjSurveyQuestionPool.php.

779 {
780 if (is_file($source))
781 {
782 $isZip = (strcmp(strtolower(substr($source, -3)), 'zip') == 0);
783 if ($isZip)
784 {
785 // unzip file
786 ilUtil::unzip($source);
787
788 // determine filenames of xml files
789 $subdir = basename($source, ".zip");
790 $source = dirname($source)."/".$subdir."/".$subdir.".xml";
791 }
792
793 $fh = fopen($source, "r") or die("");
794 $xml = fread($fh, filesize($source));
795 fclose($fh) or die("");
796 if ($isZip)
797 {
798 $subdir = basename($source, ".zip");
799 if (@is_dir(dirname($source)."/".$subdir))
800 {
801 ilUtil::delDir(dirname($source)."/".$subdir);
802 }
803 }
804 if (strpos($xml, "questestinterop") > 0)
805 {
806 include_once("./Modules/Survey/exceptions/class.ilInvalidSurveyImportFileException.php");
807 throw new ilInvalidSurveyImportFileException("Unsupported survey version (< 3.8) found.");
808
809 // survey questions for ILIAS < 3.8
810 /*
811 include_once "./Services/Survey/classes/class.SurveyImportParserPre38.php";
812 $import = new SurveyImportParserPre38($this->getId(), "", $spl_exists);
813 $import->setXMLContent($xml);
814 $import->startParsing();*/
815 }
816 else
817 {
818 // survey questions for ILIAS >= 3.8
819 include_once "./Services/Survey/classes/class.SurveyImportParser.php";
820 $import = new SurveyImportParser($this->getId(), "", $spl_exists);
821 $import->setXMLContent($xml);
822 $import->startParsing();
823 }
824 }
825 }
Survey Question Import Parser.
static unzip($a_file, $overwrite=false, $a_flat=false)
unzip file
if(!file_exists(getcwd().'/ilias.ini.php')) if(isset( $_GET["client_id"]))
registration confirmation script for ilias
Definition: confirmReg.php:20

References ilUtil\delDir(), ilObject\getId(), and ilUtil\unzip().

+ Here is the call graph for this function:

◆ isInUse()

ilObjSurveyQuestionPool::isInUse (   $question_id)

Checks if a question is in use by a survey.

Parameters
integer$question_idThe database id of the question
Returns
mixed An array of the surveys which use the question, when the question is in use by at least one survey, otherwise false @access public

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

400 {
401 global $ilDB;
402 // check out the already answered questions
403 $result = $ilDB->queryF("SELECT answer_id FROM svy_answer WHERE question_fi = %s",
404 array('integer'),
405 array($question_id)
406 );
407 $answered = $result->numRows();
408
409 // check out the questions inserted in surveys
410 $result = $ilDB->queryF("SELECT svy_svy.* FROM svy_svy, svy_svy_qst WHERE svy_svy_qst.survey_fi = svy_svy.survey_id AND svy_svy_qst.question_fi = %s",
411 array('integer'),
412 array($question_id)
413 );
414 $inserted = $result->numRows();
415 if (($inserted + $answered) == 0)
416 {
417 return false;
418 }
419 $result_array = array();
420 while ($row = $ilDB->fetchObject($result))
421 {
422 array_push($result_array, $row);
423 }
424 return $result_array;
425 }

References $ilDB, $result, and $row.

◆ isPluginActive()

ilObjSurveyQuestionPool::isPluginActive (   $a_pname)

Checks whether or not a question plugin with a given name is active.

Parameters
string$a_pnameThe plugin name @access public

Definition at line 1068 of file class.ilObjSurveyQuestionPool.php.

1069 {
1070 global $ilPluginAdmin;
1071 if ($ilPluginAdmin->isActive(IL_COMP_MODULE, "SurveyQuestionPool", "svyq", $a_pname))
1072 {
1073 return TRUE;
1074 }
1075 else
1076 {
1077 return FALSE;
1078 }
1079 }

References IL_COMP_MODULE.

Referenced by getQuestionsData(), and getQuestionsInfo().

+ Here is the caller graph for this function:

◆ loadFromDb()

ilObjSurveyQuestionPool::loadFromDb ( )

Loads a ilObjQuestionpool object from a database.

@access public

Definition at line 191 of file class.ilObjSurveyQuestionPool.php.

192 {
193 global $ilDB;
194
195 $result = $ilDB->queryF("SELECT * FROM svy_qpl WHERE obj_fi = %s",
196 array('integer'),
197 array($this->getId())
198 );
199 if ($result->numRows() == 1)
200 {
201 $row = $ilDB->fetchAssoc($result);
202 $this->setOnline($row["isonline"]);
203 }
204 }
setOnline($a_online_status)
Sets the questionpool online status.

References $ilDB, $result, $row, ilObject\getId(), and setOnline().

Referenced by read().

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

◆ moveToClipboard()

ilObjSurveyQuestionPool::moveToClipboard (   $question_id)

Moves a question to the clipboard.

Parameters
integer$question_idObject id of the question

Definition at line 1148 of file class.ilObjSurveyQuestionPool.php.

1149 {
1150 if (!array_key_exists("spl_clipboard", $_SESSION))
1151 {
1152 $_SESSION["spl_clipboard"] = array();
1153 }
1154 $_SESSION["spl_clipboard"][$question_id] = array("question_id" => $question_id, "action" => "move");
1155 }

References $_SESSION.

◆ notify()

ilObjSurveyQuestionPool::notify (   $a_event,
  $a_ref_id,
  $a_parent_non_rbac_id,
  $a_node_id,
  $a_params = 0 
)

notifys an object about an event occured Based on the event happend, each object may decide how it reacts.

If you are not required to handle any events related to your module, just delete this method. (For an example how this method is used, look at ilObjGroup)

@access public

Parameters
stringevent
integerreference id of object where the event occured
arraypasses optional parameters if required
Returns
boolean

Reimplemented from ilObject.

Definition at line 299 of file class.ilObjSurveyQuestionPool.php.

300 {
301 global $tree;
302
303 switch ($a_event)
304 {
305 case "link":
306
307 //var_dump("<pre>",$a_params,"</pre>");
308 //echo "Module name ".$this->getRefId()." triggered by link event. Objects linked into target object ref_id: ".$a_ref_id;
309 //exit;
310 break;
311
312 case "cut":
313
314 //echo "Module name ".$this->getRefId()." triggered by cut event. Objects are removed from target object ref_id: ".$a_ref_id;
315 //exit;
316 break;
317
318 case "copy":
319
320 //var_dump("<pre>",$a_params,"</pre>");
321 //echo "Module name ".$this->getRefId()." triggered by copy event. Objects are copied into target object ref_id: ".$a_ref_id;
322 //exit;
323 break;
324
325 case "paste":
326
327 //echo "Module name ".$this->getRefId()." triggered by paste (cut) event. Objects are pasted into target object ref_id: ".$a_ref_id;
328 //exit;
329 break;
330
331 case "new":
332
333 //echo "Module name ".$this->getRefId()." triggered by paste (new) event. Objects are applied to target object ref_id: ".$a_ref_id;
334 //exit;
335 break;
336 }
337
338 // At the beginning of the recursive process it avoids second call of the notify function with the same parameter
339 if ($a_node_id==$_GET["ref_id"])
340 {
341 $parent_obj =& $this->ilias->obj_factory->getInstanceByRefId($a_node_id);
342 $parent_type = $parent_obj->getType();
343 if($parent_type == $this->getType())
344 {
345 $a_node_id = (int) $tree->getParentId($a_node_id);
346 }
347 }
348
349 parent::notify($a_event,$a_ref_id,$a_parent_non_rbac_id,$a_node_id,$a_params);
350 }
$_GET["client_id"]

References $_GET, and ilObject\getType().

+ Here is the call graph for this function:

◆ paste()

ilObjSurveyQuestionPool::paste (   $question_id)

Pastes a question in the question pool.

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

Definition at line 433 of file class.ilObjSurveyQuestionPool.php.

434 {
435 $this->duplicateQuestion($question_id, $this->getId());
436 }

References duplicateQuestion(), and ilObject\getId().

+ Here is the call graph for this function:

◆ pasteFromClipboard()

ilObjSurveyQuestionPool::pasteFromClipboard ( )

Copies/Moves a question from the clipboard.

Definition at line 1160 of file class.ilObjSurveyQuestionPool.php.

1161 {
1162 global $ilDB;
1163
1164 if (array_key_exists("spl_clipboard", $_SESSION))
1165 {
1166 foreach ($_SESSION["spl_clipboard"] as $question_object)
1167 {
1168 if (strcmp($question_object["action"], "move") == 0)
1169 {
1170 $result = $ilDB->queryF("SELECT obj_fi FROM svy_question WHERE question_id = %s",
1171 array('integer'),
1172 array($question_object["question_id"])
1173 );
1174 if ($result->numRows() == 1)
1175 {
1176 $row = $ilDB->fetchAssoc($result);
1177 $source_questionpool = $row["obj_fi"];
1178 if ($this->getId() != $source_questionpool)
1179 {
1180 // change the questionpool id in the qpl_questions table
1181 $affectedRows = $ilDB->manipulateF("UPDATE svy_question SET obj_fi = %s WHERE question_id = %s",
1182 array('integer','integer'),
1183 array($this->getId(), $question_object["question_id"])
1184 );
1185
1186 // move question data to the new target directory
1187 $source_path = CLIENT_WEB_DIR . "/survey/" . $source_questionpool . "/" . $question_object["question_id"] . "/";
1188 if (@is_dir($source_path))
1189 {
1190 $target_path = CLIENT_WEB_DIR . "/survey/" . $this->getId() . "/";
1191 if (!@is_dir($target_path))
1192 {
1193 include_once "./Services/Utilities/classes/class.ilUtil.php";
1194 ilUtil::makeDirParents($target_path);
1195 }
1196 @rename($source_path, $target_path . $question_object["question_id"]);
1197 }
1198 }
1199 else
1200 {
1201 ilUtil::sendFailure($this->lng->txt("spl_move_same_pool"), true);
1202 return;
1203 }
1204 }
1205 }
1206 else
1207 {
1208 $this->copyQuestion($question_object["question_id"], $this->getId());
1209 }
1210 }
1211 }
1212 ilUtil::sendSuccess($this->lng->txt("spl_paste_success"), true);
1213 unset($_SESSION["spl_clipboard"]);
1214 }
copyQuestion($question_id, $questionpool_to)
Copies a question into another question pool.
static sendSuccess($a_info="", $a_keep=false)
Send Success Message to Screen.
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
static makeDirParents($a_dir)
Create a new directory and all parent directories.

References $_SESSION, $ilDB, $result, $row, copyQuestion(), ilObject\getId(), ilUtil\makeDirParents(), ilUtil\sendFailure(), and ilUtil\sendSuccess().

+ Here is the call graph for this function:

◆ purgeQuestions()

ilObjSurveyQuestionPool::purgeQuestions ( )

Definition at line 1115 of file class.ilObjSurveyQuestionPool.php.

1116 {
1117 global $ilDB, $ilUser;
1118
1119 $result = $ilDB->queryF("SELECT question_id FROM svy_question WHERE owner_fi = %s AND tstamp = %s",
1120 array("integer", "integer"),
1121 array($ilUser->getId(), 0)
1122 );
1123 while ($data = $ilDB->fetchAssoc($result))
1124 {
1125 $this->removeQuestion($data["question_id"]);
1126 }
1127 }

References $data, $ilDB, $ilUser, $result, and removeQuestion().

+ Here is the call graph for this function:

◆ read()

ilObjSurveyQuestionPool::read (   $a_force_db = false)

read object data from db into object

Parameters
boolean@access public

Reimplemented from ilObject.

Definition at line 93 of file class.ilObjSurveyQuestionPool.php.

94 {
95 parent::read($a_force_db);
96 $this->loadFromDb();
97 }
loadFromDb()
Loads a ilObjQuestionpool object from a database.

References loadFromDb().

+ Here is the call graph for this function:

◆ removeQuestion()

ilObjSurveyQuestionPool::removeQuestion (   $question_id)

Removes a question from the question pool.

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

Definition at line 358 of file class.ilObjSurveyQuestionPool.php.

359 {
360 if ($question_id < 1) return;
361 include_once "./Modules/SurveyQuestionPool/classes/class.SurveyQuestion.php";
362 $question =& SurveyQuestion::_instanciateQuestion($question_id);
363 $question->delete($question_id);
364 }

References SurveyQuestion\_instanciateQuestion().

Referenced by deleteAllData(), and purgeQuestions().

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

◆ saveToDb()

ilObjSurveyQuestionPool::saveToDb ( )

Saves a ilObjSurveyQuestionPool object to a database.

@access public

Definition at line 211 of file class.ilObjSurveyQuestionPool.php.

212 {
213 global $ilDB;
214
215 parent::update();
216
217 $result = $ilDB->queryF("SELECT * FROM svy_qpl WHERE obj_fi = %s",
218 array('integer'),
219 array($this->getId())
220 );
221 if ($result->numRows() == 1)
222 {
223 $affectedRows = $ilDB->manipulateF("UPDATE svy_qpl SET isonline = %s, tstamp = %s WHERE obj_fi = %s",
224 array('text','integer','integer'),
225 array($this->getOnline(), time(), $this->getId())
226 );
227 }
228 else
229 {
230 $next_id = $ilDB->nextId('svy_qpl');
231 $query = $ilDB->manipulateF("INSERT INTO svy_qpl (id_questionpool, isonline, obj_fi, tstamp) VALUES (%s, %s, %s, %s)",
232 array('integer', 'text', 'integer', 'integer'),
233 array($next_id, $this->getOnline(), $this->getId(), time())
234 );
235 }
236 }

References $ilDB, $query, $result, ilObject\getId(), and getOnline().

+ Here is the call graph for this function:

◆ setObligatoryStates()

ilObjSurveyQuestionPool::setObligatoryStates (   $obligatory_questions)

Sets the obligatory states for questions in a survey from the questions form.

Parameters
array$obligatory_questionsThe questions which should be set obligatory from the questions form, the remaining questions should be setted not obligatory @access public

Definition at line 1222 of file class.ilObjSurveyQuestionPool.php.

1223 {
1224 global $ilDB;
1225
1226 foreach($this->getQuestions() as $question_id)
1227 {
1228 $status = (int)(in_array($question_id, $obligatory_questions));
1229
1230 $ilDB->manipulate("UPDATE svy_question".
1231 " SET obligatory = ".$ilDB->quote($status, "integer").
1232 " WHERE question_id = ".$ilDB->quote($question_id, "integer"));
1233 }
1234 }

References $ilDB, and getQuestions().

+ Here is the call graph for this function:

◆ setOnline()

ilObjSurveyQuestionPool::setOnline (   $a_online_status)

Sets the questionpool online status.

Parameters
integer$a_online_statusOnline status of the questionpool
See also
online @access User interface

Definition at line 852 of file class.ilObjSurveyQuestionPool.php.

853 {
854 switch ($a_online_status)
855 {
856 case 0:
857 case 1:
858 $this->online = $a_online_status;
859 break;
860 default:
861 $this->online = 0;
862 break;
863 }
864 }

Referenced by loadFromDb().

+ Here is the caller graph for this function:

◆ toXML()

ilObjSurveyQuestionPool::toXML (   $questions)

export questions to xml

Definition at line 693 of file class.ilObjSurveyQuestionPool.php.

694 {
695 if (!is_array($questions))
696 {
697 $questions =& $this->getQuestions();
698 }
699 if (count($questions) == 0)
700 {
701 $questions =& $this->getQuestions();
702 }
703 $xml = "";
704
705 include_once("./Services/Xml/classes/class.ilXmlWriter.php");
706 $a_xml_writer = new ilXmlWriter;
707 // set xml header
708 $a_xml_writer->xmlHeader();
709 $attrs = array(
710 "xmlns:xsi" => "http://www.w3.org/2001/XMLSchema-instance",
711 "xsi:noNamespaceSchemaLocation" => "http://www.ilias.de/download/xsd/ilias_survey_4_2.xsd"
712 );
713 $a_xml_writer->xmlStartTag("surveyobject", $attrs);
714 $attrs = array(
715 "id" => "qpl_" . $this->getId(),
716 "label" => $this->getTitle(),
717 "online" => $this->getOnline()
718 );
719 $a_xml_writer->xmlStartTag("surveyquestions", $attrs);
720 $a_xml_writer->xmlElement("dummy", NULL, "dummy");
721 // add ILIAS specific metadata
722 $a_xml_writer->xmlStartTag("metadata");
723 $a_xml_writer->xmlStartTag("metadatafield");
724 $a_xml_writer->xmlElement("fieldlabel", NULL, "SCORM");
725 include_once "./Services/MetaData/classes/class.ilMD.php";
726 $md = new ilMD($this->getId(),0, $this->getType());
727 $writer = new ilXmlWriter();
728 $md->toXml($writer);
729 $metadata = $writer->xmlDumpMem();
730 $a_xml_writer->xmlElement("fieldentry", NULL, $metadata);
731 $a_xml_writer->xmlEndTag("metadatafield");
732 $a_xml_writer->xmlEndTag("metadata");
733
734 $a_xml_writer->xmlEndTag("surveyquestions");
735 $a_xml_writer->xmlEndTag("surveyobject");
736
737 $xml = $a_xml_writer->xmlDumpMem(FALSE);
738
739 $questionxml = "";
740 foreach ($questions as $key => $value)
741 {
742 $questiontype = $this->getQuestiontype($value);
743 include_once "./Modules/SurveyQuestionPool/classes/class.SurveyQuestion.php";
744 SurveyQuestion::_includeClass($questiontype);
745 $question = new $questiontype();
746 $question->loadFromDb($value);
747 $questionxml .= $question->toXML(false);
748 }
749
750 $xml = str_replace("<dummy>dummy</dummy>", $questionxml, $xml);
751 return $xml;
752 }
static _includeClass($question_type, $gui=0)
Include the php class file for a given question type.
getTitle()
get object title @access public
XML writer class.
xmlHeader()
Writes xml header @access public.

References SurveyQuestion\_includeClass(), ilObject\getId(), getOnline(), getQuestions(), getQuestiontype(), ilObject\getTitle(), ilObject\getType(), and ilXmlWriter\xmlHeader().

+ Here is the call graph for this function:

◆ update()

ilObjSurveyQuestionPool::update ( )

update object data

@access public

Returns
boolean

Reimplemented from ilObject.

Definition at line 75 of file class.ilObjSurveyQuestionPool.php.

76 {
77 $this->updateMetaData();
78 if (!parent::update())
79 {
80 return false;
81 }
82
83 // put here object specific stuff
84
85 return true;
86 }
updateMetaData()
update meta data entry

References ilObject\updateMetaData().

+ Here is the call graph for this function:

Field Documentation

◆ $online

ilObjSurveyQuestionPool::$online

Definition at line 43 of file class.ilObjSurveyQuestionPool.php.

Referenced by getOnline().


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