ILIAS  release_7 Revision v7.30-3-g800a261c036
ilObjQuestionPool Class Reference
+ Inheritance diagram for ilObjQuestionPool:
+ Collaboration diagram for ilObjQuestionPool:

Public Member Functions

 __construct ($a_id=0, $a_call_by_reference=true)
 Constructor @access public. More...
 
 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...
 
 updateMetaData ()
 update meta data entry More...
 
 read ($a_force_db=false)
 read object data from db into object More...
 
 delete ()
 delete object and all related data More...
 
 deleteQuestionpool ()
 
 deleteQuestion ($question_id)
 Deletes a question from the question pool. More...
 
 addQuestionChangeListeners (assQuestion $question)
 
 loadFromDb ()
 Loads a ilObjQuestionpool object from a database. More...
 
 saveToDb ()
 Saves a ilObjQuestionpool object to a database. More...
 
 getQuestiontype ($question_id)
 Returns the question type of a question with a given id. More...
 
 getDescription ()
 get description of content object More...
 
 setDescription ($a_description)
 set description of content object More...
 
 getTitle ()
 get title of glossary object More...
 
 setTitle ($a_title)
 set title of glossary object More...
 
 isInUse ($question_id)
 Checks whether the question is in use or not. More...
 
createQuestion ($question_type, $question_id=-1)
 
 duplicateQuestion ($question_id)
 Duplicates a question for a questionpool. More...
 
 copyQuestion ($question_id, $questionpool_to)
 Copies a question into another question pool. More...
 
 getPrintviewQuestions ()
 Calculates the data for the print view of the questionpool. More...
 
 objectToXmlWriter (ilXmlWriter &$a_xml_writer, $a_inst, $a_target_dir, &$expLog, $questions)
 export pages of test to xml (see ilias_co.dtd) More...
 
 exportXMLMetaData (&$a_xml_writer)
 export content objects meta data to xml (see ilias_co.dtd) More...
 
 modifyExportIdentifier ($a_tag, $a_param, $a_value)
 
 exportXMLPageObjects (&$a_xml_writer, $a_inst, &$expLog, $questions)
 export page objects to xml (see ilias_co.dtd) More...
 
 exportXMLMediaObjects (&$a_xml_writer, $a_inst, $a_target_dir, &$expLog)
 export media objects to xml (see ilias_co.dtd) More...
 
 exportFileItems ($target_dir, &$expLog)
 export files of file itmes More...
 
 createExportDirectory ()
 creates data directory for export files (data_dir/qpl_data/qpl_<id>/export, depending on data directory that is set in ILIAS setup/ini) More...
 
 getExportDirectory ($type="")
 get export directory of questionpool More...
 
 getImportDirectory ()
 
getAllQuestions ()
 Retrieve an array containing all question ids of the questionpool. More...
 
getAllQuestionIds ()
 
 checkQuestionParent ($questionId)
 
 getImportMapping ()
 get array of (two) new created questions for import id More...
 
 questionsToXML ($questions)
 Returns a QTI xml representation of a list of questions. More...
 
 setOnline ($a_online_status)
 Sets the questionpool online status. More...
 
 getOnline ()
 
 setShowTaxonomies ($showTaxonomies)
 
 getShowTaxonomies ()
 
 setNavTaxonomyId ($navTaxonomyId)
 
 getNavTaxonomyId ()
 
 isNavTaxonomyActive ()
 
 pasteFromClipboard ()
 Copies/Moves a question from the clipboard. More...
 
 copyToClipboard ($question_id)
 Copies a question to the clipboard. More...
 
 moveToClipboard ($question_id)
 Moves a question to the clipboard. More...
 
 cleanupClipboard ($deletedQuestionId)
 
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...
 
 _getFullPathToQpl ($ref_id)
 Retrieves the full path to a question pool with a given reference id. More...
 
getQplQuestions ()
 
 cloneObject ($a_target_id, $a_copy_id=0, $a_omit_tree=false)
 Creates a 1:1 copy of the object and places the copy in a given repository. More...
 
 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 ($skillServiceEnabled)
 
 fromXML ($xmlFile)
 
- Public Member Functions inherited from ilObject
 __construct ($a_id=0, $a_reference=true)
 Constructor @access public. More...
 
 withReferences ()
 determines wehter objects are referenced or not (got ref ids or not) More...
 
 read ()
 read object data from db into object More...
 
 getId ()
 get object id @access public More...
 
 setId ($a_id)
 set object id @access public More...
 
 setRefId ($a_id)
 set reference id @access public More...
 
 getRefId ()
 get reference id @access public More...
 
 getType ()
 get object type @access public More...
 
 setType ($a_type)
 set object type @access public More...
 
 getPresentationTitle ()
 get presentation title Normally same as title Overwritten for sessions More...
 
 getTitle ()
 get object title @access public More...
 
 getUntranslatedTitle ()
 get untranslated object title @access public More...
 
 setTitle ($a_title)
 set object title More...
 
 getDescription ()
 get object description More...
 
 setDescription ($a_desc)
 set object description More...
 
 getLongDescription ()
 get object long description (stored in object_description) More...
 
 getImportId ()
 get import id More...
 
 setImportId ($a_import_id)
 set import id More...
 
 setOfflineStatus ($a_status)
 Set offline status. More...
 
 getOfflineStatus ()
 Get offline status. More...
 
 supportsOfflineHandling ()
 Check whether object supports offline handling. More...
 
 getOwner ()
 get object owner More...
 
 getOwnerName ()
 
 setOwner ($a_owner)
 set object owner More...
 
 getCreateDate ()
 get create date @access public More...
 
 getLastUpdateDate ()
 get last update date @access public More...
 
 getDiskUsage ()
 Gets the disk usage of the object in bytes. More...
 
 create ()
 create More...
 
 update ()
 update object in db More...
 
 MDUpdateListener ($a_element)
 Meta data update listener. More...
 
 createMetaData ()
 create meta data entry More...
 
 updateMetaData ()
 update meta data entry More...
 
 deleteMetaData ()
 delete meta data entry More...
 
 updateOwner ()
 update owner of object in db More...
 
 putInTree ($a_parent_ref)
 maybe this method should be in tree object!? More...
 
 setPermissions ($a_parent_ref)
 set permissions of object More...
 
 setParentRolePermissions ($a_parent_ref)
 Initialize the permissions of parent roles (local roles of categories, global roles...) This method is overwritten in e.g courses, groups for building permission intersections with non_member templates. More...
 
 createReference ()
 creates reference for object More...
 
 countReferences ()
 count references of object More...
 
 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 If you want to setup default local roles you MUST overwrite this method in derived object classes (see ilObjForum for an example) @access public More...
 
 applyDidacticTemplate ($a_tpl_id)
 Apply template. More...
 
 setRegisterMode ($a_bool)
 
 isUserRegistered ($a_user_id=0)
 
 requireRegistration ()
 
 getXMLZip ()
 
 getHTMLDirectory ()
 
 appendCopyInfo ($a_target_id, $a_copy_id)
 Prepend Copy info if object with same name exists in that container. More...
 
 cloneDependencies ($a_target_id, $a_copy_id)
 Clone object dependencies. More...
 
 cloneMetaData ($target_obj)
 Copy meta data. More...
 
 getPossibleSubObjects ($a_filter=true)
 get all possible subobjects of this type the object can decide which types of subobjects are possible jut in time overwrite if the decision distinguish from standard model More...
 

Static Public Member Functions

static _createImportDirectory ()
 creates data directory for import files (data_dir/qpl_data/qpl_<id>/import, depending on data directory that is set in ILIAS setup/ini) More...
 
static _setImportDirectory ($a_import_dir=null)
 set import directory More...
 
static _getImportDirectory ()
 get import directory of lm More...
 
static _getQuestionCount ($questionpool_id, $complete_questions_only=false)
 Returns the number of questions in a question pool. More...
 
static _lookupOnline ($a_obj_id, $is_reference=false)
 
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 ($use_object_id=false, $equal_points=false, $could_be_offline=false, $showPath=false, $with_questioncount=false, $permission="read", $usr_id="")
 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)
 Get all self assessment question types. More...
 
static _updateQuestionCount ($object_id)
 Updates the number of available questions for a question pool in the database. More...
 
static isSkillManagementGloballyActivated ()
 
- Static Public Member Functions inherited from ilObject
static _lookupObjIdByImportId ($a_import_id)
 
static _lookupImportId ($a_obj_id)
 
static _lookupOwnerName ($a_owner_id)
 lookup owner name for owner id More...
 
static _getIdForImportId ($a_import_id)
 get current object id for import id (static) More...
 
static _getAllReferences ($a_id)
 get all reference ids of object More...
 
static _lookupTitle ($a_id)
 lookup object title More...
 
static lookupOfflineStatus ($a_obj_id)
 Lookup offline status using objectDataCache. More...
 
static _lookupOwner ($a_id)
 lookup object owner More...
 
static _getIdsForTitle ($title, $type='', $partialmatch=false)
 
static _lookupDescription ($a_id)
 lookup object description More...
 
static _lookupLastUpdate ($a_id, $a_as_string=false)
 lookup last update More...
 
static _getLastUpdateOfObjects ($a_objs)
 Get last update for a set of media objects. More...
 
static _lookupObjId ($a_id)
 
static _setDeletedDate ($a_ref_id, $a_deleted_by)
 
static setDeletedDates ($a_ref_ids, $a_user_id)
 Set deleted date. More...
 
static _resetDeletedDate ($a_ref_id)
 only called in ilObjectGUI::insertSavedNodes More...
 
static _lookupDeletedDate ($a_ref_id)
 only called in ilObjectGUI::insertSavedNodes More...
 
static _writeTitle ($a_obj_id, $a_title)
 write title to db (static) More...
 
static _writeDescription ($a_obj_id, $a_desc)
 write description to db (static) More...
 
static _writeImportId ($a_obj_id, $a_import_id)
 write import id to db (static) More...
 
static _lookupType ($a_id, $a_reference=false)
 lookup object type More...
 
static _isInTrash ($a_ref_id)
 checks wether object is in trash More...
 
static _hasUntrashedReference ($a_obj_id)
 checks wether an object has at least one reference that is not in trash More...
 
static _lookupObjectId ($a_ref_id)
 lookup object id More...
 
static _getObjectsDataForType ($a_type, $a_omit_trash=false)
 get all objects of a certain type More...
 
static _exists ($a_id, $a_reference=false, $a_type=null)
 checks if an object exists in object_data@access public More...
 
static _getObjectsByType ($a_obj_type="", $a_owner="")
 Get objects by type. More...
 
static _prepareCloneSelection ($a_ref_ids, $new_type, $show_path=true)
 Prepare copy wizard object selection. More...
 
static _getIcon ( $a_obj_id="", $a_size="big", $a_type="", $a_offline=false)
 Get icon for repository item. More...
 
static collectDeletionDependencies (&$deps, $a_ref_id, $a_obj_id, $a_type, $a_depth=0)
 Collect deletion dependencies. More...
 
static getDeletionDependencies ($a_obj_id)
 Get deletion dependencies. More...
 
static getLongDescriptions (array $a_obj_ids)
 Get long description data. More...
 
static getAllOwnedRepositoryObjects ($a_user_id)
 Get all ids of objects user owns. More...
 
static fixMissingTitles ($a_type, array &$a_obj_title_map)
 Try to fix missing object titles. More...
 
static _lookupCreationDate ($a_id)
 Lookup creation date. More...
 
static hasAutoRating ($a_type, $a_ref_id)
 Check if auto rating is active for parent group/course. More...
 

Data Fields

 $online
 
- Data Fields inherited from ilObject
const TITLE_LENGTH = 255
 max length of object title More...
 
const DESC_LENGTH = 128
 
 $lng
 
 $id
 
 $ref_id
 
 $type
 
 $title
 
 $untranslatedTitle
 
 $desc
 
 $long_desc
 
 $owner
 
 $create_date
 
 $last_update
 
 $import_id
 
 $register = false
 
 $referenced
 
 $objectList
 
 $max_title
 
 $max_desc
 
 $add_dots
 

Protected Member Functions

 populateQuestionSkillAssignmentsXml (ilXmlWriter &$a_xml_writer, $questions)
 

Private Member Functions

 exportXMLSettings ($xmlWriter)
 

Private Attributes

 $showTaxonomies = null
 
 $navTaxonomyId = null
 
 $skillServiceEnabled
 
 $import_dir
 

Static Private Attributes

static $isSkillManagementGloballyActivated = null
 

Additional Inherited Members

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

Detailed Description

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

Constructor & Destructor Documentation

◆ __construct()

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

Constructor @access public.

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

Reimplemented from ilObject.

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

57 {
58 $this->type = "qpl";
59 parent::__construct($a_id, $a_call_by_reference);
60 $this->setOnline(0);
61
62 $this->skillServiceEnabled = false;
63 }
setOnline($a_online_status)
Sets the questionpool online status.
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc

References ILIAS\GlobalScreen\Provider\__construct(), and setOnline().

+ Here is the call graph for this function:

Member Function Documentation

◆ _createImportDirectory()

static ilObjQuestionPool::_createImportDirectory ( )
static

creates data directory for import files (data_dir/qpl_data/qpl_<id>/import, depending on data directory that is set in ILIAS setup/ini)

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

741 {
742 global $DIC;
743 $ilias = $DIC['ilias'];
744
745 include_once "./Services/Utilities/classes/class.ilUtil.php";
746 $qpl_data_dir = ilUtil::getDataDir() . "/qpl_data";
747 ilUtil::makeDir($qpl_data_dir);
748
749 if (!is_writable($qpl_data_dir)) {
750 $ilias->raiseError("Questionpool Data Directory (" . $qpl_data_dir
751 . ") not writeable.", $ilias->error_obj->FATAL);
752 }
753
754 // create questionpool directory (data_dir/qpl_data/qpl_import)
755 $qpl_dir = $qpl_data_dir . "/qpl_import";
756 ilUtil::makeDir($qpl_dir);
757 if (!@is_dir($qpl_dir)) {
758 $ilias->raiseError("Creation of Questionpool Directory failed.", $ilias->error_obj->FATAL);
759 }
760 return $qpl_dir;
761 }
static getDataDir()
get data directory (outside webspace)
static makeDir($a_dir)
creates a new directory and inherits all filesystem permissions of the parent directory You may pass ...
global $DIC
Definition: goto.php:24

References $DIC, ilUtil\getDataDir(), and ilUtil\makeDir().

Referenced by ilObjQuestionPoolGUI\uploadQplObject().

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

◆ _getAvailableQuestionpools()

static ilObjQuestionPool::_getAvailableQuestionpools (   $use_object_id = false,
  $equal_points = false,
  $could_be_offline = false,
  $showPath = false,
  $with_questioncount = false,
  $permission = "read",
  $usr_id = "" 
)
static

Returns the available question pools for the active user.

Returns
array The available question pools @access public

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

1284 {
1285 global $DIC;
1286 $ilUser = $DIC['ilUser'];
1287 $ilDB = $DIC['ilDB'];
1288 $lng = $DIC['lng'];
1289
1290 $result_array = array();
1291 $permission = (strlen($permission) == 0) ? "read" : $permission;
1292 $qpls = ilUtil::_getObjectsByOperations("qpl", $permission, (strlen($usr_id)) ? $usr_id : $ilUser->getId(), -1);
1293 $obj_ids = array();
1294 foreach ($qpls as $ref_id) {
1296 $obj_ids[$ref_id] = $obj_id;
1297 }
1298 $titles = ilObject::_prepareCloneSelection($qpls, "qpl");
1299 if (count($obj_ids)) {
1300 $in = $ilDB->in('object_data.obj_id', $obj_ids, false, 'integer');
1301 if ($could_be_offline) {
1302 $result = $ilDB->query("SELECT qpl_questionpool.*, object_data.title FROM qpl_questionpool, object_data WHERE " .
1303 "qpl_questionpool.obj_fi = object_data.obj_id AND $in ORDER BY object_data.title");
1304 } else {
1305 $result = $ilDB->queryF(
1306 "SELECT qpl_questionpool.*, object_data.title FROM qpl_questionpool, object_data WHERE " .
1307 "qpl_questionpool.obj_fi = object_data.obj_id AND $in AND qpl_questionpool.isonline = %s " .
1308 "ORDER BY object_data.title",
1309 array('text'),
1310 array(1)
1311 );
1312 }
1313 while ($row = $ilDB->fetchAssoc($result)) {
1314 $add = true;
1315 if ($equal_points) {
1316 if (!ilObjQuestionPool::_hasEqualPoints($row["obj_fi"])) {
1317 $add = false;
1318 }
1319 }
1320 if ($add) {
1321 $ref_id = array_search($row["obj_fi"], $obj_ids);
1322 $title = (($showPath) ? $titles[$ref_id] : $row["title"]);
1323 if ($with_questioncount) {
1324 $title .= " [" . $row["questioncount"] . " " . ($row["questioncount"] == 1 ? $lng->txt("ass_question") : $lng->txt("assQuestions")) . "]";
1325 }
1326
1327 if ($use_object_id) {
1328 $result_array[$row["obj_fi"]] = array(
1329 'qpl_id' => $row['obj_fi'],
1330 'qpl_title' => $row['title'],
1331 "title" => $title,
1332 "count" => $row["questioncount"]
1333 );
1334 } else {
1335 $result_array[$ref_id] = array(
1336 'qpl_id' => $row['obj_fi'],
1337 'qpl_title' => $row['title'],
1338 "title" => $title,
1339 "count" => $row["questioncount"]
1340 );
1341 }
1342 }
1343 }
1344 }
1345 return $result_array;
1346 }
$result
if(php_sapi_name() !='cli') $in
Definition: Utf8Test.php:37
static _hasEqualPoints($a_obj_id, $is_reference=false)
Checks a question pool for questions with the same maximum points.
static _lookupObjId($a_id)
static _prepareCloneSelection($a_ref_ids, $new_type, $show_path=true)
Prepare copy wizard object selection.
static _getObjectsByOperations($a_obj_type, $a_operation, $a_usr_id=0, $limit=0)
Get all objects of a specific type and check access This function is not recursive,...
$ilUser
Definition: imgupload.php:18
global $ilDB

References $DIC, $ilDB, $ilUser, $in, ilObject\$lng, ilObject\$ref_id, $result, ilObject\$title, ilUtil\_getObjectsByOperations(), _hasEqualPoints(), ilObject\_lookupObjId(), and ilObject\_prepareCloneSelection().

Referenced by ilTestExpressPageObjectGUI\addQuestion(), ilObjTestGUI\addQuestionObject(), ilObjTestGUI\createQuestionObject(), ilObjTest\getAvailableQuestionpools(), ilObjTest\getAvailableQuestions(), ilTestQuestionBrowserTableGUI\getQuestionParentObjIds(), and ilObjTest\randomSelectQuestions().

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

◆ _getFullPathToQpl()

ilObjQuestionPool::_getFullPathToQpl (   $ref_id)

Retrieves the full path to a question pool with a given reference id.

Returns
string The full path to the question pool including the locator @access public

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

1257 {
1258 global $DIC;
1259 $tree = $DIC['tree'];
1260 $path = $tree->getPathFull($ref_id);
1261 $items = array();
1262 $counter = 0;
1263 foreach ($path as $item) {
1264 if (($counter > 0) && ($counter < count($path) - 1)) {
1265 array_push($items, $item["title"]);
1266 }
1267 $counter++;
1268 }
1269 $fullpath = join(" > ", $items);
1270 include_once "./Services/Utilities/classes/class.ilStr.php";
1271 if (strlen($fullpath) > 60) {
1272 $fullpath = ilStr::subStr($fullpath, 0, 30) . "..." . ilStr::subStr($fullpath, ilStr::strLen($fullpath) - 30, 30);
1273 }
1274 return $fullpath;
1275 }
static subStr($a_str, $a_start, $a_length=null)
Definition: class.ilStr.php:15
static strLen($a_string)
Definition: class.ilStr.php:78

References $DIC, ilObject\$ref_id, ilObject\$tree, ilStr\strLen(), and ilStr\subStr().

+ Here is the call graph for this function:

◆ _getImportDirectory()

static ilObjQuestionPool::_getImportDirectory ( )
static

get import directory of lm

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

779 {
780 if (strlen($_SESSION["qpl_import_dir"])) {
781 return $_SESSION["qpl_import_dir"];
782 }
783 return null;
784 }
$_SESSION["AccountId"]

References $_SESSION.

Referenced by assFormulaQuestionImport\fromXML(), getImportDirectory(), assQuestionImport\getQplImportArchivDirectory(), ilObjQuestionPoolGUI\importVerifiedFileObject(), and ilObjQuestionPoolGUI\uploadQplObject().

+ Here is the caller graph for this function:

◆ _getQuestionCount()

static ilObjQuestionPool::_getQuestionCount (   $questionpool_id,
  $complete_questions_only = false 
)
static

Returns the number of questions in a question pool.

Parameters
integer$questonpool_idObject id of the questionpool to examine
boolean$complete_questions_onlyIf set to TRUE, returns only the number of complete questions in the questionpool. Default is FALSE
Returns
integer The number of questions in the questionpool object @access public

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

897 {
898 global $DIC;
899 $ilDB = $DIC['ilDB'];
900 if ($complete_questions_only) {
901 $result = $ilDB->queryF(
902 "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",
903 array('integer', 'text'),
904 array($questionpool_id, 1)
905 );
906 } else {
907 $result = $ilDB->queryF(
908 "SELECT COUNT(question_id) question_count FROM qpl_questions WHERE obj_fi = %s AND qpl_questions.tstamp > 0 AND original_id IS NULL",
909 array('integer'),
910 array($questionpool_id)
911 );
912 }
913 $row = $ilDB->fetchAssoc($result);
914 return $row["question_count"];
915 }

References $DIC, $ilDB, and $result.

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 1421 of file class.ilObjQuestionPool.php.

1422 {
1423 global $DIC;
1424 $ilDB = $DIC['ilDB'];
1425 $lng = $DIC['lng'];
1426
1427 include_once "./Modules/Test/classes/class.ilObjAssessmentFolder.php";
1429 $lng->loadLanguageModule("assessment");
1430 $result = $ilDB->query("SELECT * FROM qpl_qst_type");
1431 $types = array();
1432 while ($row = $ilDB->fetchAssoc($result)) {
1433 if ($all_tags || (!in_array($row["question_type_id"], $forbidden_types))) {
1434 global $DIC;
1435 $ilLog = $DIC['ilLog'];
1436
1437 if ($row["plugin"] == 0) {
1438 $types[$lng->txt($row["type_tag"])] = $row;
1439 } else {
1440 global $DIC;
1441 $ilPluginAdmin = $DIC['ilPluginAdmin'];
1442 $pl_names = $ilPluginAdmin->getActivePluginsForSlot(IL_COMP_MODULE, "TestQuestionPool", "qst");
1443 foreach ($pl_names as $pl_name) {
1444 $pl = ilPlugin::getPluginObject(IL_COMP_MODULE, "TestQuestionPool", "qst", $pl_name);
1445 if (strcmp($pl->getQuestionType(), $row["type_tag"]) == 0) {
1446 $types[$pl->getQuestionTypeTranslation()] = $row;
1447 }
1448 }
1449 }
1450 }
1451 }
1452
1453 require_once 'Modules/TestQuestionPool/classes/class.ilAssQuestionTypeOrderer.php';
1455 $orderer = new ilAssQuestionTypeOrderer($types, $orderMode);
1456 $types = $orderer->getOrderedTypes($withDeprecatedTypes);
1457
1458 return $types;
1459 }
const IL_COMP_MODULE
const ORDER_MODE_FIX
order mode with fixed priority for ordering
const ORDER_MODE_ALPHA
order mode that orders by alphanumerical priority
static _getForbiddenQuestionTypes()
Returns the forbidden questiontypes for ILIAS.
static getPluginObject(string $a_ctype, string $a_cname, string $a_slot_id, string $a_pname)

References $DIC, $ilDB, ilObject\$lng, $result, ilObjAssessmentFolder\_getForbiddenQuestionTypes(), ilPlugin\getPluginObject(), IL_COMP_MODULE, ilAssQuestionTypeOrderer\ORDER_MODE_ALPHA, and ilAssQuestionTypeOrderer\ORDER_MODE_FIX.

Referenced by _getSelfAssessmentQuestionTypes(), ilTestRandomQuestionSetPoolDefinitionFormGUI\build(), getQuestionTypes(), ilTestRandomQuestionSetSourcePoolDefinition\getTypeFilterAsTypeTags(), ilTestQuestionBrowserTableGUI\initFilter(), ilQuestionBrowserTableGUI\initFilter(), ilTestTaxonomyFilterLabelTranslater\loadTypeLabels(), ilObjAssessmentFolderGUI\saveSettingsObject(), and ilTestRandomQuestionSetSourcePoolDefinition\setTypeFilterFromTypeTags().

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

◆ _getSelfAssessmentQuestionTypes()

static & ilObjQuestionPool::_getSelfAssessmentQuestionTypes (   $all_tags = false)
static

Get all self assessment question types.

Todo:
Make it more flexible

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

1510 {
1511 /* $allowed_types = array(
1512 "assSingleChoice" => 1,
1513 "assMultipleChoice" => 2,
1514 "assClozeTest" => 3,
1515 "assMatchingQuestion" => 4,
1516 "assOrderingQuestion" => 5,
1517 "assOrderingHorizontal" => 6,
1518 "assImagemapQuestion" => 7,
1519 "assTextQuestion" => 8,
1520 "assTextSubset" => 9,
1521 "assErrorText" => 10
1522 );*/
1523 $allowed_types = array(
1524 "assSingleChoice" => 1,
1525 "assMultipleChoice" => 2,
1526 "assKprimChoice" => 3,
1527 "assClozeTest" => 4,
1528 "assMatchingQuestion" => 5,
1529 "assOrderingQuestion" => 6,
1530 "assOrderingHorizontal" => 7,
1531 "assImagemapQuestion" => 8,
1532 "assTextSubset" => 9,
1533 "assErrorText" => 10,
1534 "assLongMenu" => 11
1535 );
1536 $satypes = array();
1537 $qtypes = ilObjQuestionPool::_getQuestionTypes($all_tags);
1538 foreach ($qtypes as $k => $t) {
1539 //if (in_array($t["type_tag"], $allowed_types))
1540 if (isset($allowed_types[$t["type_tag"]])) {
1541 $t["order"] = $allowed_types[$t["type_tag"]];
1542 $satypes[$k] = $t;
1543 }
1544 }
1545 return $satypes;
1546 }
static _getQuestionTypes($all_tags=false, $fixOrder=false, $withDeprecatedTypes=true)

References _getQuestionTypes().

Referenced by ilCopySelfAssQuestionTableGUI\getQuestions(), 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 1001 of file class.ilObjQuestionPool.php.

1002 {
1003 global $DIC;
1004 $ilDB = $DIC['ilDB'];
1005
1006 if ($is_reference) {
1007 $result = $ilDB->queryF(
1008 "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",
1009 array('integer'),
1010 array($a_obj_id)
1011 );
1012 } else {
1013 $result = $ilDB->queryF(
1014 "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",
1015 array('integer'),
1016 array($a_obj_id)
1017 );
1018 }
1019 if ($result->numRows() == 1) {
1020 $row = $ilDB->fetchAssoc($result);
1021 if ($row["equal_points"] == 1) {
1022 return 1;
1023 } else {
1024 return 0;
1025 }
1026 }
1027 return 0;
1028 }

References $DIC, $ilDB, and $result.

Referenced by _getAvailableQuestionpools().

+ Here is the caller graph for this function:

◆ _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 1143 of file class.ilObjQuestionPool.php.

1144 {
1145 global $DIC;
1146 $rbacsystem = $DIC['rbacsystem'];
1147
1148 include_once "./Services/Object/classes/class.ilObject.php";
1149 $refs = ilObject::_getAllReferences($object_id);
1150 if (count($refs)) {
1151 foreach ($refs as $ref_id) {
1152 if ($rbacsystem->checkAccess("write", $ref_id) && (ilObject::_hasUntrashedReference($object_id))) {
1153 return true;
1154 }
1155 }
1156 }
1157 return false;
1158 }
static _getAllReferences($a_id)
get all reference ids of object
static _hasUntrashedReference($a_obj_id)
checks wether an object has at least one reference that is not in trash

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:

◆ _lookupOnline()

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

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

971 {
972 global $DIC;
973 $ilDB = $DIC['ilDB'];
974
975 if ($is_reference) {
976 $result = $ilDB->queryF(
977 "SELECT qpl_questionpool.isonline FROM qpl_questionpool,object_reference WHERE object_reference.ref_id = %s AND object_reference.obj_id = qpl_questionpool.obj_fi",
978 array('integer'),
979 array($a_obj_id)
980 );
981 } else {
982 $result = $ilDB->queryF(
983 "SELECT isonline FROM qpl_questionpool WHERE obj_fi = %s",
984 array('integer'),
985 array($a_obj_id)
986 );
987 }
988 if ($result->numRows() == 1) {
989 $row = $ilDB->fetchAssoc($result);
990 return $row["isonline"];
991 }
992 return 0;
993 }

References $DIC, $ilDB, and $result.

Referenced by ilObjQuestionPoolListGUI\getProperties().

+ Here is the caller graph for this function:

◆ _setImportDirectory()

static ilObjQuestionPool::_setImportDirectory (   $a_import_dir = null)
static

set import directory

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

767 {
768 if (strlen($a_import_dir)) {
769 $_SESSION["qpl_import_dir"] = $a_import_dir;
770 } else {
771 unset($_SESSION["qpl_import_dir"]);
772 }
773 }

References $_SESSION.

Referenced by ilTestQuestionPoolImporter\importXmlRepresentation(), and ilObjQuestionPoolGUI\uploadQplObject().

+ Here is the caller graph for this function:

◆ _updateQuestionCount()

static ilObjQuestionPool::_updateQuestionCount (   $object_id)
static

Updates the number of available questions for a question pool in the database.

Parameters
integer$object_idObject id of the questionpool to examine @access public

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

1573 {
1574 global $DIC;
1575 $ilDB = $DIC['ilDB'];
1576 $result = $ilDB->manipulateF(
1577 "UPDATE qpl_questionpool SET questioncount = %s, tstamp = %s WHERE obj_fi = %s",
1578 array('integer','integer','integer'),
1579 array(ilObjQuestionPool::_getQuestionCount($object_id, true), time(), $object_id)
1580 );
1581 }
static _getQuestionCount($questionpool_id, $complete_questions_only=false)
Returns the number of questions in a question pool.

References $DIC, $ilDB, $result, 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:

◆ addQuestionChangeListeners()

ilObjQuestionPool::addQuestionChangeListeners ( assQuestion  $question)
Parameters
assQuestion$question

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

205 {
206 global $DIC;
207 $ilDB = $DIC['ilDB'];
208
209 foreach (ilObjTest::getPoolQuestionChangeListeners($ilDB, $this->getId()) as $listener) {
210 $question->addQuestionChangeListener($listener);
211 }
212 }
addQuestionChangeListener(ilQuestionChangeListener $listener)
static getPoolQuestionChangeListeners(ilDBInterface $db, $poolObjId)
getId()
get object id @access public

References $DIC, $ilDB, assQuestion\addQuestionChangeListener(), ilObject\getId(), and ilObjTest\getPoolQuestionChangeListeners().

Referenced by deleteQuestion().

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

◆ checkQuestionParent()

ilObjQuestionPool::checkQuestionParent (   $questionId)

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

839 {
840 global $DIC; /* @var ILIAS\DI\Container $DIC */
841
842 $row = $DIC->database()->fetchAssoc($DIC->database()->queryF(
843 "SELECT COUNT(question_id) cnt FROM qpl_questions WHERE question_id = %s AND obj_fi = %s",
844 array('integer', 'integer'),
845 array($questionId, $this->getId())
846 ));
847
848 return (bool) $row['cnt'];
849 }

References $DIC, and ilObject\getId().

+ Here is the call graph for this function:

◆ cleanupClipboard()

ilObjQuestionPool::cleanupClipboard (   $deletedQuestionId)

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

1120 {
1121 if (!isset($_SESSION['qpl_clipboard'])) {
1122 return;
1123 }
1124
1125 if (!isset($_SESSION['qpl_clipboard'][$deletedQuestionId])) {
1126 return;
1127 }
1128
1129 unset($_SESSION['qpl_clipboard'][$deletedQuestionId]);
1130
1131 if (!count($_SESSION['qpl_clipboard'])) {
1132 unset($_SESSION['qpl_clipboard']);
1133 }
1134 }

References $_SESSION.

◆ cloneObject()

ilObjQuestionPool::cloneObject (   $a_target_id,
  $a_copy_id = 0,
  $a_omit_tree = false 
)

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

@access public

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

1371 {
1372 $newObj = parent::cloneObject($a_target_id, $a_copy_id, $a_omit_tree);
1373
1374 $cp_options = ilCopyWizardOptions::_getInstance($a_copy_id);
1375 $newObj->setOnline($this->getOnline());
1376 if ($cp_options->isRootNode($this->getRefId())) {
1377 $newObj->setOnline(0);
1378 }
1379
1380 $newObj->setSkillServiceEnabled($this->isSkillServiceEnabled());
1381 $newObj->setShowTaxonomies($this->getShowTaxonomies());
1382 $newObj->saveToDb();
1383
1384 // clone the questions in the question pool
1385 $questions = &$this->getQplQuestions();
1386 $questionIdsMap = array();
1387 foreach ($questions as $question_id) {
1388 $newQuestionId = $newObj->copyQuestion($question_id, $newObj->getId());
1389 $questionIdsMap[$question_id] = $newQuestionId;
1390 }
1391
1392 // clone meta data
1393 include_once "./Services/MetaData/classes/class.ilMD.php";
1394 $md = new ilMD($this->getId(), 0, $this->getType());
1395 $md->cloneMD($newObj->getId(), 0, $newObj->getType());
1396
1397 // update the metadata with the new title of the question pool
1398 $newObj->updateMetaData();
1399
1400 require_once 'Modules/TestQuestionPool/classes/class.ilQuestionPoolTaxonomiesDuplicator.php';
1401 $duplicator = new ilQuestionPoolTaxonomiesDuplicator();
1402 $duplicator->setSourceObjId($this->getId());
1403 $duplicator->setSourceObjType($this->getType());
1404 $duplicator->setTargetObjId($newObj->getId());
1405 $duplicator->setTargetObjType($newObj->getType());
1406 $duplicator->setQuestionIdMapping($questionIdsMap);
1407 $duplicator->duplicate($duplicator->getAllTaxonomiesForSourceObject());
1408
1409 $duplicatedTaxKeyMap = $duplicator->getDuplicatedTaxonomiesKeysMap();
1410 $newObj->setNavTaxonomyId($duplicatedTaxKeyMap->getMappedTaxonomyId($this->getNavTaxonomyId()));
1411 $newObj->saveToDb();
1412
1413 return $newObj;
1414 }
static _getInstance($a_copy_id)
Get instance of copy wizard options.
getType()
get object type @access public

References ilCopyWizardOptions\_getInstance(), ilObject\getId(), getOnline(), getQplQuestions(), getShowTaxonomies(), ilObject\getType(), and isSkillServiceEnabled().

+ Here is the call graph for this function:

◆ copyQuestion()

ilObjQuestionPool::copyQuestion (   $question_id,
  $questionpool_to 
)

Copies a question into another question pool.

Parameters
integer$question_idDatabase id of the question
integer$questionpool_toDatabase id of the target questionpool @access public

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

412 {
413 $question_gui = &$this->createQuestion("", $question_id);
414 if ($question_gui->object->getObjId() == $questionpool_to) {
415 // the question is copied into the same question pool
416 return $this->duplicateQuestion($question_id);
417 } else {
418 // the question is copied into another question pool
419 $newtitle = $question_gui->object->getTitle();
420 if ($question_gui->object->questionTitleExists($this->getId(), $question_gui->object->getTitle())) {
421 $counter = 2;
422 while ($question_gui->object->questionTitleExists($this->getId(), $question_gui->object->getTitle() . " ($counter)")) {
423 $counter++;
424 }
425 $newtitle = $question_gui->object->getTitle() . " ($counter)";
426 }
427 return $question_gui->object->copyObject($this->getId(), $newtitle);
428 }
429 }
duplicateQuestion($question_id)
Duplicates a question for a questionpool.
& createQuestion($question_type, $question_id=-1)

References 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 1097 of file class.ilObjQuestionPool.php.

1098 {
1099 if (!array_key_exists("qpl_clipboard", $_SESSION)) {
1100 $_SESSION["qpl_clipboard"] = array();
1101 }
1102 $_SESSION["qpl_clipboard"][$question_id] = array("question_id" => $question_id, "action" => "copy");
1103 }

References $_SESSION.

◆ create()

ilObjQuestionPool::create (   $a_upload = false)

create questionpool object

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

69 {
70 parent::create();
71
72 // meta data will be created by
73 // import parser
74 if (!$a_upload) {
75 $this->createMetaData();
76 }
77 }
createMetaData()
create meta data entry

References ilObject\createMetaData().

+ Here is the call graph for this function:

◆ createExportDirectory()

ilObjQuestionPool::createExportDirectory ( )

creates data directory for export files (data_dir/qpl_data/qpl_<id>/export, depending on data directory that is set in ILIAS setup/ini)

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

687 {
688 include_once "./Services/Utilities/classes/class.ilUtil.php";
689 $qpl_data_dir = ilUtil::getDataDir() . "/qpl_data";
690 ilUtil::makeDir($qpl_data_dir);
691 if (!is_writable($qpl_data_dir)) {
692 $this->ilias->raiseError("Questionpool Data Directory (" . $qpl_data_dir
693 . ") not writeable.", $this->ilias->error_obj->FATAL);
694 }
695
696 // create learning module directory (data_dir/lm_data/lm_<id>)
697 $qpl_dir = $qpl_data_dir . "/qpl_" . $this->getId();
698 ilUtil::makeDir($qpl_dir);
699 if (!@is_dir($qpl_dir)) {
700 $this->ilias->raiseError("Creation of Questionpool Directory failed.", $this->ilias->error_obj->FATAL);
701 }
702 // create Export subdirectory (data_dir/lm_data/lm_<id>/Export)
703 ilUtil::makeDir($this->getExportDirectory('xls'));
704 if (!@is_dir($this->getExportDirectory('xls'))) {
705 $this->ilias->raiseError("Creation of Export Directory failed.", $this->ilias->error_obj->FATAL);
706 }
707 ilUtil::makeDir($this->getExportDirectory('zip'));
708 if (!@is_dir($this->getExportDirectory('zip'))) {
709 $this->ilias->raiseError("Creation of Export Directory failed.", $this->ilias->error_obj->FATAL);
710 }
711 }
getExportDirectory($type="")
get export directory of questionpool
redirection script todo: (a better solution should control the processing via a xml file)

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

+ Here is the call graph for this function:

◆ createQuestion()

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

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

370 {
371 include_once "./Modules/TestQuestionPool/classes/class.assQuestion.php";
372 if ($question_id > 0) {
373 return assQuestion::_instanciateQuestionGUI($question_id);
374 }
375 assQuestion::_includeClass($question_type, 1);
376 $question_type_gui = $question_type . "GUI";
377 $question_gui = new $question_type_gui();
378 return $question_gui;
379 }
static & _instanciateQuestionGUI($question_id)
Creates an instance of a question gui with a given question id.
static _includeClass($question_type, $gui=0)
Include the php class file for a given question type.

References assQuestion\_includeClass(), and assQuestion\_instanciateQuestionGUI().

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

+ Here is the call graph for this function:
+ 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 85 of file class.ilObjQuestionPool.php.

86 {
87 $result = parent::createReference();
88 $this->saveToDb();
89 return $result;
90 }
saveToDb()
Saves a ilObjQuestionpool object to a database.

References $result, and 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 145 of file class.ilObjQuestionPool.php.

146 {
147 // always call parent delete function first!!
148 if (!parent::delete()) {
149 return false;
150 }
151
152 // delete meta data
153 $this->deleteMetaData();
154
155 //put here your module specific stuff
156 $this->deleteQuestionpool();
157
158 require_once 'Modules/TestQuestionPool/classes/questions/class.ilAssQuestionSkillAssignmentImportFails.php';
159 $qsaImportFails = new ilAssQuestionSkillAssignmentImportFails($this->getId());
160 $qsaImportFails->deleteRegisteredImportFails();
161
162 return true;
163 }
deleteMetaData()
delete meta data entry

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

+ Here is the call graph for this function:

◆ deleteQuestion()

ilObjQuestionPool::deleteQuestion (   $question_id)

Deletes a question from the question pool.

Parameters
integer$question_idThe database id of the question @access private

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

192 {
193 include_once "./Modules/Test/classes/class.ilObjTest.php";
194 include_once "./Modules/TestQuestionPool/classes/class.assQuestion.php";
195
196 $question = assQuestion::_instanciateQuestion($question_id);
197 $this->addQuestionChangeListeners($question);
198 $question->delete($question_id);
199 }
static _instanciateQuestion($question_id)
Creates an instance of a question with a given question id.
addQuestionChangeListeners(assQuestion $question)

References assQuestion\_instanciateQuestion(), and addQuestionChangeListeners().

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 165 of file class.ilObjQuestionPool.php.

166 {
167 $questions = &$this->getAllQuestions();
168
169 if (count($questions)) {
170 foreach ($questions as $question_id) {
171 $this->deleteQuestion($question_id);
172 }
173 }
174
175 // delete export files
176 include_once "./Services/Utilities/classes/class.ilUtil.php";
177 $qpl_data_dir = ilUtil::getDataDir() . "/qpl_data";
178 $directory = $qpl_data_dir . "/qpl_" . $this->getId();
179 if (is_dir($directory)) {
180 include_once "./Services/Utilities/classes/class.ilUtil.php";
181 ilUtil::delDir($directory);
182 }
183 }
deleteQuestion($question_id)
Deletes a question from the question pool.
& getAllQuestions()
Retrieve an array containing all question ids of the questionpool.
static delDir($a_dir, $a_clean_only=false)
removes a dir and all its content (subdirs and files) recursively

References ilUtil\delDir(), deleteQuestion(), getAllQuestions(), ilUtil\getDataDir(), and ilObject\getId().

Referenced by delete().

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

◆ duplicateQuestion()

ilObjQuestionPool::duplicateQuestion (   $question_id)

Duplicates a question for a questionpool.

Parameters
integer$question_idThe database id of the question @access public

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

388 {
389 $question = &$this->createQuestion("", $question_id);
390 $newtitle = $question->object->getTitle();
391 if ($question->object->questionTitleExists($this->getId(), $question->object->getTitle())) {
392 $counter = 2;
393 while ($question->object->questionTitleExists($this->getId(), $question->object->getTitle() . " ($counter)")) {
394 $counter++;
395 }
396 $newtitle = $question->object->getTitle() . " ($counter)";
397 }
398 $new_id = $question->object->duplicate(false, $newtitle);
399 // update question count of question pool
401 return $new_id;
402 }
static _updateQuestionCount($object_id)
Updates the number of available questions for a question pool in the database.

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

Referenced by copyQuestion().

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

◆ exportFileItems()

ilObjQuestionPool::exportFileItems (   $target_dir,
$expLog 
)

export files of file itmes

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

661 : void
662 {
663 include_once("./Modules/File/classes/class.ilObjFile.php");
664
665 foreach ($this->file_ids as $file_id) {
666 $expLog->write(date("[y-m-d H:i:s] ") . "File Item " . $file_id);
667 $file_dir = $target_dir . '/objects/il_' . IL_INST_ID . '_file_' . $file_id;
668 ilUtil::makeDir($file_dir);
669 $file_obj = new ilObjFile($file_id, false);
670 $source_file = $file_obj->getFile($file_obj->getVersion());
671 if (!is_file($source_file)) {
672 $source_file = $file_obj->getFile();
673 }
674 if (is_file($source_file)) {
675 copy($source_file, $file_dir . '/' . $file_obj->getFileName());
676 }
677 unset($file_obj);
678 }
679 }
Class ilObjFile.
const IL_INST_ID
Definition: constants.php:38

References IL_INST_ID, and ilUtil\makeDir().

Referenced by objectToXmlWriter().

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

◆ exportXMLMediaObjects()

ilObjQuestionPool::exportXMLMediaObjects ( $a_xml_writer,
  $a_inst,
  $a_target_dir,
$expLog 
)

export media objects to xml (see ilias_co.dtd)

Parameters
object$a_xml_writerilXmlWriter object that receives the xml data

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

643 {
644 include_once("./Services/MediaObjects/classes/class.ilObjMediaObject.php");
645
646 foreach ($this->mob_ids as $mob_id) {
647 $expLog->write(date("[y-m-d H:i:s] ") . "Media Object " . $mob_id);
648 if (ilObjMediaObject::_exists($mob_id)) {
649 $media_obj = new ilObjMediaObject($mob_id);
650 $media_obj->exportXML($a_xml_writer, $a_inst);
651 $media_obj->exportFiles($a_target_dir);
652 unset($media_obj);
653 }
654 }
655 }
Class ilObjMediaObject.
static _exists($a_id, $a_reference=false, $a_type=null)
checks wether a lm content object with specified id exists or not

References ilObjMediaObject\_exists().

Referenced by objectToXmlWriter().

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

◆ exportXMLMetaData()

ilObjQuestionPool::exportXMLMetaData ( $a_xml_writer)

export content objects meta data to xml (see ilias_co.dtd)

Parameters
object$a_xml_writerilXmlWriter object that receives the xml data

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

558 {
559 include_once("Services/MetaData/classes/class.ilMD2XML.php");
560 $md2xml = new ilMD2XML($this->getId(), 0, $this->getType());
561 $md2xml->setExportMode(true);
562 $md2xml->startExport();
563 $a_xml_writer->appendXML($md2xml->getXML());
564 }

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

Referenced by objectToXmlWriter().

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

◆ exportXMLPageObjects()

ilObjQuestionPool::exportXMLPageObjects ( $a_xml_writer,
  $a_inst,
$expLog,
  $questions 
)

export page objects to xml (see ilias_co.dtd)

Parameters
object$a_xml_writerilXmlWriter object that receives the xml data

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

584 {
585 global $DIC;
586 $ilBench = $DIC['ilBench'];
587
588 include_once "./Modules/LearningModule/classes/class.ilLMPageObject.php";
589
590 foreach ($questions as $question_id) {
591 $ilBench->start("ContentObjectExport", "exportPageObject");
592 $expLog->write(date("[y-m-d H:i:s] ") . "Page Object " . $question_id);
593
594 $attrs = array();
595 $a_xml_writer->xmlStartTag("PageObject", $attrs);
596
597
598 // export xml to writer object
599 $ilBench->start("ContentObjectExport", "exportPageObject_XML");
600 include_once("./Modules/TestQuestionPool/classes/class.ilAssQuestionPage.php");
601 $page_object = new ilAssQuestionPage($question_id);
602 $page_object->buildDom();
603 $page_object->insertInstIntoIDs($a_inst);
604 $mob_ids = $page_object->collectMediaObjects(false);
605 require_once 'Services/COPage/classes/class.ilPCFileList.php';
606 $file_ids = ilPCFileList::collectFileItems($page_object, $page_object->getDomDoc());
607 $xml = $page_object->getXMLFromDom(false, false, false, "", true);
608 $xml = str_replace("&", "&amp;", $xml);
609 $a_xml_writer->appendXML($xml);
610 $page_object->freeDom();
611 unset($page_object);
612
613 $ilBench->stop("ContentObjectExport", "exportPageObject_XML");
614
615 // collect media objects
616 $ilBench->start("ContentObjectExport", "exportPageObject_CollectMedia");
617 foreach ($mob_ids as $mob_id) {
618 $this->mob_ids[$mob_id] = $mob_id;
619 }
620 $ilBench->stop("ContentObjectExport", "exportPageObject_CollectMedia");
621
622 // collect all file items
623 $ilBench->start("ContentObjectExport", "exportPageObject_CollectFileItems");
624 //$file_ids = $page_obj->getFileItemIds();
625 foreach ($file_ids as $file_id) {
626 $this->file_ids[$file_id] = $file_id;
627 }
628 $ilBench->stop("ContentObjectExport", "exportPageObject_CollectFileItems");
629
630 $a_xml_writer->xmlEndTag("PageObject");
631
632 $ilBench->stop("ContentObjectExport", "exportPageObject");
633 }
634 }
Question page object.
static collectFileItems($a_page, $a_domdoc)
Get all file items that are used within the page.
global $ilBench
Definition: ilias.php:21
$xml
Definition: metadata.php:332

References $DIC, $ilBench, $xml, and ilPCFileList\collectFileItems().

Referenced by objectToXmlWriter().

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

◆ exportXMLSettings()

ilObjQuestionPool::exportXMLSettings (   $xmlWriter)
private
Parameters
ilXmlWriter$xmlWriter

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

467 {
468 $xmlWriter->xmlStartTag('Settings');
469
470 $xmlWriter->xmlElement('ShowTaxonomies', null, (int) $this->getShowTaxonomies());
471 $xmlWriter->xmlElement('NavTaxonomy', null, (int) $this->getNavTaxonomyId());
472 $xmlWriter->xmlElement('SkillService', null, (int) $this->isSkillServiceEnabled());
473
474 $xmlWriter->xmlEndTag('Settings');
475 }

References getNavTaxonomyId(), getShowTaxonomies(), and isSkillServiceEnabled().

Referenced by objectToXmlWriter().

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

◆ fromXML()

ilObjQuestionPool::fromXML (   $xmlFile)

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

1668 {
1669 require_once 'Modules/TestQuestionPool/classes/class.ilObjQuestionPoolXMLParser.php';
1670 $parser = new ilObjQuestionPoolXMLParser($this, $xmlFile);
1671 $parser->startParsing();
1672 }

◆ getAllQuestionIds()

& ilObjQuestionPool::getAllQuestionIds ( )

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

814 {
815 global $DIC;
816 $ilDB = $DIC['ilDB'];
817
818 $query_result = $ilDB->queryF(
819 "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",
820 array('integer','text'),
821 array($this->getId(), 1)
822 );
823 $questions = array();
824 if ($query_result->numRows()) {
825 while ($row = $ilDB->fetchAssoc($query_result)) {
826 if ($row["plugin"]) {
827 if ($this->isPluginActive($row["type_tag"])) {
828 array_push($questions, $row["question_id"]);
829 }
830 } else {
831 array_push($questions, $row["question_id"]);
832 }
833 }
834 }
835 return $questions;
836 }
isPluginActive($questionType)
Checks wheather or not a question plugin with a given name is active.

References $DIC, $ilDB, 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 796 of file class.ilObjQuestionPool.php.

797 {
798 global $DIC;
799 $ilDB = $DIC['ilDB'];
800
801 $result = $ilDB->queryF(
802 "SELECT question_id FROM qpl_questions WHERE obj_fi = %s AND qpl_questions.tstamp > 0 AND original_id IS NULL",
803 array('integer'),
804 array($this->getId())
805 );
806 $questions = array();
807 while ($row = $ilDB->fetchAssoc($result)) {
808 array_push($questions, $row["question_id"]);
809 }
810 return $questions;
811 }

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

Referenced by deleteQuestionpool().

+ Here is the call graph for this function:
+ Here is the caller 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 1190 of file class.ilObjQuestionPool.php.

1191 {
1192 global $DIC;
1193 $ilDB = $DIC['ilDB'];
1194 $ilLog = $DIC['ilLog'];
1195
1196 $result = array();
1197 $query_result = $ilDB->query("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 " . $ilDB->in('qpl_questions.question_id', $question_ids, false, 'integer') . " ORDER BY qpl_questions.title");
1198 if ($query_result->numRows()) {
1199 include_once "./Modules/TestQuestionPool/classes/class.assQuestion.php";
1200 while ($row = $ilDB->fetchAssoc($query_result)) {
1201 if (!assQuestion::_isUsedInRandomTest($row["question_id"])) {
1202 array_push($result, $row);
1203 } else {
1204 // the question was used in a random test prior to ILIAS 3.7 so it was inserted
1205 // as a reference to the original question pool object and not as a copy. To allow
1206 // the deletion of the question pool object, a copy must be created and all database references
1207 // of the original question must changed with the reference of the copy
1208
1209 // 1. Create a copy of the original question
1210 $question = &$this->createQuestion("", $row["question_id"]);
1211 $duplicate_id = $question->object->duplicate(true);
1212 if ($duplicate_id > 0) {
1213 // 2. replace the question id in the solutions
1214 $affectedRows = $ilDB->manipulateF(
1215 "UPDATE tst_solutions SET question_fi = %s WHERE question_fi = %s",
1216 array('integer','integer'),
1217 array($duplicate_id, $row["question_id"])
1218 );
1219
1220 // 3. replace the question id in the question list of random tests
1221 $affectedRows = $ilDB->manipulateF(
1222 "UPDATE tst_test_rnd_qst SET question_fi = %s WHERE question_fi = %s",
1223 array('integer','integer'),
1224 array($duplicate_id, $row["question_id"])
1225 );
1226
1227 // 4. replace the question id in the test results
1228 $affectedRows = $ilDB->manipulateF(
1229 "UPDATE tst_test_result SET question_fi = %s WHERE question_fi = %s",
1230 array('integer','integer'),
1231 array($duplicate_id, $row["question_id"])
1232 );
1233
1234 // 5. replace the question id in the test&assessment log
1235 $affectedRows = $ilDB->manipulateF(
1236 "UPDATE ass_log SET question_fi = %s WHERE question_fi = %s",
1237 array('integer','integer'),
1238 array($duplicate_id, $row["question_id"])
1239 );
1240
1241 // 6. The original question can be deleted, so add it to the list of questions
1242 array_push($result, $row);
1243 }
1244 }
1245 }
1246 }
1247 return $result;
1248 }
static _isUsedInRandomTest($question_id="")
Checks whether the question is used in a random test or not.

References $DIC, $ilDB, $result, assQuestion\_isUsedInRandomTest(), and createQuestion().

+ Here is the call graph for this function:

◆ getDescription()

ilObjQuestionPool::getDescription ( )

get description of content object

Returns
string description

Reimplemented from ilObject.

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

318 {
319 return parent::getDescription();
320 }

◆ getExportDirectory()

ilObjQuestionPool::getExportDirectory (   $type = "")

get export directory of questionpool

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

717 {
718 include_once "./Services/Utilities/classes/class.ilUtil.php";
719 switch ($type) {
720 case 'xml':
721 include_once("./Services/Export/classes/class.ilExport.php");
722 $export_dir = ilExport::_getExportDirectory($this->getId(), $type, $this->getType());
723 break;
724 case 'xls':
725 case 'zip':
726 $export_dir = ilUtil::getDataDir() . "/qpl_data" . "/qpl_" . $this->getId() . "/export_$type";
727 break;
728 default:
729 $export_dir = ilUtil::getDataDir() . "/qpl_data" . "/qpl_" . $this->getId() . "/export";
730 break;
731 }
732 return $export_dir;
733 }
static _getExportDirectory($a_obj_id, $a_type="xml", $a_obj_type="", $a_entity="")
Get export directory for an repository object.

References ilObject\$type, ilExport\_getExportDirectory(), ilUtil\getDataDir(), ilObject\getId(), and ilObject\getType().

Referenced by createExportDirectory().

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

◆ getImportDirectory()

ilObjQuestionPool::getImportDirectory ( )

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

787 {
789 }
static _getImportDirectory()
get import directory of lm

References _getImportDirectory().

+ Here is the call graph for this function:

◆ getImportMapping()

ilObjQuestionPool::getImportMapping ( )

get array of (two) new created questions for import id

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

856 {
857 if (!is_array($this->import_mapping)) {
858 return array();
859 } else {
860 return $this->import_mapping;
861 }
862 }

◆ getNavTaxonomyId()

ilObjQuestionPool::getNavTaxonomyId ( )

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

References $navTaxonomyId.

Referenced by exportXMLSettings(), isNavTaxonomyActive(), and saveToDb().

+ Here is the caller graph for this function:

◆ getOnline()

ilObjQuestionPool::getOnline ( )

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

938 {
939 if (strcmp($this->online, "") == 0) {
940 $this->online = "0";
941 }
942 return $this->online;
943 }

References $online.

Referenced by cloneObject(), and saveToDb().

+ Here is the caller graph for this function:

◆ getPrintviewQuestions()

ilObjQuestionPool::getPrintviewQuestions ( )

Calculates the data for the print view of the questionpool.

@access public

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

437 {
438 global $DIC;
439 $ilDB = $DIC['ilDB'];
440
441 $query_result = $ilDB->queryF(
442 "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",
443 array('integer'),
444 array($this->getId())
445 );
446 $rows = array();
447 $types = $this->getQuestionTypeTranslations();
448 if ($query_result->numRows()) {
449 while ($row = $ilDB->fetchAssoc($query_result)) {
450 $row['ttype'] = $types[$row['type_tag']];
451 if ($row["plugin"]) {
452 if ($this->isPluginActive($row["type_tag"])) {
453 array_push($rows, $row);
454 }
455 } else {
456 array_push($rows, $row);
457 }
458 }
459 }
460 return $rows;
461 }
$rows
Definition: xhr_table.php:10

References $DIC, $ilDB, $rows, ilObject\getId(), getQuestionTypeTranslations(), and isPluginActive().

+ Here is the call graph for this function:

◆ getQplQuestions()

& ilObjQuestionPool::getQplQuestions ( )

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

1349 {
1350 global $DIC;
1351 $ilDB = $DIC['ilDB'];
1352
1353 $questions = array();
1354 $result = $ilDB->queryF(
1355 "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",
1356 array('integer'),
1357 array($this->getId())
1358 );
1359 while ($row = $ilDB->fetchAssoc($result)) {
1360 array_push($questions, $row["question_id"]);
1361 }
1362 return $questions;
1363 }

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

Referenced by cloneObject().

+ 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 1167 of file class.ilObjQuestionPool.php.

1168 {
1169 global $DIC;
1170 $ilDB = $DIC['ilDB'];
1171
1172 $result = array();
1173 $query_result = $ilDB->query("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 " . $ilDB->in('qpl_questions.question_id', $question_ids, false, 'integer') . " ORDER BY qpl_questions.title");
1174 if ($query_result->numRows()) {
1175 while ($row = $ilDB->fetchAssoc($query_result)) {
1176 array_push($result, $row);
1177 }
1178 }
1179 return $result;
1180 }

References $DIC, $ilDB, and $result.

◆ getQuestionList()

& ilObjQuestionPool::getQuestionList ( )

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

1550 {
1551 global $DIC;
1552 $ilDB = $DIC['ilDB'];
1553
1554 $questions = array();
1555 $result = $ilDB->queryF(
1556 "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",
1557 array('integer'),
1558 array($this->getId())
1559 );
1560 while ($row = $ilDB->fetchAssoc($result)) {
1561 array_push($questions, $row);
1562 }
1563 return $questions;
1564 }

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

+ Here is the call graph for this function:

◆ getQuestiontype()

ilObjQuestionPool::getQuestiontype (   $question_id)

Returns the question type of a question with a given id.

Parameters
integer$question_idThe database id of the question
Returns
string The question type string @access private

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

291 {
292 global $DIC;
293 $ilDB = $DIC['ilDB'];
294
295 if ($question_id < 1) {
296 return;
297 }
298
299 $result = $ilDB->queryF(
300 "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",
301 array('integer'),
302 array($question_id)
303 );
304 if ($result->numRows() == 1) {
305 $data = $ilDB->fetchAssoc($result);
306 return $data["type_tag"];
307 } else {
308 return;
309 }
310 }
$data
Definition: storeScorm.php:23

References $data, $DIC, $ilDB, and $result.

◆ getQuestionTypeByTypeId()

static ilObjQuestionPool::getQuestionTypeByTypeId (   $type_id)
static

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

1462 {
1463 global $DIC;
1464 $ilDB = $DIC['ilDB'];
1465
1466 $query = "SELECT type_tag FROM qpl_qst_type WHERE question_type_id = %s";
1467 $types = array('integer');
1468 $values = array($type_id);
1469 $result = $ilDB->queryF($query, $types, $values);
1470
1471 if ($row = $ilDB->fetchAssoc($result)) {
1472 return $row['type_tag'];
1473 }
1474 }
$query

References $DIC, $ilDB, $query, and $result.

Referenced by ilTestExpressPageObjectGUI\addPageOfQuestions(), ilTestCorrectionsGUI\allowedInAdjustment(), ilTestExpressPageObjectGUI\executeCommand(), ilObjTestGUI\executeCreateQuestionObject(), and ilTestExpressPageObjectGUI\handleToolbarCommand().

+ Here is the caller graph for this function:

◆ getQuestionTypes()

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

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

1417 {
1418 return self::_getQuestionTypes($all_tags, $fixOrder, $withDeprecatedTypes);
1419 }

References _getQuestionTypes().

+ Here is the call graph for this function:

◆ getQuestionTypeTranslations()

static ilObjQuestionPool::getQuestionTypeTranslations ( )
static

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

1477 {
1478 global $DIC;
1479 $ilDB = $DIC['ilDB'];
1480 $lng = $DIC['lng'];
1481 $ilLog = $DIC['ilLog'];
1482 $ilPluginAdmin = $DIC['ilPluginAdmin'];
1483
1484 $lng->loadLanguageModule("assessment");
1485 $result = $ilDB->query("SELECT * FROM qpl_qst_type");
1486 $types = array();
1487 while ($row = $ilDB->fetchAssoc($result)) {
1488 if ($row["plugin"] == 0) {
1489 $types[$row['type_tag']] = $lng->txt($row["type_tag"]);
1490 } else {
1491 $pl_names = $ilPluginAdmin->getActivePluginsForSlot(IL_COMP_MODULE, "TestQuestionPool", "qst");
1492 foreach ($pl_names as $pl_name) {
1493 $pl = ilPlugin::getPluginObject(IL_COMP_MODULE, "TestQuestionPool", "qst", $pl_name);
1494 if (strcmp($pl->getQuestionType(), $row["type_tag"]) == 0) {
1495 $types[$row['type_tag']] = $pl->getQuestionTypeTranslation();
1496 }
1497 }
1498 }
1499 }
1500 ksort($types);
1501 return $types;
1502 }

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

Referenced by getPrintviewQuestions().

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

◆ getShowTaxonomies()

ilObjQuestionPool::getShowTaxonomies ( )

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

References $showTaxonomies.

Referenced by cloneObject(), exportXMLSettings(), isNavTaxonomyActive(), and saveToDb().

+ 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 1632 of file class.ilObjQuestionPool.php.

1633 {
1634 require_once 'Services/Taxonomy/classes/class.ilObjTaxonomy.php';
1635 return ilObjTaxonomy::getUsageOfObject($this->getId());
1636 }
static getUsageOfObject($a_obj_id, $a_include_titles=false)
Get usage of object.

References ilObject\getId(), and ilObjTaxonomy\getUsageOfObject().

+ Here is the call graph for this function:

◆ getTitle()

ilObjQuestionPool::getTitle ( )

get title of glossary object

Returns
string title

Reimplemented from ilObject.

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

336 {
337 return parent::getTitle();
338 }

Referenced by updateMetaData().

+ Here is the caller graph for this function:

◆ isInUse()

ilObjQuestionPool::isInUse (   $question_id)

Checks whether the question is in use or not.

Parameters
integer$question_idThe question id of the question to be checked
Returns
boolean The number of datasets which are affected by the use of the query. @access public

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

356 {
357 global $DIC;
358 $ilDB = $DIC['ilDB'];
359
360 $result = $ilDB->queryF(
361 "SELECT COUNT(solution_id) solution_count FROM tst_solutions WHERE question_fi = %s",
362 array('integer'),
363 array($question_id)
364 );
365 $row = $ilDB->fetchAssoc($result);
366 return $row["solution_count"];
367 }

References $DIC, $ilDB, and $result.

◆ isNavTaxonomyActive()

ilObjQuestionPool::isNavTaxonomyActive ( )

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

966 {
967 return $this->getShowTaxonomies() && (int) $this->getNavTaxonomyId();
968 }

References getNavTaxonomyId(), and getShowTaxonomies().

+ Here is the call graph for this function:

◆ 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 1589 of file class.ilObjQuestionPool.php.

1590 {
1591 /* @var ilPluginAdmin $ilPluginAdmin */
1592 global $DIC;
1593 $ilPluginAdmin = $DIC['ilPluginAdmin'];
1594
1595 $plugins = $ilPluginAdmin->getActivePluginsForSlot(IL_COMP_MODULE, "TestQuestionPool", "qst");
1596 foreach ($plugins as $pluginName) {
1597 if ($pluginName == $questionType) { // plugins having pname == qtype
1598 return true;
1599 }
1600
1601 /* @var ilQuestionsPlugin $plugin */
1602 $plugin = ilPlugin::getPluginObject(IL_COMP_MODULE, "TestQuestionPool", "qst", $pluginName);
1603
1604 if ($plugin->getQuestionType() == $questionType) { // plugins havin an independent name
1605 return true;
1606 }
1607 }
1608
1609 return false;
1610 }

References $DIC, XapiProxy\$plugin, ilPlugin\getPluginObject(), and IL_COMP_MODULE.

Referenced by getAllQuestionIds(), and getPrintviewQuestions().

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

◆ isSkillManagementGloballyActivated()

static ilObjQuestionPool::isSkillManagementGloballyActivated ( )
static

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

1657 {
1658 if (self::$isSkillManagementGloballyActivated === null) {
1659 $skmgSet = new ilSkillManagementSettings();
1660
1661 self::$isSkillManagementGloballyActivated = $skmgSet->isActivated();
1662 }
1663
1665 }

References $isSkillManagementGloballyActivated.

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

+ Here is the caller graph for this function:

◆ isSkillServiceEnabled()

ilObjQuestionPool::isSkillServiceEnabled ( )
Returns
boolean

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

References $skillServiceEnabled.

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

+ Here is the caller graph for this function:

◆ loadFromDb()

ilObjQuestionPool::loadFromDb ( )

Loads a ilObjQuestionpool object from a database.

@access public

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

220 {
221 global $DIC;
222 $ilDB = $DIC['ilDB'];
223
224 $result = $ilDB->queryF(
225 "SELECT * FROM qpl_questionpool WHERE obj_fi = %s",
226 array('integer'),
227 array($this->getId())
228 );
229 if ($result->numRows() == 1) {
230 $row = $ilDB->fetchAssoc($result);
231 $this->setOnline($row['isonline']);
232 $this->setShowTaxonomies($row['show_taxonomies']);
233 $this->setNavTaxonomyId($row['nav_taxonomy']);
234 $this->setSkillServiceEnabled($row['skill_service']);
235 }
236 }
setShowTaxonomies($showTaxonomies)
setNavTaxonomyId($navTaxonomyId)
setSkillServiceEnabled($skillServiceEnabled)

References $DIC, $ilDB, $result, ilObject\getId(), setNavTaxonomyId(), setOnline(), setShowTaxonomies(), and setSkillServiceEnabled().

Referenced by read().

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

◆ modifyExportIdentifier()

ilObjQuestionPool::modifyExportIdentifier (   $a_tag,
  $a_param,
  $a_value 
)

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

567 {
568 if ($a_tag == "Identifier" && $a_param == "Entry") {
569 include_once "./Services/Utilities/classes/class.ilUtil.php";
570 $a_value = ilUtil::insertInstIntoID($a_value);
571 }
572
573 return $a_value;
574 }
static insertInstIntoID($a_value)
inserts installation id into ILIAS id

References ilUtil\insertInstIntoID().

+ Here is the call graph for this function:

◆ moveToClipboard()

ilObjQuestionPool::moveToClipboard (   $question_id)

Moves a question to the clipboard.

Parameters
integer$question_idObject id of the question @access private

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

1112 {
1113 if (!array_key_exists("qpl_clipboard", $_SESSION)) {
1114 $_SESSION["qpl_clipboard"] = array();
1115 }
1116 $_SESSION["qpl_clipboard"][$question_id] = array("question_id" => $question_id, "action" => "move");
1117 }

References $_SESSION.

◆ objectToXmlWriter()

ilObjQuestionPool::objectToXmlWriter ( ilXmlWriter $a_xml_writer,
  $a_inst,
  $a_target_dir,
$expLog,
  $questions 
)

export pages of test to xml (see ilias_co.dtd)

Parameters
object$a_xml_writerilXmlWriter object that receives the xml data

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

484 {
485 global $DIC;
486 $ilBench = $DIC['ilBench'];
487
488 $this->mob_ids = array();
489 $this->file_ids = array();
490
491 $attrs = array();
492 $attrs["Type"] = "Questionpool_Test";
493 $a_xml_writer->xmlStartTag("ContentObject", $attrs);
494
495 // MetaData
496 $this->exportXMLMetaData($a_xml_writer);
497
498 // Settings
499 $this->exportXMLSettings($a_xml_writer);
500
501 // PageObjects
502 $expLog->write(date("[y-m-d H:i:s] ") . "Start Export Page Objects");
503 $ilBench->start("ContentObjectExport", "exportPageObjects");
504 $this->exportXMLPageObjects($a_xml_writer, $a_inst, $expLog, $questions);
505 $ilBench->stop("ContentObjectExport", "exportPageObjects");
506 $expLog->write(date("[y-m-d H:i:s] ") . "Finished Export Page Objects");
507
508 // MediaObjects
509 $expLog->write(date("[y-m-d H:i:s] ") . "Start Export Media Objects");
510 $ilBench->start("ContentObjectExport", "exportMediaObjects");
511 $this->exportXMLMediaObjects($a_xml_writer, $a_inst, $a_target_dir, $expLog);
512 $ilBench->stop("ContentObjectExport", "exportMediaObjects");
513 $expLog->write(date("[y-m-d H:i:s] ") . "Finished Export Media Objects");
514
515 // FileItems
516 $expLog->write(date("[y-m-d H:i:s] ") . "Start Export File Items");
517 $ilBench->start("ContentObjectExport", "exportFileItems");
518 $this->exportFileItems($a_target_dir, $expLog);
519 $ilBench->stop("ContentObjectExport", "exportFileItems");
520 $expLog->write(date("[y-m-d H:i:s] ") . "Finished Export File Items");
521
522 // skill assignments
523 $this->populateQuestionSkillAssignmentsXml($a_xml_writer, $questions);
524
525 $a_xml_writer->xmlEndTag("ContentObject");
526 }
exportFileItems($target_dir, &$expLog)
export files of file itmes
exportXMLMediaObjects(&$a_xml_writer, $a_inst, $a_target_dir, &$expLog)
export media objects to xml (see ilias_co.dtd)
exportXMLPageObjects(&$a_xml_writer, $a_inst, &$expLog, $questions)
export page objects to xml (see ilias_co.dtd)
exportXMLMetaData(&$a_xml_writer)
export content objects meta data to xml (see ilias_co.dtd)
populateQuestionSkillAssignmentsXml(ilXmlWriter &$a_xml_writer, $questions)
xmlEndTag($tag)
Writes an endtag.
xmlStartTag($tag, $attrs=null, $empty=false, $encode=true, $escape=true)
Writes a starttag.

References $DIC, $ilBench, exportFileItems(), exportXMLMediaObjects(), exportXMLMetaData(), exportXMLPageObjects(), exportXMLSettings(), populateQuestionSkillAssignmentsXml(), ilXmlWriter\xmlEndTag(), and ilXmlWriter\xmlStartTag().

+ Here is the call graph for this function:

◆ pasteFromClipboard()

ilObjQuestionPool::pasteFromClipboard ( )

Copies/Moves a question from the clipboard.

@access private

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

1036 {
1037 global $DIC;
1038 $ilDB = $DIC['ilDB'];
1039
1040 $success = false;
1041 if (array_key_exists("qpl_clipboard", $_SESSION)) {
1042 $success = true;
1043 foreach ($_SESSION["qpl_clipboard"] as $question_object) {
1044 if (strcmp($question_object["action"], "move") == 0) {
1045 $result = $ilDB->queryF(
1046 "SELECT obj_fi FROM qpl_questions WHERE question_id = %s",
1047 array('integer'),
1048 array($question_object["question_id"])
1049 );
1050 if ($result->numRows() == 1) {
1051 $row = $ilDB->fetchAssoc($result);
1052 $source_questionpool = $row["obj_fi"];
1053 // change the questionpool id in the qpl_questions table
1054 $affectedRows = $ilDB->manipulateF(
1055 "UPDATE qpl_questions SET obj_fi = %s WHERE question_id = %s",
1056 array('integer','integer'),
1057 array($this->getId(), $question_object["question_id"])
1058 );
1059 if (!$affectedRows) {
1060 $success = false;
1061 }
1062
1063 // move question data to the new target directory
1064 $source_path = CLIENT_WEB_DIR . "/assessment/" . $source_questionpool . "/" . $question_object["question_id"] . "/";
1065 if (@is_dir($source_path)) {
1066 $target_path = CLIENT_WEB_DIR . "/assessment/" . $this->getId() . "/";
1067 if (!@is_dir($target_path)) {
1068 include_once "./Services/Utilities/classes/class.ilUtil.php";
1069 ilUtil::makeDirParents($target_path);
1070 }
1071 rename($source_path, $target_path . $question_object["question_id"]);
1072 }
1073 // update question count of source question pool
1074 ilObjQuestionPool::_updateQuestionCount($source_questionpool);
1075 }
1076 } else {
1077 $new_question_id = $this->copyQuestion($question_object["question_id"], $this->getId());
1078 if (!$new_question_id) {
1079 $success = false;
1080 }
1081 }
1082 }
1083 }
1084 // update question count of question pool
1086 unset($_SESSION["qpl_clipboard"]);
1087
1088 return (bool) $success;
1089 }
$success
Definition: Utf8Test.php:86
copyQuestion($question_id, $questionpool_to)
Copies a question into another question pool.
static makeDirParents($a_dir)
Create a new directory and all parent directories.
const CLIENT_WEB_DIR
Definition: constants.php:45

References $_SESSION, $DIC, $ilDB, $result, $success, _updateQuestionCount(), CLIENT_WEB_DIR, copyQuestion(), ilObject\getId(), and ilUtil\makeDirParents().

+ Here is the call graph for this function:

◆ populateQuestionSkillAssignmentsXml()

ilObjQuestionPool::populateQuestionSkillAssignmentsXml ( ilXmlWriter $a_xml_writer,
  $questions 
)
protected
Parameters
ilXmlWriter$a_xml_writer
$questions

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

533 {
534 global $DIC;
535 $ilDB = $DIC['ilDB'];
536
537 require_once 'Modules/TestQuestionPool/classes/class.ilAssQuestionSkillAssignmentList.php';
538 $assignmentList = new ilAssQuestionSkillAssignmentList($ilDB);
539 $assignmentList->setParentObjId($this->getId());
540 $assignmentList->loadFromDb();
541 $assignmentList->loadAdditionalSkillData();
542
543 require_once 'Modules/TestQuestionPool/classes/questions/class.ilAssQuestionSkillAssignmentExporter.php';
544 $skillQuestionAssignmentExporter = new ilAssQuestionSkillAssignmentExporter();
545 $skillQuestionAssignmentExporter->setXmlWriter($a_xml_writer);
546 $skillQuestionAssignmentExporter->setQuestionIds($questions);
547 $skillQuestionAssignmentExporter->setAssignmentList($assignmentList);
548 $skillQuestionAssignmentExporter->export();
549 }

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

Referenced by objectToXmlWriter().

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

◆ purgeQuestions()

ilObjQuestionPool::purgeQuestions ( )

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

1616 {
1617 global $DIC;
1618 $ilDB = $DIC['ilDB'];
1619 $ilUser = $DIC['ilUser'];
1620
1621 require_once 'Modules/TestQuestionPool/classes/class.ilAssIncompleteQuestionPurger.php';
1622 $incompleteQuestionPurger = new ilAssIncompleteQuestionPurger($ilDB);
1623 $incompleteQuestionPurger->setOwnerId($ilUser->getId());
1624 $incompleteQuestionPurger->purge();
1625 }

References $DIC, $ilDB, and $ilUser.

◆ 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

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

872 {
873 $xml = "";
874 // export button was pressed
875 if (count($questions) > 0) {
876 foreach ($questions as $key => $value) {
877 $question = &$this->createQuestion("", $value);
878 $xml .= $question->object->toXML();
879 }
880 if (count($questions) > 1) {
881 $xml = preg_replace("/<\/questestinterop>\s*<.xml.*?>\s*<questestinterop>/", "", $xml);
882 }
883 }
884 $xml = preg_replace("/(<\?xml[^>]*?>)/", "\\1" . "<!DOCTYPE questestinterop SYSTEM \"ims_qtiasiv1p2p1.dtd\">", $xml);
885 return $xml;
886 }

References $xml, and 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 132 of file class.ilObjQuestionPool.php.

133 {
134 parent::read($a_force_db);
135 $this->loadFromDb();
136 }
loadFromDb()
Loads a ilObjQuestionpool object from a database.

References loadFromDb().

+ Here is the call graph for this function:

◆ saveToDb()

ilObjQuestionPool::saveToDb ( )

Saves a ilObjQuestionpool object to a database.

@access public

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

244 {
245 global $DIC;
246 $ilDB = $DIC['ilDB'];
247
248 $result = $ilDB->queryF(
249 "SELECT id_questionpool FROM qpl_questionpool WHERE obj_fi = %s",
250 array('integer'),
251 array($this->getId())
252 );
253
254 if ($result->numRows() == 1) {
255 $result = $ilDB->update(
256 'qpl_questionpool',
257 array(
258 'isonline' => array('text', $this->getOnline()),
259 'show_taxonomies' => array('integer', (int) $this->getShowTaxonomies()),
260 'nav_taxonomy' => array('integer', (int) $this->getNavTaxonomyId()),
261 'skill_service' => array('integer', (int) $this->isSkillServiceEnabled()),
262 'tstamp' => array('integer', time())
263 ),
264 array(
265 'obj_fi' => array('integer', $this->getId())
266 )
267 );
268 } else {
269 $next_id = $ilDB->nextId('qpl_questionpool');
270
271 $result = $ilDB->insert('qpl_questionpool', array(
272 'id_questionpool' => array('integer', $next_id),
273 'isonline' => array('text', $this->getOnline()),
274 'show_taxonomies' => array('integer', (int) $this->getShowTaxonomies()),
275 'nav_taxonomy' => array('integer', (int) $this->getNavTaxonomyId()),
276 'skill_service' => array('integer', (int) $this->isSkillServiceEnabled()),
277 'tstamp' => array('integer', time()),
278 'obj_fi' => array('integer', $this->getId())
279 ));
280 }
281 }

References $DIC, $ilDB, $result, ilObject\getId(), getNavTaxonomyId(), getOnline(), getShowTaxonomies(), and isSkillServiceEnabled().

Referenced by createReference().

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

◆ setDescription()

ilObjQuestionPool::setDescription (   $a_description)

set description of content object

Reimplemented from ilObject.

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

326 {
327 parent::setDescription($a_description);
328 }

◆ setNavTaxonomyId()

ilObjQuestionPool::setNavTaxonomyId (   $navTaxonomyId)

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

956 {
957 $this->navTaxonomyId = $navTaxonomyId;
958 }

References $navTaxonomyId.

Referenced by loadFromDb().

+ Here is the caller graph for this function:

◆ setOnline()

ilObjQuestionPool::setOnline (   $a_online_status)

Sets the questionpool online status.

Parameters
integer$a_online_statusOnline status of the questionpool
See also
online @access User interface

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

925 {
926 switch ($a_online_status) {
927 case 0:
928 case 1:
929 $this->online = $a_online_status;
930 break;
931 default:
932 $this->online = 0;
933 break;
934 }
935 }

Referenced by __construct(), and loadFromDb().

+ Here is the caller graph for this function:

◆ setShowTaxonomies()

ilObjQuestionPool::setShowTaxonomies (   $showTaxonomies)

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

946 {
947 $this->showTaxonomies = $showTaxonomies;
948 }

References $showTaxonomies.

Referenced by loadFromDb().

+ Here is the caller graph for this function:

◆ setSkillServiceEnabled()

ilObjQuestionPool::setSkillServiceEnabled (   $skillServiceEnabled)
Parameters
boolean$skillServiceEnabled

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

1650 {
1651 $this->skillServiceEnabled = $skillServiceEnabled;
1652 }

References $skillServiceEnabled.

Referenced by loadFromDb().

+ Here is the caller graph for this function:

◆ setTitle()

ilObjQuestionPool::setTitle (   $a_title)

set title of glossary object

Reimplemented from ilObject.

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

344 {
345 parent::setTitle($a_title);
346 }

◆ update()

ilObjQuestionPool::update ( )

update object data

@access public

Returns
boolean

Reimplemented from ilObject.

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

99 {
100 $this->updateMetaData();
101 if (!parent::update()) {
102 return false;
103 }
104
105 // put here object specific stuff
106
107 return true;
108 }
updateMetaData()
update meta data entry

References updateMetaData().

+ Here is the call graph for this function:

◆ updateMetaData()

ilObjQuestionPool::updateMetaData ( )

update meta data entry

Reimplemented from ilObject.

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

111 {
112 global $DIC;
113 $ilUser = $DIC['ilUser'];
114 include_once "./Services/MetaData/classes/class.ilMD.php";
115 $md = new ilMD($this->getId(), 0, $this->getType());
116 $md_gen = &$md->getGeneral();
117 if ($md_gen == false) {
118 include_once "./Services/MetaData/classes/class.ilMDCreator.php";
119 $md_creator = new ilMDCreator($this->getId(), 0, $this->getType());
120 $md_creator->setTitle($this->getTitle());
121 $md_creator->setTitleLanguage($ilUser->getPref('language'));
122 $md_creator->create();
123 }
124 parent::updateMetaData();
125 }
getTitle()
get title of glossary object

References $DIC, $ilUser, ilObject\getId(), getTitle(), and ilObject\getType().

Referenced by update().

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

Field Documentation

◆ $import_dir

ilObjQuestionPool::$import_dir
private

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

◆ $isSkillManagementGloballyActivated

ilObjQuestionPool::$isSkillManagementGloballyActivated = null
staticprivate

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

Referenced by isSkillManagementGloballyActivated().

◆ $navTaxonomyId

ilObjQuestionPool::$navTaxonomyId = null
private

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

Referenced by getNavTaxonomyId(), and setNavTaxonomyId().

◆ $online

ilObjQuestionPool::$online

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

Referenced by getOnline().

◆ $showTaxonomies

ilObjQuestionPool::$showTaxonomies = null
private

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

Referenced by getShowTaxonomies(), and setShowTaxonomies().

◆ $skillServiceEnabled

ilObjQuestionPool::$skillServiceEnabled
private

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

Referenced by isSkillServiceEnabled(), and setSkillServiceEnabled().


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