ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
All Data Structures Namespaces Files Functions Variables Modules Pages
ilObjSurveyQuestionPool Class Reference

Class ilObjSurveyQuestionPool. More...

+ 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...
 
 setOfflineStatus ($a_status)
 Set offline status. More...
 
 getOfflineStatus ()
 Get offline status. More...
 
 supportsOfflineHandling ()
 Check whether object supports offline handling. 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 lookupOfflineStatus ($a_obj_id)
 Lookup offline status using objectDataCache. 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, $a_deleted_by)
 
static setDeletedDates ($a_ref_ids, $a_user_id)
 Set deleted date. 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 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

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

References $DIC, ILIAS\GlobalScreen\Provider\__construct(), and user().

36  {
37  global $DIC;
38 
39  $this->log = $DIC["ilLog"];
40  $this->db = $DIC->database();
41  $this->user = $DIC->user();
42  $this->plugin_admin = $DIC["ilPluginAdmin"];
43  $this->type = "spl";
44  parent::__construct($a_id, $a_call_by_reference);
45  }
user()
Definition: user.php:4
__construct(Container $dic, ilPlugin $plugin)
$DIC
Definition: xapitoken.php:46
+ 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 880 of file class.ilObjSurveyQuestionPool.php.

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

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

881  {
882  global $DIC;
883 
884  $ilUser = $DIC->user();
885  global $DIC;
886 
887  $ilDB = $DIC->database();
888 
889  $result_array = array();
890  $qpls = ilUtil::_getObjectsByOperations("spl", $permission, $ilUser->getId(), -1);
891  $titles = ilObject::_prepareCloneSelection($qpls, "spl", $showPath);
892  $allqpls = array();
893  $result = $ilDB->query("SELECT obj_fi, isonline FROM svy_qpl");
894  while ($row = $ilDB->fetchAssoc($result)) {
895  $allqpls[$row['obj_fi']] = $row['isonline'];
896  }
897  foreach ($qpls as $ref_id) {
898  $obj_id = ilObject::_lookupObjectId($ref_id);
899  if ($could_be_offline || $allqpls[$obj_id] == 1) {
900  if ($use_object_id) {
901  $result_array[$obj_id] = $titles[$ref_id];
902  } else {
903  $result_array[$ref_id] = $titles[$ref_id];
904  }
905  }
906  }
907  return $result_array;
908  }
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
$ilUser
Definition: imgupload.php:18
global $ilDB
$DIC
Definition: xapitoken.php:46
+ 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 770 of file class.ilObjSurveyQuestionPool.php.

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

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

771  {
772  global $DIC;
773 
774  $ilDB = $DIC->database();
775  global $DIC;
776 
777  $lng = $DIC->language();
778 
779  $lng->loadLanguageModule("survey");
780  $types = array();
781  $query_result = $ilDB->query("SELECT * FROM svy_qtype ORDER BY type_tag");
782  while ($row = $ilDB->fetchAssoc($query_result)) {
783  //array_push($questiontypes, $row["type_tag"]);
784  if ($row["plugin"] == 0) {
785  $types[$lng->txt($row["type_tag"])] = $row;
786  } else {
787  global $DIC;
788 
789  $ilPluginAdmin = $DIC["ilPluginAdmin"];
790  $pl_names = $ilPluginAdmin->getActivePluginsForSlot(IL_COMP_MODULE, "SurveyQuestionPool", "svyq");
791  foreach ($pl_names as $pl_name) {
792  $pl = ilPlugin::getPluginObject(IL_COMP_MODULE, "SurveyQuestionPool", "svyq", $pl_name);
793  if (strcmp($pl->getQuestionType(), $row["type_tag"]) == 0) {
794  $types[$pl->getQuestionTypeTranslation()] = $row;
795  }
796  }
797  }
798  }
799  ksort($types);
800 
801 
802  // #14263 - default sorting
803 
804  $default_sorting = array_flip(array(
805  "SurveySingleChoiceQuestion",
806  "SurveyMultipleChoiceQuestion",
807  "SurveyMatrixQuestion",
808  "SurveyMetricQuestion",
809  "SurveyTextQuestion"
810  ));
811 
812  $sorted = array();
813  $idx = sizeof($default_sorting);
814  foreach ($types as $caption => $item) {
815  $type = $item["type_tag"];
816  $item["caption"] = $caption;
817 
818  // default
819  if (array_key_exists($type, $default_sorting)) {
820  $sorted[$default_sorting[$type]] = $item;
821  }
822  // plugin (append alphabetically sorted)
823  else {
824  $sorted[$idx] = $item;
825  $idx++;
826  }
827  }
828  ksort($sorted);
829 
830  // redo captions as index
831  $types = array();
832  foreach ($sorted as $item) {
833  $types[$item["caption"]] = $item;
834  }
835 
836  return $types;
837  }
static getPluginObject(string $a_ctype, string $a_cname, string $a_slot_id, string $a_pname)
const IL_COMP_MODULE
global $ilDB
$DIC
Definition: xapitoken.php:46
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _getQuestionTypeTranslations()

static ilObjSurveyQuestionPool::_getQuestionTypeTranslations ( )
static

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

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

Referenced by ilObjSurvey\getQuestionsTable().

840  {
841  global $DIC;
842 
843  $ilDB = $DIC->database();
844  global $DIC;
845 
846  $lng = $DIC->language();
847  global $DIC;
848 
849  $ilLog = $DIC["ilLog"];
850  global $DIC;
851 
852  $ilPluginAdmin = $DIC["ilPluginAdmin"];
853 
854  $lng->loadLanguageModule("survey");
855  $result = $ilDB->query("SELECT * FROM svy_qtype");
856  $types = array();
857  while ($row = $ilDB->fetchAssoc($result)) {
858  if ($row["plugin"] == 0) {
859  $types[$row['type_tag']] = $lng->txt($row["type_tag"]);
860  } else {
861  $pl_names = $ilPluginAdmin->getActivePluginsForSlot(IL_COMP_MODULE, "SurveyQuestionPool", "svyq");
862  foreach ($pl_names as $pl_name) {
863  $pl = ilPlugin::getPluginObject(IL_COMP_MODULE, "SurveyQuestionPool", "svyq", $pl_name);
864  if (strcmp($pl->getQuestionType(), $row["type_tag"]) == 0) {
865  $types[$row['type_tag']] = $pl->getQuestionTypeTranslation();
866  }
867  }
868  }
869  }
870  ksort($types);
871  return $types;
872  }
static getPluginObject(string $a_ctype, string $a_cname, string $a_slot_id, string $a_pname)
$result
const IL_COMP_MODULE
global $ilDB
$DIC
Definition: xapitoken.php:46
+ 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 745 of file class.ilObjSurveyQuestionPool.php.

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

Referenced by SurveyQuestion\_isWriteable().

746  {
747  global $DIC;
748 
749  $rbacsystem = $DIC->rbac()->system();
750  global $DIC;
751 
752  $ilDB = $DIC->database();
753 
754  $refs = ilObject::_getAllReferences($object_id);
755  $result = false;
756  foreach ($refs as $ref) {
757  if ($rbacsystem->checkAccess("write", $ref) && (ilObject::_hasUntrashedReference($object_id))) {
758  $result = true;
759  }
760  }
761  return $result;
762  }
static _hasUntrashedReference($a_obj_id)
checks wether an object has at least one reference that is not in trash
$result
static _getAllReferences($a_id)
get all reference ids of object
global $ilDB
$DIC
Definition: xapitoken.php:46
+ 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 720 of file class.ilObjSurveyQuestionPool.php.

References $DIC, $ilDB, and $result.

Referenced by ilObjSurveyQuestionPoolListGUI\getProperties().

721  {
722  global $DIC;
723 
724  $ilDB = $DIC->database();
725 
726  $result = $ilDB->queryF(
727  "SELECT isonline FROM svy_qpl WHERE obj_fi = %s",
728  array('integer'),
729  array($a_obj_id)
730  );
731  if ($result->numRows() == 1) {
732  $row = $ilDB->fetchAssoc($result);
733  return $row["isonline"];
734  }
735  return 0;
736  }
$result
global $ilDB
$DIC
Definition: xapitoken.php:46
+ Here is the caller graph for this function:

◆ _setOnline()

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

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

References $DIC, and $ilDB.

673  {
674  global $DIC;
675 
676  $ilDB = $DIC->database();
677 
678  $status = "0";
679  switch ($a_online_status) {
680  case 0:
681  case 1:
682  $status = "$a_online_status";
683  break;
684  }
685  $affectedRows = $ilDB->manipulateF(
686  "UPDATE svy_qpl SET isonline = %s WHERE obj_fi = %s",
687  array('text','integer'),
688  array($status, $a_obj_id)
689  );
690  }
global $ilDB
$DIC
Definition: xapitoken.php:46

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

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

92  {
94  $newObj = parent::cloneObject($a_target_id, $a_copy_id, $a_omit_tree);
95 
96  //copy online status if object is not the root copy object
97  $cp_options = ilCopyWizardOptions::_getInstance($a_copy_id);
98 
99  if (!$cp_options->isRootNode($this->getRefId())) {
100  $newObj->setOnline($this->getOnline());
101  }
102 
103  $newObj->saveToDb();
104  // clone the questions in the question pool
105  $questions = &$this->getQuestions();
106  foreach ($questions as $question_id) {
107  $newObj->copyQuestion($question_id, $newObj->getId());
108  }
109 
110  // clone meta data
111  $md = new ilMD($this->getId(), 0, $this->getType());
112  $new_md = &$md->cloneMD($newObj->getId(), 0, $newObj->getType());
113 
114  // update the metadata with the new title of the question pool
115  $newObj->updateMetaData();
116  return $newObj;
117  }
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 142 of file class.ilObjSurveyQuestionPool.php.

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

Referenced by pasteFromClipboard().

143  {
144  $question_gui = &$this->createQuestion("", $question_id);
145  if ($question_gui->object->getObjId() == $questionpool_to) {
146  // the question is copied into the same question pool
147  $this->duplicateQuestion($question_id);
148  } else {
149  // the question is copied into another question pool
150  $newtitle = $question_gui->object->getTitle();
151  if ($question_gui->object->questionTitleExists($question_gui->object->getTitle(), $questionpool_to)) {
152  $counter = 2;
153  while ($question_gui->object->questionTitleExists($question_gui->object->getTitle() . " ($counter)", $questionpool_to)) {
154  $counter++;
155  }
156  $newtitle = $question_gui->object->getTitle() . " ($counter)";
157  }
158  $question_gui->object->copyObject($this->getId(), $newtitle);
159  }
160  }
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 977 of file class.ilObjSurveyQuestionPool.php.

References $_SESSION.

978  {
979  if (!array_key_exists("spl_clipboard", $_SESSION)) {
980  $_SESSION["spl_clipboard"] = array();
981  }
982  $_SESSION["spl_clipboard"][$question_id] = array("question_id" => $question_id, "action" => "copy");
983  }
$_SESSION["AccountId"]

◆ create()

ilObjSurveyQuestionPool::create (   $a_upload = false)

create question pool object

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

References ilObject\createMetaData().

51  {
52  parent::create();
53  if (!$a_upload) {
54  $this->createMetaData();
55  }
56  }
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 447 of file class.ilObjSurveyQuestionPool.php.

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

448  {
449  $spl_data_dir = ilUtil::getDataDir() . "/spl_data";
450  ilUtil::makeDir($spl_data_dir);
451  if (!is_writable($spl_data_dir)) {
452  throw new ilSurveyException("Survey Questionpool Data Directory (" . $spl_data_dir . ") not writeable.");
453  }
454 
455  // create learning module directory (data_dir/lm_data/lm_<id>)
456  $spl_dir = $spl_data_dir . "/spl_" . $this->getId();
457  ilUtil::makeDir($spl_dir);
458  if (!@is_dir($spl_dir)) {
459  throw new ilSurveyException("Creation of Survey Questionpool Directory failed.");
460  }
461  // create Export subdirectory (data_dir/lm_data/lm_<id>/Export)
462  $export_dir = $spl_dir . "/export";
463  ilUtil::makeDir($export_dir);
464  if (!@is_dir($export_dir)) {
465  throw new ilSurveyException("Creation of Survey Questionpool Export Directory failed.");
466  }
467  }
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 520 of file class.ilObjSurveyQuestionPool.php.

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

521  {
522  $spl_data_dir = ilUtil::getDataDir() . "/spl_data";
523  ilUtil::makeDir($spl_data_dir);
524 
525  if (!is_writable($spl_data_dir)) {
526  throw new ilSurveyException("Survey Questionpool Data Directory (" . $spl_data_dir . ") not writeable.");
527  }
528 
529  // create test directory (data_dir/spl_data/spl_<id>)
530  $spl_dir = $spl_data_dir . "/spl_" . $this->getId();
531  ilUtil::makeDir($spl_dir);
532  if (!@is_dir($spl_dir)) {
533  throw new ilSurveyException("Creation of Survey Questionpool Directory failed.");
534  }
535 
536  // create import subdirectory (data_dir/spl_data/spl_<id>/import)
537  $import_dir = $spl_dir . "/import";
538  ilUtil::makeDir($import_dir);
539  if (!@is_dir($import_dir)) {
540  throw new ilSurveyException("Creation of Survey Questionpool Import Directory failed.");
541  }
542  }
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 119 of file class.ilObjSurveyQuestionPool.php.

References getQuestiontype().

Referenced by copyQuestion().

120  {
121  if ((!$question_type) and ($question_id > 0)) {
122  $question_type = $this->getQuestiontype($question_id);
123  }
124 
125  $question_type_gui = $question_type . "GUI";
126  $question = new $question_type_gui();
127 
128  if ($question_id > 0) {
129  $question->object->loadFromDb($question_id);
130  }
131 
132  return $question;
133  }
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 220 of file class.ilObjSurveyQuestionPool.php.

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

221  {
222  $remove = parent::delete();
223  // always call parent delete function first!!
224  if (!$remove) {
225  return false;
226  }
227 
228  // delete all related questions
229  $this->deleteAllData();
230 
231  // delete meta data
232  $this->deleteMetaData();
233 
234  return true;
235  }
deleteMetaData()
delete meta data entry
+ Here is the call graph for this function:

◆ deleteAllData()

ilObjSurveyQuestionPool::deleteAllData ( )

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

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

Referenced by delete().

238  {
239  $ilDB = $this->db;
240  $result = $ilDB->queryF(
241  "SELECT question_id FROM svy_question WHERE obj_fi = %s AND original_id IS NULL",
242  array('integer'),
243  array($this->getId())
244  );
245  $found_questions = array();
246  while ($row = $ilDB->fetchAssoc($result)) {
247  $this->removeQuestion($row["question_id"]);
248  }
249 
250  // delete export files
251  $spl_data_dir = ilUtil::getDataDir() . "/spl_data";
252  $directory = $spl_data_dir . "/spl_" . $this->getId();
253  if (is_dir($directory)) {
254  ilUtil::delDir($directory);
255  }
256  }
$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 375 of file class.ilObjSurveyQuestionPool.php.

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

Referenced by copyQuestion(), and paste().

376  {
378  $question = SurveyQuestion::_instanciateQuestion($question_id);
379  $suffix = "";
380  $counter = 1;
381  while ($question->questionTitleExists($question->getTitle() . $suffix, $obj_id)) {
382  $counter++;
383  if ($counter > 1) {
384  $suffix = " ($counter)";
385  }
386  }
387  if ($obj_id) {
388  $question->setObjId($obj_id);
389  }
390  $question->duplicate(false, $question->getTitle() . $suffix, $ilUser->fullname, $ilUser->id);
391  }
$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 472 of file class.ilObjSurveyQuestionPool.php.

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

473  {
474  $export_dir = ilUtil::getDataDir() . "/spl_data" . "/spl_" . $this->getId() . "/export";
475  return $export_dir;
476  }
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 481 of file class.ilObjSurveyQuestionPool.php.

482  {
483  // quit if import dir not available
484  if (!@is_dir($dir) or
485  !is_writeable($dir)) {
486  return array();
487  }
488 
489  // open directory
490  $dir = dir($dir);
491 
492  // initialize array
493  $file = array();
494 
495  // get files and save the in the array
496  while ($entry = $dir->read()) {
497  if ($entry != "." &&
498  $entry != ".." &&
499  preg_match("/^[0-9]{10}__[0-9]+__(spl_)*[0-9]+\.[A-Za-z]{3}$/", $entry)) {
500  $file[] = $entry;
501  }
502  }
503 
504  // close import directory
505  $dir->close();
506  // sort files
507  sort($file);
508  reset($file);
509 
510  return $file;
511  }

◆ getImportDirectory()

ilObjSurveyQuestionPool::getImportDirectory ( )

get import directory of survey

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

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

548  {
549  $import_dir = ilUtil::getDataDir() . "/spl_data" .
550  "/spl_" . $this->getId() . "/import";
551  if (@is_dir($import_dir)) {
552  return $import_dir;
553  } else {
554  return false;
555  }
556  }
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 712 of file class.ilObjSurveyQuestionPool.php.

References $online.

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

713  {
714  if (strcmp($this->online, "") == 0) {
715  $this->online = "0";
716  }
717  return $this->online;
718  }
+ 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 932 of file class.ilObjSurveyQuestionPool.php.

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

933  {
934  $ilDB = $this->db;
935 
936  $found = array();
937  $query_result = $ilDB->query("SELECT svy_question.*, svy_qtype.type_tag FROM svy_question, svy_qtype " .
938  "WHERE svy_question.questiontype_fi = svy_qtype.questiontype_id " .
939  "AND svy_question.tstamp > 0 AND " . $ilDB->in('svy_question.question_id', $question_ids, false, 'integer') . " " .
940  "ORDER BY svy_question.title");
941  if ($query_result->numRows() > 0) {
942  while ($data = $ilDB->fetchAssoc($query_result)) {
943  if (in_array($data["question_id"], $question_ids)) {
944  array_push($found, array('id' => $data["question_id"],
945  'title' => $data["title"],
946  'description' => $data["description"],
947  'type_tag' => $data["type_tag"]));
948  }
949  }
950  }
951  return $found;
952  }
$data
Definition: storeScorm.php:23
global $ilDB

◆ getQuestions()

& ilObjSurveyQuestionPool::getQuestions ( )

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

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

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

617  {
618  $ilDB = $this->db;
619  $questions = array();
620  $result = $ilDB->queryF(
621  "SELECT question_id FROM svy_question WHERE obj_fi = %s AND svy_question.tstamp > 0 AND original_id IS NULL",
622  array('integer'),
623  array($this->getId())
624  );
625  if ($result->numRows()) {
626  while ($row = $ilDB->fetchAssoc($result)) {
627  array_push($questions, $row["question_id"]);
628  }
629  }
630  return $questions;
631  }
$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 398 of file class.ilObjSurveyQuestionPool.php.

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

399  {
401  $ilDB = $this->db;
402  $where = "";
403  if (is_array($arrFilter)) {
404  foreach ($arrFilter as $key => $value) {
405  $arrFilter[$key] = str_replace('%', '', $arrFilter[$key]);
406  }
407  if (array_key_exists('title', $arrFilter) && strlen($arrFilter['title'])) {
408  $where .= " AND " . $ilDB->like('svy_question.title', 'text', "%%" . $arrFilter['title'] . "%%");
409  }
410  if (array_key_exists('description', $arrFilter) && strlen($arrFilter['description'])) {
411  $where .= " AND " . $ilDB->like('svy_question.description', 'text', "%%" . $arrFilter['description'] . "%%");
412  }
413  if (array_key_exists('author', $arrFilter) && strlen($arrFilter['author'])) {
414  $where .= " AND " . $ilDB->like('svy_question.author', 'text', "%%" . $arrFilter['author'] . "%%");
415  }
416  if (array_key_exists('type', $arrFilter) && strlen($arrFilter['type'])) {
417  $where .= " AND svy_qtype.type_tag = " . $ilDB->quote($arrFilter['type'], 'text');
418  }
419  }
420  $query_result = $ilDB->queryF(
421  "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,
422  array('integer'),
423  array($this->getId())
424  );
425  $rows = array();
426  if ($query_result->numRows()) {
427  while ($row = $ilDB->fetchAssoc($query_result)) {
428  if ($row["plugin"]) {
429  if ($this->isPluginActive($row["type_tag"])) {
430  array_push($rows, $row);
431  }
432  } else {
433  array_push($rows, $row);
434  }
435  }
436  }
437  return $rows;
438  }
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
$rows
Definition: xhr_table.php:10
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 352 of file class.ilObjSurveyQuestionPool.php.

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

353  {
354  $ilDB = $this->db;
355  $result_array = array();
356  $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'));
357  while ($row = $ilDB->fetchAssoc($result)) {
358  if ($row["plugin"]) {
359  if ($this->isPluginActive($row["type_tag"])) {
360  array_push($result_array, $row);
361  }
362  } else {
363  array_push($result_array, $row);
364  }
365  }
366  return $result_array;
367  }
$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 280 of file class.ilObjSurveyQuestionPool.php.

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

Referenced by createQuestion(), and toXML().

281  {
282  $ilDB = $this->db;
283  if ($question_id < 1) {
284  return;
285  }
286  $result = $ilDB->queryF(
287  "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",
288  array('integer'),
289  array($question_id)
290  );
291  if ($result->numRows() == 1) {
292  $data = $ilDB->fetchAssoc($result);
293  return $data["type_tag"];
294  } else {
295  return;
296  }
297  }
$data
Definition: storeScorm.php:23
$result
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 639 of file class.ilObjSurveyQuestionPool.php.

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

640  {
641  if (is_file($source)) {
642  $isZip = (strcmp(strtolower(substr($source, -3)), 'zip') == 0);
643  if ($isZip) {
644  // unzip file
646 
647  // determine filenames of xml files
648  $subdir = basename($source, ".zip");
649  $source = dirname($source) . "/" . $subdir . "/" . $subdir . ".xml";
650  }
651 
652  $fh = fopen($source, "r") or die("");
653  $xml = fread($fh, filesize($source));
654  fclose($fh) or die("");
655  if ($isZip) {
656  $subdir = basename($source, ".zip");
657  if (@is_dir(dirname($source) . "/" . $subdir)) {
658  ilUtil::delDir(dirname($source) . "/" . $subdir);
659  }
660  }
661  if (strpos($xml, "questestinterop") > 0) {
662  throw new ilInvalidSurveyImportFileException("Unsupported survey version (< 3.8) found.");
663  } else {
664  // survey questions for ILIAS >= 3.8
665  $import = new SurveyImportParser($this->getId(), "", $spl_exists);
666  $import->setXMLContent($xml);
667  $import->startParsing();
668  }
669  }
670  }
static unzip($a_file, $overwrite=false, $a_flat=false)
unzip file
Survey Question Import Parser.
if(!file_exists(getcwd() . '/ilias.ini.php'))
registration confirmation script for ilias
Definition: confirmReg.php:12
getId()
get object id public
$xml
Definition: metadata.php:332
Class ilInvalidSurveyImportFileException.
static delDir($a_dir, $a_clean_only=false)
removes a dir and all its content (subdirs and files) recursively
$source
Definition: metadata.php:76
+ 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 306 of file class.ilObjSurveyQuestionPool.php.

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

307  {
308  $ilDB = $this->db;
309  // check out the already answered questions
310  $result = $ilDB->queryF(
311  "SELECT answer_id FROM svy_answer WHERE question_fi = %s",
312  array('integer'),
313  array($question_id)
314  );
315  $answered = $result->numRows();
316 
317  // check out the questions inserted in surveys
318  $result = $ilDB->queryF(
319  "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",
320  array('integer'),
321  array($question_id)
322  );
323  $inserted = $result->numRows();
324  if (($inserted + $answered) == 0) {
325  return false;
326  }
327  $result_array = array();
328  while ($row = $ilDB->fetchObject($result)) {
329  array_push($result_array, $row);
330  }
331  return $result_array;
332  }
$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 916 of file class.ilObjSurveyQuestionPool.php.

References $plugin_admin, and IL_COMP_MODULE.

Referenced by getQuestionsData(), and getQuestionsInfo().

917  {
918  $ilPluginAdmin = $this->plugin_admin;
919  if ($ilPluginAdmin->isActive(IL_COMP_MODULE, "SurveyQuestionPool", "svyq", $a_pname)) {
920  return true;
921  } else {
922  return false;
923  }
924  }
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 167 of file class.ilObjSurveyQuestionPool.php.

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

Referenced by read().

168  {
169  $ilDB = $this->db;
170 
171  $result = $ilDB->queryF(
172  "SELECT * FROM svy_qpl WHERE obj_fi = %s",
173  array('integer'),
174  array($this->getId())
175  );
176  if ($result->numRows() == 1) {
177  $row = $ilDB->fetchAssoc($result);
178  $this->setOnline($row["isonline"]);
179  }
180  }
$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 990 of file class.ilObjSurveyQuestionPool.php.

References $_SESSION.

991  {
992  if (!array_key_exists("spl_clipboard", $_SESSION)) {
993  $_SESSION["spl_clipboard"] = array();
994  }
995  $_SESSION["spl_clipboard"][$question_id] = array("question_id" => $question_id, "action" => "move");
996  }
$_SESSION["AccountId"]

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

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

341  {
342  $this->duplicateQuestion($question_id, $this->getId());
343  }
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 1001 of file class.ilObjSurveyQuestionPool.php.

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

1002  {
1003  $ilDB = $this->db;
1004 
1005  if (array_key_exists("spl_clipboard", $_SESSION)) {
1006  foreach ($_SESSION["spl_clipboard"] as $question_object) {
1007  if (strcmp($question_object["action"], "move") == 0) {
1008  $result = $ilDB->queryF(
1009  "SELECT obj_fi FROM svy_question WHERE question_id = %s",
1010  array('integer'),
1011  array($question_object["question_id"])
1012  );
1013  if ($result->numRows() == 1) {
1014  $row = $ilDB->fetchAssoc($result);
1015  $source_questionpool = $row["obj_fi"];
1016  if ($this->getId() != $source_questionpool) {
1017  // change the questionpool id in the qpl_questions table
1018  $affectedRows = $ilDB->manipulateF(
1019  "UPDATE svy_question SET obj_fi = %s WHERE question_id = %s",
1020  array('integer','integer'),
1021  array($this->getId(), $question_object["question_id"])
1022  );
1023 
1024  // move question data to the new target directory
1025  $source_path = CLIENT_WEB_DIR . "/survey/" . $source_questionpool . "/" . $question_object["question_id"] . "/";
1026  if (@is_dir($source_path)) {
1027  $target_path = CLIENT_WEB_DIR . "/survey/" . $this->getId() . "/";
1028  if (!@is_dir($target_path)) {
1029  ilUtil::makeDirParents($target_path);
1030  }
1031  @rename($source_path, $target_path . $question_object["question_id"]);
1032  }
1033  } else {
1034  ilUtil::sendFailure($this->lng->txt("spl_move_same_pool"), true);
1035  return;
1036  }
1037  }
1038  } else {
1039  $this->copyQuestion($question_object["question_id"], $this->getId());
1040  }
1041  }
1042  }
1043  ilUtil::sendSuccess($this->lng->txt("spl_paste_success"), true);
1044  unset($_SESSION["spl_clipboard"]);
1045  }
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
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 957 of file class.ilObjSurveyQuestionPool.php.

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

958  {
959  $ilDB = $this->db;
961 
962  $result = $ilDB->queryF(
963  "SELECT question_id FROM svy_question WHERE owner_fi = %s AND tstamp = %s",
964  array("integer", "integer"),
965  array($ilUser->getId(), 0)
966  );
967  while ($data = $ilDB->fetchAssoc($result)) {
968  $this->removeQuestion($data["question_id"]);
969  }
970  }
$data
Definition: storeScorm.php:23
$result
$ilUser
Definition: imgupload.php:18
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 80 of file class.ilObjSurveyQuestionPool.php.

References loadFromDb().

81  {
82  parent::read();
83  $this->loadFromDb();
84  }
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 264 of file class.ilObjSurveyQuestionPool.php.

References SurveyQuestion\_instanciateQuestion().

Referenced by deleteAllData(), and purgeQuestions().

265  {
266  if ($question_id < 1) {
267  return;
268  }
269  $question = &SurveyQuestion::_instanciateQuestion($question_id);
270  $question->delete($question_id);
271  }
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 187 of file class.ilObjSurveyQuestionPool.php.

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

188  {
189  $ilDB = $this->db;
190 
191  parent::update();
192 
193  $result = $ilDB->queryF(
194  "SELECT * FROM svy_qpl WHERE obj_fi = %s",
195  array('integer'),
196  array($this->getId())
197  );
198  if ($result->numRows() == 1) {
199  $affectedRows = $ilDB->manipulateF(
200  "UPDATE svy_qpl SET isonline = %s, tstamp = %s WHERE obj_fi = %s",
201  array('text','integer','integer'),
202  array($this->getOnline(), time(), $this->getId())
203  );
204  } else {
205  $next_id = $ilDB->nextId('svy_qpl');
206  $query = $ilDB->manipulateF(
207  "INSERT INTO svy_qpl (id_questionpool, isonline, obj_fi, tstamp) VALUES (%s, %s, %s, %s)",
208  array('integer', 'text', 'integer', 'integer'),
209  array($next_id, $this->getOnline(), $this->getId(), time())
210  );
211  }
212  }
$result
getId()
get object id public
$query
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 1053 of file class.ilObjSurveyQuestionPool.php.

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

1054  {
1055  $ilDB = $this->db;
1056 
1057  foreach ($this->getQuestions() as $question_id) {
1058  $status = (int) (in_array($question_id, $obligatory_questions));
1059 
1060  $ilDB->manipulate("UPDATE svy_question" .
1061  " SET obligatory = " . $ilDB->quote($status, "integer") .
1062  " WHERE question_id = " . $ilDB->quote($question_id, "integer"));
1063  }
1064  }
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 699 of file class.ilObjSurveyQuestionPool.php.

Referenced by loadFromDb().

700  {
701  switch ($a_online_status) {
702  case 0:
703  case 1:
704  $this->online = $a_online_status;
705  break;
706  default:
707  $this->online = 0;
708  break;
709  }
710  }
+ Here is the caller graph for this function:

◆ toXML()

ilObjSurveyQuestionPool::toXML (   $questions)

export questions to xml

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

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

562  {
563  if (!is_array($questions)) {
564  $questions = &$this->getQuestions();
565  }
566  if (count($questions) == 0) {
567  $questions = &$this->getQuestions();
568  }
569  $xml = "";
570 
571  $a_xml_writer = new ilXmlWriter;
572  // set xml header
573  $a_xml_writer->xmlHeader();
574  $attrs = array(
575  "xmlns:xsi" => "http://www.w3.org/2001/XMLSchema-instance",
576  "xsi:noNamespaceSchemaLocation" => "http://www.ilias.de/download/xsd/ilias_survey_4_2.xsd"
577  );
578  $a_xml_writer->xmlStartTag("surveyobject", $attrs);
579  $attrs = array(
580  "id" => "qpl_" . $this->getId(),
581  "label" => $this->getTitle(),
582  "online" => $this->getOnline()
583  );
584  $a_xml_writer->xmlStartTag("surveyquestions", $attrs);
585  $a_xml_writer->xmlElement("dummy", null, "dummy");
586  // add ILIAS specific metadata
587  $a_xml_writer->xmlStartTag("metadata");
588  $a_xml_writer->xmlStartTag("metadatafield");
589  $a_xml_writer->xmlElement("fieldlabel", null, "SCORM");
590  $md = new ilMD($this->getId(), 0, $this->getType());
591  $writer = new ilXmlWriter();
592  $md->toXml($writer);
593  $metadata = $writer->xmlDumpMem();
594  $a_xml_writer->xmlElement("fieldentry", null, $metadata);
595  $a_xml_writer->xmlEndTag("metadatafield");
596  $a_xml_writer->xmlEndTag("metadata");
597 
598  $a_xml_writer->xmlEndTag("surveyquestions");
599  $a_xml_writer->xmlEndTag("surveyobject");
600 
601  $xml = $a_xml_writer->xmlDumpMem(false);
602 
603  $questionxml = "";
604  foreach ($questions as $key => $value) {
605  $questiontype = $this->getQuestiontype($value);
606  SurveyQuestion::_includeClass($questiontype);
607  $question = new $questiontype();
608  $question->loadFromDb($value);
609  $questionxml .= $question->toXML(false);
610  }
611 
612  $xml = str_replace("<dummy>dummy</dummy>", $questionxml, $xml);
613  return $xml;
614  }
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.
getId()
get object id public
getTitle()
get object title public
xmlHeader()
Writes xml header public.
$xml
Definition: metadata.php:332
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 64 of file class.ilObjSurveyQuestionPool.php.

References ilObject\updateMetaData().

65  {
66  $this->updateMetaData();
67  if (!parent::update()) {
68  return false;
69  }
70 
71  // put here object specific stuff
72 
73  return true;
74  }
updateMetaData()
update meta data entry
+ Here is the call graph for this function:

Field Documentation

◆ $online

ilObjSurveyQuestionPool::$online

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

Referenced by getOnline().

◆ $plugin_admin

ilObjSurveyQuestionPool::$plugin_admin
protected

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

Referenced by isPluginActive().

◆ $user

ilObjSurveyQuestionPool::$user
protected

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