ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
ilObjSurveyQuestionPool Class Reference
+ Inheritance diagram for ilObjSurveyQuestionPool:
+ Collaboration diagram for ilObjSurveyQuestionPool:

Public Member Functions

 __construct ($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 ()
 read object data from db into object @access public More...
 
 cloneObject ($a_target_id, $a_copy_id=0, $a_omit_tree=false)
 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 ()
 
 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 ()
 
 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
 __construct ($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 ()
 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 ()
 
 setOwner ($a_owner)
 set object owner More...
 
 getCreateDate ()
 get create date @access public More...
 
 getLastUpdateDate ()
 get last update date @access public More...
 
 getDiskUsage ()
 
 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...
 
 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...
 
 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...
 
 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 _lookupOnline ($a_obj_id)
 
static _isWriteable ($object_id, $user_id)
 Returns true, if the question pool is writeable by a given user. More...
 
static _getQuestiontypes ()
 Creates a list of all available question types. More...
 
static _getQuestionTypeTranslations ()
 
static _getAvailableQuestionpools ($use_object_id=FALSE, $could_be_offline=FALSE, $showPath=FALSE, $permission="read")
 Returns the available question pools for the active user. More...
 
- Static Public Member Functions inherited from ilObject
static _lookupObjIdByImportId ($a_import_id)
 
static _lookupImportId ($a_obj_id)
 
static _lookupOwnerName ($a_owner_id)
 lookup owner name for owner id More...
 
static _getIdForImportId ($a_import_id)
 get current object id for import id (static) More...
 
static _getAllReferences ($a_id)
 get all reference ids of object More...
 
static _lookupTitle ($a_id)
 lookup object title More...
 
static _lookupOwner ($a_id)
 lookup object owner More...
 
static _getIdsForTitle ($title, $type='', $partialmatch=false)
 
static _lookupDescription ($a_id)
 lookup object description More...
 
static _lookupLastUpdate ($a_id, $a_as_string=false)
 lookup last update More...
 
static _getLastUpdateOfObjects ($a_objs)
 Get last update for a set of media objects. More...
 
static _lookupObjId ($a_id)
 
static _setDeletedDate ($a_ref_id)
 only called in ilTree::saveSubTree More...
 
static setDeletedDates ($a_ref_ids)
 Set deleted date @global type $ilDB. More...
 
static _resetDeletedDate ($a_ref_id)
 only called in ilObjectGUI::insertSavedNodes More...
 
static _lookupDeletedDate ($a_ref_id)
 only called in ilObjectGUI::insertSavedNodes More...
 
static _writeTitle ($a_obj_id, $a_title)
 write title to db (static) More...
 
static _writeDescription ($a_obj_id, $a_desc)
 write description to db (static) More...
 
static _writeImportId ($a_obj_id, $a_import_id)
 write import id to db (static) More...
 
static _lookupType ($a_id, $a_reference=false)
 lookup object type More...
 
static _isInTrash ($a_ref_id)
 checks wether object is in trash More...
 
static _hasUntrashedReference ($a_obj_id)
 checks wether an object has at least one reference that is not in trash More...
 
static _lookupObjectId ($a_ref_id)
 lookup object id More...
 
static _getObjectsDataForType ($a_type, $a_omit_trash=false)
 get all objects of a certain type 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 _lookupCreationDate ($a_id)
 Lookup creation date. 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
 

Detailed Description

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

Constructor & Destructor Documentation

◆ __construct()

ilObjSurveyQuestionPool::__construct (   $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)

Reimplemented from ilObject.

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

52 {
53 $this->type = "spl";
54 parent::__construct($a_id,$a_call_by_reference);
55 }

Member Function Documentation

◆ _getAvailableQuestionpools()

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

Returns the available question pools for the active user.

Returns
array The available question pools @access public

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

958 {
959 global $ilUser;
960 global $ilDB;
961
962 $result_array = array();
963 $qpls = ilUtil::_getObjectsByOperations("spl", $permission, $ilUser->getId(), -1);
964 $titles = ilObject::_prepareCloneSelection($qpls, "spl", $showPath);
965 $allqpls = array();
966 $result = $ilDB->query("SELECT obj_fi, isonline FROM svy_qpl");
967 while ($row = $ilDB->fetchAssoc($result))
968 {
969 $allqpls[$row['obj_fi']] = $row['isonline'];
970 }
971 foreach ($qpls as $ref_id)
972 {
974 if ($could_be_offline || $allqpls[$obj_id] == 1)
975 {
976 if ($use_object_id)
977 {
978 $result_array[$obj_id] = $titles[$ref_id];
979 }
980 else
981 {
982 $result_array[$ref_id] = $titles[$ref_id];
983 }
984 }
985 }
986 return $result_array;
987 }
$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
$ilUser
Definition: imgupload.php:18

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()

static ilObjSurveyQuestionPool::_getQuestiontypes ( )
static

Creates a list of all available question types.

Returns
array An array containing the available questiontypes @access public

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

846 {
847 global $ilDB;
848 global $lng;
849
850 $lng->loadLanguageModule("survey");
851 $types = array();
852 $query_result = $ilDB->query("SELECT * FROM svy_qtype ORDER BY type_tag");
853 while ($row = $ilDB->fetchAssoc($query_result))
854 {
855 //array_push($questiontypes, $row["type_tag"]);
856 if ($row["plugin"] == 0)
857 {
858 $types[$lng->txt($row["type_tag"])] = $row;
859 }
860 else
861 {
862 global $ilPluginAdmin;
863 $pl_names = $ilPluginAdmin->getActivePluginsForSlot(IL_COMP_MODULE, "SurveyQuestionPool", "svyq");
864 foreach ($pl_names as $pl_name)
865 {
866 $pl = ilPlugin::getPluginObject(IL_COMP_MODULE, "SurveyQuestionPool", "svyq", $pl_name);
867 if (strcmp($pl->getQuestionType(), $row["type_tag"]) == 0)
868 {
869 $types[$pl->getQuestionTypeTranslation()] = $row;
870 }
871 }
872 }
873 }
874 ksort($types);
875
876
877 // #14263 - default sorting
878
879 $default_sorting = array_flip(array(
880 "SurveySingleChoiceQuestion",
881 "SurveyMultipleChoiceQuestion",
882 "SurveyMatrixQuestion",
883 "SurveyMetricQuestion",
884 "SurveyTextQuestion"
885 ));
886
887 $sorted = array();
888 $idx = sizeof($default_sorting);
889 foreach($types as $caption => $item)
890 {
891 $type = $item["type_tag"];
892 $item["caption"] = $caption;
893
894 // default
895 if(array_key_exists($type, $default_sorting))
896 {
897 $sorted[$default_sorting[$type]] = $item;
898 }
899 // plugin (append alphabetically sorted)
900 else
901 {
902 $sorted[$idx] = $item;
903 $idx++;
904 }
905 }
906 ksort($sorted);
907
908 // redo captions as index
909 $types = array();
910 foreach($sorted as $item)
911 {
912 $types[$item["caption"]] = $item;
913 }
914
915 return $types;
916 }
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 918 of file class.ilObjSurveyQuestionPool.php.

919 {
920 global $ilDB;
921 global $lng;
922 global $ilLog;
923 global $ilPluginAdmin;
924
925 $lng->loadLanguageModule("survey");
926 $result = $ilDB->query("SELECT * FROM svy_qtype");
927 $types = array();
928 while ($row = $ilDB->fetchAssoc($result))
929 {
930 if ($row["plugin"] == 0)
931 {
932 $types[$row['type_tag']] = $lng->txt($row["type_tag"]);
933 }
934 else
935 {
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[$row['type_tag']] = $pl->getQuestionTypeTranslation();
943 }
944 }
945 }
946 }
947 ksort($types);
948 return $types;
949 }

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()

static ilObjSurveyQuestionPool::_isWriteable (   $object_id,
  $user_id 
)
static

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

823 {
824 global $rbacsystem;
825 global $ilDB;
826
827 $refs = ilObject::_getAllReferences($object_id);
828 $result = false;
829 foreach ($refs as $ref)
830 {
831 if ($rbacsystem->checkAccess("write", $ref) && (ilObject::_hasUntrashedReference($object_id)))
832 {
833 $result = true;
834 }
835 }
836 return $result;
837 }
static _getAllReferences($a_id)
get all reference ids of object
static _hasUntrashedReference($a_obj_id)
checks wether an object has at least one reference that is not in trash

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()

static ilObjSurveyQuestionPool::_lookupOnline (   $a_obj_id)
static

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

800 {
801 global $ilDB;
802
803 $result = $ilDB->queryF("SELECT isonline FROM svy_qpl WHERE obj_fi = %s",
804 array('integer'),
805 array($a_obj_id)
806 );
807 if ($result->numRows() == 1)
808 {
809 $row = $ilDB->fetchAssoc($result);
810 return $row["isonline"];
811 }
812 return 0;
813 }

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

755 {
756 global $ilDB;
757
758 $status = "0";
759 switch ($a_online_status)
760 {
761 case 0:
762 case 1:
763 $status = "$a_online_status";
764 break;
765 }
766 $affectedRows = $ilDB->manipulateF("UPDATE svy_qpl SET isonline = %s WHERE obj_fi = %s",
767 array('text','integer'),
768 array($status, $a_obj_id)
769 );
770 }

References $ilDB.

◆ cloneObject()

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

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

@access public

Reimplemented from ilObject.

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

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

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

References $counter, 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 1061 of file class.ilObjSurveyQuestionPool.php.

1062 {
1063 if (!array_key_exists("spl_clipboard", $_SESSION))
1064 {
1065 $_SESSION["spl_clipboard"] = array();
1066 }
1067 $_SESSION["spl_clipboard"][$question_id] = array("question_id" => $question_id, "action" => "copy");
1068 }
$_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)

Exceptions
ilSurveyException

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

489 {
490 $spl_data_dir = ilUtil::getDataDir()."/spl_data";
491 ilUtil::makeDir($spl_data_dir);
492 if(!is_writable($spl_data_dir))
493 {
494 include_once "Modules/Survey/exceptions/class.ilSurveyException.php";
495 throw new ilSurveyException("Survey Questionpool Data Directory (".$spl_data_dir.") not writeable.");
496 }
497
498 // create learning module directory (data_dir/lm_data/lm_<id>)
499 $spl_dir = $spl_data_dir."/spl_".$this->getId();
500 ilUtil::makeDir($spl_dir);
501 if(!@is_dir($spl_dir))
502 {
503 include_once "Modules/Survey/exceptions/class.ilSurveyException.php";
504 throw new ilSurveyException("Creation of Survey Questionpool Directory failed.");
505 }
506 // create Export subdirectory (data_dir/lm_data/lm_<id>/Export)
507 $export_dir = $spl_dir."/export";
508 ilUtil::makeDir($export_dir);
509 if(!@is_dir($export_dir))
510 {
511 include_once "Modules/Survey/exceptions/class.ilSurveyException.php";
512 throw new ilSurveyException("Creation of Survey Questionpool Export Directory failed.");
513 }
514 }
Survey exception class.
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 ...

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)

Exceptions
ilSurveyException

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

571 {
572 $spl_data_dir = ilUtil::getDataDir()."/spl_data";
573 ilUtil::makeDir($spl_data_dir);
574
575 if(!is_writable($spl_data_dir))
576 {
577 include_once "Modules/Survey/exceptions/class.ilSurveyException.php";
578 throw new ilSurveyException("Survey Questionpool Data Directory (".$spl_data_dir.") not writeable.");
579 }
580
581 // create test directory (data_dir/spl_data/spl_<id>)
582 $spl_dir = $spl_data_dir."/spl_".$this->getId();
583 ilUtil::makeDir($spl_dir);
584 if(!@is_dir($spl_dir))
585 {
586 include_once "Modules/Survey/exceptions/class.ilSurveyException.php";
587 throw new ilSurveyException("Creation of Survey Questionpool Directory failed.");
588 }
589
590 // create import subdirectory (data_dir/spl_data/spl_<id>/import)
591 $import_dir = $spl_dir."/import";
592 ilUtil::makeDir($import_dir);
593 if(!@is_dir($import_dir))
594 {
595 include_once "Modules/Survey/exceptions/class.ilSurveyException.php";
596 throw new ilSurveyException("Creation of Survey Questionpool Import Directory failed.");
597 }
598 }

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

135 {
136 if ((!$question_type) and ($question_id > 0))
137 {
138 $question_type = $this->getQuestiontype($question_id);
139 }
140
141 include_once "./Modules/SurveyQuestionPool/classes/class.".$question_type."GUI.php";
142 $question_type_gui = $question_type . "GUI";
143 $question = new $question_type_gui();
144
145 if ($question_id > 0)
146 {
147 $question->object->loadFromDb($question_id);
148 }
149
150 return $question;
151 }
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 243 of file class.ilObjSurveyQuestionPool.php.

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

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

+ Here is the call graph for this function:

◆ deleteAllData()

ilObjSurveyQuestionPool::deleteAllData ( )

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

262 {
263 global $ilDB;
264 $result = $ilDB->queryF("SELECT question_id FROM svy_question WHERE obj_fi = %s AND original_id IS NULL",
265 array('integer'),
266 array($this->getId())
267 );
268 $found_questions = array();
269 while ($row = $ilDB->fetchAssoc($result))
270 {
271 $this->removeQuestion($row["question_id"]);
272 }
273
274 // delete export files
275 $spl_data_dir = ilUtil::getDataDir()."/spl_data";
276 $directory = $spl_data_dir."/spl_".$this->getId();
277 if (is_dir($directory))
278 {
279 ilUtil::delDir($directory);
280 }
281 }
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 404 of file class.ilObjSurveyQuestionPool.php.

405 {
406 global $ilUser;
407 include_once "./Modules/SurveyQuestionPool/classes/class.SurveyQuestion.php";
408 $question = SurveyQuestion::_instanciateQuestion($question_id);
409 $suffix = "";
410 $counter = 1;
411 while ($question->questionTitleExists($question->getTitle().$suffix, $obj_id))
412 {
413 $counter++;
414 if ($counter > 1) $suffix = " ($counter)";
415 }
416 if ($obj_id)
417 {
418 $question->setObjId($obj_id);
419 }
420 $question->duplicate(false, $question->getTitle() . $suffix, $ilUser->fullname, $ilUser->id);
421 }
static _instanciateQuestion($question_id)
Creates an instance of a question with a given question id.

References $counter, $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 519 of file class.ilObjSurveyQuestionPool.php.

520 {
521 $export_dir = ilUtil::getDataDir()."/spl_data"."/spl_".$this->getId()."/export";
522 return $export_dir;
523 }

References ilUtil\getDataDir().

+ Here is the call graph for this function:

◆ getExportFiles()

ilObjSurveyQuestionPool::getExportFiles (   $dir)

get export files

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

529 {
530 // quit if import dir not available
531 if (!@is_dir($dir) or
532 !is_writeable($dir))
533 {
534 return array();
535 }
536
537 // open directory
538 $dir = dir($dir);
539
540 // initialize array
541 $file = array();
542
543 // get files and save the in the array
544 while ($entry = $dir->read())
545 {
546 if ($entry != "." &&
547 $entry != ".." &&
548 preg_match("/^[0-9]{10}__[0-9]+__(spl_)*[0-9]+\.[A-Za-z]{3}$/", $entry))
549 {
550 $file[] = $entry;
551 }
552 }
553
554 // close import directory
555 $dir->close();
556 // sort files
557 sort ($file);
558 reset ($file);
559
560 return $file;
561 }
if(!file_exists("$old.txt")) if( $old===$new) if(file_exists("$new.txt")) $file

References $file.

◆ getImportDirectory()

ilObjSurveyQuestionPool::getImportDirectory ( )

get import directory of survey

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

604 {
605 $import_dir = ilUtil::getDataDir()."/spl_data".
606 "/spl_".$this->getId()."/import";
607 if(@is_dir($import_dir))
608 {
609 return $import_dir;
610 }
611 else
612 {
613 return false;
614 }
615 }

References ilUtil\getDataDir().

+ Here is the call graph for this function:

◆ getOnline()

ilObjSurveyQuestionPool::getOnline ( )

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

794 {
795 if (strcmp($this->online, "") == 0) $this->online = "0";
796 return $this->online;
797 }

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

1015 {
1016 global $ilDB;
1017
1018 $found = array();
1019 $query_result = $ilDB->query("SELECT svy_question.*, svy_qtype.type_tag FROM svy_question, svy_qtype " .
1020 "WHERE svy_question.questiontype_fi = svy_qtype.questiontype_id " .
1021 "AND svy_question.tstamp > 0 AND " . $ilDB->in('svy_question.question_id', $question_ids, false, 'integer') . " " .
1022 "ORDER BY svy_question.title");
1023 if ($query_result->numRows() > 0)
1024 {
1025 while ($data = $ilDB->fetchAssoc($query_result))
1026 {
1027 if (in_array($data["question_id"], $question_ids))
1028 {
1029 array_push($found, array('id' => $data["question_id"],
1030 'title' => $data["title"],
1031 'description' => $data["description"],
1032 'type_tag' => $data["type_tag"]));
1033 }
1034 }
1035 }
1036 return $found;
1037 }

References $data, and $ilDB.

◆ getQuestions()

& ilObjSurveyQuestionPool::getQuestions ( )

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

682 {
683 global $ilDB;
684 $questions = array();
685 $result = $ilDB->queryF("SELECT question_id FROM svy_question WHERE obj_fi = %s AND svy_question.tstamp > 0 AND original_id IS NULL",
686 array('integer'),
687 array($this->getId())
688 );
689 if ($result->numRows())
690 {
691 while ($row = $ilDB->fetchAssoc($result))
692 {
693 array_push($questions, $row["question_id"]);
694 }
695 }
696 return $questions;
697 }

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

429 {
430 global $ilUser;
431 global $ilDB;
432 $where = "";
433 if (is_array($arrFilter))
434 {
435 foreach ($arrFilter as $key => $value)
436 {
437 $arrFilter[$key] = str_replace('%', '', $arrFilter[$key]);
438 }
439 if (array_key_exists('title', $arrFilter) && strlen($arrFilter['title']))
440 {
441 $where .= " AND " . $ilDB->like('svy_question.title', 'text', "%%" . $arrFilter['title'] . "%%");
442 }
443 if (array_key_exists('description', $arrFilter) && strlen($arrFilter['description']))
444 {
445 $where .= " AND " . $ilDB->like('svy_question.description', 'text', "%%" . $arrFilter['description'] . "%%");
446 }
447 if (array_key_exists('author', $arrFilter) && strlen($arrFilter['author']))
448 {
449 $where .= " AND " . $ilDB->like('svy_question.author', 'text', "%%" . $arrFilter['author'] . "%%");
450 }
451 if (array_key_exists('type', $arrFilter) && strlen($arrFilter['type']))
452 {
453 $where .= " AND svy_qtype.type_tag = " . $ilDB->quote($arrFilter['type'], 'text');
454 }
455 }
456 $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,
457 array('integer'),
458 array($this->getId())
459 );
460 $rows = array();
461 if ($query_result->numRows())
462 {
463 while ($row = $ilDB->fetchAssoc($query_result))
464 {
465 if ($row["plugin"])
466 {
467 if ($this->isPluginActive($row["type_tag"]))
468 {
469 array_push($rows, $row);
470 }
471 }
472 else
473 {
474 array_push($rows, $row);
475 }
476 }
477 }
478 return $rows;
479 }
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 376 of file class.ilObjSurveyQuestionPool.php.

377 {
378 global $ilDB;
379 $result_array = array();
380 $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'));
381 while ($row = $ilDB->fetchAssoc($result))
382 {
383 if ($row["plugin"])
384 {
385 if ($this->isPluginActive($row["type_tag"]))
386 {
387 array_push($result_array, $row);
388 }
389 }
390 else
391 {
392 array_push($result_array, $row);
393 }
394 }
395 return $result_array;
396 }

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

305 {
306 global $ilDB;
307 if ($question_id < 1) return;
308 $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",
309 array('integer'),
310 array($question_id)
311 );
312 if ($result->numRows() == 1)
313 {
314 $data = $ilDB->fetchAssoc($result);
315 return $data["type_tag"];
316 }
317 else
318 {
319 return;
320 }
321 }

References $data, $ilDB, and $result.

Referenced by createQuestion(), and toXML().

+ Here is the caller 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 705 of file class.ilObjSurveyQuestionPool.php.

706 {
707 if (is_file($source))
708 {
709 $isZip = (strcmp(strtolower(substr($source, -3)), 'zip') == 0);
710 if ($isZip)
711 {
712 // unzip file
713 ilUtil::unzip($source);
714
715 // determine filenames of xml files
716 $subdir = basename($source, ".zip");
717 $source = dirname($source)."/".$subdir."/".$subdir.".xml";
718 }
719
720 $fh = fopen($source, "r") or die("");
721 $xml = fread($fh, filesize($source));
722 fclose($fh) or die("");
723 if ($isZip)
724 {
725 $subdir = basename($source, ".zip");
726 if (@is_dir(dirname($source)."/".$subdir))
727 {
728 ilUtil::delDir(dirname($source)."/".$subdir);
729 }
730 }
731 if (strpos($xml, "questestinterop") > 0)
732 {
733 include_once("./Modules/Survey/exceptions/class.ilInvalidSurveyImportFileException.php");
734 throw new ilInvalidSurveyImportFileException("Unsupported survey version (< 3.8) found.");
735
736 // survey questions for ILIAS < 3.8
737 /*
738 include_once "./Services/Survey/classes/class.SurveyImportParserPre38.php";
739 $import = new SurveyImportParserPre38($this->getId(), "", $spl_exists);
740 $import->setXMLContent($xml);
741 $import->startParsing();*/
742 }
743 else
744 {
745 // survey questions for ILIAS >= 3.8
746 include_once "./Services/Survey/classes/class.SurveyImportParser.php";
747 $import = new SurveyImportParser($this->getId(), "", $spl_exists);
748 $import->setXMLContent($xml);
749 $import->startParsing();
750 }
751 }
752 }
PHPExcel root directory.
Definition: PHPExcel.php:30
Survey Question Import Parser.
static unzip($a_file, $overwrite=false, $a_flat=false)
unzip file

References $fh, 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 330 of file class.ilObjSurveyQuestionPool.php.

331 {
332 global $ilDB;
333 // check out the already answered questions
334 $result = $ilDB->queryF("SELECT answer_id FROM svy_answer WHERE question_fi = %s",
335 array('integer'),
336 array($question_id)
337 );
338 $answered = $result->numRows();
339
340 // check out the questions inserted in surveys
341 $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",
342 array('integer'),
343 array($question_id)
344 );
345 $inserted = $result->numRows();
346 if (($inserted + $answered) == 0)
347 {
348 return false;
349 }
350 $result_array = array();
351 while ($row = $ilDB->fetchObject($result))
352 {
353 array_push($result_array, $row);
354 }
355 return $result_array;
356 }

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

996 {
997 global $ilPluginAdmin;
998 if ($ilPluginAdmin->isActive(IL_COMP_MODULE, "SurveyQuestionPool", "svyq", $a_pname))
999 {
1000 return TRUE;
1001 }
1002 else
1003 {
1004 return FALSE;
1005 }
1006 }

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

191 {
192 global $ilDB;
193
194 $result = $ilDB->queryF("SELECT * FROM svy_qpl WHERE obj_fi = %s",
195 array('integer'),
196 array($this->getId())
197 );
198 if ($result->numRows() == 1)
199 {
200 $row = $ilDB->fetchAssoc($result);
201 $this->setOnline($row["isonline"]);
202 }
203 }
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 1075 of file class.ilObjSurveyQuestionPool.php.

1076 {
1077 if (!array_key_exists("spl_clipboard", $_SESSION))
1078 {
1079 $_SESSION["spl_clipboard"] = array();
1080 }
1081 $_SESSION["spl_clipboard"][$question_id] = array("question_id" => $question_id, "action" => "move");
1082 }

References $_SESSION.

◆ 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 364 of file class.ilObjSurveyQuestionPool.php.

365 {
366 $this->duplicateQuestion($question_id, $this->getId());
367 }

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

1088 {
1089 global $ilDB;
1090
1091 if (array_key_exists("spl_clipboard", $_SESSION))
1092 {
1093 foreach ($_SESSION["spl_clipboard"] as $question_object)
1094 {
1095 if (strcmp($question_object["action"], "move") == 0)
1096 {
1097 $result = $ilDB->queryF("SELECT obj_fi FROM svy_question WHERE question_id = %s",
1098 array('integer'),
1099 array($question_object["question_id"])
1100 );
1101 if ($result->numRows() == 1)
1102 {
1103 $row = $ilDB->fetchAssoc($result);
1104 $source_questionpool = $row["obj_fi"];
1105 if ($this->getId() != $source_questionpool)
1106 {
1107 // change the questionpool id in the qpl_questions table
1108 $affectedRows = $ilDB->manipulateF("UPDATE svy_question SET obj_fi = %s WHERE question_id = %s",
1109 array('integer','integer'),
1110 array($this->getId(), $question_object["question_id"])
1111 );
1112
1113 // move question data to the new target directory
1114 $source_path = CLIENT_WEB_DIR . "/survey/" . $source_questionpool . "/" . $question_object["question_id"] . "/";
1115 if (@is_dir($source_path))
1116 {
1117 $target_path = CLIENT_WEB_DIR . "/survey/" . $this->getId() . "/";
1118 if (!@is_dir($target_path))
1119 {
1120 ilUtil::makeDirParents($target_path);
1121 }
1122 @rename($source_path, $target_path . $question_object["question_id"]);
1123 }
1124 }
1125 else
1126 {
1127 ilUtil::sendFailure($this->lng->txt("spl_move_same_pool"), true);
1128 return;
1129 }
1130 }
1131 }
1132 else
1133 {
1134 $this->copyQuestion($question_object["question_id"], $this->getId());
1135 }
1136 }
1137 }
1138 ilUtil::sendSuccess($this->lng->txt("spl_paste_success"), true);
1139 unset($_SESSION["spl_clipboard"]);
1140 }
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 1042 of file class.ilObjSurveyQuestionPool.php.

1043 {
1044 global $ilDB, $ilUser;
1045
1046 $result = $ilDB->queryF("SELECT question_id FROM svy_question WHERE owner_fi = %s AND tstamp = %s",
1047 array("integer", "integer"),
1048 array($ilUser->getId(), 0)
1049 );
1050 while ($data = $ilDB->fetchAssoc($result))
1051 {
1052 $this->removeQuestion($data["question_id"]);
1053 }
1054 }

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

+ Here is the call graph for this function:

◆ read()

ilObjSurveyQuestionPool::read ( )

read object data from db into object @access public

Reimplemented from ilObject.

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

93 {
94 parent::read();
95 $this->loadFromDb();
96 }
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 289 of file class.ilObjSurveyQuestionPool.php.

290 {
291 if ($question_id < 1) return;
292 include_once "./Modules/SurveyQuestionPool/classes/class.SurveyQuestion.php";
293 $question =& SurveyQuestion::_instanciateQuestion($question_id);
294 $question->delete($question_id);
295 }

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

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

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

1149 {
1150 global $ilDB;
1151
1152 foreach($this->getQuestions() as $question_id)
1153 {
1154 $status = (int)(in_array($question_id, $obligatory_questions));
1155
1156 $ilDB->manipulate("UPDATE svy_question".
1157 " SET obligatory = ".$ilDB->quote($status, "integer").
1158 " WHERE question_id = ".$ilDB->quote($question_id, "integer"));
1159 }
1160 }

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

780 {
781 switch ($a_online_status)
782 {
783 case 0:
784 case 1:
785 $this->online = $a_online_status;
786 break;
787 default:
788 $this->online = 0;
789 break;
790 }
791 }

Referenced by loadFromDb().

+ Here is the caller graph for this function:

◆ toXML()

ilObjSurveyQuestionPool::toXML (   $questions)

export questions to xml

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

621 {
622 if (!is_array($questions))
623 {
624 $questions =& $this->getQuestions();
625 }
626 if (count($questions) == 0)
627 {
628 $questions =& $this->getQuestions();
629 }
630 $xml = "";
631
632 include_once("./Services/Xml/classes/class.ilXmlWriter.php");
633 $a_xml_writer = new ilXmlWriter;
634 // set xml header
635 $a_xml_writer->xmlHeader();
636 $attrs = array(
637 "xmlns:xsi" => "http://www.w3.org/2001/XMLSchema-instance",
638 "xsi:noNamespaceSchemaLocation" => "http://www.ilias.de/download/xsd/ilias_survey_4_2.xsd"
639 );
640 $a_xml_writer->xmlStartTag("surveyobject", $attrs);
641 $attrs = array(
642 "id" => "qpl_" . $this->getId(),
643 "label" => $this->getTitle(),
644 "online" => $this->getOnline()
645 );
646 $a_xml_writer->xmlStartTag("surveyquestions", $attrs);
647 $a_xml_writer->xmlElement("dummy", NULL, "dummy");
648 // add ILIAS specific metadata
649 $a_xml_writer->xmlStartTag("metadata");
650 $a_xml_writer->xmlStartTag("metadatafield");
651 $a_xml_writer->xmlElement("fieldlabel", NULL, "SCORM");
652 include_once "./Services/MetaData/classes/class.ilMD.php";
653 $md = new ilMD($this->getId(),0, $this->getType());
654 $writer = new ilXmlWriter();
655 $md->toXml($writer);
656 $metadata = $writer->xmlDumpMem();
657 $a_xml_writer->xmlElement("fieldentry", NULL, $metadata);
658 $a_xml_writer->xmlEndTag("metadatafield");
659 $a_xml_writer->xmlEndTag("metadata");
660
661 $a_xml_writer->xmlEndTag("surveyquestions");
662 $a_xml_writer->xmlEndTag("surveyobject");
663
664 $xml = $a_xml_writer->xmlDumpMem(FALSE);
665
666 $questionxml = "";
667 foreach ($questions as $key => $value)
668 {
669 $questiontype = $this->getQuestiontype($value);
670 include_once "./Modules/SurveyQuestionPool/classes/class.SurveyQuestion.php";
671 SurveyQuestion::_includeClass($questiontype);
672 $question = new $questiontype();
673 $question->loadFromDb($value);
674 $questionxml .= $question->toXML(false);
675 }
676
677 $xml = str_replace("<dummy>dummy</dummy>", $questionxml, $xml);
678 return $xml;
679 }
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: