ILIAS  trunk Revision v13.0_alpha-62-g3b72d83f2e5
ilObjQuestionPool Class Reference
+ Inheritance diagram for ilObjQuestionPool:
+ Collaboration diagram for ilObjQuestionPool:

Public Member Functions

 __construct (int $a_id=0, bool $a_call_by_reference=true)
 
 create ($a_upload=false)
 create questionpool object More...
 
 createReference ()
 Creates a database reference id for the object (saves the object to the database and creates a reference id in the database) More...
 
 update ()
 update object data More...
 
 read ($a_force_db=false)
 read object data from db into object More...
 
 delete ()
 delete object and all related data More...
 
 deleteQuestionpool ()
 
 deleteQuestion (int $question_id)
 
 loadFromDb ()
 
 saveToDb ()
 
 getQuestiontype ($question_id)
 
 isInUse (int $question_id)
 
 createQuestion (string $question_type, int $question_id=-1)
 
 duplicateQuestion (int $question_id)
 
 copyQuestion (int $question_id, int $questionpool_to)
 
 appendCounterToQuestionTitleIfNecessary (string $title)
 
 getPrintviewQuestions ()
 
& getAllQuestions ()
 Retrieve an array containing all question ids of the questionpool. More...
 
& getAllQuestionIds ()
 
 checkQuestionParent (int $question_id)
 
 questionsToXML ($questions)
 Returns a QTI xml representation of a list of questions. More...
 
 pasteFromClipboard ()
 Copies/Moves a question from the clipboard. More...
 
 copyToClipboard ($question_id)
 Copies a question to the clipboard. More...
 
 moveToClipboard (int $question_id)
 Moves a question to the clipboard. More...
 
 cleanupClipboard (int $deleted_question_id)
 
 getQuestionDetails ($question_ids)
 Returns an array containing the qpl_question and qpl_qst_type fields for an array of question ids. More...
 
 getDeleteableQuestionDetails ($question_ids)
 Returns an array containing the qpl_question and qpl_qst_type fields of deleteable questions for an array of question ids. More...
 
 getQplQuestions ()
 
 cloneObject (int $target_id, int $copy_id=0, bool $omit_tree=false)
 Creates a 1:1 copy of the object and places the copy in a given repository. More...
 
 getQuestionTypes ($all_tags=false, $fixOrder=false, $withDeprecatedTypes=true)
 
 getQuestionList ()
 
 isPluginActive ($questionType)
 Checks wheather or not a question plugin with a given name is active. More...
 
 purgeQuestions ()
 
 getTaxonomyIds ()
 get ids of all taxonomies corresponding to current pool More...
 
 isSkillServiceEnabled ()
 
 setSkillServiceEnabled (bool $skill_service_enabled)
 
- 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, int $new_obj_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 _hasEqualPoints ($a_obj_id, $is_reference=false)
 Checks a question pool for questions with the same maximum points. More...
 
static _isWriteable ($object_id, $user_id)
 Returns true, if the question pool is writeable by a given user. More...
 
static _getAvailableQuestionpools (bool $use_object_id=false, bool $equal_points=false, bool $could_be_offline=false, bool $showPath=false, bool $with_questioncount=false, string $permission='read', int $usr_id=0)
 Returns the available question pools for the active user. More...
 
static _getQuestionTypes ($all_tags=false, $fixOrder=false, $withDeprecatedTypes=true)
 
static getQuestionTypeByTypeId ($type_id)
 
static getQuestionTypeTranslations ()
 
static & _getSelfAssessmentQuestionTypes ($all_tags=false)
 
static _updateQuestionCount (int $object_id)
 
static isSkillManagementGloballyActivated ()
 
- 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)
 

Static Protected Member Functions

static _getQuestionCount (int $pool_id)
 

Private Attributes

ilComponentRepository $component_repository
 
bool $skill_service_enabled
 
GeneralQuestionPropertiesRepository $questionrepository
 

Static Private Attributes

static $isSkillManagementGloballyActivated = null
 

Additional Inherited Members

- 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 Member Functions inherited from ilObject
 doMDUpdateListener (string $a_element)
 
 beforeMDUpdateListener (string $a_element)
 
 doCreateMetaData ()
 
 beforeCreateMetaData ()
 
 doUpdateMetaData ()
 
 beforeUpdateMetaData ()
 
 doDeleteMetaData ()
 
 beforeDeleteMetaData ()
 
 handleAutoRating ()
 
 hasAutoRating ()
 
- 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
 

Detailed Description

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

Constructor & Destructor Documentation

◆ __construct()

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

Definition at line 40 of file class.ilObjQuestionPool.php.

41 {
42 global $DIC;
43 $this->component_repository = $DIC['component.repository'];
44
45 $local_dic = QuestionPoolDIC::dic();
46 $this->questionrepository = $local_dic['question.general_properties.repository'];
47
48 $this->type = 'qpl';
49
50 parent::__construct((int) $a_id, $a_call_by_reference);
51
52 $this->skill_service_enabled = false;
53 }
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
global $DIC
Definition: shib_login.php:26

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

+ Here is the call graph for this function:

Member Function Documentation

◆ _getAvailableQuestionpools()

static ilObjQuestionPool::_getAvailableQuestionpools ( bool  $use_object_id = false,
bool  $equal_points = false,
bool  $could_be_offline = false,
bool  $showPath = false,
bool  $with_questioncount = false,
string  $permission = 'read',
int  $usr_id = 0 
)
static

Returns the available question pools for the active user.

Returns
array The available question pools @access public

Definition at line 668 of file class.ilObjQuestionPool.php.

676 : array {
677 global $DIC;
678 $ilUser = $DIC['ilUser'];
679 $ilDB = $DIC['ilDB'];
680 $lng = $DIC['lng'];
681
682 $result_array = [];
683 $qpls = ilUtil::_getObjectsByOperations('qpl', $permission, $usr_id > 0 ? $usr_id : $ilUser->getId(), -1);
684 $obj_ids = [];
685 foreach ($qpls as $ref_id) {
687 $obj_ids[$ref_id] = $obj_id;
688 }
689 $titles = ilObject::_prepareCloneSelection($qpls, 'qpl');
690 if (count($obj_ids)) {
691 $in = $ilDB->in('object_data.obj_id', $obj_ids, false, 'integer');
692 if ($could_be_offline) {
693 $result = $ilDB->query(
694 'SELECT qpl_questionpool.*, object_data.title FROM qpl_questionpool, object_data WHERE ' .
695 'qpl_questionpool.obj_fi = object_data.obj_id AND ' . $in . ' ORDER BY object_data.title'
696 );
697 } else {
698 $result = $ilDB->queryF(
699 'SELECT qpl_questionpool.*, object_data.title FROM qpl_questionpool, object_data WHERE ' .
700 'qpl_questionpool.obj_fi = object_data.obj_id AND ' . $in . ' AND object_data.offline = %s ' .
701 'ORDER BY object_data.title',
702 ['text'],
703 [0]
704 );
705 }
706 while ($row = $ilDB->fetchAssoc($result)) {
707 $add = true;
708 if ($equal_points !== false) {
709 if (!ilObjQuestionPool::_hasEqualPoints($row['obj_fi'])) {
710 $add = false;
711 }
712 }
713 if ($add) {
714 $ref_id = array_search($row['obj_fi'], $obj_ids);
715 $title = (($showPath) ? $titles[$ref_id] : $row['title']);
716 if ($with_questioncount) {
717 $title .= ' [' . $row['questioncount'] . ' ' . ($row['questioncount'] == 1 ? $lng->txt(
718 'ass_question'
719 ) : $lng->txt('assQuestions')) . ']';
720 }
721
722 if ($use_object_id) {
723 $result_array[$row['obj_fi']] = [
724 'qpl_id' => $row['obj_fi'],
725 'qpl_title' => $row['title'],
726 'title' => $title,
727 'count' => $row['questioncount']
728 ];
729 } else {
730 $result_array[$ref_id] = [
731 'qpl_id' => $row['obj_fi'],
732 'qpl_title' => $row['title'],
733 'title' => $title,
734 'count' => $row['questioncount']
735 ];
736 }
737 }
738 }
739 }
740 return $result_array;
741 }
txt(string|LanguageIdentifier $a_topic, ?int $n=null)
gets the text for a given topic if the topic is not in the list, the topic itself with "-" will be re...
static _hasEqualPoints($a_obj_id, $is_reference=false)
Checks a question pool for questions with the same maximum points.
string $title
ilLanguage $lng
static _prepareCloneSelection(array $ref_ids, string $new_type, bool $show_path=true)
Prepare copy wizard object selection.
static _lookupObjId(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,...

Referenced by ilObjTestGUI\buildInputPoolSelection(), ilObjTest\getAvailableQuestions(), and ilTestQuestionBrowserTableGUI\getQuestionParentObjIds().

+ Here is the caller graph for this function:

◆ _getQuestionCount()

static ilObjQuestionPool::_getQuestionCount ( int  $pool_id)
staticprotected

Definition at line 388 of file class.ilObjQuestionPool.php.

388 : int
389 {
390 global $DIC;
391 $ilDB = $DIC['ilDB'];
392 $result = $ilDB->queryF(
393 'SELECT COUNT(question_id) question_count FROM qpl_questions WHERE obj_fi = %s AND qpl_questions.tstamp > 0 AND original_id IS NULL AND complete = %s',
394 ['integer', 'text'],
395 [$pool_id, 1]
396 );
397 $row = $ilDB->fetchAssoc($result);
398 return $row['question_count'];
399 }

References $DIC, and $ilDB.

Referenced by _updateQuestionCount().

+ Here is the caller graph for this function:

◆ _getQuestionTypes()

static ilObjQuestionPool::_getQuestionTypes (   $all_tags = false,
  $fixOrder = false,
  $withDeprecatedTypes = true 
)
static

Definition at line 800 of file class.ilObjQuestionPool.php.

800 : array
801 {
802 global $DIC;
803 $ilDB = $DIC['ilDB'];
804 $lng = $DIC['lng'];
805 $component_factory = $DIC['component.factory'];
806 $disabled_question_types = QuestionPoolDIC::dic()['global_test_settings']->getDisabledQuestionTypes();
807
808 $lng->loadLanguageModule('assessment');
809 $result = $ilDB->query('SELECT * FROM qpl_qst_type');
810 $types = [];
811 while ($row = $ilDB->fetchAssoc($result)) {
812 if ($all_tags || (!in_array($row['question_type_id'], $disabled_question_types))) {
813 if ($row['plugin'] == 0) {
814 $types[$lng->txt($row['type_tag'])] = $row;
815 } else {
816 foreach ($component_factory->getActivePluginsInSlot('qst') as $pl) {
817 if (strcmp($pl->getQuestionType(), $row['type_tag']) == 0) {
818 $types[$pl->getQuestionTypeTranslation()] = $row;
819 }
820 }
821 }
822 }
823 }
824
826 $orderer = new ilAssQuestionTypeOrderer($types, $orderMode);
827 $types = $orderer->getOrderedTypes($withDeprecatedTypes);
828
829 return $types;
830 }
const ORDER_MODE_FIX
order mode with fixed priority for ordering
const ORDER_MODE_ALPHA
order mode that orders by alphanumerical priority
loadLanguageModule(string $a_module)
Load language module.

References $DIC, $ilDB, $lng, ilAssQuestionTypeOrderer\ORDER_MODE_ALPHA, and ilAssQuestionTypeOrderer\ORDER_MODE_FIX.

Referenced by _getSelfAssessmentQuestionTypes(), ilTestRandomQuestionSetPoolDefinitionFormGUI\build(), ILIAS\TestQuestionPool\Questions\Presentation\QuestionTable\getFilter(), ilTestRandomQuestionSetSourcePoolDefinition\getTypeFilterAsTypeTags(), ilQuestionBrowserTableGUI\initFilter(), ilTestQuestionFilterLabelTranslator\loadTypeLabels(), ILIAS\Test\Questions\Presentation\QuestionsBrowserFilter\resolveQuestionTypeFilterOptions(), and ilTestRandomQuestionSetSourcePoolDefinition\setTypeFilterFromTypeTags().

+ Here is the caller graph for this function:

◆ _getSelfAssessmentQuestionTypes()

static & ilObjQuestionPool::_getSelfAssessmentQuestionTypes (   $all_tags = false)
static
Todo:
Make it more flexible

Definition at line 876 of file class.ilObjQuestionPool.php.

876 : array
877 {
878 $allowed_types = [
879 'assSingleChoice' => 1,
880 'assMultipleChoice' => 2,
881 'assKprimChoice' => 3,
882 'assClozeTest' => 4,
883 'assMatchingQuestion' => 5,
884 'assOrderingQuestion' => 6,
885 'assOrderingHorizontal' => 7,
886 'assImagemapQuestion' => 8,
887 'assTextSubset' => 9,
888 'assErrorText' => 10,
889 'assLongMenu' => 11
890 ];
891 $satypes = [];
892 $qtypes = ilObjQuestionPool::_getQuestionTypes($all_tags);
893 foreach ($qtypes as $k => $t) {
894 if (isset($allowed_types[$t['type_tag']])) {
895 $t['order'] = $allowed_types[$t['type_tag']];
896 $satypes[$k] = $t;
897 }
898 }
899 return $satypes;
900 }
static _getQuestionTypes($all_tags=false, $fixOrder=false, $withDeprecatedTypes=true)

References _getQuestionTypes().

Referenced by ILIAS\COPage\PC\Question\SelfAssQuestionRetrieval\collectData(), and ilPCQuestionGUI\insert().

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

◆ _hasEqualPoints()

static ilObjQuestionPool::_hasEqualPoints (   $a_obj_id,
  $is_reference = false 
)
static

Checks a question pool for questions with the same maximum points.

Parameters
integer$a_obj_idObject id of the question pool @access private

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

407 : int
408 {
409 global $DIC;
410 $ilDB = $DIC['ilDB'];
411
412 if ($is_reference) {
413 $result = $ilDB->queryF(
414 'SELECT count(DISTINCT qpl_questions.points) equal_points FROM qpl_questions, object_reference WHERE object_reference.ref_id = %s AND qpl_questions.tstamp > 0 AND object_reference.obj_id = qpl_questions.obj_fi AND qpl_questions.original_id IS NULL',
415 ['integer'],
416 [$a_obj_id]
417 );
418 } else {
419 $result = $ilDB->queryF(
420 'SELECT count(DISTINCT points) equal_points FROM qpl_questions WHERE obj_fi = %s AND qpl_questions.tstamp > 0 AND qpl_questions.original_id IS NULL',
421 ['integer'],
422 [$a_obj_id]
423 );
424 }
425 if ($result->numRows() == 1) {
426 $row = $ilDB->fetchAssoc($result);
427 if ($row['equal_points'] == 1) {
428 return 1;
429 } else {
430 return 0;
431 }
432 }
433 return 0;
434 }

References $DIC, and $ilDB.

◆ _isWriteable()

static ilObjQuestionPool::_isWriteable (   $object_id,
  $user_id 
)
static

Returns true, if the question pool is writeable by a given user.

Parameters
integer$object_idThe object id of the question pool object
integer$user_idThe database id of the user @access public

Definition at line 550 of file class.ilObjQuestionPool.php.

550 : bool
551 {
552 global $DIC;
553 $rbacsystem = $DIC['rbacsystem'];
554
555 $refs = ilObject::_getAllReferences($object_id);
556 if (count($refs)) {
557 foreach ($refs as $ref_id) {
558 if ($rbacsystem->checkAccess('write', $ref_id) && (ilObject::_hasUntrashedReference($object_id))) {
559 return true;
560 }
561 }
562 }
563 return false;
564 }
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

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

Referenced by assQuestion\isWriteable().

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

◆ _updateQuestionCount()

static ilObjQuestionPool::_updateQuestionCount ( int  $object_id)
static

Definition at line 916 of file class.ilObjQuestionPool.php.

916 : void
917 {
918 global $DIC;
919 $ilDB = $DIC['ilDB'];
920 $ilDB->manipulateF(
921 'UPDATE qpl_questionpool SET questioncount = %s, tstamp = %s WHERE obj_fi = %s',
922 ['integer', 'integer', 'integer'],
923 [ilObjQuestionPool::_getQuestionCount($object_id), time(), $object_id]
924 );
925 }
static _getQuestionCount(int $pool_id)

References $DIC, $ilDB, and _getQuestionCount().

Referenced by assQuestion\delete(), duplicateQuestion(), pasteFromClipboard(), and assQuestion\saveToDb().

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

◆ appendCounterToQuestionTitleIfNecessary()

ilObjQuestionPool::appendCounterToQuestionTitleIfNecessary ( string  $title)

Definition at line 266 of file class.ilObjQuestionPool.php.

266 : string
267 {
268 $result = $this->db->queryF(
269 "SELECT COUNT(question_id) AS cnt FROM qpl_questions WHERE obj_fi = %s AND title like %s",
270 ['integer','text'],
271 [$this->getId(), "{$title}%"]
272 );
273 $counter_object = $this->db->fetchObject($result);
274 if ($counter_object->cnt === 0) {
275 return $title;
276 }
277 return "{$title} ({$counter_object->cnt})";
278 }

References ilObject\$title, and ilObject\getId().

Referenced by copyQuestion(), ilObjTestGUI\copyQuestionToPool(), and duplicateQuestion().

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

◆ checkQuestionParent()

ilObjQuestionPool::checkQuestionParent ( int  $question_id)

Definition at line 345 of file class.ilObjQuestionPool.php.

345 : bool
346 {
347 $row = $this->db->fetchAssoc(
348 $this->db->queryF(
349 'SELECT COUNT(question_id) cnt FROM qpl_questions WHERE question_id = %s AND obj_fi = %s',
350 ['integer', 'integer'],
351 [$question_id, $this->getId()]
352 )
353 );
354
355 return (bool) $row['cnt'];
356 }

◆ cleanupClipboard()

ilObjQuestionPool::cleanupClipboard ( int  $deleted_question_id)

Definition at line 523 of file class.ilObjQuestionPool.php.

523 : void
524 {
525 if (ilSession::get('qpl_clipboard') == null) {
526 return;
527 }
528
529 $clip = ilSession::get('qpl_clipboard');
530 if (!isset($clip[$deleted_question_id])) {
531 return;
532 }
533
534 unset($clip[$deleted_question_id]);
535
536 if (!count($clip)) {
537 ilSession::clear('qpl_clipboard');
538 } else {
539 ilSession::set('qpl_clipboard', $clip);
540 }
541 }
static get(string $a_var)
static clear(string $a_var)
static set(string $a_var, $a_val)
Set a value.

References ilSession\clear(), ilSession\get(), and ilSession\set().

+ Here is the call graph for this function:

◆ cloneObject()

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

Creates a 1:1 copy of the object and places the copy in a given repository.

@access public

Definition at line 762 of file class.ilObjQuestionPool.php.

762 : ?ilObject
763 {
764 $new_obj = parent::cloneObject($target_id, $copy_id, $omit_tree);
765
766 $new_obj->update();
767
768 $new_obj->setSkillServiceEnabled($this->isSkillServiceEnabled());
769 $new_obj->saveToDb();
770
771 // clone the questions in the question pool
772 $questions = $this->getQplQuestions();
773 $questionIdsMap = [];
774 foreach ($questions as $question_id) {
775 $newQuestionId = $new_obj->copyQuestion($question_id, $new_obj->getId());
776 $questionIdsMap[$question_id] = $newQuestionId;
777 }
778
779 $this->cloneMetaData($new_obj);
780 $new_obj->updateMetaData();
781
782 $duplicator = new ilQuestionPoolTaxonomiesDuplicator();
783 $duplicator->setSourceObjId($this->getId());
784 $duplicator->setSourceObjType($this->getType());
785 $duplicator->setTargetObjId($new_obj->getId());
786 $duplicator->setTargetObjType($new_obj->getType());
787 $duplicator->setQuestionIdMapping($questionIdsMap);
788 $duplicator->duplicate($duplicator->getAllTaxonomiesForSourceObject());
789
790 $new_obj->saveToDb();
791
792 return $new_obj;
793 }
Class ilObject Basic functions for all objects.
cloneMetaData(ilObject $target_obj)
Copy meta data.

References ILIAS\Survey\Mode\getId().

+ Here is the call graph for this function:

◆ copyQuestion()

ilObjQuestionPool::copyQuestion ( int  $question_id,
int  $questionpool_to 
)

Definition at line 250 of file class.ilObjQuestionPool.php.

250 : int
251 {
252 $question_gui = $this->createQuestion('', $question_id);
253 if ($question_gui->getObject()->getObjId() == $questionpool_to) {
254 // the question is copied into the same question pool
255 return $this->duplicateQuestion($question_id);
256 } else {
257 // the question is copied into another question pool
259 $question_gui->getObject()->getTitle()
260 );
261
262 return $question_gui->getObject()->copyObject($this->getId(), $newtitle);
263 }
264 }
duplicateQuestion(int $question_id)
createQuestion(string $question_type, int $question_id=-1)
appendCounterToQuestionTitleIfNecessary(string $title)

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

Referenced by pasteFromClipboard().

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

◆ copyToClipboard()

ilObjQuestionPool::copyToClipboard (   $question_id)

Copies a question to the clipboard.

Parameters
integer$question_idObject id of the question @access private

Definition at line 497 of file class.ilObjQuestionPool.php.

497 : void
498 {
499 if (ilSession::get('qpl_clipboard') == null) {
500 ilSession::set('qpl_clipboard', []);
501 }
502 $clip = ilSession::get('qpl_clipboard');
503 $clip[$question_id] = ['question_id' => $question_id, 'action' => 'copy'];
504 ilSession::set('qpl_clipboard', $clip);
505 }

References ilSession\get(), and ilSession\set().

+ Here is the call graph for this function:

◆ create()

ilObjQuestionPool::create (   $a_upload = false)

create questionpool object

Definition at line 58 of file class.ilObjQuestionPool.php.

58 : int
59 {
60 $id = parent::create();
61
62 // meta data will be created by
63 // import parser
64 if (!$a_upload) {
65 $this->createMetaData();
66 }
67 return $id;
68 }
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23

References $id, and ilObject\createMetaData().

+ Here is the call graph for this function:

◆ createQuestion()

ilObjQuestionPool::createQuestion ( string  $question_type,
int  $question_id = -1 
)

Definition at line 229 of file class.ilObjQuestionPool.php.

230 {
231 if ($question_id > 0) {
232 return assQuestion::instantiateQuestionGUI($question_id);
233 }
234 $question_type_gui = $question_type . 'GUI';
235 $question_gui = new $question_type_gui();
236 return $question_gui;
237 }

Referenced by copyQuestion(), duplicateQuestion(), getDeleteableQuestionDetails(), and questionsToXML().

+ Here is the caller graph for this function:

◆ createReference()

ilObjQuestionPool::createReference ( )

Creates a database reference id for the object (saves the object to the database and creates a reference id in the database)

@access public

Reimplemented from ilObject.

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

76 : int
77 {
78 $result = parent::createReference();
79 $this->saveToDb();
80 return $result;
81 }

References saveToDb().

+ Here is the call graph for this function:

◆ delete()

ilObjQuestionPool::delete ( )

delete object and all related data

@access public

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

Reimplemented from ilObject.

Definition at line 118 of file class.ilObjQuestionPool.php.

118 : bool
119 {
120 // always call parent delete function first!!
121 if (!parent::delete()) {
122 return false;
123 }
124
125 // delete meta data
126 $this->deleteMetaData();
127
128 //put here your module specific stuff
129 $this->deleteQuestionpool();
130
131 $qsaImportFails = new ilAssQuestionSkillAssignmentImportFails($this->getId());
132 $qsaImportFails->deleteRegisteredImportFails();
133
134 return true;
135 }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...

References ilObject\deleteMetaData(), deleteQuestionpool(), and ilObject\getId().

+ Here is the call graph for this function:

◆ deleteQuestion()

ilObjQuestionPool::deleteQuestion ( int  $question_id)

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

149 : void
150 {
151 $question = assQuestion::instantiateQuestion($question_id);
152 $question->delete($question_id);
153 }
static instantiateQuestion(int $question_id)

References assQuestion\instantiateQuestion().

Referenced by deleteQuestionpool().

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

◆ deleteQuestionpool()

ilObjQuestionPool::deleteQuestionpool ( )

Definition at line 137 of file class.ilObjQuestionPool.php.

137 : void
138 {
139 foreach ($this->getQplQuestions() as $question_id) {
140 $this->deleteQuestion($question_id);
141 }
142
143 $directory = ilFileUtils::getDataDir() . "/qpl_data/qpl_{$this->getId()}";
144 if (is_dir($directory)) {
145 ilFileUtils::delDir($directory);
146 }
147 }
static delDir(string $a_dir, bool $a_clean_only=false)
removes a dir and all its content (subdirs and files) recursively
static getDataDir()
get data directory (outside webspace)
deleteQuestion(int $question_id)

References ilFileUtils\delDir(), deleteQuestion(), ilFileUtils\getDataDir(), and getQplQuestions().

Referenced by delete().

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

◆ duplicateQuestion()

ilObjQuestionPool::duplicateQuestion ( int  $question_id)

Definition at line 239 of file class.ilObjQuestionPool.php.

239 : int
240 {
241 $question = $this->createQuestion('', $question_id);
243 $question->getObject()->getTitle()
244 );
245 $new_id = $question->getObject()->duplicate(false, $newtitle);
247 return $new_id;
248 }
static _updateQuestionCount(int $object_id)

References _updateQuestionCount(), appendCounterToQuestionTitleIfNecessary(), and createQuestion().

Referenced by copyQuestion().

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

◆ getAllQuestionIds()

& ilObjQuestionPool::getAllQuestionIds ( )

Definition at line 323 of file class.ilObjQuestionPool.php.

323 : array
324 {
325 $query_result = $this->db->queryF(
326 'SELECT question_id, qpl_qst_type.type_tag, qpl_qst_type.plugin FROM qpl_questions, qpl_qst_type WHERE original_id IS NULL AND qpl_questions.tstamp > 0 AND obj_fi = %s AND complete = %s AND qpl_questions.question_type_fi = qpl_qst_type.question_type_id',
327 ['integer', 'text'],
328 [$this->getId(), 1]
329 );
330 $questions = [];
331 if ($query_result->numRows()) {
332 while ($row = $this->db->fetchAssoc($query_result)) {
333 if ($row['plugin']) {
334 if ($this->isPluginActive($row['type_tag'])) {
335 array_push($questions, $row['question_id']);
336 }
337 } else {
338 array_push($questions, $row['question_id']);
339 }
340 }
341 }
342 return $questions;
343 }
isPluginActive($questionType)
Checks wheather or not a question plugin with a given name is active.

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

+ Here is the call graph for this function:

◆ getAllQuestions()

& ilObjQuestionPool::getAllQuestions ( )

Retrieve an array containing all question ids of the questionpool.

Returns
array An array containing all question ids of the questionpool

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

309 : array
310 {
311 $result = $this->db->queryF(
312 'SELECT question_id FROM qpl_questions WHERE obj_fi = %s AND qpl_questions.tstamp > 0 AND original_id IS NULL',
313 ['integer'],
314 [$this->getId()]
315 );
316 $questions = [];
317 while ($row = $this->db->fetchAssoc($result)) {
318 array_push($questions, $row['question_id']);
319 }
320 return $questions;
321 }

References ilObject\getId().

+ Here is the call graph for this function:

◆ getDeleteableQuestionDetails()

ilObjQuestionPool::getDeleteableQuestionDetails (   $question_ids)

Returns an array containing the qpl_question and qpl_qst_type fields of deleteable questions for an array of question ids.

Parameters
array$question_idsAn array containing the question ids
Returns
array An array containing the details of the requested questions @access public

Definition at line 603 of file class.ilObjQuestionPool.php.

603 : array
604 {
605 $result = [];
606 $query_result = $this->db->query(
607 'SELECT qpl_questions.*, qpl_qst_type.type_tag FROM qpl_questions, qpl_qst_type WHERE qpl_questions.question_type_fi = qpl_qst_type.question_type_id AND '
608 . $this->db->in('qpl_questions.question_id', $question_ids, false, 'integer')
609 . ' ORDER BY qpl_questions.title'
610 );
611 if ($query_result->numRows()) {
612 while ($row = $this->db->fetchAssoc($query_result)) {
613 if (!$this->questionrepository->isUsedInRandomTest($row['question_id'])) {
614 array_push($result, $row);
615 } else {
616 // the question was used in a random test prior to ILIAS 3.7 so it was inserted
617 // as a reference to the original question pool object and not as a copy. To allow
618 // the deletion of the question pool object, a copy must be created and all database references
619 // of the original question must changed with the reference of the copy
620
621 // 1. Create a copy of the original question
622 $question = $this->createQuestion('', $row['question_id']);
623 $duplicate_id = $question->getObject()->duplicate(true);
624 if ($duplicate_id > 0) {
625 // 2. replace the question id in the solutions
626 $affectedRows = $this->db->manipulateF(
627 'UPDATE tst_solutions SET question_fi = %s WHERE question_fi = %s',
628 ['integer', 'integer'],
629 [$duplicate_id, $row['question_id']]
630 );
631
632 // 3. replace the question id in the question list of random tests
633 $affectedRows = $this->db->manipulateF(
634 'UPDATE tst_test_rnd_qst SET question_fi = %s WHERE question_fi = %s',
635 ['integer', 'integer'],
636 [$duplicate_id, $row['question_id']]
637 );
638
639 // 4. replace the question id in the test results
640 $affectedRows = $this->db->manipulateF(
641 'UPDATE tst_test_result SET question_fi = %s WHERE question_fi = %s',
642 ['integer', 'integer'],
643 [$duplicate_id, $row['question_id']]
644 );
645
646 // 5. replace the question id in the test&assessment log
647 $affectedRows = $this->db->manipulateF(
648 'UPDATE ass_log SET question_fi = %s WHERE question_fi = %s',
649 ['integer', 'integer'],
650 [$duplicate_id, $row['question_id']]
651 );
652
653 // 6. The original question can be deleted, so add it to the list of questions
654 array_push($result, $row);
655 }
656 }
657 }
658 }
659 return $result;
660 }

References createQuestion().

+ Here is the call graph for this function:

◆ getPrintviewQuestions()

ilObjQuestionPool::getPrintviewQuestions ( )

Definition at line 280 of file class.ilObjQuestionPool.php.

280 : array
281 {
282 $query_result = $this->db->queryF(
283 'SELECT qpl_questions.*, qpl_qst_type.type_tag, qpl_qst_type.plugin, qpl_questions.tstamp updated FROM qpl_questions, qpl_qst_type WHERE qpl_questions.original_id IS NULL AND qpl_questions.tstamp > 0 AND qpl_questions.question_type_fi = qpl_qst_type.question_type_id AND qpl_questions.obj_fi = %s',
284 ['integer'],
285 [$this->getId()]
286 );
287 $rows = [];
288 $types = $this->getQuestionTypeTranslations();
289 if ($query_result->numRows()) {
290 while ($row = $this->db->fetchAssoc($query_result)) {
291 $row['ttype'] = $types[$row['type_tag']];
292 if ($row['plugin']) {
293 if ($this->isPluginActive($row['type_tag'])) {
294 array_push($rows, $row);
295 }
296 } else {
297 array_push($rows, $row);
298 }
299 }
300 }
301 return $rows;
302 }

References ILIAS\Scripts\PHPStan\$rows, ilObject\getId(), getQuestionTypeTranslations(), and isPluginActive().

+ Here is the call graph for this function:

◆ getQplQuestions()

ilObjQuestionPool::getQplQuestions ( )

Definition at line 743 of file class.ilObjQuestionPool.php.

743 : array
744 {
745 $questions = [];
746 $result = $this->db->queryF(
747 'SELECT qpl_questions.question_id FROM qpl_questions WHERE qpl_questions.original_id IS NULL AND qpl_questions.tstamp > 0 AND qpl_questions.obj_fi = %s',
749 [$this->getId()]
750 );
751 while ($row = $this->db->fetchAssoc($result)) {
752 $questions[] = $row['question_id'];
753 }
754 return $questions;
755 }

References ILIAS\Survey\Mode\getId(), and ilDBConstants\T_INTEGER.

Referenced by deleteQuestionpool().

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

◆ getQuestionDetails()

ilObjQuestionPool::getQuestionDetails (   $question_ids)

Returns an array containing the qpl_question and qpl_qst_type fields for an array of question ids.

Parameters
array$question_idsAn array containing the question ids
Returns
array An array containing the details of the requested questions @access public

Definition at line 573 of file class.ilObjQuestionPool.php.

573 : array
574 {
575 $result = [];
576 $query_result = $this->db->query(
577 'SELECT qpl_questions.*, qpl_qst_type.type_tag '
578 . 'FROM qpl_questions, qpl_qst_type '
579 . 'WHERE qpl_questions.question_type_fi = qpl_qst_type.question_type_id '
580 . 'AND ' . $this->db->in(
581 'qpl_questions.question_id',
582 $question_ids,
583 false,
584 'integer'
585 ) . ' ORDER BY qpl_questions.title'
586 );
587 if ($query_result->numRows()) {
588 while ($row = $this->db->fetchAssoc($query_result)) {
589 array_push($result, $row);
590 }
591 }
592 return $result;
593 }

◆ getQuestionList()

ilObjQuestionPool::getQuestionList ( )

Definition at line 902 of file class.ilObjQuestionPool.php.

902 : array
903 {
904 $questions = [];
905 $result = $this->db->queryF(
906 'SELECT qpl_questions.*, qpl_qst_type.* FROM qpl_questions, qpl_qst_type WHERE qpl_questions.original_id IS NULL AND qpl_questions.obj_fi = %s AND qpl_questions.tstamp > 0 AND qpl_questions.question_type_fi = qpl_qst_type.question_type_id',
907 ['integer'],
908 [$this->getId()]
909 );
910 while ($row = $this->db->fetchAssoc($result)) {
911 array_push($questions, $row);
912 }
913 return $questions;
914 }

References ILIAS\Survey\Mode\getId().

+ Here is the call graph for this function:

◆ getQuestiontype()

ilObjQuestionPool::getQuestiontype (   $question_id)

Definition at line 199 of file class.ilObjQuestionPool.php.

200 {
201 if ($question_id < 1) {
202 return null;
203 }
204
205 $result = $this->db->queryF(
206 'SELECT qpl_qst_type.type_tag FROM qpl_questions, qpl_qst_type WHERE qpl_questions.question_type_fi = qpl_qst_type.question_type_id AND qpl_questions.question_id = %s',
207 ['integer'],
208 [$question_id]
209 );
210
211 if ($result->numRows() == 1) {
212 $data = $this->db->fetchAssoc($result);
213 return $data['type_tag'];
214 }
215 return null;
216 }
$data
Definition: storeScorm.php:45

References $data.

◆ getQuestionTypeByTypeId()

static ilObjQuestionPool::getQuestionTypeByTypeId (   $type_id)
static

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

833 {
834 global $DIC;
835 $ilDB = $DIC['ilDB'];
836
837 $query = 'SELECT type_tag FROM qpl_qst_type WHERE question_type_id = %s';
838 $types = ['integer'];
839 $values = [$type_id];
840 $result = $ilDB->queryF($query, $types, $values);
841
842 if ($row = $ilDB->fetchAssoc($result)) {
843 return $row['type_tag'];
844 }
845 return null;
846 }

References $DIC, and $ilDB.

◆ getQuestionTypes()

ilObjQuestionPool::getQuestionTypes (   $all_tags = false,
  $fixOrder = false,
  $withDeprecatedTypes = true 
)

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

795 : array
796 {
797 return self::_getQuestionTypes($all_tags, $fixOrder, $withDeprecatedTypes);
798 }

◆ getQuestionTypeTranslations()

static ilObjQuestionPool::getQuestionTypeTranslations ( )
static

Definition at line 848 of file class.ilObjQuestionPool.php.

848 : array
849 {
850 global $DIC;
851 $ilDB = $DIC['ilDB'];
852 $lng = $DIC['lng'];
853 $component_factory = $DIC['component.factory'];
854
855 $lng->loadLanguageModule('assessment');
856 $result = $ilDB->query('SELECT * FROM qpl_qst_type');
857 $types = [];
858 while ($row = $ilDB->fetchAssoc($result)) {
859 if ($row['plugin'] == 0) {
860 $types[$row['type_tag']] = $lng->txt($row['type_tag']);
861 } else {
862 foreach ($component_factory->getActivePluginsInSlot('qst') as $pl) {
863 if (strcmp($pl->getQuestionType(), $row['type_tag']) == 0) {
864 $types[$row['type_tag']] = $pl->getQuestionTypeTranslation();
865 }
866 }
867 }
868 }
869 ksort($types);
870 return $types;
871 }

References $DIC, $ilDB, and $lng.

Referenced by getPrintviewQuestions().

+ Here is the caller graph for this function:

◆ getTaxonomyIds()

ilObjQuestionPool::getTaxonomyIds ( )

get ids of all taxonomies corresponding to current pool

Returns
array

Definition at line 967 of file class.ilObjQuestionPool.php.

967 : array
968 {
969 return ilObjTaxonomy::getUsageOfObject($this->getId());
970 }
static getUsageOfObject(int $a_obj_id, bool $a_include_titles=false)

References ILIAS\Survey\Mode\getId(), and ilObjTaxonomy\getUsageOfObject().

+ Here is the call graph for this function:

◆ isInUse()

ilObjQuestionPool::isInUse ( int  $question_id)

Definition at line 218 of file class.ilObjQuestionPool.php.

218 : bool
219 {
220 $result = $this->db->queryF(
221 'SELECT COUNT(solution_id) solution_count FROM tst_solutions WHERE question_fi = %s',
222 ['integer'],
223 [$question_id]
224 );
225 $row = $this->db->fetchAssoc($result);
226 return $row['solution_count'];
227 }

◆ isPluginActive()

ilObjQuestionPool::isPluginActive (   $questionType)

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

Parameters
string$a_pnameThe plugin name @access public

Definition at line 933 of file class.ilObjQuestionPool.php.

933 : bool
934 {
935 if (!$this->component_repository->getComponentByTypeAndName(
937 'TestQuestionPool'
938 )->getPluginSlotById('qst')->hasPluginName($questionType)) {
939 return false;
940 }
941
942 return $this->component_repository
943 ->getComponentByTypeAndName(
945 'TestQuestionPool'
946 )
947 ->getPluginSlotById(
948 'qst'
949 )
950 ->getPluginByName(
951 $questionType
952 )->isActive();
953 }

References ilComponentInfo\TYPE_COMPONENT.

Referenced by getAllQuestionIds(), and getPrintviewQuestions().

+ Here is the caller graph for this function:

◆ isSkillManagementGloballyActivated()

static ilObjQuestionPool::isSkillManagementGloballyActivated ( )
static

Definition at line 984 of file class.ilObjQuestionPool.php.

984 : ?bool
985 {
986 if (self::$isSkillManagementGloballyActivated === null) {
987 $skmgSet = new ilSkillManagementSettings();
988
989 self::$isSkillManagementGloballyActivated = $skmgSet->isActivated();
990 }
991
993 }

Referenced by ilObjQuestionPoolSettingsGeneralGUI\buildForm(), ilQuestionPoolSkillAdministrationGUI\isAccessDenied(), and ilObjQuestionPoolGUI\isSkillsTabRequired().

+ Here is the caller graph for this function:

◆ isSkillServiceEnabled()

ilObjQuestionPool::isSkillServiceEnabled ( )

Definition at line 972 of file class.ilObjQuestionPool.php.

972 : bool
973 {
975 }

Referenced by saveToDb().

+ Here is the caller graph for this function:

◆ loadFromDb()

ilObjQuestionPool::loadFromDb ( )

Definition at line 155 of file class.ilObjQuestionPool.php.

155 : void
156 {
157 $result = $this->db->queryF(
158 'SELECT * FROM qpl_questionpool WHERE obj_fi = %s',
159 ['integer'],
160 [$this->getId()]
161 );
162 if ($result->numRows() == 1) {
163 $row = $this->db->fetchAssoc($result);
164 $this->setSkillServiceEnabled((bool) $row['skill_service']);
165 }
166 }
setSkillServiceEnabled(bool $skill_service_enabled)

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

Referenced by read().

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

◆ moveToClipboard()

ilObjQuestionPool::moveToClipboard ( int  $question_id)

Moves a question to the clipboard.

Parameters
integer$question_idObject id of the question @access private

Definition at line 513 of file class.ilObjQuestionPool.php.

513 : void
514 {
515 if (ilSession::get('qpl_clipboard') == null) {
516 ilSession::set('qpl_clipboard', []);
517 }
518 $clip = ilSession::get('qpl_clipboard');
519 $clip[$question_id] = ['question_id' => $question_id, 'action' => 'move'];
520 ilSession::set('qpl_clipboard', $clip);
521 }

References ilSession\get(), and ilSession\set().

+ Here is the call graph for this function:

◆ pasteFromClipboard()

ilObjQuestionPool::pasteFromClipboard ( )

Copies/Moves a question from the clipboard.

@access private

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

441 : bool
442 {
443 $success = false;
444 if (ilSession::get('qpl_clipboard') != null) {
445 $success = true;
446 foreach (ilSession::get('qpl_clipboard') as $question_object) {
447 if (strcmp($question_object['action'], 'move') == 0) {
448 $result = $this->db->queryF(
449 'SELECT obj_fi FROM qpl_questions WHERE question_id = %s',
450 ['integer'],
451 [$question_object['question_id']]
452 );
453 if ($result->numRows() == 1) {
454 $row = $this->db->fetchAssoc($result);
455 $source_questionpool = $row['obj_fi'];
456 $affectedRows = $this->db->manipulateF(
457 'UPDATE qpl_questions SET obj_fi = %s WHERE question_id = %s',
458 ['integer', 'integer'],
459 [$this->getId(), $question_object['question_id']]
460 );
461 if (!$affectedRows) {
462 $success = false;
463 }
464
465 $source_path = CLIENT_WEB_DIR . '/assessment/' . $source_questionpool . '/' . $question_object['question_id'] . '/';
466 if (@is_dir($source_path)) {
467 $target_path = CLIENT_WEB_DIR . '/assessment/' . $this->getId() . '/';
468 if (!@is_dir($target_path)) {
469 ilFileUtils::makeDirParents($target_path);
470 }
471 rename($source_path, $target_path . $question_object['question_id']);
472 }
473
474 ilObjQuestionPool::_updateQuestionCount($source_questionpool);
475 }
476 } else {
477 $new_question_id = $this->copyQuestion($question_object['question_id'], $this->getId());
478 if (!$new_question_id) {
479 $success = false;
480 }
481 }
482 }
483 }
484 // update question count of question pool
486 ilSession::clear('qpl_clipboard');
487
488 return $success;
489 }
static makeDirParents(string $a_dir)
Create a new directory and all parent directories.
copyQuestion(int $question_id, int $questionpool_to)
const CLIENT_WEB_DIR
Definition: constants.php:47

References _updateQuestionCount(), ilSession\clear(), CLIENT_WEB_DIR, copyQuestion(), ilSession\get(), ilObject\getId(), and ilFileUtils\makeDirParents().

+ Here is the call graph for this function:

◆ purgeQuestions()

ilObjQuestionPool::purgeQuestions ( )

Definition at line 955 of file class.ilObjQuestionPool.php.

955 : void
956 {
957 $incompleteQuestionPurger = new ilAssIncompleteQuestionPurger($this->db);
958 $incompleteQuestionPurger->setOwnerId($this->user->getId());
959 $incompleteQuestionPurger->purge();
960 }

References ILIAS\Repository\user().

+ Here is the call graph for this function:

◆ questionsToXML()

ilObjQuestionPool::questionsToXML (   $questions)

Returns a QTI xml representation of a list of questions.

Parameters
array$questionsAn array containing the question ids of the questions
Returns
string The QTI xml representation of the questions @access public
Deprecated:
12: Use ILIAS\Test\ExportImport\TestExporter instead

Definition at line 367 of file class.ilObjQuestionPool.php.

367 : string
368 {
369 $xml = '';
370 // export button was pressed
371 if (count($questions) > 0) {
372 foreach ($questions as $key => $value) {
373 $question = $this->createQuestion('', $value);
374 $xml .= $question->getObject()->toXML();
375 }
376 if (count($questions) > 1) {
377 $xml = preg_replace('/<\/questestinterop>\s*<.xml.*?>\s*<questestinterop>/', '', $xml);
378 }
379 }
380 $xml = preg_replace(
381 '/(<\?xml[^>]*?>)/',
382 '\\1' . '<!DOCTYPE questestinterop SYSTEM "ims_qtiasiv1p2p1.dtd">',
383 $xml
384 );
385 return $xml;
386 }

References createQuestion().

+ Here is the call graph for this function:

◆ read()

ilObjQuestionPool::read (   $a_force_db = false)

read object data from db into object

Parameters
boolean@access public

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

106 : void
107 {
108 parent::read($a_force_db);
109 $this->loadFromDb();
110 }

References loadFromDb().

+ Here is the call graph for this function:

◆ saveToDb()

ilObjQuestionPool::saveToDb ( )

Definition at line 168 of file class.ilObjQuestionPool.php.

168 : void
169 {
170 $result = $this->db->queryF(
171 'SELECT id_questionpool FROM qpl_questionpool WHERE obj_fi = %s',
172 ['integer'],
173 [$this->getId()]
174 );
175
176 if ($result->numRows() == 1) {
177 $result = $this->db->update(
178 'qpl_questionpool',
179 [
180 'skill_service' => ['integer', (int) $this->isSkillServiceEnabled()],
181 'tstamp' => ['integer', time()]
182 ],
183 [
184 'obj_fi' => ['integer', $this->getId()]
185 ]
186 );
187 } else {
188 $next_id = $this->db->nextId('qpl_questionpool');
189
190 $result = $this->db->insert('qpl_questionpool', [
191 'id_questionpool' => ['integer', $next_id],
192 'skill_service' => ['integer', (int) $this->isSkillServiceEnabled()],
193 'tstamp' => ['integer', time()],
194 'obj_fi' => ['integer', $this->getId()]
195 ]);
196 }
197 }

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

Referenced by createReference().

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

◆ setSkillServiceEnabled()

ilObjQuestionPool::setSkillServiceEnabled ( bool  $skill_service_enabled)

Definition at line 977 of file class.ilObjQuestionPool.php.

977 : void
978 {
979 $this->skill_service_enabled = $skill_service_enabled;
980 }

Referenced by loadFromDb().

+ Here is the caller graph for this function:

◆ update()

ilObjQuestionPool::update ( )

update object data

@access public

Returns
boolean

Reimplemented from ilObject.

Definition at line 89 of file class.ilObjQuestionPool.php.

89 : bool
90 {
91 $this->updateMetaData();
92 if (!parent::update()) {
93 return false;
94 }
95
96 // put here object specific stuff
97
98 return true;
99 }

References ilObject\updateMetaData().

+ Here is the call graph for this function:

Field Documentation

◆ $component_repository

ilComponentRepository ilObjQuestionPool::$component_repository
private

Definition at line 35 of file class.ilObjQuestionPool.php.

◆ $isSkillManagementGloballyActivated

ilObjQuestionPool::$isSkillManagementGloballyActivated = null
staticprivate

Definition at line 982 of file class.ilObjQuestionPool.php.

◆ $questionrepository

GeneralQuestionPropertiesRepository ilObjQuestionPool::$questionrepository
private

Definition at line 38 of file class.ilObjQuestionPool.php.

◆ $skill_service_enabled

bool ilObjQuestionPool::$skill_service_enabled
private

Definition at line 37 of file class.ilObjQuestionPool.php.


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