/** * Returns the available question pools for the active user * * @return array The available question pools * @access public */ function &_getAvailableQuestionpools($use_object_id = FALSE, $equal_points = FALSE, $could_be_offline = FALSE, $showPath = FALSE, $with_questioncount = FALSE, $permission = "read", $usr_id = "") { global $ilUser; global $ilDB; $result_array = array(); $permission = strlen($permission) == 0 ? "read" : $permission; $qpls = ilUtil::_getObjectsByOperations("qpl", $permission, strlen($usr_id) ? $usr_id : $ilUser->getId(), -1); $obj_ids = array(); foreach ($qpls as $ref_id) { $obj_id = ilObject::_lookupObjId($ref_id); $obj_ids[$ref_id] = $obj_id; } $titles = ilObject::_prepareCloneSelection($qpls, "qpl"); if (count($obj_ids)) { $in = $ilDB->in('object_data.obj_id', $obj_ids, false, 'integer'); if ($could_be_offline) { $result = $ilDB->query("SELECT qpl_questionpool.*, object_data.title FROM qpl_questionpool, object_data WHERE " . "qpl_questionpool.obj_fi = object_data.obj_id AND {$in} ORDER BY object_data.title"); } else { $result = $ilDB->queryF("SELECT qpl_questionpool.*, object_data.title FROM qpl_questionpool, object_data WHERE " . "qpl_questionpool.obj_fi = object_data.obj_id AND {$in} AND qpl_questionpool.isonline = %s " . "ORDER BY object_data.title", array('text'), array(1)); } while ($row = $ilDB->fetchAssoc($result)) { $add = TRUE; if ($equal_points) { if (!ilObjQuestionPool::_hasEqualPoints($row["obj_fi"])) { $add = FALSE; } } if ($add) { $ref_id = array_search($row["obj_fi"], $obj_ids); $title = $showPath ? $titles[$ref_id] : $row["title"]; if ($with_questioncount) { $title .= " [" . $row["questioncount"] . " " . ($row["questioncount"] == 1 ? $this->lng->txt("ass_question") : $this->lng->txt("assQuestions")) . "]"; } if ($use_object_id) { $result_array[$row["obj_fi"]] = array('qpl_id' => $row['obj_fi'], 'qpl_title' => $row['title'], "title" => $title, "count" => $row["questioncount"]); } else { $result_array[$ref_id] = array('qpl_id' => $row['obj_fi'], 'qpl_title' => $row['title'], "title" => $title, "count" => $row["questioncount"]); } } } } return $result_array; }