ILIAS  release_8 Revision v8.24
ilObjSurveyQuestionPool Class Reference

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V. 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 ()
 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...
 
 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...
 
 getQuestions ()
 
 importObject (string $source, bool $spl_exists=false)
 Imports survey questions into ILIAS. More...
 
 setOnline (bool $a_online_status)
 
 getOnline ()
 
 isPluginActive (string $a_pname)
 Checks whether or not a question plugin with a given name is active. 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
 __construct (int $id=0, bool $reference=true)
 
 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 $desc)
 
 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 _setOnline (int $a_obj_id, bool $a_online_status)
 
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 _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

ILIAS SurveyQuestionPool Editing 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
 
int $id
 
bool $referenced
 
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 = ""
 
bool $offline = false
 
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

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V.

ILIAS is licensed with the GPL-3.0, see https://www.gnu.org/licenses/gpl-3.0.en.html You should have received a copy of said license along with the source code, too.

If this is not the case or you just want to try ILIAS, you'll find us at: https://www.ilias.de https://github.com/ILIAS-eLearning Class ilObjSurveyQuestionPool

Author
Helmut Schottmüller helmu.nosp@m.t.sc.nosp@m.hottm.nosp@m.uell.nosp@m.er@ma.nosp@m.c.co.nosp@m.m

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

Constructor & Destructor Documentation

◆ __construct()

ilObjSurveyQuestionPool::__construct ( int  $id = 0,
bool  $reference = true 
)
Parameters
int$idreference_id or object_id
bool$referencebool treat the id as reference_id (true) or object_id (false)

Reimplemented from ilObject.

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

35 {
36 global $DIC;
37 $this->main_tpl = $DIC->ui()->mainTemplate();
38
39 $this->log = $DIC["ilLog"];
40 $this->db = $DIC->database();
41 $this->user = $DIC->user();
42 $this->component_repository = $DIC["component.repository"];
43 $this->type = "spl";
44 parent::__construct($a_id, $a_call_by_reference);
45 $this->edit_manager = $DIC->surveyQuestionPool()
46 ->internal()
47 ->domain()
48 ->editing();
49 }
global $DIC
Definition: feed.php:28
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc

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

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

800 : array {
801 global $DIC;
802
803 $ilUser = $DIC->user();
804 global $DIC;
805
806 $ilDB = $DIC->database();
807
808 $result_array = array();
809 $qpls = ilUtil::_getObjectsByOperations("spl", $permission, $ilUser->getId(), -1);
810 $titles = ilObject::_prepareCloneSelection($qpls, "spl", $showPath);
811 $allqpls = array();
812 $result = $ilDB->query("SELECT obj_fi, isonline FROM svy_qpl");
813 while ($row = $ilDB->fetchAssoc($result)) {
814 $allqpls[$row['obj_fi']] = $row['isonline'];
815 }
816 foreach ($qpls as $ref_id) {
818 if ($could_be_offline || ($allqpls[$obj_id] ?? 0) == 1) {
819 if ($use_object_id) {
820 $result_array[$obj_id] = $titles[$ref_id];
821 } else {
822 $result_array[(int) $ref_id] = $titles[$ref_id];
823 }
824 }
825 }
826 return $result_array;
827 }
static _lookupObjectId(int $ref_id)
static _prepareCloneSelection(array $ref_ids, string $new_type, bool $show_path=true)
Prepare copy wizard object selection.
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,...
$ilUser
Definition: imgupload.php:34

Referenced by ilSurveyQuestionbrowserTableGUI\__construct().

+ Here is the caller graph for this function:

◆ _getQuestionClasses()

static ilObjSurveyQuestionPool::_getQuestionClasses ( )
static

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

750 : array
751 {
752 $classes = array_map(
753 static function (array $c): string {
754 return $c["type_tag"];
755 },
757 );
758 return $classes;
759 }
static _getQuestiontypes()
Get all available question types.
$c
Definition: cli.php:38

References $c.

Referenced by ilObjSurvey\getMaxSumScore().

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

685 : array
686 {
687 global $DIC;
688
689 $ilDB = $DIC->database();
690 $lng = $DIC->language();
691
692 $lng->loadLanguageModule("survey");
693 $types = array();
694 $query_result = $ilDB->query("SELECT * FROM svy_qtype ORDER BY type_tag");
695 while ($row = $ilDB->fetchAssoc($query_result)) {
696 //array_push($questiontypes, $row["type_tag"]);
697 if ((int) $row["plugin"] === 0) {
698 $types[$lng->txt($row["type_tag"])] = $row;
699 } else {
700 global $DIC;
701
702 $component_factory = $DIC["component.factory"];
703 foreach ($component_factory->getActivePluginsInSlot("svyq") as $pl) {
704 if (strcmp($pl->getQuestionType(), $row["type_tag"]) === 0) {
705 $types[$pl->getQuestionTypeTranslation()] = $row;
706 }
707 }
708 }
709 }
710 ksort($types);
711
712
713 // #14263 - default sorting
714
715 $default_sorting = array_flip(array(
716 "SurveySingleChoiceQuestion",
717 "SurveyMultipleChoiceQuestion",
718 "SurveyMatrixQuestion",
719 "SurveyMetricQuestion",
720 "SurveyTextQuestion"
721 ));
722
723 $sorted = array();
724 $idx = count($default_sorting);
725 foreach ($types as $caption => $item) {
726 $type = $item["type_tag"];
727 $item["caption"] = $caption;
728
729 // default
730 if (array_key_exists($type, $default_sorting)) {
731 $sorted[$default_sorting[$type]] = $item;
732 }
733 // plugin (append alphabetically sorted)
734 else {
735 $sorted[$idx] = $item;
736 $idx++;
737 }
738 }
739 ksort($sorted);
740
741 // redo captions as index
742 $types = array();
743 foreach ($sorted as $item) {
744 $types[$item["caption"]] = $item;
745 }
746
747 return $types;
748 }
loadLanguageModule(string $a_module)
Load language module.
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...
ilLanguage $lng
string $type

References $DIC, $ilDB, $lng, and $type.

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

+ Here is the caller graph for this function:

◆ _getQuestionTypeTranslations()

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

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

764 : array
765 {
766 global $DIC;
767
768 $ilDB = $DIC->database();
769 $lng = $DIC->language();
770
771 $component_factory = $DIC["component.factory"];
772
773 $lng->loadLanguageModule("survey");
774 $result = $ilDB->query("SELECT * FROM svy_qtype");
775 $types = array();
776 while ($row = $ilDB->fetchAssoc($result)) {
777 if ((int) $row["plugin"] === 0) {
778 $types[$row['type_tag']] = $lng->txt($row["type_tag"]);
779 } else {
780 foreach ($component_factory->getActivePluginsInSlot("svyq") as $pl) {
781 if (strcmp($pl->getQuestionType(), $row["type_tag"]) === 0) {
782 $types[$row['type_tag']] = $pl->getQuestionTypeTranslation();
783 }
784 }
785 }
786 }
787 ksort($types);
788 return $types;
789 }

References $DIC, $ilDB, and $lng.

◆ _isWriteable()

static ilObjSurveyQuestionPool::_isWriteable ( int  $object_id)
static

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

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

667 : bool {
668 global $DIC;
669
670 $rbacsystem = $DIC->rbac()->system();
671 $refs = ilObject::_getAllReferences($object_id);
672 $result = false;
673 foreach ($refs as $ref) {
674 if ($rbacsystem->checkAccess("write", $ref) && (ilObject::_hasUntrashedReference($object_id))) {
675 $result = true;
676 }
677 }
678 return $result;
679 }
static _hasUntrashedReference(int $obj_id)
checks whether an object has at least one reference that is not in trash
static _getAllReferences(int $id)
get all reference ids for object ID

◆ _lookupOnline()

static ilObjSurveyQuestionPool::_lookupOnline ( int  $a_obj_id)
static

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

644 : bool
645 {
646 global $DIC;
647
648 $ilDB = $DIC->database();
649
650 $result = $ilDB->queryF(
651 "SELECT isonline FROM svy_qpl WHERE obj_fi = %s",
652 array('integer'),
653 array($a_obj_id)
654 );
655 if ($row = $ilDB->fetchAssoc($result)) {
656 return (bool) $row["isonline"];
657 }
658 return false;
659 }

References $DIC, and $ilDB.

Referenced by ilObjSurveyQuestionPoolListGUI\getProperties(), and ilContainer\legacyOnlineFilter().

+ Here is the caller graph for this function:

◆ _setOnline()

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

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

621 : void {
622 global $DIC;
623
624 $status = (string) (int) $a_online_status;
625 $db = $DIC->database();
626
628 "UPDATE svy_qpl SET isonline = %s WHERE obj_fi = %s",
629 array('text','integer'),
630 array($status, $a_obj_id)
631 );
632 }
ilDBInterface $db
manipulateF(string $query, array $types, array $values)

◆ cloneObject()

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

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

75 : ?ilObject
76 {
77 $newObj = parent::cloneObject($target_id, $copy_id, $omit_tree);
78
79 //copy online status if object is not the root copy object
80 $cp_options = ilCopyWizardOptions::_getInstance($copy_id);
81
82 if (!$cp_options->isRootNode($this->getRefId())) {
83 $newObj->setOnline($this->getOnline());
84 }
85
86 $newObj->saveToDb();
87 // clone the questions in the question pool
88 $questions = $this->getQuestions();
89 foreach ($questions as $question_id) {
90 $newObj->copyQuestion($question_id, $newObj->getId());
91 }
92
93 // clone meta data
94 $md = new ilMD($this->getId(), 0, $this->getType());
95 $new_md = $md->cloneMD($newObj->getId(), 0, $newObj->getType());
96
97 // update the metadata with the new title of the question pool
98 $newObj->updateMetaData();
99 return $newObj;
100 }
static _getInstance(int $a_copy_id)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
$target_id
Definition: goto.php:52

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

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

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)

◆ copyToClipboard()

ilObjSurveyQuestionPool::copyToClipboard ( int  $question_id)

Copies a question to the clipboard.

Parameters
int$question_idObject id of the question

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

890 : void {
891 $this->edit_manager->addQuestionToClipboard($question_id, "copy");
892 }

◆ create()

ilObjSurveyQuestionPool::create (   $a_upload = false)

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

51 : int
52 {
53 $id = parent::create();
54 if (!$a_upload) {
55 $this->createMetaData();
56 }
57 return $id;
58 }

References ilObject\$id, and ilObject\createMetaData().

+ Here is the call graph for this function:

◆ createExportDirectory()

ilObjSurveyQuestionPool::createExportDirectory ( )

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

Exceptions
ilSurveyException

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

407 : void
408 {
409 $spl_data_dir = ilFileUtils::getDataDir() . "/spl_data";
410 ilFileUtils::makeDir($spl_data_dir);
411 if (!is_writable($spl_data_dir)) {
412 throw new ilSurveyException("Survey Questionpool Data Directory (" . $spl_data_dir . ") not writeable.");
413 }
414
415 // create learning module directory (data_dir/lm_data/lm_<id>)
416 $spl_dir = $spl_data_dir . "/spl_" . $this->getId();
417 ilFileUtils::makeDir($spl_dir);
418 if (!is_dir($spl_dir)) {
419 throw new ilSurveyException("Creation of Survey Questionpool Directory failed.");
420 }
421 // create Export subdirectory (data_dir/lm_data/lm_<id>/Export)
422 $export_dir = $spl_dir . "/export";
423 ilFileUtils::makeDir($export_dir);
424 if (!is_dir($export_dir)) {
425 throw new ilSurveyException("Creation of Survey Questionpool Export Directory failed.");
426 }
427 }
static makeDir(string $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)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...

References ilFileUtils\getDataDir(), ILIAS\Survey\Mode\getId(), and ilFileUtils\makeDir().

+ Here is the call graph for this function:

◆ createImportDirectory()

ilObjSurveyQuestionPool::createImportDirectory ( )

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

Exceptions
ilSurveyException

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

477 : void
478 {
479 $spl_data_dir = ilFileUtils::getDataDir() . "/spl_data";
480 ilFileUtils::makeDir($spl_data_dir);
481
482 if (!is_writable($spl_data_dir)) {
483 throw new ilSurveyException("Survey Questionpool Data Directory (" . $spl_data_dir . ") not writeable.");
484 }
485
486 // create test directory (data_dir/spl_data/spl_<id>)
487 $spl_dir = $spl_data_dir . "/spl_" . $this->getId();
488 ilFileUtils::makeDir($spl_dir);
489 if (!is_dir($spl_dir)) {
490 throw new ilSurveyException("Creation of Survey Questionpool Directory failed.");
491 }
492
493 // create import subdirectory (data_dir/spl_data/spl_<id>/import)
494 $import_dir = $spl_dir . "/import";
495 ilFileUtils::makeDir($import_dir);
496 if (!is_dir($import_dir)) {
497 throw new ilSurveyException("Creation of Survey Questionpool Import Directory failed.");
498 }
499 }

References ilFileUtils\getDataDir(), ILIAS\Survey\Mode\getId(), and ilFileUtils\makeDir().

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

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

References getQuestiontype().

+ Here is the call graph for this function:

◆ delete()

ilObjSurveyQuestionPool::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!!

Returns
bool true if object was removed completely; false if only a references was removed

Reimplemented from ilObject.

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

191 : bool
192 {
193 $remove = parent::delete();
194 // always call parent delete function first!!
195 if (!$remove) {
196 return false;
197 }
198
199 // delete all related questions
200 $this->deleteAllData();
201
202 // delete meta data
203 $this->deleteMetaData();
204
205 return true;
206 }

◆ deleteAllData()

ilObjSurveyQuestionPool::deleteAllData ( )

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

208 : void
209 {
211 $result = $ilDB->queryF(
212 "SELECT question_id FROM svy_question WHERE obj_fi = %s AND original_id IS NULL",
213 array('integer'),
214 array($this->getId())
215 );
216 $found_questions = array();
217 while ($row = $ilDB->fetchAssoc($result)) {
218 $this->removeQuestion($row["question_id"]);
219 }
220
221 // delete export files
222 $spl_data_dir = ilFileUtils::getDataDir() . "/spl_data";
223 $directory = $spl_data_dir . "/spl_" . $this->getId();
224 if (is_dir($directory)) {
225 ilFileUtils::delDir($directory);
226 }
227 }
static delDir(string $a_dir, bool $a_clean_only=false)
removes a dir and all its content (subdirs and files) recursively
removeQuestion(int $question_id)
Removes a question from the question pool.

References $ilDB, ilFileUtils\delDir(), ilFileUtils\getDataDir(), and ILIAS\Survey\Mode\getId().

+ Here is the call graph for this function:

◆ duplicateQuestion()

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

Duplicates a question for a question pool.

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

333 : void {
335 $question = SurveyQuestion::_instanciateQuestion($question_id);
336 $suffix = "";
337 $counter = 1;
338 while ($question->questionTitleExists($question->getTitle() . $suffix, $obj_id)) {
339 $counter++;
340 if ($counter > 1) {
341 $suffix = " ($counter)";
342 }
343 }
344 if ($obj_id) {
345 $question->setObjId($obj_id);
346 }
347 $max_len = 195;
348 if (strlen($question->getTitle() . $suffix) > $max_len) {
349 $title = substr($question->getTitle(), 0, $max_len - strlen($suffix)) . $suffix;
350 } else {
351 $title = $question->getTitle() . $suffix;
352 }
353 $question->duplicate(false, $title, $ilUser->fullname, $ilUser->id);
354 }
static _instanciateQuestion(int $question_id)
Get question object.
string $title

◆ getExportDirectory()

ilObjSurveyQuestionPool::getExportDirectory ( )

get export directory of survey

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

432 : string
433 {
434 $export_dir = ilFileUtils::getDataDir() . "/spl_data" . "/spl_" . $this->getId() . "/export";
435 return $export_dir;
436 }

References ilFileUtils\getDataDir(), and ILIAS\Survey\Mode\getId().

+ Here is the call graph for this function:

◆ getExportFiles()

ilObjSurveyQuestionPool::getExportFiles ( string  $dir)

get export files

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

441 : array
442 {
443 // quit if import dir not available
444 if (!is_dir($dir) or
445 !is_writable($dir)) {
446 return array();
447 }
448
449 // open directory
450 $dir = dir($dir);
451
452 // initialize array
453 $file = array();
454
455 // get files and save the in the array
456 while ($entry = $dir->read()) {
457 if ($entry !== "." &&
458 $entry !== ".." &&
459 preg_match("/^[0-9]{10}__[0-9]+__(spl_)*[0-9]+\.[A-Za-z]{3}$/", $entry)) {
460 $file[] = $entry;
461 }
462 }
463
464 // close import directory
465 $dir->close();
466 // sort files
467 sort($file);
468
469 return $file;
470 }

◆ getImportDirectory()

ilObjSurveyQuestionPool::getImportDirectory ( )

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

501 : string
502 {
503 return ilFileUtils::getDataDir() . "/spl_data" .
504 "/spl_" . $this->getId() . "/import";
505 }

References ilFileUtils\getDataDir(), and ILIAS\Survey\Mode\getId().

+ Here is the call graph for this function:

◆ getOnline()

ilObjSurveyQuestionPool::getOnline ( )

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

639 : bool
640 {
641 return $this->online;
642 }

Referenced by cloneObject().

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

843 : array
844 {
846
847 $found = array();
848 $query_result = $ilDB->query("SELECT svy_question.*, svy_qtype.type_tag FROM svy_question, svy_qtype " .
849 "WHERE svy_question.questiontype_fi = svy_qtype.questiontype_id " .
850 "AND svy_question.tstamp > 0 AND " . $ilDB->in('svy_question.question_id', $question_ids, false, 'integer') . " " .
851 "ORDER BY svy_question.title");
852 if ($query_result->numRows() > 0) {
853 while ($data = $ilDB->fetchAssoc($query_result)) {
854 if (in_array($data["question_id"], $question_ids)) {
855 $found[] = array('id' => $data["question_id"],
856 'title' => $data["title"],
857 'description' => $data["description"],
858 'type_tag' => $data["type_tag"]
859 );
860 }
861 }
862 }
863 return $found;
864 }

References $data, and $ilDB.

◆ getQuestions()

ilObjSurveyQuestionPool::getQuestions ( )

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

561 : array
562 {
564 $questions = array();
565 $result = $ilDB->queryF(
566 "SELECT question_id FROM svy_question WHERE obj_fi = %s AND svy_question.tstamp > 0 AND original_id IS NULL",
567 array('integer'),
568 array($this->getId())
569 );
570 if ($result->numRows()) {
571 while ($row = $ilDB->fetchAssoc($result)) {
572 $questions[] = $row["question_id"];
573 }
574 }
575 return $questions;
576 }

References $ilDB, and ILIAS\Survey\Mode\getId().

Referenced by cloneObject().

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

362 : array {
364 $where = "";
365 if (count($arrFilter) > 0) {
366 foreach ($arrFilter as $key => $value) {
367 $arrFilter[$key] = str_replace('%', '', $value);
368 }
369 if (array_key_exists('title', $arrFilter) && strlen($arrFilter['title'])) {
370 $where .= " AND " . $ilDB->like('svy_question.title', 'text', "%%" . $arrFilter['title'] . "%%");
371 }
372 if (array_key_exists('description', $arrFilter) && strlen($arrFilter['description'])) {
373 $where .= " AND " . $ilDB->like('svy_question.description', 'text', "%%" . $arrFilter['description'] . "%%");
374 }
375 if (array_key_exists('author', $arrFilter) && strlen($arrFilter['author'])) {
376 $where .= " AND " . $ilDB->like('svy_question.author', 'text', "%%" . $arrFilter['author'] . "%%");
377 }
378 if (array_key_exists('type', $arrFilter) && strlen($arrFilter['type'])) {
379 $where .= " AND svy_qtype.type_tag = " . $ilDB->quote($arrFilter['type'], 'text');
380 }
381 }
382 $query_result = $ilDB->queryF(
383 "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,
384 array('integer'),
385 array($this->getId())
386 );
387 $rows = array();
388 if ($query_result->numRows()) {
389 while ($row = $ilDB->fetchAssoc($query_result)) {
390 if ($row["plugin"]) {
391 if ($this->isPluginActive($row["type_tag"])) {
392 $rows[] = $row;
393 }
394 } else {
395 $rows[] = $row;
396 }
397 }
398 }
399 return $rows;
400 }
isPluginActive(string $a_pname)
Checks whether or not a question plugin with a given name is active.
string $key
Consumer key/client ID value.
Definition: System.php:193
$rows
Definition: xhr_table.php:10

References $ilDB, and ILIAS\LTI\ToolProvider\$key.

◆ getQuestionsInfo()

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

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

311 : array {
313 $result_array = array();
314 $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'));
315 while ($row = $ilDB->fetchAssoc($result)) {
316 if ($row["plugin"]) {
317 if ($this->isPluginActive($row["type_tag"])) {
318 $result_array[] = $row;
319 }
320 } else {
321 $result_array[] = $row;
322 }
323 }
324 return $result_array;
325 }

◆ getQuestiontype()

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

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

246 : ?string {
248 if ($question_id < 1) {
249 return null;
250 }
251 $result = $ilDB->queryF(
252 "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",
253 array('integer'),
254 array($question_id)
255 );
256 if ($result->numRows() === 1) {
257 $data = $ilDB->fetchAssoc($result);
258 return $data["type_tag"];
259 } else {
260 return null;
261 }
262 }

Referenced by createQuestion().

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

586 : void {
587 if (is_file($source)) {
588 $isZip = (strcmp(strtolower(substr($source, -3)), 'zip') === 0);
589 if ($isZip) {
590 // unzip file
592
593 // determine filenames of xml files
594 $subdir = basename($source, ".zip");
595 $source = dirname($source) . "/" . $subdir . "/" . $subdir . ".xml";
596 }
597
598 $fh = fopen($source, 'rb') or die("");
599 $xml = fread($fh, filesize($source));
600 fclose($fh) or die("");
601 if ($isZip) {
602 $subdir = basename($source, ".zip");
603 if (is_dir(dirname($source) . "/" . $subdir)) {
604 ilFileUtils::delDir(dirname($source) . "/" . $subdir);
605 }
606 }
607 if (strpos($xml, "questestinterop") > 0) {
608 throw new ilInvalidSurveyImportFileException("Unsupported survey version (< 3.8) found.");
609 }
610
611 // survey questions for ILIAS >= 3.8
612 $import = new SurveyImportParser($this->getId(), "", $spl_exists);
613 $import->setXMLContent($xml);
614 $import->startParsing();
615 }
616 }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static unzip(string $path_to_zip_file, bool $overwrite_existing=false, bool $unpack_flat=false)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
if(!file_exists(getcwd() . '/ilias.ini.php'))
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Definition: confirmReg.php:20
$source
Definition: metadata.php:93
$xml
Definition: metadata.php:351

References $source, $xml, ilFileUtils\delDir(), ILIAS\Survey\Mode\getId(), and ilFileUtils\unzip().

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

269 : ?array
270 {
272 // check out the already answered questions
273 $result = $ilDB->queryF(
274 "SELECT answer_id FROM svy_answer WHERE question_fi = %s",
275 array('integer'),
276 array($question_id)
277 );
278 $answered = $result->numRows();
279
280 // check out the questions inserted in surveys
281 $result = $ilDB->queryF(
282 "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",
283 array('integer'),
284 array($question_id)
285 );
286 $inserted = $result->numRows();
287 if (($inserted + $answered) === 0) {
288 return null;
289 }
290 $result_array = array();
291 while ($row = $ilDB->fetchObject($result)) {
292 $result_array[] = $row;
293 }
294 return $result_array;
295 }

References $ilDB.

◆ isPluginActive()

ilObjSurveyQuestionPool::isPluginActive ( string  $a_pname)

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

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

832 : bool
833 {
834 return $this->component_repository->getPluginByName($a_pname)->isActive();
835 }

◆ loadFromDb()

ilObjSurveyQuestionPool::loadFromDb ( )

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

149 : void
150 {
152
153 $result = $ilDB->queryF(
154 "SELECT isonline FROM svy_qpl WHERE obj_fi = %s",
155 array('integer'),
156 array($this->getId())
157 );
158 if ($result->numRows() === 1) {
159 $row = $ilDB->fetchAssoc($result);
160 $this->setOnline((bool) $row["isonline"]);
161 }
162 }

References $ilDB, and ILIAS\Survey\Mode\getId().

Referenced by read().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ moveToClipboard()

ilObjSurveyQuestionPool::moveToClipboard ( int  $question_id)

Moves a question to the clipboard.

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

899 : void {
900 $this->edit_manager->addQuestionToClipboard($question_id, "move");
901 }

◆ paste()

ilObjSurveyQuestionPool::paste ( int  $question_id)

Pastes a duplicate of a question in the question pool.

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

300 : void
301 {
302 $this->duplicateQuestion($question_id, $this->getId());
303 }

References ILIAS\Survey\Mode\getId().

+ Here is the call graph for this function:

◆ pasteFromClipboard()

ilObjSurveyQuestionPool::pasteFromClipboard ( )

Copies/Moves a question from the clipboard.

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

906 : void
907 {
909
910 $qentries = $this->edit_manager->getQuestionsFromClipboard();
911 if (count($qentries) > 0) {
912 foreach ($qentries as $question_object) {
913 if (strcmp($question_object["action"], "move") === 0) {
914 $result = $ilDB->queryF(
915 "SELECT obj_fi FROM svy_question WHERE question_id = %s",
916 array('integer'),
917 array($question_object["question_id"])
918 );
919 if ($result->numRows() === 1) {
920 $row = $ilDB->fetchAssoc($result);
921 $source_questionpool = $row["obj_fi"];
922 if ($this->getId() != $source_questionpool) {
923 // change the questionpool id in the qpl_questions table
924 $affectedRows = $ilDB->manipulateF(
925 "UPDATE svy_question SET obj_fi = %s WHERE question_id = %s",
926 array('integer','integer'),
927 array($this->getId(), $question_object["question_id"])
928 );
929
930 // move question data to the new target directory
931 $source_path = CLIENT_WEB_DIR . "/survey/" . $source_questionpool . "/" . $question_object["question_id"] . "/";
932 if (is_dir($source_path)) {
933 $target_path = CLIENT_WEB_DIR . "/survey/" . $this->getId() . "/";
934 if (!is_dir($target_path)) {
935 ilFileUtils::makeDirParents($target_path);
936 }
937 ilFileUtils::rename($source_path, $target_path . $question_object["question_id"]);
938 }
939 } else {
940 $this->main_tpl->setOnScreenMessage('failure', $this->lng->txt("spl_move_same_pool"), true);
941 return;
942 }
943 }
944 } else {
945 $this->copyQuestion($question_object["question_id"], $this->getId());
946 }
947 }
948 }
949 $this->main_tpl->setOnScreenMessage('success', $this->lng->txt("spl_paste_success"), true);
950 $this->edit_manager->clearClipboardQuestions();
951 }
static makeDirParents(string $a_dir)
Create a new directory and all parent directories.
static rename(string $a_source, string $a_target)
copyQuestion(int $question_id, int $questionpool_to)
const CLIENT_WEB_DIR
Definition: constants.php:47

References $ilDB, CLIENT_WEB_DIR, ILIAS\Survey\Mode\getId(), ILIAS\Repository\lng(), ilFileUtils\makeDirParents(), and ilFileUtils\rename().

+ Here is the call graph for this function:

◆ purgeQuestions()

ilObjSurveyQuestionPool::purgeQuestions ( )

Remove all questions with tstamp = 0.

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

869 : void
870 {
873
874 $result = $ilDB->queryF(
875 "SELECT question_id FROM svy_question WHERE owner_fi = %s AND tstamp = %s",
876 array("integer", "integer"),
877 array($ilUser->getId(), 0)
878 );
879 while ($data = $ilDB->fetchAssoc($result)) {
880 $this->removeQuestion($data["question_id"]);
881 }
882 }

References $data, $ilDB, and $ilUser.

◆ read()

ilObjSurveyQuestionPool::read ( )

Reimplemented from ilObject.

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

69 : void
70 {
71 parent::read();
72 $this->loadFromDb();
73 }

References loadFromDb().

+ Here is the call graph for this function:

◆ removeQuestion()

ilObjSurveyQuestionPool::removeQuestion ( int  $question_id)

Removes a question from the question pool.

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

232 : void
233 {
234 if ($question_id < 1) {
235 return;
236 }
237 $question = SurveyQuestion::_instanciateQuestion($question_id);
238 $question->delete($question_id);
239 }

References SurveyQuestion\_instanciateQuestion().

+ Here is the call graph for this function:

◆ saveToDb()

ilObjSurveyQuestionPool::saveToDb ( )

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

164 : void
165 {
167
168 parent::update();
169
170 $result = $ilDB->queryF(
171 "SELECT * FROM svy_qpl WHERE obj_fi = %s",
172 array('integer'),
173 array($this->getId())
174 );
175 if ($result->numRows() === 1) {
176 $affectedRows = $ilDB->manipulateF(
177 "UPDATE svy_qpl SET isonline = %s, tstamp = %s WHERE obj_fi = %s",
178 array('text','integer','integer'),
179 array($this->getOnline(), time(), $this->getId())
180 );
181 } else {
182 $next_id = $ilDB->nextId('svy_qpl');
183 $query = $ilDB->manipulateF(
184 "INSERT INTO svy_qpl (id_questionpool, isonline, obj_fi, tstamp) VALUES (%s, %s, %s, %s)",
185 array('integer', 'text', 'integer', 'integer'),
186 array($next_id, $this->getOnline(), $this->getId(), time())
187 );
188 }
189 }
$query

References $ilDB, $query, and ILIAS\Survey\Mode\getId().

+ Here is the call graph for this function:

◆ setObligatoryStates()

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

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

958 : void {
960 foreach ($this->getQuestions() as $question_id) {
961 $status = (int) (isset($obligatory_questions["$question_id"]));
962
963 $ilDB->manipulate("UPDATE svy_question" .
964 " SET obligatory = " . $ilDB->quote($status, "integer") .
965 " WHERE question_id = " . $ilDB->quote($question_id, "integer"));
966 }
967 }

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

+ Here is the call graph for this function:

◆ setOnline()

ilObjSurveyQuestionPool::setOnline ( bool  $a_online_status)

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

634 : void
635 {
636 $this->online = $a_online_status;
637 }

◆ toXML()

ilObjSurveyQuestionPool::toXML ( ?array  $questions)

export questions to xml

Todo:
move to export sub-component

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

511 : string
512 {
513 if (is_null($questions) || count($questions) === 0) {
514 $questions = $this->getQuestions();
515 }
516 $a_xml_writer = new ilXmlWriter();
517 // set xml header
518 $a_xml_writer->xmlHeader();
519 $attrs = array(
520 "xmlns:xsi" => "http://www.w3.org/2001/XMLSchema-instance",
521 "xsi:noNamespaceSchemaLocation" => "https://www.ilias.de/download/xsd/ilias_survey_4_2.xsd"
522 );
523 $a_xml_writer->xmlStartTag("surveyobject", $attrs);
524 $attrs = array(
525 "id" => "qpl_" . $this->getId(),
526 "label" => $this->getTitle(),
527 "online" => $this->getOnline()
528 );
529 $a_xml_writer->xmlStartTag("surveyquestions", $attrs);
530 $a_xml_writer->xmlElement("dummy", null, "dummy");
531 // add ILIAS specific metadata
532 $a_xml_writer->xmlStartTag("metadata");
533 $a_xml_writer->xmlStartTag("metadatafield");
534 $a_xml_writer->xmlElement("fieldlabel", null, "SCORM");
535 $md = new ilMD($this->getId(), 0, $this->getType());
536 $writer = new ilXmlWriter();
537 $md->toXML($writer);
538 $metadata = $writer->xmlDumpMem();
539 $a_xml_writer->xmlElement("fieldentry", null, $metadata);
540 $a_xml_writer->xmlEndTag("metadatafield");
541 $a_xml_writer->xmlEndTag("metadata");
542
543 $a_xml_writer->xmlEndTag("surveyquestions");
544 $a_xml_writer->xmlEndTag("surveyobject");
545
546 $xml = $a_xml_writer->xmlDumpMem(false);
547
548 $questionxml = "";
549 foreach ($questions as $key => $value) {
550 $questiontype = $this->getQuestiontype($value);
551 SurveyQuestion::_includeClass($questiontype);
552 $question = new $questiontype();
553 $question->loadFromDb($value);
554 $questionxml .= $question->toXML(false);
555 }
556
557 $xml = str_replace("<dummy>dummy</dummy>", $questionxml, $xml);
558 return $xml;
559 }
static _includeClass(string $question_type, int $gui=0)
Include the php class file for a given question type.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...

References ILIAS\LTI\ToolProvider\$key, $xml, SurveyQuestion\_includeClass(), and ILIAS\Survey\Mode\getId().

+ Here is the call graph for this function:

◆ update()

ilObjSurveyQuestionPool::update ( )

Reimplemented from ilObject.

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

60 : bool
61 {
62 $this->updateMetaData();
63 if (!parent::update()) {
64 return false;
65 }
66 return true;
67 }

References ilObject\updateMetaData().

+ Here is the call graph for this function:

Field Documentation

◆ $component_repository

ilComponentRepository ilObjSurveyQuestionPool::$component_repository
protected

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

◆ $edit_manager

ILIAS SurveyQuestionPool Editing EditManager ilObjSurveyQuestionPool::$edit_manager
protected

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

◆ $main_tpl

ilGlobalTemplateInterface ilObjSurveyQuestionPool::$main_tpl
private

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

◆ $online

bool ilObjSurveyQuestionPool::$online = false

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

◆ $user

ilObjUser ilObjSurveyQuestionPool::$user
protected

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


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