ILIAS  release_5-0 Revision 5.0.0-1144-gc4397b1f870
ilObjSurveyQuestionPool Class Reference
+ Inheritance diagram for ilObjSurveyQuestionPool:
+ Collaboration diagram for ilObjSurveyQuestionPool:

Public Member Functions

 ilObjSurveyQuestionPool ($a_id=0, $a_call_by_reference=true)
 Constructor 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...
 
 getTitle ()
 get title of survey question pool object More...
 
 setTitle ($a_title)
 set title of survey question pool object 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 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 public More...
 
 setId ($a_id)
 set object id public More...
 
 setRefId ($a_id)
 set reference id public More...
 
 getRefId ()
 get reference id public More...
 
 getType ()
 get object type public More...
 
 setType ($a_type)
 set object type public More...
 
 getPresentationTitle ()
 get presentation title Normally same as title Overwritten for sessions More...
 
 getTitle ()
 get object title public More...
 
 getUntranslatedTitle ()
 get untranslated object title 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 public More...
 
 getLastUpdateDate ()
 get last update date public More...
 
 getDiskUsage ()
 Gets the disk usage of the object in bytes. More...
 
 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) 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...
 

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 _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 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 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 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 public

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

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

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

1044  {
1045  global $ilUser;
1046  global $ilDB;
1047 
1048  $result_array = array();
1049  $qpls = ilUtil::_getObjectsByOperations("spl", $permission, $ilUser->getId(), -1);
1050  $titles = ilObject::_prepareCloneSelection($qpls, "spl", $showPath);
1051  $allqpls = array();
1052  $result = $ilDB->query("SELECT obj_fi, isonline FROM svy_qpl");
1053  while ($row = $ilDB->fetchAssoc($result))
1054  {
1055  $allqpls[$row['obj_fi']] = $row['isonline'];
1056  }
1057  foreach ($qpls as $ref_id)
1058  {
1059  $obj_id = ilObject::_lookupObjectId($ref_id);
1060  if ($could_be_offline || $allqpls[$obj_id] == 1)
1061  {
1062  if ($use_object_id)
1063  {
1064  $result_array[$obj_id] = $titles[$ref_id];
1065  }
1066  else
1067  {
1068  $result_array[$ref_id] = $titles[$ref_id];
1069  }
1070  }
1071  }
1072  return $result_array;
1073  }
static _prepareCloneSelection($a_ref_ids, $new_type, $show_path=true)
Prepare copy wizard object selection.
$result
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, instead it parses the serialized rbac_pa entries.
static _lookupObjectId($a_ref_id)
lookup object id
global $ilUser
Definition: imgupload.php:15
global $ilDB
+ 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 public

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

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

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

◆ _getQuestionTypeTranslations()

static& ilObjSurveyQuestionPool::_getQuestionTypeTranslations ( )
static

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

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

Referenced by ilObjSurvey\getQuestionsTable().

1005  {
1006  global $ilDB;
1007  global $lng;
1008  global $ilLog;
1009  global $ilPluginAdmin;
1010 
1011  $lng->loadLanguageModule("survey");
1012  $result = $ilDB->query("SELECT * FROM svy_qtype");
1013  $types = array();
1014  while ($row = $ilDB->fetchAssoc($result))
1015  {
1016  if ($row["plugin"] == 0)
1017  {
1018  $types[$row['type_tag']] = $lng->txt($row["type_tag"]);
1019  }
1020  else
1021  {
1022  $pl_names = $ilPluginAdmin->getActivePluginsForSlot(IL_COMP_MODULE, "SurveyQuestionPool", "svyq");
1023  foreach ($pl_names as $pl_name)
1024  {
1025  $pl = ilPlugin::getPluginObject(IL_COMP_MODULE, "SurveyQuestionPool", "svyq", $pl_name);
1026  if (strcmp($pl->getQuestionType(), $row["type_tag"]) == 0)
1027  {
1028  $types[$row['type_tag']] = $pl->getQuestionTypeTranslation();
1029  }
1030  }
1031  }
1032  }
1033  ksort($types);
1034  return $types;
1035  }
static getPluginObject($a_ctype, $a_cname, $a_slot_id, $a_pname)
Get plugin object.
$result
const IL_COMP_MODULE
global $ilDB
+ 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 public

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

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

Referenced by SurveyQuestion\_isWriteable().

909  {
910  global $rbacsystem;
911  global $ilDB;
912 
913  $refs = ilObject::_getAllReferences($object_id);
914  $result = false;
915  foreach ($refs as $ref)
916  {
917  if ($rbacsystem->checkAccess("write", $ref) && (ilObject::_hasUntrashedReference($object_id)))
918  {
919  $result = true;
920  }
921  }
922  return $result;
923  }
$result
static _getAllReferences($a_id)
get all reference ids of object
_hasUntrashedReference($a_obj_id)
checks wether an object has at least one reference that is not in trash
global $ilDB
+ 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 885 of file class.ilObjSurveyQuestionPool.php.

References $ilDB, $result, and $row.

Referenced by ilObjSurveyQuestionPoolListGUI\getProperties().

886  {
887  global $ilDB;
888 
889  $result = $ilDB->queryF("SELECT isonline FROM svy_qpl WHERE obj_fi = %s",
890  array('integer'),
891  array($a_obj_id)
892  );
893  if ($result->numRows() == 1)
894  {
895  $row = $ilDB->fetchAssoc($result);
896  return $row["isonline"];
897  }
898  return 0;
899  }
$result
global $ilDB
+ Here is the caller graph for this function:

◆ _setOnline()

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

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

References $ilDB.

841  {
842  global $ilDB;
843 
844  $status = "0";
845  switch ($a_online_status)
846  {
847  case 0:
848  case 1:
849  $status = "$a_online_status";
850  break;
851  }
852  $affectedRows = $ilDB->manipulateF("UPDATE svy_qpl SET isonline = %s WHERE obj_fi = %s",
853  array('text','integer'),
854  array($status, $a_obj_id)
855  );
856  }
global $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.

public

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

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

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.
getId()
get object id public
getType()
get object type public
+ 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 public

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

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

Referenced by pasteFromClipboard().

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  }
duplicateQuestion($question_id, $obj_id="")
Duplicates a question for a questionpool.
getId()
get object id public
& createQuestion($question_type, $question_id=-1)
+ 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 1147 of file class.ilObjSurveyQuestionPool.php.

References $_SESSION.

1148  {
1149  if (!array_key_exists("spl_clipboard", $_SESSION))
1150  {
1151  $_SESSION["spl_clipboard"] = array();
1152  }
1153  $_SESSION["spl_clipboard"][$question_id] = array("question_id" => $question_id, "action" => "copy");
1154  }
< a tabindex="-1" style="border-style: none;" href="#" title="Refresh Image" onclick="document.getElementById('siimage').src = './securimage_show.php?sid=' + Math.random(); this.blur(); return false">< img src="./images/refresh.png" alt="Reload Image" height="32" width="32" onclick="this.blur()" align="bottom" border="0"/></a >< br/>< strong > Enter Code *if($_SERVER['REQUEST_METHOD']=='POST' &&@ $_POST['do']=='contact') $_SESSION['ctform']['success']

◆ create()

ilObjSurveyQuestionPool::create (   $a_upload = false)

create question pool object

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

References ilObject\createMetaData().

61  {
62  parent::create();
63  if(!$a_upload)
64  {
65  $this->createMetaData();
66  }
67  }
createMetaData()
create meta data entry
+ 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 580 of file class.ilObjSurveyQuestionPool.php.

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

581  {
582  include_once "./Services/Utilities/classes/class.ilUtil.php";
583  $spl_data_dir = ilUtil::getDataDir()."/spl_data";
584  ilUtil::makeDir($spl_data_dir);
585  if(!is_writable($spl_data_dir))
586  {
587  $this->ilias->raiseError("Survey Questionpool Data Directory (".$spl_data_dir
588  .") not writeable.",$this->ilias->error_obj->FATAL);
589  }
590 
591  // create learning module directory (data_dir/lm_data/lm_<id>)
592  $spl_dir = $spl_data_dir."/spl_".$this->getId();
593  ilUtil::makeDir($spl_dir);
594  if(!@is_dir($spl_dir))
595  {
596  $this->ilias->raiseError("Creation of Survey Questionpool Directory failed.",$this->ilias->error_obj->FATAL);
597  }
598  // create Export subdirectory (data_dir/lm_data/lm_<id>/Export)
599  $export_dir = $spl_dir."/export";
600  ilUtil::makeDir($export_dir);
601  if(!@is_dir($export_dir))
602  {
603  $this->ilias->raiseError("Creation of Export Directory failed.",$this->ilias->error_obj->FATAL);
604  }
605  }
getId()
get object id public
redirection script todo: (a better solution should control the processing via a xml file) ...
static makeDir($a_dir)
creates a new directory and inherits all filesystem permissions of the parent directory You may pass ...
static getDataDir()
get data directory (outside webspace)
+ 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 660 of file class.ilObjSurveyQuestionPool.php.

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

661  {
662  include_once "./Services/Utilities/classes/class.ilUtil.php";
663  $spl_data_dir = ilUtil::getDataDir()."/spl_data";
664  ilUtil::makeDir($spl_data_dir);
665 
666  if(!is_writable($spl_data_dir))
667  {
668  $this->ilias->raiseError("Survey Questionpool Data Directory (".$spl_data_dir
669  .") not writeable.",$this->ilias->error_obj->FATAL);
670  }
671 
672  // create test directory (data_dir/spl_data/spl_<id>)
673  $spl_dir = $spl_data_dir."/spl_".$this->getId();
674  ilUtil::makeDir($spl_dir);
675  if(!@is_dir($spl_dir))
676  {
677  $this->ilias->raiseError("Creation of Survey Questionpool Directory failed.",$this->ilias->error_obj->FATAL);
678  }
679 
680  // create import subdirectory (data_dir/spl_data/spl_<id>/import)
681  $import_dir = $spl_dir."/import";
682  ilUtil::makeDir($import_dir);
683  if(!@is_dir($import_dir))
684  {
685  $this->ilias->raiseError("Creation of Import Directory failed.",$this->ilias->error_obj->FATAL);
686  }
687  }
getId()
get object id public
redirection script todo: (a better solution should control the processing via a xml file) ...
static makeDir($a_dir)
creates a new directory and inherits all filesystem permissions of the parent directory You may pass ...
static getDataDir()
get data directory (outside webspace)
+ 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.

References getQuestiontype().

Referenced by copyQuestion().

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.
+ 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

public

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

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

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

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

◆ deleteAllData()

ilObjSurveyQuestionPool::deleteAllData ( )

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

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

Referenced by delete().

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

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

References $ilUser, and SurveyQuestion\_instanciateQuestion().

Referenced by copyQuestion(), and paste().

491  {
492  global $ilUser;
493  include_once "./Modules/SurveyQuestionPool/classes/class.SurveyQuestion.php";
494  $question = SurveyQuestion::_instanciateQuestion($question_id);
495  $suffix = "";
496  $counter = 1;
497  while ($question->questionTitleExists($question->getTitle().$suffix, $obj_id))
498  {
499  $counter++;
500  if ($counter > 1) $suffix = " ($counter)";
501  }
502  if ($obj_id)
503  {
504  $question->setObjId($obj_id);
505  }
506  $question->duplicate(false, $question->getTitle() . $suffix, $ilUser->fullname, $ilUser->id);
507  }
global $ilUser
Definition: imgupload.php:15
& _instanciateQuestion($question_id)
Creates an instance of a question with a given question id.
+ 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 610 of file class.ilObjSurveyQuestionPool.php.

References ilUtil\getDataDir().

611  {
612  include_once "./Services/Utilities/classes/class.ilUtil.php";
613  $export_dir = ilUtil::getDataDir()."/spl_data"."/spl_".$this->getId()."/export";
614  return $export_dir;
615  }
static getDataDir()
get data directory (outside webspace)
+ Here is the call graph for this function:

◆ getExportFiles()

ilObjSurveyQuestionPool::getExportFiles (   $dir)

get export files

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

References $file.

621  {
622  // quit if import dir not available
623  if (!@is_dir($dir) or
624  !is_writeable($dir))
625  {
626  return array();
627  }
628 
629  // open directory
630  $dir = dir($dir);
631 
632  // initialize array
633  $file = array();
634 
635  // get files and save the in the array
636  while ($entry = $dir->read())
637  {
638  if ($entry != "." &&
639  $entry != ".." &&
640  ereg("^[0-9]{10}_{2}[0-9]+_{2}(spl_)*[0-9]+\.[A-Za-z]{3}\$", $entry))
641  {
642  $file[] = $entry;
643  }
644  }
645 
646  // close import directory
647  $dir->close();
648  // sort files
649  sort ($file);
650  reset ($file);
651 
652  return $file;
653  }
print $file

◆ getImportDirectory()

ilObjSurveyQuestionPool::getImportDirectory ( )

get import directory of survey

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

References ilUtil\getDataDir().

693  {
694  include_once "./Services/Utilities/classes/class.ilUtil.php";
695  $import_dir = ilUtil::getDataDir()."/spl_data".
696  "/spl_".$this->getId()."/import";
697  if(@is_dir($import_dir))
698  {
699  return $import_dir;
700  }
701  else
702  {
703  return false;
704  }
705  }
static getDataDir()
get data directory (outside webspace)
+ Here is the call graph for this function:

◆ getOnline()

ilObjSurveyQuestionPool::getOnline ( )

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

References $online.

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

880  {
881  if (strcmp($this->online, "") == 0) $this->online = "0";
882  return $this->online;
883  }
+ 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 1100 of file class.ilObjSurveyQuestionPool.php.

References $data, and $ilDB.

1101  {
1102  global $ilDB;
1103 
1104  $found = array();
1105  $query_result = $ilDB->query("SELECT svy_question.*, svy_qtype.type_tag FROM svy_question, svy_qtype " .
1106  "WHERE svy_question.questiontype_fi = svy_qtype.questiontype_id " .
1107  "AND svy_question.tstamp > 0 AND " . $ilDB->in('svy_question.question_id', $question_ids, false, 'integer') . " " .
1108  "ORDER BY svy_question.title");
1109  if ($query_result->numRows() > 0)
1110  {
1111  while ($data = $ilDB->fetchAssoc($query_result))
1112  {
1113  if (in_array($data["question_id"], $question_ids))
1114  {
1115  array_push($found, array('id' => $data["question_id"],
1116  'title' => $data["title"],
1117  'description' => $data["description"],
1118  'type_tag' => $data["type_tag"]));
1119  }
1120  }
1121  }
1122  return $found;
1123  }
global $ilDB

◆ getQuestions()

& ilObjSurveyQuestionPool::getQuestions ( )

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

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

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

772  {
773  global $ilDB;
774  $questions = array();
775  $result = $ilDB->queryF("SELECT question_id FROM svy_question WHERE obj_fi = %s AND svy_question.tstamp > 0 AND original_id IS NULL",
776  array('integer'),
777  array($this->getId())
778  );
779  if ($result->numRows())
780  {
781  while ($row = $ilDB->fetchAssoc($result))
782  {
783  array_push($questions, $row["question_id"]);
784  }
785  }
786  return $questions;
787  }
$result
getId()
get object id public
global $ilDB
+ 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.

public

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

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

515  {
516  global $ilUser;
517  global $ilDB;
518  $where = "";
519  if (is_array($arrFilter))
520  {
521  foreach ($arrFilter as $key => $value)
522  {
523  $arrFilter[$key] = str_replace('%', '', $arrFilter[$key]);
524  }
525  if (array_key_exists('title', $arrFilter) && strlen($arrFilter['title']))
526  {
527  $where .= " AND " . $ilDB->like('svy_question.title', 'text', "%%" . $arrFilter['title'] . "%%");
528  }
529  if (array_key_exists('description', $arrFilter) && strlen($arrFilter['description']))
530  {
531  $where .= " AND " . $ilDB->like('svy_question.description', 'text', "%%" . $arrFilter['description'] . "%%");
532  }
533  if (array_key_exists('author', $arrFilter) && strlen($arrFilter['author']))
534  {
535  $where .= " AND " . $ilDB->like('svy_question.author', 'text', "%%" . $arrFilter['author'] . "%%");
536  }
537  if (array_key_exists('type', $arrFilter) && strlen($arrFilter['type']))
538  {
539  $where .= " AND svy_qtype.type_tag = " . $ilDB->quote($arrFilter['type'], 'text');
540  }
541  }
542  $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,
543  array('integer'),
544  array($this->getId())
545  );
546  $rows = array();
547  if ($query_result->numRows())
548  {
549  while ($row = $ilDB->fetchAssoc($query_result))
550  {
551  // first part fix #19469
552  $set = $ilDB->query("SELECT question_fi FROM svy_svy_qst ".
553  " WHERE question_fi = ".$ilDB->quote($row["question_id"], "integer")
554  );
555  if ($temp = $ilDB->fetchAssoc($set))
556  {
557  continue;
558  }
559  if ($row["plugin"])
560  {
561  if ($this->isPluginActive($row["type_tag"]))
562  {
563  array_push($rows, $row);
564  }
565  }
566  else
567  {
568  array_push($rows, $row);
569  }
570  }
571  }
572  return $rows;
573  }
isPluginActive($a_pname)
Checks whether or not a question plugin with a given name is active.
getId()
get object id public
global $ilUser
Definition: imgupload.php:15
global $ilDB
+ 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 public

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

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

463  {
464  global $ilDB;
465  $result_array = array();
466  $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'));
467  while ($row = $ilDB->fetchAssoc($result))
468  {
469  if ($row["plugin"])
470  {
471  if ($this->isPluginActive($row["type_tag"]))
472  {
473  array_push($result_array, $row);
474  }
475  }
476  else
477  {
478  array_push($result_array, $row);
479  }
480  }
481  return $result_array;
482  }
$result
isPluginActive($a_pname)
Checks whether or not a question plugin with a given name is active.
global $ilDB
+ 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 private

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

References $data, $ilDB, and $result.

Referenced by createQuestion(), and toXML().

391  {
392  global $ilDB;
393  if ($question_id < 1) return;
394  $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",
395  array('integer'),
396  array($question_id)
397  );
398  if ($result->numRows() == 1)
399  {
400  $data = $ilDB->fetchAssoc($result);
401  return $data["type_tag"];
402  }
403  else
404  {
405  return;
406  }
407  }
$result
global $ilDB
+ Here is the caller graph for this function:

◆ getTitle()

ilObjSurveyQuestionPool::getTitle ( )

get title of survey question pool object

Returns
string title

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

Referenced by toXML().

356  {
357  //return $this->title;
358  return parent::getTitle();
359  }
+ Here is the caller graph for this function:

◆ ilObjSurveyQuestionPool()

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

Constructor 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.

References ilObject\ilObject().

52  {
53  $this->type = "spl";
54  $this->ilObject($a_id,$a_call_by_reference);
55  }
ilObject($a_id=0, $a_reference=true)
Constructor public.
+ 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 public

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

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

796  {
797  if (is_file($source))
798  {
799  $isZip = (strcmp(strtolower(substr($source, -3)), 'zip') == 0);
800  if ($isZip)
801  {
802  // unzip file
803  ilUtil::unzip($source);
804 
805  // determine filenames of xml files
806  $subdir = basename($source, ".zip");
807  $source = dirname($source)."/".$subdir."/".$subdir.".xml";
808  }
809 
810  $fh = fopen($source, "r") or die("");
811  $xml = fread($fh, filesize($source));
812  fclose($fh) or die("");
813  if ($isZip)
814  {
815  $subdir = basename($source, ".zip");
816  if (@is_dir(dirname($source)."/".$subdir))
817  {
818  ilUtil::delDir(dirname($source)."/".$subdir);
819  }
820  }
821  if (strpos($xml, "questestinterop") > 0)
822  {
823  // survey questions for ILIAS < 3.8
824  include_once "./Services/Survey/classes/class.SurveyImportParserPre38.php";
825  $import = new SurveyImportParserPre38($this->getId(), "", $spl_exists);
826  $import->setXMLContent($xml);
827  $import->startParsing();
828  }
829  else
830  {
831  // survey questions for ILIAS >= 3.8
832  include_once "./Services/Survey/classes/class.SurveyImportParser.php";
833  $import = new SurveyImportParser($this->getId(), "", $spl_exists);
834  $import->setXMLContent($xml);
835  $import->startParsing();
836  }
837  }
838  }
static unzip($a_file, $overwrite=false, $a_flat=false)
unzip file
Survey Question Import Parser.
getId()
get object id public
if(!file_exists(getcwd().'/ilias.ini.php')) if(isset( $_GET["client_id"]))
registration confirmation script for ilias
Definition: confirmReg.php:20
static delDir($a_dir, $a_clean_only=false)
removes a dir and all its content (subdirs and files) recursively
Survey Question Import Parser.
+ 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 public

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

References $ilDB, $result, and $row.

417  {
418  global $ilDB;
419  // check out the already answered questions
420  $result = $ilDB->queryF("SELECT answer_id FROM svy_answer WHERE question_fi = %s",
421  array('integer'),
422  array($question_id)
423  );
424  $answered = $result->numRows();
425 
426  // check out the questions inserted in surveys
427  $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",
428  array('integer'),
429  array($question_id)
430  );
431  $inserted = $result->numRows();
432  if (($inserted + $answered) == 0)
433  {
434  return false;
435  }
436  $result_array = array();
437  while ($row = $ilDB->fetchObject($result))
438  {
439  array_push($result_array, $row);
440  }
441  return $result_array;
442  }
$result
global $ilDB

◆ isPluginActive()

ilObjSurveyQuestionPool::isPluginActive (   $a_pname)

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

Parameters
string$a_pnameThe plugin name public

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

References IL_COMP_MODULE.

Referenced by getQuestionsData(), and getQuestionsInfo().

1082  {
1083  global $ilPluginAdmin;
1084  if ($ilPluginAdmin->isActive(IL_COMP_MODULE, "SurveyQuestionPool", "svyq", $a_pname))
1085  {
1086  return TRUE;
1087  }
1088  else
1089  {
1090  return FALSE;
1091  }
1092  }
const IL_COMP_MODULE
+ Here is the caller graph for this function:

◆ loadFromDb()

ilObjSurveyQuestionPool::loadFromDb ( )

Loads a ilObjQuestionpool object from a database.

public

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

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

Referenced by read().

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  }
$result
setOnline($a_online_status)
Sets the questionpool online status.
getId()
get object id public
global $ilDB
+ 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 1161 of file class.ilObjSurveyQuestionPool.php.

References $_SESSION.

1162  {
1163  if (!array_key_exists("spl_clipboard", $_SESSION))
1164  {
1165  $_SESSION["spl_clipboard"] = array();
1166  }
1167  $_SESSION["spl_clipboard"][$question_id] = array("question_id" => $question_id, "action" => "move");
1168  }
< a tabindex="-1" style="border-style: none;" href="#" title="Refresh Image" onclick="document.getElementById('siimage').src = './securimage_show.php?sid=' + Math.random(); this.blur(); return false">< img src="./images/refresh.png" alt="Reload Image" height="32" width="32" onclick="this.blur()" align="bottom" border="0"/></a >< br/>< strong > Enter Code *if($_SERVER['REQUEST_METHOD']=='POST' &&@ $_POST['do']=='contact') $_SESSION['ctform']['success']

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

public

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

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

References $_GET, and ilObject\getType().

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

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

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

451  {
452  $this->duplicateQuestion($question_id, $this->getId());
453  }
duplicateQuestion($question_id, $obj_id="")
Duplicates a question for a questionpool.
getId()
get object id public
+ Here is the call graph for this function:

◆ pasteFromClipboard()

ilObjSurveyQuestionPool::pasteFromClipboard ( )

Copies/Moves a question from the clipboard.

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

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

1174  {
1175  global $ilDB;
1176 
1177  if (array_key_exists("spl_clipboard", $_SESSION))
1178  {
1179  foreach ($_SESSION["spl_clipboard"] as $question_object)
1180  {
1181  if (strcmp($question_object["action"], "move") == 0)
1182  {
1183  $result = $ilDB->queryF("SELECT obj_fi FROM svy_question WHERE question_id = %s",
1184  array('integer'),
1185  array($question_object["question_id"])
1186  );
1187  if ($result->numRows() == 1)
1188  {
1189  $row = $ilDB->fetchAssoc($result);
1190  $source_questionpool = $row["obj_fi"];
1191  if ($this->getId() != $source_questionpool)
1192  {
1193  // change the questionpool id in the qpl_questions table
1194  $affectedRows = $ilDB->manipulateF("UPDATE svy_question SET obj_fi = %s WHERE question_id = %s",
1195  array('integer','integer'),
1196  array($this->getId(), $question_object["question_id"])
1197  );
1198 
1199  // move question data to the new target directory
1200  $source_path = CLIENT_WEB_DIR . "/survey/" . $source_questionpool . "/" . $question_object["question_id"] . "/";
1201  if (@is_dir($source_path))
1202  {
1203  $target_path = CLIENT_WEB_DIR . "/survey/" . $this->getId() . "/";
1204  if (!@is_dir($target_path))
1205  {
1206  include_once "./Services/Utilities/classes/class.ilUtil.php";
1207  ilUtil::makeDirParents($target_path);
1208  }
1209  @rename($source_path, $target_path . $question_object["question_id"]);
1210  }
1211  }
1212  else
1213  {
1214  ilUtil::sendFailure($this->lng->txt("spl_move_same_pool"), true);
1215  return;
1216  }
1217  }
1218  }
1219  else
1220  {
1221  $this->copyQuestion($question_object["question_id"], $this->getId());
1222  }
1223  }
1224  }
1225  ilUtil::sendSuccess($this->lng->txt("spl_paste_success"), true);
1226  unset($_SESSION["spl_clipboard"]);
1227  }
< a tabindex="-1" style="border-style: none;" href="#" title="Refresh Image" onclick="document.getElementById('siimage').src = './securimage_show.php?sid=' + Math.random(); this.blur(); return false">< img src="./images/refresh.png" alt="Reload Image" height="32" width="32" onclick="this.blur()" align="bottom" border="0"/></a >< br/>< strong > Enter Code *if($_SERVER['REQUEST_METHOD']=='POST' &&@ $_POST['do']=='contact') $_SESSION['ctform']['success']
static sendSuccess($a_info="", $a_keep=false)
Send Success Message to Screen.
static makeDirParents($a_dir)
Create a new directory and all parent directories.
$result
copyQuestion($question_id, $questionpool_to)
Copies a question into another question pool.
getId()
get object id public
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
global $ilDB
+ Here is the call graph for this function:

◆ purgeQuestions()

ilObjSurveyQuestionPool::purgeQuestions ( )

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

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

1129  {
1130  global $ilDB, $ilUser;
1131 
1132  $result = $ilDB->queryF("SELECT question_id FROM svy_question WHERE owner_fi = %s AND tstamp = %s",
1133  array("integer", "integer"),
1134  array($ilUser->getId(), 0)
1135  );
1136  while ($data = $ilDB->fetchAssoc($result))
1137  {
1138  $this->removeQuestion($data["question_id"]);
1139  }
1140  }
$result
removeQuestion($question_id)
Removes a question from the question pool.
global $ilUser
Definition: imgupload.php:15
global $ilDB
+ Here is the call graph for this function:

◆ read()

ilObjSurveyQuestionPool::read (   $a_force_db = false)

read object data from db into object

Parameters
booleanpublic

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

References loadFromDb().

94  {
95  parent::read($a_force_db);
96  $this->loadFromDb();
97  }
loadFromDb()
Loads a ilObjQuestionpool object from a database.
+ 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 private

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

References SurveyQuestion\_instanciateQuestion().

Referenced by deleteAllData(), and purgeQuestions().

376  {
377  if ($question_id < 1) return;
378  include_once "./Modules/SurveyQuestionPool/classes/class.SurveyQuestion.php";
379  $question =& SurveyQuestion::_instanciateQuestion($question_id);
380  $question->delete($question_id);
381  }
& _instanciateQuestion($question_id)
Creates an instance of a question with a given question id.
+ 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.

public

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

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

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

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

References $ilDB, and getQuestions().

1236  {
1237  global $ilDB;
1238 
1239  foreach($this->getQuestions() as $question_id)
1240  {
1241  $status = (int)(in_array($question_id, $obligatory_questions));
1242 
1243  $ilDB->manipulate("UPDATE svy_question".
1244  " SET obligatory = ".$ilDB->quote($status, "integer").
1245  " WHERE question_id = ".$ilDB->quote($question_id, "integer"));
1246  }
1247  }
global $ilDB
+ 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 User interface

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

Referenced by loadFromDb().

866  {
867  switch ($a_online_status)
868  {
869  case 0:
870  case 1:
871  $this->online = $a_online_status;
872  break;
873  default:
874  $this->online = 0;
875  break;
876  }
877  }
+ Here is the caller graph for this function:

◆ setTitle()

ilObjSurveyQuestionPool::setTitle (   $a_title)

set title of survey question pool object

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

365  {
366  parent::setTitle($a_title);
367  }

◆ toXML()

ilObjSurveyQuestionPool::toXML (   $questions)

export questions to xml

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

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

711  {
712  if (!is_array($questions))
713  {
714  $questions =& $this->getQuestions();
715  }
716  if (count($questions) == 0)
717  {
718  $questions =& $this->getQuestions();
719  }
720  $xml = "";
721 
722  include_once("./Services/Xml/classes/class.ilXmlWriter.php");
723  $a_xml_writer = new ilXmlWriter;
724  // set xml header
725  $a_xml_writer->xmlHeader();
726  $attrs = array(
727  "xmlns:xsi" => "http://www.w3.org/2001/XMLSchema-instance",
728  "xsi:noNamespaceSchemaLocation" => "http://www.ilias.de/download/xsd/ilias_survey_4_2.xsd"
729  );
730  $a_xml_writer->xmlStartTag("surveyobject", $attrs);
731  $attrs = array(
732  "id" => "qpl_" . $this->getId(),
733  "label" => $this->getTitle(),
734  "online" => $this->getOnline()
735  );
736  $a_xml_writer->xmlStartTag("surveyquestions", $attrs);
737  $a_xml_writer->xmlElement("dummy", NULL, "dummy");
738  // add ILIAS specific metadata
739  $a_xml_writer->xmlStartTag("metadata");
740  $a_xml_writer->xmlStartTag("metadatafield");
741  $a_xml_writer->xmlElement("fieldlabel", NULL, "SCORM");
742  include_once "./Services/MetaData/classes/class.ilMD.php";
743  $md = new ilMD($this->getId(),0, $this->getType());
744  $writer = new ilXmlWriter();
745  $md->toXml($writer);
746  $metadata = $writer->xmlDumpMem();
747  $a_xml_writer->xmlElement("fieldentry", NULL, $metadata);
748  $a_xml_writer->xmlEndTag("metadatafield");
749  $a_xml_writer->xmlEndTag("metadata");
750 
751  $a_xml_writer->xmlEndTag("surveyquestions");
752  $a_xml_writer->xmlEndTag("surveyobject");
753 
754  $xml = $a_xml_writer->xmlDumpMem(FALSE);
755 
756  $questionxml = "";
757  foreach ($questions as $key => $value)
758  {
759  $questiontype = $this->getQuestiontype($value);
760  include_once "./Modules/SurveyQuestionPool/classes/class.SurveyQuestion.php";
761  SurveyQuestion::_includeClass($questiontype);
762  $question = new $questiontype();
763  $question->loadFromDb($value);
764  $questionxml .= $question->toXML(false);
765  }
766 
767  $xml = str_replace("<dummy>dummy</dummy>", $questionxml, $xml);
768  return $xml;
769  }
getQuestiontype($question_id)
Returns the question type of a question with a given id.
getTitle()
get title of survey question pool object
static _includeClass($question_type, $gui=0)
Include the php class file for a given question type.
XML writer class.
getId()
get object id public
xmlHeader()
Writes xml header public.
getType()
get object type public
+ Here is the call graph for this function:

◆ update()

ilObjSurveyQuestionPool::update ( )

update object data

public

Returns
boolean

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

References ilObject\updateMetaData().

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
+ 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: