ILIAS  trunk Revision v11.0_alpha-1866-gfa368f7776e
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
ilObjSurveyQuestionPool Class Reference

Class ilObjSurveyQuestionPool. More...

+ Inheritance diagram for ilObjSurveyQuestionPool:
+ Collaboration diagram for ilObjSurveyQuestionPool:

Public Member Functions

 __construct (int $a_id=0, bool $a_call_by_reference=true)
 
 create ($a_upload=false)
 
 update ()
 
 read ()
 
 cloneObject (int $target_id, int $copy_id=0, bool $omit_tree=false)
 
 createQuestion (string $question_type, int $question_id=-1)
 
 copyQuestion (int $question_id, int $questionpool_to)
 
 loadFromDb ()
 
 saveToDb ()
 
 delete ()
 
 deleteAllData ()
 
 removeQuestion (int $question_id)
 Removes a question from the question pool. More...
 
 getQuestiontype (int $question_id)
 
 isInUse (int $question_id)
 Checks if a question is in use by a survey. More...
 
 paste (int $question_id)
 Pastes a duplicate of a question in the question pool. More...
 
 getQuestionsInfo (array $question_array)
 
 duplicateQuestion (int $question_id, int $obj_id=0)
 Duplicates a question for a question pool. More...
 
 getQuestionsData (array $arrFilter)
 Retrieve the data for the output of the question pool. More...
 
 createExportDirectory ()
 creates data directory for export files data_dir/spl_data/spl_<id>/export More...
 
 getExportDirectory ()
 get export directory of survey More...
 
 getExportFiles (string $dir)
 get export files More...
 
 createImportDirectory ()
 creates data directory for import files (data_dir/spl_data/spl_<id>/import More...
 
 getImportDirectory ()
 
 toXML (?array $questions)
 export questions to xml More...
 
 toXmlForExport ()
 
 getQuestions ()
 
 importObject (string $source, bool $spl_exists=false)
 Imports survey questions into ILIAS. More...
 
 getQuestionInfos (array $question_ids)
 Returns title, description and type for an array of question id's. More...
 
 purgeQuestions ()
 Remove all questions with tstamp = 0. More...
 
 copyToClipboard (int $question_id)
 Copies a question to the clipboard. More...
 
 moveToClipboard (int $question_id)
 Moves a question to the clipboard. More...
 
 pasteFromClipboard ()
 Copies/Moves a question from the clipboard. More...
 
 setObligatoryStates (array $obligatory_questions)
 
- Public Member Functions inherited from ilObject
 getObjectProperties ()
 
 flushObjectProperties ()
 
 withReferences ()
 determines whether objects are referenced or not (got ref ids or not) More...
 
 processAutoRating ()
 
 read ()
 
 getId ()
 
 setId (int $id)
 
 setRefId (int $ref_id)
 
 getRefId ()
 
 getType ()
 
 setType (string $type)
 
 getPresentationTitle ()
 get presentation title Normally same as title Overwritten for sessions More...
 
 getTitle ()
 
 getUntranslatedTitle ()
 Get untranslated object title WebDAV needs to access the untranslated title of an object. More...
 
 setTitle (string $title)
 
 getDescription ()
 
 setDescription (string $description)
 
 getLongDescription ()
 get object long description (stored in object_description) More...
 
 getImportId ()
 
 setImportId (string $import_id)
 
 setOfflineStatus (bool $status)
 
 getOfflineStatus ()
 
 supportsOfflineHandling ()
 
 getOwner ()
 
 getOwnerName ()
 get full name of object owner More...
 
 setOwner (int $usr_id)
 
 getCreateDate ()
 Get create date in YYYY-MM-DD HH-MM-SS format. More...
 
 getLastUpdateDate ()
 Get last update date in YYYY-MM-DD HH-MM-SS format. More...
 
 create ()
 note: title, description and type should be set when this function is called More...
 
 update ()
 
 MDUpdateListener (string $element)
 Metadata update listener. More...
 
 createMetaData ()
 
 updateMetaData ()
 
 deleteMetaData ()
 
 updateOwner ()
 update owner of object in db More...
 
 putInTree (int $parent_ref_id)
 maybe this method should be in tree object!? More...
 
 setPermissions (int $parent_ref_id)
 
 setParentRolePermissions (int $parent_ref_id)
 Initialize the permissions of parent roles (local roles of categories, global roles...) This method is overwritten in e.g. More...
 
 createReference ()
 creates reference for object More...
 
 countReferences ()
 
 delete ()
 delete object or referenced object (in the case of a referenced object, object data is only deleted if last reference is deleted) This function removes an object entirely from system!! More...
 
 initDefaultRoles ()
 init default roles settings Purpose of this function is to create a local role folder and local roles, that are needed depending on the object type. More...
 
 applyDidacticTemplate (int $tpl_id)
 
 getXMLZip ()
 
 getHTMLDirectory ()
 
 appendCopyInfo (int $target_id, int $copy_id)
 Prepend Copy info if object with same name exists in that container. More...
 
 cloneDependencies (int $target_id, int $copy_id)
 Clone object dependencies. More...
 
 cloneMetaData (ilObject $target_obj)
 Copy meta data. More...
 
 selfOrParentWithRatingEnabled ()
 
 getPossibleSubObjects (bool $filter=true)
 get all possible sub objects of this type the object can decide which types of sub objects are possible jut in time overwrite if the decision distinguish from standard model More...
 

Static Public Member Functions

static _lookupOnline (int $a_obj_id)
 
static _isWriteable (int $object_id)
 Returns true, if the question pool is writeable for the current user. More...
 
static _getQuestiontypes ()
 Get all available question types. More...
 
static _getQuestionClasses ()
 
static _getQuestionTypeTranslations ()
 
static _getAvailableQuestionpools (bool $use_object_id=false, bool $could_be_offline=false, bool $showPath=false, string $permission="read")
 Returns the available question pools for the active user. More...
 
- Static Public Member Functions inherited from ilObject
static _lookupObjIdByImportId (string $import_id)
 Get (latest) object id for an import id. More...
 
static _lookupImportId (int $obj_id)
 
static _lookupOwnerName (int $owner_id)
 Lookup owner name for owner id. More...
 
static _getIdForImportId (string $import_id)
 
static _getAllReferences (int $id)
 get all reference ids for object ID More...
 
static _lookupTitle (int $obj_id)
 
static lookupOfflineStatus (int $obj_id)
 Lookup offline status using objectDataCache. More...
 
static _lookupOwner (int $obj_id)
 Lookup owner user ID for object ID. More...
 
static _getIdsForTitle (string $title, string $type='', bool $partial_match=false)
 
static _lookupDescription (int $obj_id)
 
static _lookupLastUpdate (int $obj_id, bool $formatted=false)
 
static _getLastUpdateOfObjects (array $obj_ids)
 
static _lookupObjId (int $ref_id)
 
static _setDeletedDate (int $ref_id, int $deleted_by)
 
static setDeletedDates (array $ref_ids, int $user_id)
 
static _resetDeletedDate (int $ref_id)
 
static _lookupDeletedDate (int $ref_id)
 
static _writeTitle (int $obj_id, string $title)
 write title to db (static) More...
 
static _writeDescription (int $obj_id, string $desc)
 write description to db (static) More...
 
static _writeImportId (int $obj_id, string $import_id)
 write import id to db (static) More...
 
static _lookupType (int $id, bool $reference=false)
 
static _isInTrash (int $ref_id)
 
static _hasUntrashedReference (int $obj_id)
 checks whether an object has at least one reference that is not in trash More...
 
static _lookupObjectId (int $ref_id)
 
static _getObjectsDataForType (string $type, bool $omit_trash=false)
 get all objects of a certain type More...
 
static _exists (int $id, bool $reference=false, ?string $type=null)
 checks if an object exists in object_data More...
 
static _getObjectsByType (string $obj_type="", ?int $owner=null)
 
static _prepareCloneSelection (array $ref_ids, string $new_type, bool $show_path=true)
 Prepare copy wizard object selection. More...
 
static getIconForType (string $type)
 
static _getIcon (int $obj_id=0, string $size="big", string $type="", bool $offline=false)
 Get icon for repository item. More...
 
static collectDeletionDependencies (array &$deps, int $ref_id, int $obj_id, string $type, int $depth=0)
 Collect deletion dependencies. More...
 
static getDeletionDependencies (int $obj_id)
 Get deletion dependencies. More...
 
static getLongDescriptions (array $obj_ids)
 
static getAllOwnedRepositoryObjects (int $user_id)
 
static fixMissingTitles ($type, array &$obj_title_map)
 Try to fix missing object titles. More...
 
static _lookupCreationDate (int $obj_id)
 
static _getObjectTypeIdByTitle (string $type, ?\ilDBInterface $ilDB=null)
 

Data Fields

bool $online = false
 
- Data Fields inherited from ilObject
const TITLE_LENGTH = 255
 
const DESC_LENGTH = 128
 
const LONG_DESC_LENGTH = 4000
 
const TABLE_OBJECT_DATA = "object_data"
 
array $objectList
 
string $untranslatedTitle
 

Protected Attributes

InternalDomainService $domain
 
EditManager $edit_manager
 
ilObjUser $user
 
ilComponentRepository $component_repository
 
- Protected Attributes inherited from ilObject
ilLogger $obj_log
 
ILIAS $ilias
 
ilObjectDefinition $obj_definition
 
ilDBInterface $db
 
ilLogger $log
 
ilErrorHandling $error
 
ilTree $tree
 
ilAppEventHandler $app_event_handler
 
ilRbacAdmin $rbac_admin
 
ilRbacReview $rbac_review
 
ilObjUser $user
 
ilLanguage $lng
 
LOMServices $lom_services
 
bool $call_by_reference
 
int $max_title = self::TITLE_LENGTH
 
int $max_desc = self::DESC_LENGTH
 
bool $add_dots = true
 
int $ref_id = null
 
string $type = ""
 
string $title = ""
 
string $desc = ""
 
string $long_desc = ""
 
int $owner = 0
 
string $create_date = ""
 
string $last_update = ""
 
string $import_id = ""
 
bool $register = false
 

Private Attributes

ilGlobalTemplateInterface $main_tpl
 

Additional Inherited Members

- Protected Member Functions inherited from ilObject
 doMDUpdateListener (string $a_element)
 
 beforeMDUpdateListener (string $a_element)
 
 doCreateMetaData ()
 
 beforeCreateMetaData ()
 
 doUpdateMetaData ()
 
 beforeUpdateMetaData ()
 
 doDeleteMetaData ()
 
 beforeDeleteMetaData ()
 
 handleAutoRating ()
 
 hasAutoRating ()
 

Detailed Description

Constructor & Destructor Documentation

◆ __construct()

ilObjSurveyQuestionPool::__construct ( int  $a_id = 0,
bool  $a_call_by_reference = true 
)

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

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

39  {
40  global $DIC;
41  $this->main_tpl = $DIC->ui()->mainTemplate();
42 
43  $this->log = $DIC["ilLog"];
44  $this->db = $DIC->database();
45  $this->user = $DIC->user();
46  $this->component_repository = $DIC["component.repository"];
47  $this->type = "spl";
48  parent::__construct($a_id, $a_call_by_reference);
49  $this->edit_manager = $DIC->surveyQuestionPool()
50  ->internal()
51  ->domain()
52  ->editing();
53  $this->domain = $DIC->surveyQuestionPool()->internal()->domain();
54  }
global $DIC
Definition: shib_login.php:22
__construct(Container $dic, ilPlugin $plugin)
+ Here is the call graph for this function:

Member Function Documentation

◆ _getAvailableQuestionpools()

static ilObjSurveyQuestionPool::_getAvailableQuestionpools ( bool  $use_object_id = false,
bool  $could_be_offline = false,
bool  $showPath = false,
string  $permission = "read" 
)
static

Returns the available question pools for the active user.

Returns
array<int, string> keys are ref or obj IDs, values are titles

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

References $DIC, $ilDB, ilObject\$ref_id, ilUtil\_getObjectsByOperations(), ilObject\_lookupObjectId(), ilObject\_prepareCloneSelection(), and ILIAS\Repository\int().

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

755  : array {
756  global $DIC;
757 
758  $ilUser = $DIC->user();
759  global $DIC;
760 
761  $ilDB = $DIC->database();
762 
763  $result_array = array();
764  $qpls = ilUtil::_getObjectsByOperations("spl", $permission, $ilUser->getId(), -1);
765  $titles = ilObject::_prepareCloneSelection($qpls, "spl", $showPath);
766  $allqpls = array();
767  $result = $ilDB->query("SELECT sq.obj_fi, od.offline as offline FROM svy_qpl sq JOIN object_data od ON (sq.obj_fi = od.obj_id) WHERE sq.obj_fi > 0 AND sq.tstamp > 0 AND NOT(od.offline = 1)");
768  while ($row = $ilDB->fetchAssoc($result)) {
769  $allqpls[$row['obj_fi']] = !($row['offline']);
770  }
771  foreach ($qpls as $ref_id) {
772  $obj_id = ilObject::_lookupObjectId($ref_id);
773  if ($could_be_offline || ($allqpls[$obj_id] ?? 0) == 1) {
774  if ($use_object_id) {
775  $result_array[$obj_id] = $titles[$ref_id];
776  } else {
777  $result_array[(int) $ref_id] = $titles[$ref_id];
778  }
779  }
780  }
781  return $result_array;
782  }
static _prepareCloneSelection(array $ref_ids, string $new_type, bool $show_path=true)
Prepare copy wizard object selection.
global $DIC
Definition: shib_login.php:22
static _lookupObjectId(int $ref_id)
static _getObjectsByOperations( $a_obj_type, string $a_operation, int $a_usr_id=0, int $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.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _getQuestionClasses()

static ilObjSurveyQuestionPool::_getQuestionClasses ( )
static

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

References $c.

Referenced by ilObjSurvey\getMaxSumScore().

711  : array
712  {
713  $classes = array_map(
714  static function (array $c): string {
715  return $c["type_tag"];
716  },
717  self::_getQuestiontypes()
718  );
719  return $classes;
720  }
$c
Definition: deliver.php:25
+ Here is the caller graph for this function:

◆ _getQuestiontypes()

static ilObjSurveyQuestionPool::_getQuestiontypes ( )
static

Get all available question types.

Todo:
move to question manager, use dto

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

References $DIC, $ilDB, ilObject\$lng, ilObject\$type, ilLanguage\loadLanguageModule(), and ilLanguage\txt().

Referenced by ilSurveyQuestionTableGUI\importData(), ilSurveyQuestionbrowserTableGUI\initFilter(), ilSurveyQuestionsTableGUI\initFilter(), ilSurveyEditorGUI\questionsObject(), and ilObjSurveyQuestionPoolGUI\questionsObject().

655  : array
656  {
657  global $DIC;
658 
659  $ilDB = $DIC->database();
660  $lng = $DIC->language();
661 
662  $lng->loadLanguageModule("survey");
663  $types = array();
664  $query_result = $ilDB->query("SELECT * FROM svy_qtype ORDER BY type_tag");
665  while ($row = $ilDB->fetchAssoc($query_result)) {
666  //array_push($questiontypes, $row["type_tag"]);
667  if ((int) $row["plugin"] === 0) {
668  $types[$lng->txt($row["type_tag"])] = $row;
669  }
670  }
671  ksort($types);
672 
673 
674  // #14263 - default sorting
675 
676  $default_sorting = array_flip(array(
677  "SurveySingleChoiceQuestion",
678  "SurveyMultipleChoiceQuestion",
679  "SurveyMatrixQuestion",
680  "SurveyMetricQuestion",
681  "SurveyTextQuestion"
682  ));
683 
684  $sorted = array();
685  $idx = count($default_sorting);
686  foreach ($types as $caption => $item) {
687  $type = $item["type_tag"];
688  $item["caption"] = $caption;
689 
690  // default
691  if (array_key_exists($type, $default_sorting)) {
692  $sorted[$default_sorting[$type]] = $item;
693  }
694  // plugin (append alphabetically sorted)
695  else {
696  $sorted[$idx] = $item;
697  $idx++;
698  }
699  }
700  ksort($sorted);
701 
702  // redo captions as index
703  $types = array();
704  foreach ($sorted as $item) {
705  $types[$item["caption"]] = $item;
706  }
707 
708  return $types;
709  }
string $type
txt(string $a_topic, string $a_default_lang_fallback_mod="")
gets the text for a given topic if the topic is not in the list, the topic itself with "-" will be re...
loadLanguageModule(string $a_module)
Load language module.
ilLanguage $lng
global $DIC
Definition: shib_login.php:22
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _getQuestionTypeTranslations()

static ilObjSurveyQuestionPool::_getQuestionTypeTranslations ( )
static
Todo:
move to question manager, use dto

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

References $DIC, $ilDB, ilObject\$lng, ilLanguage\loadLanguageModule(), and ilLanguage\txt().

Referenced by ilObjSurvey\getQuestionsTable().

725  : array
726  {
727  global $DIC;
728 
729  $ilDB = $DIC->database();
730  $lng = $DIC->language();
731 
732  $component_factory = $DIC["component.factory"];
733 
734  $lng->loadLanguageModule("survey");
735  $result = $ilDB->query("SELECT * FROM svy_qtype");
736  $types = array();
737  while ($row = $ilDB->fetchAssoc($result)) {
738  if ((int) $row["plugin"] === 0) {
739  $types[$row['type_tag']] = $lng->txt($row["type_tag"]);
740  }
741  }
742  ksort($types);
743  return $types;
744  }
txt(string $a_topic, string $a_default_lang_fallback_mod="")
gets the text for a given topic if the topic is not in the list, the topic itself with "-" will be re...
loadLanguageModule(string $a_module)
Load language module.
ilLanguage $lng
global $DIC
Definition: shib_login.php:22
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _isWriteable()

static ilObjSurveyQuestionPool::_isWriteable ( int  $object_id)
static

Returns true, if the question pool is writeable for the current user.

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

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

Referenced by SurveyQuestion\_isWriteable().

637  : bool {
638  global $DIC;
639 
640  $rbacsystem = $DIC->rbac()->system();
641  $refs = ilObject::_getAllReferences($object_id);
642  $result = false;
643  foreach ($refs as $ref) {
644  if ($rbacsystem->checkAccess("write", $ref) && (ilObject::_hasUntrashedReference($object_id))) {
645  $result = true;
646  }
647  }
648  return $result;
649  }
static _getAllReferences(int $id)
get all reference ids for object ID
static _hasUntrashedReference(int $obj_id)
checks whether an object has at least one reference that is not in trash
global $DIC
Definition: shib_login.php:22
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _lookupOnline()

static ilObjSurveyQuestionPool::_lookupOnline ( int  $a_obj_id)
static

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

Referenced by ILIAS\UI\Component\Legacy\Content\Filter\FilterManager\legacyOnlineFilter().

626  : bool
627  {
628  return !self::getOfflineStatus($a_obj_id);
629  }
+ Here is the caller graph for this function:

◆ cloneObject()

ilObjSurveyQuestionPool::cloneObject ( int  $target_id,
int  $copy_id = 0,
bool  $omit_tree = false 
)

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

References ilCopyWizardOptions\_getInstance(), ilObject\cloneMetaData(), and getQuestions().

80  : ?ilObject
81  {
82  $newObj = parent::cloneObject($target_id, $copy_id, $omit_tree);
83 
84  //copy online status if object is not the root copy object
85  $cp_options = ilCopyWizardOptions::_getInstance($copy_id);
86 
87  $newObj->saveToDb();
88  // clone the questions in the question pool
89  $questions = $this->getQuestions();
90  foreach ($questions as $question_id) {
91  $newObj->copyQuestion($question_id, $newObj->getId());
92  }
93 
94  // clone meta data
95  $this->cloneMetaData($newObj);
96 
97  // update the metadata with the new title of the question pool
98  $newObj->updateMetaData();
99  return $newObj;
100  }
cloneMetaData(ilObject $target_obj)
Copy meta data.
static _getInstance(int $a_copy_id)
+ Here is the call graph for this function:

◆ copyQuestion()

ilObjSurveyQuestionPool::copyQuestion ( int  $question_id,
int  $questionpool_to 
)
Parameters
int$question_id
int$questionpool_toquestion pool id

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

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

Referenced by pasteFromClipboard().

130  : void {
131  $question_gui = $this->createQuestion("", $question_id);
132  if ($question_gui->object->getObjId() === $questionpool_to) {
133  // the question is copied into the same question pool
134  $this->duplicateQuestion($question_id);
135  } else {
136  // the question is copied into another question pool
137  $newtitle = $question_gui->object->getTitle();
138  if ($question_gui->object->questionTitleExists($question_gui->object->getTitle(), $questionpool_to)) {
139  $counter = 2;
140  while ($question_gui->object->questionTitleExists($question_gui->object->getTitle() . " ($counter)", $questionpool_to)) {
141  $counter++;
142  }
143  $newtitle = $question_gui->object->getTitle() . " ($counter)";
144  }
145  $question_gui->object->copyObject($this->getId(), $newtitle);
146  }
147  }
duplicateQuestion(int $question_id, int $obj_id=0)
Duplicates a question for a question pool.
createQuestion(string $question_type, int $question_id=-1)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ copyToClipboard()

ilObjSurveyQuestionPool::copyToClipboard ( int  $question_id)

Copies a question to the clipboard.

Parameters
int$question_idObject id of the question

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

837  : void {
838  $this->edit_manager->addQuestionToClipboard($question_id, "copy");
839  }

◆ create()

ilObjSurveyQuestionPool::create (   $a_upload = false)

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

References $id, and ilObject\createMetaData().

56  : int
57  {
58  $id = parent::create();
59  if (!$a_upload) {
60  $this->createMetaData();
61  }
62  return $id;
63  }
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
+ Here is the call graph for this function:

◆ createExportDirectory()

ilObjSurveyQuestionPool::createExportDirectory ( )

creates data directory for export files data_dir/spl_data/spl_<id>/export

Exceptions
ilSurveyException

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

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

386  : void
387  {
388  $spl_data_dir = ilFileUtils::getDataDir() . "/spl_data";
389  ilFileUtils::makeDir($spl_data_dir);
390  if (!is_writable($spl_data_dir)) {
391  throw new ilSurveyException("Survey Questionpool Data Directory (" . $spl_data_dir . ") not writeable.");
392  }
393 
394  // create learning module directory (data_dir/lm_data/lm_<id>)
395  $spl_dir = $spl_data_dir . "/spl_" . $this->getId();
396  ilFileUtils::makeDir($spl_dir);
397  if (!is_dir($spl_dir)) {
398  throw new ilSurveyException("Creation of Survey Questionpool Directory failed.");
399  }
400  // create Export subdirectory (data_dir/lm_data/lm_<id>/Export)
401  $export_dir = $spl_dir . "/export";
402  ilFileUtils::makeDir($export_dir);
403  if (!is_dir($export_dir)) {
404  throw new ilSurveyException("Creation of Survey Questionpool Export Directory failed.");
405  }
406  }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static getDataDir()
get data directory (outside webspace)
static makeDir(string $a_dir)
creates a new directory and inherits all filesystem permissions of the parent directory You may pass ...
+ Here is the call graph for this function:

◆ createImportDirectory()

ilObjSurveyQuestionPool::createImportDirectory ( )

creates data directory for import files (data_dir/spl_data/spl_<id>/import

Exceptions
ilSurveyException

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

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

456  : void
457  {
458  $spl_data_dir = ilFileUtils::getDataDir() . "/spl_data";
459  ilFileUtils::makeDir($spl_data_dir);
460 
461  if (!is_writable($spl_data_dir)) {
462  throw new ilSurveyException("Survey Questionpool Data Directory (" . $spl_data_dir . ") not writeable.");
463  }
464 
465  // create test directory (data_dir/spl_data/spl_<id>)
466  $spl_dir = $spl_data_dir . "/spl_" . $this->getId();
467  ilFileUtils::makeDir($spl_dir);
468  if (!is_dir($spl_dir)) {
469  throw new ilSurveyException("Creation of Survey Questionpool Directory failed.");
470  }
471 
472  // create import subdirectory (data_dir/spl_data/spl_<id>/import)
473  $import_dir = $spl_dir . "/import";
474  ilFileUtils::makeDir($import_dir);
475  if (!is_dir($import_dir)) {
476  throw new ilSurveyException("Creation of Survey Questionpool Import Directory failed.");
477  }
478  }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static getDataDir()
get data directory (outside webspace)
static makeDir(string $a_dir)
creates a new directory and inherits all filesystem permissions of the parent directory You may pass ...
+ Here is the call graph for this function:

◆ createQuestion()

ilObjSurveyQuestionPool::createQuestion ( string  $question_type,
int  $question_id = -1 
)
Todo:
check this method, it does not seem to create anything

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

References getQuestiontype().

Referenced by copyQuestion().

109  if ((!$question_type) and ($question_id > 0)) {
110  $question_type = $this->getQuestiontype($question_id);
111  }
112 
113  $question_type_gui = $question_type . "GUI";
114  $question = new $question_type_gui();
115 
116  if ($question_id > 0) {
117  $question->object->loadFromDb($question_id);
118  }
119 
120  return $question;
121  }
Basic class for all survey question types The SurveyQuestionGUI class defines and encapsulates basic ...
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ delete()

ilObjSurveyQuestionPool::delete ( )

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

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

174  : bool
175  {
176  $remove = parent::delete();
177  // always call parent delete function first!!
178  if (!$remove) {
179  return false;
180  }
181 
182  // delete all related questions
183  $this->deleteAllData();
184 
185  // delete meta data
186  $this->deleteMetaData();
187 
188  return true;
189  }
+ Here is the call graph for this function:

◆ deleteAllData()

ilObjSurveyQuestionPool::deleteAllData ( )

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

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

Referenced by delete().

191  : void
192  {
193  $ilDB = $this->db;
194  $result = $ilDB->queryF(
195  "SELECT question_id FROM svy_question WHERE obj_fi = %s AND original_id IS NULL",
196  array('integer'),
197  array($this->getId())
198  );
199  $found_questions = array();
200  while ($row = $ilDB->fetchAssoc($result)) {
201  $this->removeQuestion($row["question_id"]);
202  }
203 
204  // delete export files
205  $spl_data_dir = ilFileUtils::getDataDir() . "/spl_data";
206  $directory = $spl_data_dir . "/spl_" . $this->getId();
207  if (is_dir($directory)) {
208  ilFileUtils::delDir($directory);
209  }
210  }
removeQuestion(int $question_id)
Removes a question from the question pool.
static delDir(string $a_dir, bool $a_clean_only=false)
removes a dir and all its content (subdirs and files) recursively
ilDBInterface $db
static getDataDir()
get data directory (outside webspace)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ duplicateQuestion()

ilObjSurveyQuestionPool::duplicateQuestion ( int  $question_id,
int  $obj_id = 0 
)

Duplicates a question for a question pool.

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

References ilObject\$title, $user, and SurveyQuestion\_instanciateQuestion().

Referenced by copyQuestion(), and paste().

314  : void {
315  $ilUser = $this->user;
316  $question = SurveyQuestion::_instanciateQuestion($question_id);
317  $suffix = "";
318  $counter = 1;
319  while ($question->questionTitleExists($question->getTitle() . $suffix, $obj_id)) {
320  $counter++;
321  if ($counter > 1) {
322  $suffix = " ($counter)";
323  }
324  }
325  if ($obj_id) {
326  $question->setObjId($obj_id);
327  }
328  $max_len = 195;
329  if (strlen($question->getTitle() . $suffix) > $max_len) {
330  $title = substr($question->getTitle(), 0, $max_len - strlen($suffix)) . $suffix;
331  } else {
332  $title = $question->getTitle() . $suffix;
333  }
334  $question->duplicate(false, $title, $ilUser->fullname, $ilUser->id);
335  }
string $title
static _instanciateQuestion(int $question_id)
Get question object.
+ 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 411 of file class.ilObjSurveyQuestionPool.php.

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

411  : string
412  {
413  $export_dir = ilFileUtils::getDataDir() . "/spl_data" . "/spl_" . $this->getId() . "/export";
414  return $export_dir;
415  }
static getDataDir()
get data directory (outside webspace)
+ Here is the call graph for this function:

◆ getExportFiles()

ilObjSurveyQuestionPool::getExportFiles ( string  $dir)

get export files

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

References ILIAS\UI\examples\Symbol\Glyph\Sort\sort().

420  : array
421  {
422  // quit if import dir not available
423  if (!is_dir($dir) or
424  !is_writable($dir)) {
425  return array();
426  }
427 
428  // open directory
429  $dir = dir($dir);
430 
431  // initialize array
432  $file = array();
433 
434  // get files and save the in the array
435  while ($entry = $dir->read()) {
436  if ($entry !== "." &&
437  $entry !== ".." &&
438  preg_match("/^[0-9]{10}__[0-9]+__(spl_)*[0-9]+\.[A-Za-z]{3}$/", $entry)) {
439  $file[] = $entry;
440  }
441  }
442 
443  // close import directory
444  $dir->close();
445  // sort files
446  sort($file);
447 
448  return $file;
449  }
sort()
description: > Example for rendering a Sort Glyph.
Definition: sort.php:41
+ Here is the call graph for this function:

◆ getImportDirectory()

ilObjSurveyQuestionPool::getImportDirectory ( )

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

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

480  : string
481  {
482  return ilFileUtils::getDataDir() . "/spl_data" .
483  "/spl_" . $this->getId() . "/import";
484  }
static getDataDir()
get data directory (outside webspace)
+ Here is the call graph for this function:

◆ getQuestionInfos()

ilObjSurveyQuestionPool::getQuestionInfos ( array  $question_ids)

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

Parameters
int[]$question_ids An array of question id's
Returns
array Array of associated arrays with title, description, type_tag
Todo:
move to question manager, use dto

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

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

790  : array
791  {
792  $ilDB = $this->db;
793 
794  $found = array();
795  $query_result = $ilDB->query("SELECT svy_question.*, svy_qtype.type_tag FROM svy_question, svy_qtype " .
796  "WHERE svy_question.questiontype_fi = svy_qtype.questiontype_id " .
797  "AND svy_question.tstamp > 0 AND " . $ilDB->in('svy_question.question_id', $question_ids, false, 'integer') . " " .
798  "ORDER BY svy_question.title");
799  if ($query_result->numRows() > 0) {
800  while ($data = $ilDB->fetchAssoc($query_result)) {
801  if (in_array($data["question_id"], $question_ids)) {
802  $found[] = array('id' => $data["question_id"],
803  'title' => $data["title"],
804  'description' => $data["description"],
805  'type_tag' => $data["type_tag"]
806  );
807  }
808  }
809  }
810  return $found;
811  }
ilDBInterface $db

◆ getQuestions()

ilObjSurveyQuestionPool::getQuestions ( )

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

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

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

569  : array
570  {
571  $ilDB = $this->db;
572  $questions = array();
573  $result = $ilDB->queryF(
574  "SELECT question_id FROM svy_question WHERE obj_fi = %s AND svy_question.tstamp > 0 AND original_id IS NULL",
575  array('integer'),
576  array($this->getId())
577  );
578  if ($result->numRows()) {
579  while ($row = $ilDB->fetchAssoc($result)) {
580  $questions[] = $row["question_id"];
581  }
582  }
583  return $questions;
584  }
ilDBInterface $db
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getQuestionsData()

ilObjSurveyQuestionPool::getQuestionsData ( array  $arrFilter)

Retrieve the data for the output of the question pool.

Todo:
move to question/pool manager

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

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

343  : array {
344  $ilDB = $this->db;
345  $where = "";
346  if (count($arrFilter) > 0) {
347  foreach ($arrFilter as $key => $value) {
348  $arrFilter[$key] = str_replace('%', '', $value);
349  }
350  if (array_key_exists('title', $arrFilter) && strlen($arrFilter['title'] ?? "")) {
351  $where .= " AND " . $ilDB->like('svy_question.title', 'text', "%%" . $arrFilter['title'] . "%%");
352  }
353  if (array_key_exists('description', $arrFilter) && strlen($arrFilter['description'] ?? "")) {
354  $where .= " AND " . $ilDB->like('svy_question.description', 'text', "%%" . $arrFilter['description'] . "%%");
355  }
356  if (array_key_exists('author', $arrFilter) && strlen($arrFilter['author'] ?? "")) {
357  $where .= " AND " . $ilDB->like('svy_question.author', 'text', "%%" . $arrFilter['author'] . "%%");
358  }
359  if (array_key_exists('type', $arrFilter) && strlen($arrFilter['type'] ?? "")) {
360  $where .= " AND svy_qtype.type_tag = " . $ilDB->quote($arrFilter['type'], 'text');
361  }
362  }
363  $query_result = $ilDB->queryF(
364  "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,
365  array('integer'),
366  array($this->getId())
367  );
368  $rows = array();
369  if ($query_result->numRows()) {
370  while ($row = $ilDB->fetchAssoc($query_result)) {
371  if ($row["plugin"]) {
372  continue;
373  } else {
374  $rows[] = $row;
375  }
376  }
377  }
378  return $rows;
379  }
ilDBInterface $db
+ Here is the call graph for this function:

◆ getQuestionsInfo()

ilObjSurveyQuestionPool::getQuestionsInfo ( array  $question_array)
Parameters
int[]$question_array question ids
Todo:
move to question manager/repo, use dto

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

References ilObject\$db, and $ilDB.

294  : array {
295  $ilDB = $this->db;
296  $result_array = array();
297  $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'));
298  while ($row = $ilDB->fetchAssoc($result)) {
299  if ($row["plugin"]) {
300  continue;
301  } else {
302  $result_array[] = $row;
303  }
304  }
305  return $result_array;
306  }
ilDBInterface $db

◆ getQuestiontype()

ilObjSurveyQuestionPool::getQuestiontype ( int  $question_id)
Returns
string|null question type string

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

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

Referenced by createQuestion(), toXML(), and toXmlForExport().

229  : ?string {
230  $ilDB = $this->db;
231  if ($question_id < 1) {
232  return null;
233  }
234  $result = $ilDB->queryF(
235  "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",
236  array('integer'),
237  array($question_id)
238  );
239  if ($result->numRows() === 1) {
240  $data = $ilDB->fetchAssoc($result);
241  return $data["type_tag"];
242  } else {
243  return null;
244  }
245  }
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
ilDBInterface $db
+ Here is the caller graph for this function:

◆ importObject()

ilObjSurveyQuestionPool::importObject ( string  $source,
bool  $spl_exists = false 
)

Imports survey questions into ILIAS.

Parameters
string$sourceThe filename of an XML import file
Exceptions
ilInvalidSurveyImportFileException

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

References ilFileUtils\delDir(), and ilObject\getId().

594  : void {
595  if (is_file($source)) {
596  $isZip = (strcmp(strtolower(substr($source, -3)), 'zip') === 0);
597  if ($isZip) {
598  // unzip file
599  $this->domain->resources()->zip()->unzipFile($source);
600 
601  // determine filenames of xml files
602  $subdir = basename($source, ".zip");
603  $source = dirname($source) . "/" . $subdir . "/" . $subdir . ".xml";
604  }
605 
606  $fh = fopen($source, 'rb') or die("");
607  $xml = fread($fh, filesize($source));
608  fclose($fh) or die("");
609  if ($isZip) {
610  $subdir = basename($source, ".zip");
611  if (is_dir(dirname($source) . "/" . $subdir)) {
612  ilFileUtils::delDir(dirname($source) . "/" . $subdir);
613  }
614  }
615  if (strpos($xml, "questestinterop") > 0) {
616  throw new ilInvalidSurveyImportFileException("Unsupported survey version (< 3.8) found.");
617  }
618 
619  // survey questions for ILIAS >= 3.8
620  $import = new SurveyImportParser($this->getId(), "", $spl_exists);
621  $import->setXMLContent($xml);
622  $import->startParsing();
623  }
624  }
if(!file_exists('../ilias.ini.php'))
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static delDir(string $a_dir, bool $a_clean_only=false)
removes a dir and all its content (subdirs and files) recursively
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
+ Here is the call graph for this function:

◆ isInUse()

ilObjSurveyQuestionPool::isInUse ( int  $question_id)

Checks if a question is in use by a survey.

Returns
mixed array of the surveys which use the question, when the question is in use by at least one survey, otherwise false

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

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

252  : ?array
253  {
254  $ilDB = $this->db;
255  // check out the already answered questions
256  $result = $ilDB->queryF(
257  "SELECT answer_id FROM svy_answer WHERE question_fi = %s",
258  array('integer'),
259  array($question_id)
260  );
261  $answered = $result->numRows();
262 
263  // check out the questions inserted in surveys
264  $result = $ilDB->queryF(
265  "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",
266  array('integer'),
267  array($question_id)
268  );
269  $inserted = $result->numRows();
270  if (($inserted + $answered) === 0) {
271  return null;
272  }
273  $result_array = array();
274  while ($row = $ilDB->fetchObject($result)) {
275  $result_array[] = $row;
276  }
277  return $result_array;
278  }
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
ilDBInterface $db

◆ loadFromDb()

ilObjSurveyQuestionPool::loadFromDb ( )

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

Referenced by read().

149  : void
150  {
151  }
+ Here is the caller graph for this function:

◆ moveToClipboard()

ilObjSurveyQuestionPool::moveToClipboard ( int  $question_id)

Moves a question to the clipboard.

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

846  : void {
847  $this->edit_manager->addQuestionToClipboard($question_id, "move");
848  }

◆ paste()

ilObjSurveyQuestionPool::paste ( int  $question_id)

Pastes a duplicate of a question in the question pool.

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

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

283  : void
284  {
285  $this->duplicateQuestion($question_id, $this->getId());
286  }
duplicateQuestion(int $question_id, int $obj_id=0)
Duplicates a question for a question pool.
+ Here is the call graph for this function:

◆ pasteFromClipboard()

ilObjSurveyQuestionPool::pasteFromClipboard ( )

Copies/Moves a question from the clipboard.

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

References ilObject\$db, $ilDB, CLIENT_WEB_DIR, copyQuestion(), ilObject\getId(), ILIAS\Repository\lng(), ilFileUtils\makeDirParents(), and ilFileUtils\rename().

853  : void
854  {
855  $ilDB = $this->db;
856 
857  $qentries = $this->edit_manager->getQuestionsFromClipboard();
858  if (count($qentries) > 0) {
859  foreach ($qentries as $question_object) {
860  if (strcmp($question_object["action"], "move") === 0) {
861  $result = $ilDB->queryF(
862  "SELECT obj_fi FROM svy_question WHERE question_id = %s",
863  array('integer'),
864  array($question_object["question_id"])
865  );
866  if ($result->numRows() === 1) {
867  $row = $ilDB->fetchAssoc($result);
868  $source_questionpool = $row["obj_fi"];
869  if ($this->getId() != $source_questionpool) {
870  // change the questionpool id in the qpl_questions table
871  $affectedRows = $ilDB->manipulateF(
872  "UPDATE svy_question SET obj_fi = %s WHERE question_id = %s",
873  array('integer','integer'),
874  array($this->getId(), $question_object["question_id"])
875  );
876 
877  // move question data to the new target directory
878  $source_path = CLIENT_WEB_DIR . "/survey/" . $source_questionpool . "/" . $question_object["question_id"] . "/";
879  if (is_dir($source_path)) {
880  $target_path = CLIENT_WEB_DIR . "/survey/" . $this->getId() . "/";
881  if (!is_dir($target_path)) {
882  ilFileUtils::makeDirParents($target_path);
883  }
884  ilFileUtils::rename($source_path, $target_path . $question_object["question_id"]);
885  }
886  } else {
887  $this->main_tpl->setOnScreenMessage('failure', $this->lng->txt("spl_move_same_pool"), true);
888  return;
889  }
890  }
891  } else {
892  $this->copyQuestion($question_object["question_id"], $this->getId());
893  }
894  }
895  }
896  $this->main_tpl->setOnScreenMessage('success', $this->lng->txt("spl_paste_success"), true);
897  $this->edit_manager->clearClipboardQuestions();
898  }
copyQuestion(int $question_id, int $questionpool_to)
static makeDirParents(string $a_dir)
Create a new directory and all parent directories.
ilDBInterface $db
const CLIENT_WEB_DIR
Definition: constants.php:47
static rename(string $a_source, string $a_target)
+ Here is the call graph for this function:

◆ purgeQuestions()

ilObjSurveyQuestionPool::purgeQuestions ( )

Remove all questions with tstamp = 0.

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

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

816  : void
817  {
818  $ilDB = $this->db;
819  $ilUser = $this->user;
820 
821  $result = $ilDB->queryF(
822  "SELECT question_id FROM svy_question WHERE owner_fi = %s AND tstamp = %s",
823  array("integer", "integer"),
824  array($ilUser->getId(), 0)
825  );
826  while ($data = $ilDB->fetchAssoc($result)) {
827  $this->removeQuestion($data["question_id"]);
828  }
829  }
removeQuestion(int $question_id)
Removes a question from the question pool.
ilDBInterface $db
+ Here is the call graph for this function:

◆ read()

ilObjSurveyQuestionPool::read ( )

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

References loadFromDb().

74  : void
75  {
76  parent::read();
77  $this->loadFromDb();
78  }
+ Here is the call graph for this function:

◆ removeQuestion()

ilObjSurveyQuestionPool::removeQuestion ( int  $question_id)

Removes a question from the question pool.

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

References SurveyQuestion\_instanciateQuestion().

Referenced by deleteAllData(), and purgeQuestions().

215  : void
216  {
217  if ($question_id < 1) {
218  return;
219  }
220  $question = SurveyQuestion::_instanciateQuestion($question_id);
221  $question->delete($question_id);
222  }
static _instanciateQuestion(int $question_id)
Get question object.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ saveToDb()

ilObjSurveyQuestionPool::saveToDb ( )

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

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

153  : void
154  {
155  $ilDB = $this->db;
156 
157  parent::update();
158 
159  $result = $ilDB->queryF(
160  "SELECT * FROM svy_qpl WHERE obj_fi = %s",
161  array('integer'),
162  array($this->getId())
163  );
164  if ($result->numRows() !== 1) {
165  $next_id = $ilDB->nextId('svy_qpl');
166  $query = $ilDB->manipulateF(
167  "INSERT INTO svy_qpl (id_questionpool, obj_fi, tstamp) VALUES (%s, %s, %s)",
168  array('integer', 'integer', 'integer'),
169  array($next_id, $this->getId(), time())
170  );
171  }
172  }
ilDBInterface $db
+ Here is the call graph for this function:

◆ setObligatoryStates()

ilObjSurveyQuestionPool::setObligatoryStates ( array  $obligatory_questions)
Parameters
int[]$obligatory_questions obligatory question ids

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

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

905  : void {
906  $ilDB = $this->db;
907  foreach ($this->getQuestions() as $question_id) {
908  $status = (int) (isset($obligatory_questions["$question_id"]));
909 
910  $ilDB->manipulate("UPDATE svy_question" .
911  " SET obligatory = " . $ilDB->quote($status, "integer") .
912  " WHERE question_id = " . $ilDB->quote($question_id, "integer"));
913  }
914  }
ilDBInterface $db
+ Here is the call graph for this function:

◆ toXML()

ilObjSurveyQuestionPool::toXML ( ?array  $questions)

export questions to xml

Todo:
move to export sub-component

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

References SurveyQuestion\_includeClass(), ilObject\getId(), getQuestions(), getQuestiontype(), ilObject\getTitle(), ilObject\getType(), and null.

490  : string
491  {
492  if (is_null($questions) || count($questions) === 0) {
493  $questions = $this->getQuestions();
494  }
495  $a_xml_writer = new ilXmlWriter();
496  // set xml header
497  $a_xml_writer->xmlHeader();
498  $attrs = array(
499  "xmlns:xsi" => "http://www.w3.org/2001/XMLSchema-instance",
500  "xsi:noNamespaceSchemaLocation" => "https://www.ilias.de/download/xsd/ilias_survey_4_2.xsd"
501  );
502  $a_xml_writer->xmlStartTag("surveyobject", $attrs);
503  $attrs = array(
504  "id" => "qpl_" . $this->getId(),
505  "label" => $this->getTitle()
506  );
507  $a_xml_writer->xmlStartTag("surveyquestions", $attrs);
508  $a_xml_writer->xmlElement("dummy", null, "dummy");
509  // add ILIAS specific metadata
510  $a_xml_writer->xmlStartTag("metadata");
511  $a_xml_writer->xmlStartTag("metadatafield");
512  $a_xml_writer->xmlElement("fieldlabel", null, "SCORM");
513  $md = new ilMD($this->getId(), 0, $this->getType());
514  $writer = new ilXmlWriter();
515  $md->toXML($writer);
516  $metadata = $writer->xmlDumpMem();
517  $a_xml_writer->xmlElement("fieldentry", null, $metadata);
518  $a_xml_writer->xmlEndTag("metadatafield");
519  $a_xml_writer->xmlEndTag("metadata");
520 
521  $a_xml_writer->xmlEndTag("surveyquestions");
522  $a_xml_writer->xmlEndTag("surveyobject");
523 
524  $xml = $a_xml_writer->xmlDumpMem(false);
525 
526  $questionxml = "";
527  foreach ($questions as $key => $value) {
528  $questiontype = $this->getQuestiontype($value);
529  SurveyQuestion::_includeClass($questiontype);
530  $question = new $questiontype();
531  $question->loadFromDb($value);
532  $questionxml .= $question->toXML(false);
533  }
534 
535  $xml = str_replace("<dummy>dummy</dummy>", $questionxml, $xml);
536  return $xml;
537  }
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
static _includeClass(string $question_type, int $gui=0)
Include the php class file for a given question type.
+ Here is the call graph for this function:

◆ toXmlForExport()

ilObjSurveyQuestionPool::toXmlForExport ( )

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

References SurveyQuestion\_includeClass(), ilObject\getId(), getQuestions(), getQuestiontype(), ilObject\getTitle(), and null.

539  : string
540  {
541  $questions = $this->getQuestions();
542  $a_xml_writer = new ilXmlWriter();
543  $attrs = array(
544  "xmlns:xsi" => "http://www.w3.org/2001/XMLSchema-instance",
545  "xsi:noNamespaceSchemaLocation" => "https://www.ilias.de/download/xsd/ilias_survey_4_2.xsd"
546  );
547  $a_xml_writer->xmlStartTag("surveyobject", $attrs);
548  $attrs = array(
549  "id" => "qpl_" . $this->getId(),
550  "label" => $this->getTitle()
551  );
552  $a_xml_writer->xmlStartTag("surveyquestions", $attrs);
553  $a_xml_writer->xmlElement("dummy", null, "dummy");
554  $a_xml_writer->xmlEndTag("surveyquestions");
555  $a_xml_writer->xmlEndTag("surveyobject");
556  $xml = $a_xml_writer->xmlDumpMem(false);
557  $questionxml = "";
558  foreach ($questions as $key => $value) {
559  $questiontype = $this->getQuestiontype($value);
560  SurveyQuestion::_includeClass($questiontype);
561  $question = new $questiontype();
562  $question->loadFromDb($value);
563  $questionxml .= $question->toXML(false);
564  }
565  $xml = str_replace("<dummy>dummy</dummy>", $questionxml, $xml);
566  return $xml;
567  }
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
static _includeClass(string $question_type, int $gui=0)
Include the php class file for a given question type.
+ Here is the call graph for this function:

◆ update()

ilObjSurveyQuestionPool::update ( )

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

References ilObject\updateMetaData().

65  : bool
66  {
67  $this->updateMetaData();
68  if (!parent::update()) {
69  return false;
70  }
71  return true;
72  }
+ Here is the call graph for this function:

Field Documentation

◆ $component_repository

ilComponentRepository ilObjSurveyQuestionPool::$component_repository
protected

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

◆ $domain

InternalDomainService ilObjSurveyQuestionPool::$domain
protected

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

◆ $edit_manager

EditManager ilObjSurveyQuestionPool::$edit_manager
protected

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

◆ $main_tpl

ilGlobalTemplateInterface ilObjSurveyQuestionPool::$main_tpl
private

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

◆ $online

bool ilObjSurveyQuestionPool::$online = false

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

◆ $user

ilObjUser ilObjSurveyQuestionPool::$user
protected

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

Referenced by duplicateQuestion(), and purgeQuestions().


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