ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
ilObjSurveyQuestionPool Class Reference
+ Inheritance diagram for ilObjSurveyQuestionPool:
+ Collaboration diagram for ilObjSurveyQuestionPool:

Public Member Functions

 __construct ($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 ()
 read object data from db into object 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 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 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 ()
 
 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...
 
 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...
 
 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...
 
 setRegisterMode ($a_bool)
 
 isUserRegistered ($a_user_id=0)
 
 requireRegistration ()
 
 getXMLZip ()
 
 getHTMLDirectory ()
 
 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 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 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
 
 $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
 

Protected Attributes

 $user
 
 $plugin_admin
 
- Protected Attributes inherited from ilObject
 $objDefinition
 
 $db
 
 $log
 
 $error
 
 $tree
 
 $app_event_handler
 
 $rbacadmin
 
 $rbacreview
 

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

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

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

References $DIC, and user().

62  {
63  global $DIC;
64 
65  $this->log = $DIC["ilLog"];
66  $this->db = $DIC->database();
67  $this->user = $DIC->user();
68  $this->plugin_admin = $DIC["ilPluginAdmin"];
69  $this->type = "spl";
70  parent::__construct($a_id, $a_call_by_reference);
71  }
global $DIC
Definition: saml.php:7
user()
Definition: user.php:4
+ Here is the call graph for this function:

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 public

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

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

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

929  {
930  global $DIC;
931 
932  $ilUser = $DIC->user();
933  global $DIC;
934 
935  $ilDB = $DIC->database();
936 
937  $result_array = array();
938  $qpls = ilUtil::_getObjectsByOperations("spl", $permission, $ilUser->getId(), -1);
939  $titles = ilObject::_prepareCloneSelection($qpls, "spl", $showPath);
940  $allqpls = array();
941  $result = $ilDB->query("SELECT obj_fi, isonline FROM svy_qpl");
942  while ($row = $ilDB->fetchAssoc($result)) {
943  $allqpls[$row['obj_fi']] = $row['isonline'];
944  }
945  foreach ($qpls as $ref_id) {
946  $obj_id = ilObject::_lookupObjectId($ref_id);
947  if ($could_be_offline || $allqpls[$obj_id] == 1) {
948  if ($use_object_id) {
949  $result_array[$obj_id] = $titles[$ref_id];
950  } else {
951  $result_array[$ref_id] = $titles[$ref_id];
952  }
953  }
954  }
955  return $result_array;
956  }
static _prepareCloneSelection($a_ref_ids, $new_type, $show_path=true)
Prepare copy wizard object selection.
$result
global $DIC
Definition: saml.php:7
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
$ilUser
Definition: imgupload.php:18
Create styles array
The data for the language used.
global $ilDB
+ 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 public

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

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

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

819  {
820  global $DIC;
821 
822  $ilDB = $DIC->database();
823  global $DIC;
824 
825  $lng = $DIC->language();
826 
827  $lng->loadLanguageModule("survey");
828  $types = array();
829  $query_result = $ilDB->query("SELECT * FROM svy_qtype ORDER BY type_tag");
830  while ($row = $ilDB->fetchAssoc($query_result)) {
831  //array_push($questiontypes, $row["type_tag"]);
832  if ($row["plugin"] == 0) {
833  $types[$lng->txt($row["type_tag"])] = $row;
834  } else {
835  global $DIC;
836 
837  $ilPluginAdmin = $DIC["ilPluginAdmin"];
838  $pl_names = $ilPluginAdmin->getActivePluginsForSlot(IL_COMP_MODULE, "SurveyQuestionPool", "svyq");
839  foreach ($pl_names as $pl_name) {
840  $pl = ilPlugin::getPluginObject(IL_COMP_MODULE, "SurveyQuestionPool", "svyq", $pl_name);
841  if (strcmp($pl->getQuestionType(), $row["type_tag"]) == 0) {
842  $types[$pl->getQuestionTypeTranslation()] = $row;
843  }
844  }
845  }
846  }
847  ksort($types);
848 
849 
850  // #14263 - default sorting
851 
852  $default_sorting = array_flip(array(
853  "SurveySingleChoiceQuestion",
854  "SurveyMultipleChoiceQuestion",
855  "SurveyMatrixQuestion",
856  "SurveyMetricQuestion",
857  "SurveyTextQuestion"
858  ));
859 
860  $sorted = array();
861  $idx = sizeof($default_sorting);
862  foreach ($types as $caption => $item) {
863  $type = $item["type_tag"];
864  $item["caption"] = $caption;
865 
866  // default
867  if (array_key_exists($type, $default_sorting)) {
868  $sorted[$default_sorting[$type]] = $item;
869  }
870  // plugin (append alphabetically sorted)
871  else {
872  $sorted[$idx] = $item;
873  $idx++;
874  }
875  }
876  ksort($sorted);
877 
878  // redo captions as index
879  $types = array();
880  foreach ($sorted as $item) {
881  $types[$item["caption"]] = $item;
882  }
883 
884  return $types;
885  }
static getPluginObject($a_ctype, $a_cname, $a_slot_id, $a_pname)
Get plugin object.
global $DIC
Definition: saml.php:7
const IL_COMP_MODULE
Create styles array
The data for the language used.
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 887 of file class.ilObjSurveyQuestionPool.php.

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

Referenced by ilObjSurvey\getQuestionsTable().

888  {
889  global $DIC;
890 
891  $ilDB = $DIC->database();
892  global $DIC;
893 
894  $lng = $DIC->language();
895  global $DIC;
896 
897  $ilLog = $DIC["ilLog"];
898  global $DIC;
899 
900  $ilPluginAdmin = $DIC["ilPluginAdmin"];
901 
902  $lng->loadLanguageModule("survey");
903  $result = $ilDB->query("SELECT * FROM svy_qtype");
904  $types = array();
905  while ($row = $ilDB->fetchAssoc($result)) {
906  if ($row["plugin"] == 0) {
907  $types[$row['type_tag']] = $lng->txt($row["type_tag"]);
908  } else {
909  $pl_names = $ilPluginAdmin->getActivePluginsForSlot(IL_COMP_MODULE, "SurveyQuestionPool", "svyq");
910  foreach ($pl_names as $pl_name) {
911  $pl = ilPlugin::getPluginObject(IL_COMP_MODULE, "SurveyQuestionPool", "svyq", $pl_name);
912  if (strcmp($pl->getQuestionType(), $row["type_tag"]) == 0) {
913  $types[$row['type_tag']] = $pl->getQuestionTypeTranslation();
914  }
915  }
916  }
917  }
918  ksort($types);
919  return $types;
920  }
static getPluginObject($a_ctype, $a_cname, $a_slot_id, $a_pname)
Get plugin object.
$result
global $DIC
Definition: saml.php:7
const IL_COMP_MODULE
Create styles array
The data for the language used.
global $ilDB
+ 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 public

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

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

Referenced by SurveyQuestion\_isWriteable().

794  {
795  global $DIC;
796 
797  $rbacsystem = $DIC->rbac()->system();
798  global $DIC;
799 
800  $ilDB = $DIC->database();
801 
802  $refs = ilObject::_getAllReferences($object_id);
803  $result = false;
804  foreach ($refs as $ref) {
805  if ($rbacsystem->checkAccess("write", $ref) && (ilObject::_hasUntrashedReference($object_id))) {
806  $result = true;
807  }
808  }
809  return $result;
810  }
static _hasUntrashedReference($a_obj_id)
checks wether an object has at least one reference that is not in trash
$result
global $DIC
Definition: saml.php:7
static _getAllReferences($a_id)
get all reference ids of object
global $ilDB
+ 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 768 of file class.ilObjSurveyQuestionPool.php.

References $DIC, $ilDB, $result, $row, and array.

Referenced by ilObjSurveyQuestionPoolListGUI\getProperties().

769  {
770  global $DIC;
771 
772  $ilDB = $DIC->database();
773 
774  $result = $ilDB->queryF(
775  "SELECT isonline FROM svy_qpl WHERE obj_fi = %s",
776  array('integer'),
777  array($a_obj_id)
778  );
779  if ($result->numRows() == 1) {
780  $row = $ilDB->fetchAssoc($result);
781  return $row["isonline"];
782  }
783  return 0;
784  }
$result
global $DIC
Definition: saml.php:7
Create styles array
The data for the language used.
global $ilDB
+ Here is the caller graph for this function:

◆ _setOnline()

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

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

References $DIC, $ilDB, and array.

721  {
722  global $DIC;
723 
724  $ilDB = $DIC->database();
725 
726  $status = "0";
727  switch ($a_online_status) {
728  case 0:
729  case 1:
730  $status = "$a_online_status";
731  break;
732  }
733  $affectedRows = $ilDB->manipulateF(
734  "UPDATE svy_qpl SET isonline = %s WHERE obj_fi = %s",
735  array('text','integer'),
736  array($status, $a_obj_id)
737  );
738  }
global $DIC
Definition: saml.php:7
Create styles array
The data for the language used.
global $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.

public

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

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

118  {
119  $ilLog = $this->log;
120  $newObj = parent::cloneObject($a_target_id, $a_copy_id, $a_omit_tree);
121 
122  //copy online status if object is not the root copy object
123  $cp_options = ilCopyWizardOptions::_getInstance($a_copy_id);
124 
125  if (!$cp_options->isRootNode($this->getRefId())) {
126  $newObj->setOnline($this->getOnline());
127  }
128 
129  $newObj->saveToDb();
130  // clone the questions in the question pool
131  $questions =&$this->getQuestions();
132  foreach ($questions as $question_id) {
133  $newObj->copyQuestion($question_id, $newObj->getId());
134  }
135 
136  // clone meta data
137  include_once "./Services/MetaData/classes/class.ilMD.php";
138  $md = new ilMD($this->getId(), 0, $this->getType());
139  $new_md =&$md->cloneMD($newObj->getId(), 0, $newObj->getType());
140 
141  // update the metadata with the new title of the question pool
142  $newObj->updateMetaData();
143  return $newObj;
144  }
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 170 of file class.ilObjSurveyQuestionPool.php.

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

Referenced by pasteFromClipboard().

171  {
172  $question_gui =&$this->createQuestion("", $question_id);
173  if ($question_gui->object->getObjId() == $questionpool_to) {
174  // the question is copied into the same question pool
175  $this->duplicateQuestion($question_id);
176  } else {
177  // the question is copied into another question pool
178  $newtitle = $question_gui->object->getTitle();
179  if ($question_gui->object->questionTitleExists($question_gui->object->getTitle(), $questionpool_to)) {
180  $counter = 2;
181  while ($question_gui->object->questionTitleExists($question_gui->object->getTitle() . " ($counter)", $questionpool_to)) {
182  $counter++;
183  }
184  $newtitle = $question_gui->object->getTitle() . " ($counter)";
185  }
186  $question_gui->object->copyObject($this->getId(), $newtitle);
187  }
188  }
$counter
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 1025 of file class.ilObjSurveyQuestionPool.php.

References $_SESSION, and array.

1026  {
1027  if (!array_key_exists("spl_clipboard", $_SESSION)) {
1028  $_SESSION["spl_clipboard"] = array();
1029  }
1030  $_SESSION["spl_clipboard"][$question_id] = array("question_id" => $question_id, "action" => "copy");
1031  }
$_SESSION["AccountId"]
Create styles array
The data for the language used.

◆ create()

ilObjSurveyQuestionPool::create (   $a_upload = false)

create question pool object

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

References ilObject\createMetaData().

77  {
78  parent::create();
79  if (!$a_upload) {
80  $this->createMetaData();
81  }
82  }
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)

Exceptions
ilSurveyException

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

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

478  {
479  $spl_data_dir = ilUtil::getDataDir() . "/spl_data";
480  ilUtil::makeDir($spl_data_dir);
481  if (!is_writable($spl_data_dir)) {
482  include_once "Modules/Survey/exceptions/class.ilSurveyException.php";
483  throw new ilSurveyException("Survey Questionpool Data Directory (" . $spl_data_dir . ") not writeable.");
484  }
485 
486  // create learning module directory (data_dir/lm_data/lm_<id>)
487  $spl_dir = $spl_data_dir . "/spl_" . $this->getId();
488  ilUtil::makeDir($spl_dir);
489  if (!@is_dir($spl_dir)) {
490  include_once "Modules/Survey/exceptions/class.ilSurveyException.php";
491  throw new ilSurveyException("Creation of Survey Questionpool Directory failed.");
492  }
493  // create Export subdirectory (data_dir/lm_data/lm_<id>/Export)
494  $export_dir = $spl_dir . "/export";
495  ilUtil::makeDir($export_dir);
496  if (!@is_dir($export_dir)) {
497  include_once "Modules/Survey/exceptions/class.ilSurveyException.php";
498  throw new ilSurveyException("Creation of Survey Questionpool Export Directory failed.");
499  }
500  }
Survey exception class.
getId()
get object id public
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)

Exceptions
ilSurveyException

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

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

554  {
555  $spl_data_dir = ilUtil::getDataDir() . "/spl_data";
556  ilUtil::makeDir($spl_data_dir);
557 
558  if (!is_writable($spl_data_dir)) {
559  include_once "Modules/Survey/exceptions/class.ilSurveyException.php";
560  throw new ilSurveyException("Survey Questionpool Data Directory (" . $spl_data_dir . ") not writeable.");
561  }
562 
563  // create test directory (data_dir/spl_data/spl_<id>)
564  $spl_dir = $spl_data_dir . "/spl_" . $this->getId();
565  ilUtil::makeDir($spl_dir);
566  if (!@is_dir($spl_dir)) {
567  include_once "Modules/Survey/exceptions/class.ilSurveyException.php";
568  throw new ilSurveyException("Creation of Survey Questionpool Directory failed.");
569  }
570 
571  // create import subdirectory (data_dir/spl_data/spl_<id>/import)
572  $import_dir = $spl_dir . "/import";
573  ilUtil::makeDir($import_dir);
574  if (!@is_dir($import_dir)) {
575  include_once "Modules/Survey/exceptions/class.ilSurveyException.php";
576  throw new ilSurveyException("Creation of Survey Questionpool Import Directory failed.");
577  }
578  }
Survey exception class.
getId()
get object id public
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 146 of file class.ilObjSurveyQuestionPool.php.

References getQuestiontype().

Referenced by copyQuestion().

147  {
148  if ((!$question_type) and ($question_id > 0)) {
149  $question_type = $this->getQuestiontype($question_id);
150  }
151 
152  include_once "./Modules/SurveyQuestionPool/classes/class." . $question_type . "GUI.php";
153  $question_type_gui = $question_type . "GUI";
154  $question = new $question_type_gui();
155 
156  if ($question_id > 0) {
157  $question->object->loadFromDb($question_id);
158  }
159 
160  return $question;
161  }
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 248 of file class.ilObjSurveyQuestionPool.php.

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

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

◆ deleteAllData()

ilObjSurveyQuestionPool::deleteAllData ( )

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

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

Referenced by delete().

266  {
267  $ilDB = $this->db;
268  $result = $ilDB->queryF(
269  "SELECT question_id FROM svy_question WHERE obj_fi = %s AND original_id IS NULL",
270  array('integer'),
271  array($this->getId())
272  );
273  $found_questions = array();
274  while ($row = $ilDB->fetchAssoc($result)) {
275  $this->removeQuestion($row["question_id"]);
276  }
277 
278  // delete export files
279  $spl_data_dir = ilUtil::getDataDir() . "/spl_data";
280  $directory = $spl_data_dir . "/spl_" . $this->getId();
281  if (is_dir($directory)) {
282  ilUtil::delDir($directory);
283  }
284  }
$result
getId()
get object id public
Create styles array
The data for the language used.
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 404 of file class.ilObjSurveyQuestionPool.php.

References $counter, $ilUser, $user, and SurveyQuestion\_instanciateQuestion().

Referenced by copyQuestion(), and paste().

405  {
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  $counter++;
413  if ($counter > 1) {
414  $suffix = " ($counter)";
415  }
416  }
417  if ($obj_id) {
418  $question->setObjId($obj_id);
419  }
420  $question->duplicate(false, $question->getTitle() . $suffix, $ilUser->fullname, $ilUser->id);
421  }
$counter
$ilUser
Definition: imgupload.php:18
static _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 505 of file class.ilObjSurveyQuestionPool.php.

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

506  {
507  $export_dir = ilUtil::getDataDir() . "/spl_data" . "/spl_" . $this->getId() . "/export";
508  return $export_dir;
509  }
getId()
get object id public
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 514 of file class.ilObjSurveyQuestionPool.php.

References $file, and array.

515  {
516  // quit if import dir not available
517  if (!@is_dir($dir) or
518  !is_writeable($dir)) {
519  return array();
520  }
521 
522  // open directory
523  $dir = dir($dir);
524 
525  // initialize array
526  $file = array();
527 
528  // get files and save the in the array
529  while ($entry = $dir->read()) {
530  if ($entry != "." &&
531  $entry != ".." &&
532  preg_match("/^[0-9]{10}__[0-9]+__(spl_)*[0-9]+\.[A-Za-z]{3}$/", $entry)) {
533  $file[] = $entry;
534  }
535  }
536 
537  // close import directory
538  $dir->close();
539  // sort files
540  sort($file);
541  reset($file);
542 
543  return $file;
544  }
Create styles array
The data for the language used.
if(!file_exists("$old.txt")) if($old===$new) if(file_exists("$new.txt")) $file

◆ getImportDirectory()

ilObjSurveyQuestionPool::getImportDirectory ( )

get import directory of survey

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

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

584  {
585  $import_dir = ilUtil::getDataDir() . "/spl_data" .
586  "/spl_" . $this->getId() . "/import";
587  if (@is_dir($import_dir)) {
588  return $import_dir;
589  } else {
590  return false;
591  }
592  }
getId()
get object id public
static getDataDir()
get data directory (outside webspace)
+ Here is the call graph for this function:

◆ getOnline()

ilObjSurveyQuestionPool::getOnline ( )

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

References $online.

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

761  {
762  if (strcmp($this->online, "") == 0) {
763  $this->online = "0";
764  }
765  return $this->online;
766  }
+ 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 980 of file class.ilObjSurveyQuestionPool.php.

References $data, ilObject\$db, $ilDB, and array.

981  {
982  $ilDB = $this->db;
983 
984  $found = array();
985  $query_result = $ilDB->query("SELECT svy_question.*, svy_qtype.type_tag FROM svy_question, svy_qtype " .
986  "WHERE svy_question.questiontype_fi = svy_qtype.questiontype_id " .
987  "AND svy_question.tstamp > 0 AND " . $ilDB->in('svy_question.question_id', $question_ids, false, 'integer') . " " .
988  "ORDER BY svy_question.title");
989  if ($query_result->numRows() > 0) {
990  while ($data = $ilDB->fetchAssoc($query_result)) {
991  if (in_array($data["question_id"], $question_ids)) {
992  array_push($found, array('id' => $data["question_id"],
993  'title' => $data["title"],
994  'description' => $data["description"],
995  'type_tag' => $data["type_tag"]));
996  }
997  }
998  }
999  return $found;
1000  }
Create styles array
The data for the language used.
global $ilDB

◆ getQuestions()

& ilObjSurveyQuestionPool::getQuestions ( )

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

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

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

656  {
657  $ilDB = $this->db;
658  $questions = array();
659  $result = $ilDB->queryF(
660  "SELECT question_id FROM svy_question WHERE obj_fi = %s AND svy_question.tstamp > 0 AND original_id IS NULL",
661  array('integer'),
662  array($this->getId())
663  );
664  if ($result->numRows()) {
665  while ($row = $ilDB->fetchAssoc($result)) {
666  array_push($questions, $row["question_id"]);
667  }
668  }
669  return $questions;
670  }
$result
getId()
get object id public
Create styles array
The data for the language used.
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 428 of file class.ilObjSurveyQuestionPool.php.

References ilObject\$db, $ilDB, $ilUser, $key, $row, $rows, $user, array, ilObject\getId(), and isPluginActive().

429  {
431  $ilDB = $this->db;
432  $where = "";
433  if (is_array($arrFilter)) {
434  foreach ($arrFilter as $key => $value) {
435  $arrFilter[$key] = str_replace('%', '', $arrFilter[$key]);
436  }
437  if (array_key_exists('title', $arrFilter) && strlen($arrFilter['title'])) {
438  $where .= " AND " . $ilDB->like('svy_question.title', 'text', "%%" . $arrFilter['title'] . "%%");
439  }
440  if (array_key_exists('description', $arrFilter) && strlen($arrFilter['description'])) {
441  $where .= " AND " . $ilDB->like('svy_question.description', 'text', "%%" . $arrFilter['description'] . "%%");
442  }
443  if (array_key_exists('author', $arrFilter) && strlen($arrFilter['author'])) {
444  $where .= " AND " . $ilDB->like('svy_question.author', 'text', "%%" . $arrFilter['author'] . "%%");
445  }
446  if (array_key_exists('type', $arrFilter) && strlen($arrFilter['type'])) {
447  $where .= " AND svy_qtype.type_tag = " . $ilDB->quote($arrFilter['type'], 'text');
448  }
449  }
450  $query_result = $ilDB->queryF(
451  "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,
452  array('integer'),
453  array($this->getId())
454  );
455  $rows = array();
456  if ($query_result->numRows()) {
457  while ($row = $ilDB->fetchAssoc($query_result)) {
458  if ($row["plugin"]) {
459  if ($this->isPluginActive($row["type_tag"])) {
460  array_push($rows, $row);
461  }
462  } else {
463  array_push($rows, $row);
464  }
465  }
466  }
467  return $rows;
468  }
isPluginActive($a_pname)
Checks whether or not a question plugin with a given name is active.
getId()
get object id public
$ilUser
Definition: imgupload.php:18
Create styles array
The data for the language used.
$rows
Definition: xhr_table.php:10
global $ilDB
$key
Definition: croninfo.php:18
+ 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 381 of file class.ilObjSurveyQuestionPool.php.

References ilObject\$db, $ilDB, $result, $row, array, and isPluginActive().

382  {
383  $ilDB = $this->db;
384  $result_array = array();
385  $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'));
386  while ($row = $ilDB->fetchAssoc($result)) {
387  if ($row["plugin"]) {
388  if ($this->isPluginActive($row["type_tag"])) {
389  array_push($result_array, $row);
390  }
391  } else {
392  array_push($result_array, $row);
393  }
394  }
395  return $result_array;
396  }
$result
isPluginActive($a_pname)
Checks whether or not a question plugin with a given name is active.
Create styles array
The data for the language used.
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 309 of file class.ilObjSurveyQuestionPool.php.

References $data, ilObject\$db, $ilDB, $result, and array.

Referenced by createQuestion(), and toXML().

310  {
311  $ilDB = $this->db;
312  if ($question_id < 1) {
313  return;
314  }
315  $result = $ilDB->queryF(
316  "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",
317  array('integer'),
318  array($question_id)
319  );
320  if ($result->numRows() == 1) {
321  $data = $ilDB->fetchAssoc($result);
322  return $data["type_tag"];
323  } else {
324  return;
325  }
326  }
$result
Create styles array
The data for the language used.
global $ilDB
+ 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 public

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

References $fh, $source, $xml, ilUtil\delDir(), ilObject\getId(), and ilUtil\unzip().

679  {
680  if (is_file($source)) {
681  $isZip = (strcmp(strtolower(substr($source, -3)), 'zip') == 0);
682  if ($isZip) {
683  // unzip file
685 
686  // determine filenames of xml files
687  $subdir = basename($source, ".zip");
688  $source = dirname($source) . "/" . $subdir . "/" . $subdir . ".xml";
689  }
690 
691  $fh = fopen($source, "r") or die("");
692  $xml = fread($fh, filesize($source));
693  fclose($fh) or die("");
694  if ($isZip) {
695  $subdir = basename($source, ".zip");
696  if (@is_dir(dirname($source) . "/" . $subdir)) {
697  ilUtil::delDir(dirname($source) . "/" . $subdir);
698  }
699  }
700  if (strpos($xml, "questestinterop") > 0) {
701  include_once("./Modules/Survey/exceptions/class.ilInvalidSurveyImportFileException.php");
702  throw new ilInvalidSurveyImportFileException("Unsupported survey version (< 3.8) found.");
703 
704  // survey questions for ILIAS < 3.8
705  /*
706  include_once "./Services/Survey/classes/class.SurveyImportParserPre38.php";
707  $import = new SurveyImportParserPre38($this->getId(), "", $spl_exists);
708  $import->setXMLContent($xml);
709  $import->startParsing();*/
710  } else {
711  // survey questions for ILIAS >= 3.8
712  include_once "./Services/Survey/classes/class.SurveyImportParser.php";
713  $import = new SurveyImportParser($this->getId(), "", $spl_exists);
714  $import->setXMLContent($xml);
715  $import->startParsing();
716  }
717  }
718  }
static unzip($a_file, $overwrite=false, $a_flat=false)
unzip file
Survey Question Import Parser.
$xml
Definition: metadata.php:240
getId()
get object id public
$source
Definition: linkback.php:22
Class ilInvalidSurveyImportFileException.
static delDir($a_dir, $a_clean_only=false)
removes a dir and all its content (subdirs and files) recursively
PHPExcel root directory.
Definition: Database.php:30
+ 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 335 of file class.ilObjSurveyQuestionPool.php.

References ilObject\$db, $ilDB, $result, $row, and array.

336  {
337  $ilDB = $this->db;
338  // check out the already answered questions
339  $result = $ilDB->queryF(
340  "SELECT answer_id FROM svy_answer WHERE question_fi = %s",
341  array('integer'),
342  array($question_id)
343  );
344  $answered = $result->numRows();
345 
346  // check out the questions inserted in surveys
347  $result = $ilDB->queryF(
348  "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",
349  array('integer'),
350  array($question_id)
351  );
352  $inserted = $result->numRows();
353  if (($inserted + $answered) == 0) {
354  return false;
355  }
356  $result_array = array();
357  while ($row = $ilDB->fetchObject($result)) {
358  array_push($result_array, $row);
359  }
360  return $result_array;
361  }
$result
Create styles array
The data for the language used.
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 964 of file class.ilObjSurveyQuestionPool.php.

References $plugin_admin, and IL_COMP_MODULE.

Referenced by getQuestionsData(), and getQuestionsInfo().

965  {
966  $ilPluginAdmin = $this->plugin_admin;
967  if ($ilPluginAdmin->isActive(IL_COMP_MODULE, "SurveyQuestionPool", "svyq", $a_pname)) {
968  return true;
969  } else {
970  return false;
971  }
972  }
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 195 of file class.ilObjSurveyQuestionPool.php.

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

Referenced by read().

196  {
197  $ilDB = $this->db;
198 
199  $result = $ilDB->queryF(
200  "SELECT * FROM svy_qpl WHERE obj_fi = %s",
201  array('integer'),
202  array($this->getId())
203  );
204  if ($result->numRows() == 1) {
205  $row = $ilDB->fetchAssoc($result);
206  $this->setOnline($row["isonline"]);
207  }
208  }
$result
setOnline($a_online_status)
Sets the questionpool online status.
getId()
get object id public
Create styles array
The data for the language used.
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 1038 of file class.ilObjSurveyQuestionPool.php.

References $_SESSION, and array.

1039  {
1040  if (!array_key_exists("spl_clipboard", $_SESSION)) {
1041  $_SESSION["spl_clipboard"] = array();
1042  }
1043  $_SESSION["spl_clipboard"][$question_id] = array("question_id" => $question_id, "action" => "move");
1044  }
$_SESSION["AccountId"]
Create styles array
The data for the language used.

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

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

370  {
371  $this->duplicateQuestion($question_id, $this->getId());
372  }
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 1049 of file class.ilObjSurveyQuestionPool.php.

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

1050  {
1051  $ilDB = $this->db;
1052 
1053  if (array_key_exists("spl_clipboard", $_SESSION)) {
1054  foreach ($_SESSION["spl_clipboard"] as $question_object) {
1055  if (strcmp($question_object["action"], "move") == 0) {
1056  $result = $ilDB->queryF(
1057  "SELECT obj_fi FROM svy_question WHERE question_id = %s",
1058  array('integer'),
1059  array($question_object["question_id"])
1060  );
1061  if ($result->numRows() == 1) {
1062  $row = $ilDB->fetchAssoc($result);
1063  $source_questionpool = $row["obj_fi"];
1064  if ($this->getId() != $source_questionpool) {
1065  // change the questionpool id in the qpl_questions table
1066  $affectedRows = $ilDB->manipulateF(
1067  "UPDATE svy_question SET obj_fi = %s WHERE question_id = %s",
1068  array('integer','integer'),
1069  array($this->getId(), $question_object["question_id"])
1070  );
1071 
1072  // move question data to the new target directory
1073  $source_path = CLIENT_WEB_DIR . "/survey/" . $source_questionpool . "/" . $question_object["question_id"] . "/";
1074  if (@is_dir($source_path)) {
1075  $target_path = CLIENT_WEB_DIR . "/survey/" . $this->getId() . "/";
1076  if (!@is_dir($target_path)) {
1077  ilUtil::makeDirParents($target_path);
1078  }
1079  @rename($source_path, $target_path . $question_object["question_id"]);
1080  }
1081  } else {
1082  ilUtil::sendFailure($this->lng->txt("spl_move_same_pool"), true);
1083  return;
1084  }
1085  }
1086  } else {
1087  $this->copyQuestion($question_object["question_id"], $this->getId());
1088  }
1089  }
1090  }
1091  ilUtil::sendSuccess($this->lng->txt("spl_paste_success"), true);
1092  unset($_SESSION["spl_clipboard"]);
1093  }
static sendSuccess($a_info="", $a_keep=false)
Send Success Message to Screen.
static makeDirParents($a_dir)
Create a new directory and all parent directories.
$_SESSION["AccountId"]
$result
copyQuestion($question_id, $questionpool_to)
Copies a question into another question pool.
getId()
get object id public
Create styles array
The data for the language used.
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 1005 of file class.ilObjSurveyQuestionPool.php.

References $data, ilObject\$db, $ilDB, $ilUser, $result, $user, array, and removeQuestion().

1006  {
1007  $ilDB = $this->db;
1008  $ilUser = $this->user;
1009 
1010  $result = $ilDB->queryF(
1011  "SELECT question_id FROM svy_question WHERE owner_fi = %s AND tstamp = %s",
1012  array("integer", "integer"),
1013  array($ilUser->getId(), 0)
1014  );
1015  while ($data = $ilDB->fetchAssoc($result)) {
1016  $this->removeQuestion($data["question_id"]);
1017  }
1018  }
$result
$ilUser
Definition: imgupload.php:18
Create styles array
The data for the language used.
removeQuestion($question_id)
Removes a question from the question pool.
global $ilDB
+ Here is the call graph for this function:

◆ read()

ilObjSurveyQuestionPool::read ( )

read object data from db into object public

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

References loadFromDb().

107  {
108  parent::read();
109  $this->loadFromDb();
110  }
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 292 of file class.ilObjSurveyQuestionPool.php.

References SurveyQuestion\_instanciateQuestion().

Referenced by deleteAllData(), and purgeQuestions().

293  {
294  if ($question_id < 1) {
295  return;
296  }
297  include_once "./Modules/SurveyQuestionPool/classes/class.SurveyQuestion.php";
298  $question =&SurveyQuestion::_instanciateQuestion($question_id);
299  $question->delete($question_id);
300  }
static _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 215 of file class.ilObjSurveyQuestionPool.php.

References ilObject\$db, $ilDB, $query, $result, array, ilObject\getId(), getOnline(), time, and League\Flysystem\Adapter\Polyfill\update().

216  {
217  $ilDB = $this->db;
218 
219  parent::update();
220 
221  $result = $ilDB->queryF(
222  "SELECT * FROM svy_qpl WHERE obj_fi = %s",
223  array('integer'),
224  array($this->getId())
225  );
226  if ($result->numRows() == 1) {
227  $affectedRows = $ilDB->manipulateF(
228  "UPDATE svy_qpl SET isonline = %s, tstamp = %s WHERE obj_fi = %s",
229  array('text','integer','integer'),
230  array($this->getOnline(), time(), $this->getId())
231  );
232  } else {
233  $next_id = $ilDB->nextId('svy_qpl');
234  $query = $ilDB->manipulateF(
235  "INSERT INTO svy_qpl (id_questionpool, isonline, obj_fi, tstamp) VALUES (%s, %s, %s, %s)",
236  array('integer', 'text', 'integer', 'integer'),
237  array($next_id, $this->getOnline(), $this->getId(), time())
238  );
239  }
240  }
$result
getId()
get object id public
$query
Create styles array
The data for the language used.
update($pash, $contents, Config $config)
global $ilDB
Add data(end) time
Method that wraps PHPs time in order to allow simulations with the workflow.
+ 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 1101 of file class.ilObjSurveyQuestionPool.php.

References ilObject\$db, $ilDB, and getQuestions().

1102  {
1103  $ilDB = $this->db;
1104 
1105  foreach ($this->getQuestions() as $question_id) {
1106  $status = (int) (in_array($question_id, $obligatory_questions));
1107 
1108  $ilDB->manipulate("UPDATE svy_question" .
1109  " SET obligatory = " . $ilDB->quote($status, "integer") .
1110  " WHERE question_id = " . $ilDB->quote($question_id, "integer"));
1111  }
1112  }
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 747 of file class.ilObjSurveyQuestionPool.php.

Referenced by loadFromDb().

748  {
749  switch ($a_online_status) {
750  case 0:
751  case 1:
752  $this->online = $a_online_status;
753  break;
754  default:
755  $this->online = 0;
756  break;
757  }
758  }
+ Here is the caller graph for this function:

◆ toXML()

ilObjSurveyQuestionPool::toXML (   $questions)

export questions to xml

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

References $key, $metadata, $xml, SurveyQuestion\_includeClass(), array, ilObject\getId(), getOnline(), getQuestions(), getQuestiontype(), ilObject\getTitle(), ilObject\getType(), and ilXmlWriter\xmlHeader().

598  {
599  if (!is_array($questions)) {
600  $questions =&$this->getQuestions();
601  }
602  if (count($questions) == 0) {
603  $questions =&$this->getQuestions();
604  }
605  $xml = "";
606 
607  include_once("./Services/Xml/classes/class.ilXmlWriter.php");
608  $a_xml_writer = new ilXmlWriter;
609  // set xml header
610  $a_xml_writer->xmlHeader();
611  $attrs = array(
612  "xmlns:xsi" => "http://www.w3.org/2001/XMLSchema-instance",
613  "xsi:noNamespaceSchemaLocation" => "http://www.ilias.de/download/xsd/ilias_survey_4_2.xsd"
614  );
615  $a_xml_writer->xmlStartTag("surveyobject", $attrs);
616  $attrs = array(
617  "id" => "qpl_" . $this->getId(),
618  "label" => $this->getTitle(),
619  "online" => $this->getOnline()
620  );
621  $a_xml_writer->xmlStartTag("surveyquestions", $attrs);
622  $a_xml_writer->xmlElement("dummy", null, "dummy");
623  // add ILIAS specific metadata
624  $a_xml_writer->xmlStartTag("metadata");
625  $a_xml_writer->xmlStartTag("metadatafield");
626  $a_xml_writer->xmlElement("fieldlabel", null, "SCORM");
627  include_once "./Services/MetaData/classes/class.ilMD.php";
628  $md = new ilMD($this->getId(), 0, $this->getType());
629  $writer = new ilXmlWriter();
630  $md->toXml($writer);
631  $metadata = $writer->xmlDumpMem();
632  $a_xml_writer->xmlElement("fieldentry", null, $metadata);
633  $a_xml_writer->xmlEndTag("metadatafield");
634  $a_xml_writer->xmlEndTag("metadata");
635 
636  $a_xml_writer->xmlEndTag("surveyquestions");
637  $a_xml_writer->xmlEndTag("surveyobject");
638 
639  $xml = $a_xml_writer->xmlDumpMem(false);
640 
641  $questionxml = "";
642  foreach ($questions as $key => $value) {
643  $questiontype = $this->getQuestiontype($value);
644  include_once "./Modules/SurveyQuestionPool/classes/class.SurveyQuestion.php";
645  SurveyQuestion::_includeClass($questiontype);
646  $question = new $questiontype();
647  $question->loadFromDb($value);
648  $questionxml .= $question->toXML(false);
649  }
650 
651  $xml = str_replace("<dummy>dummy</dummy>", $questionxml, $xml);
652  return $xml;
653  }
getQuestiontype($question_id)
Returns the question type of a question with a given id.
static _includeClass($question_type, $gui=0)
Include the php class file for a given question type.
XML writer class.
$metadata['__DYNAMIC:1__']
$xml
Definition: metadata.php:240
getId()
get object id public
getTitle()
get object title public
xmlHeader()
Writes xml header public.
getType()
get object type public
Create styles array
The data for the language used.
$key
Definition: croninfo.php:18
+ Here is the call graph for this function:

◆ update()

ilObjSurveyQuestionPool::update ( )

update object data

public

Returns
boolean

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

References League\Flysystem\Adapter\Polyfill\update(), and ilObject\updateMetaData().

91  {
92  $this->updateMetaData();
93  if (!parent::update()) {
94  return false;
95  }
96 
97  // put here object specific stuff
98 
99  return true;
100  }
updateMetaData()
update meta data entry
update($pash, $contents, Config $config)
+ Here is the call graph for this function:

Field Documentation

◆ $online

ilObjSurveyQuestionPool::$online

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

Referenced by getOnline().

◆ $plugin_admin

ilObjSurveyQuestionPool::$plugin_admin
protected

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

Referenced by isPluginActive().

◆ $user

ilObjSurveyQuestionPool::$user
protected

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