本文整理汇总了PHP中question_extend_settings_navigation函数的典型用法代码示例。如果您正苦于以下问题:PHP question_extend_settings_navigation函数的具体用法?PHP question_extend_settings_navigation怎么用?PHP question_extend_settings_navigation使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了question_extend_settings_navigation函数的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: load_front_page_settings
/**
* This function loads all of the front page settings into the settings navigation.
* This function is called when the user is on the front page, or $COURSE==$SITE
* @param bool $forceopen (optional)
* @return navigation_node
*/
protected function load_front_page_settings($forceopen = false)
{
global $SITE, $CFG;
$course = clone $SITE;
$coursecontext = get_context_instance(CONTEXT_COURSE, $course->id);
// Course context
$frontpage = $this->add(get_string('frontpagesettings'), null, self::TYPE_SETTING, null, 'frontpage');
if ($forceopen) {
$frontpage->force_open();
}
$frontpage->id = 'frontpagesettings';
if (has_capability('moodle/course:update', $coursecontext)) {
// Add the turn on/off settings
$url = new moodle_url('/course/view.php', array('id' => $course->id, 'sesskey' => sesskey()));
if ($this->page->user_is_editing()) {
$url->param('edit', 'off');
$editstring = get_string('turneditingoff');
} else {
$url->param('edit', 'on');
$editstring = get_string('turneditingon');
}
$frontpage->add($editstring, $url, self::TYPE_SETTING, null, null, new pix_icon('i/edit', ''));
// Add the course settings link
$url = new moodle_url('/admin/settings.php', array('section' => 'frontpagesettings'));
$frontpage->add(get_string('editsettings'), $url, self::TYPE_SETTING, null, null, new pix_icon('i/settings', ''));
}
// add enrol nodes
enrol_add_course_navigation($frontpage, $course);
// Manage filters
if (has_capability('moodle/filter:manage', $coursecontext) && count(filter_get_available_in_context($coursecontext)) > 0) {
$url = new moodle_url('/filter/manage.php', array('contextid' => $coursecontext->id));
$frontpage->add(get_string('filters', 'admin'), $url, self::TYPE_SETTING, null, null, new pix_icon('i/filter', ''));
}
// Backup this course
if (has_capability('moodle/backup:backupcourse', $coursecontext)) {
$url = new moodle_url('/backup/backup.php', array('id' => $course->id));
$frontpage->add(get_string('backup'), $url, self::TYPE_SETTING, null, null, new pix_icon('i/backup', ''));
}
// Restore to this course
if (has_capability('moodle/restore:restorecourse', $coursecontext)) {
$url = new moodle_url('/backup/restorefile.php', array('contextid' => $coursecontext->id));
$frontpage->add(get_string('restore'), $url, self::TYPE_SETTING, null, null, new pix_icon('i/restore', ''));
}
// Questions
require_once $CFG->libdir . '/questionlib.php';
question_extend_settings_navigation($frontpage, $coursecontext)->trim_if_empty();
// Manage files
if ($course->legacyfiles == 2 and has_capability('moodle/course:managefiles', $this->context)) {
//hiden in new installs
$url = new moodle_url('/files/index.php', array('contextid' => $coursecontext->id, 'itemid' => 0, 'component' => 'course', 'filearea' => 'legacy'));
$frontpage->add(get_string('sitelegacyfiles'), $url, self::TYPE_SETTING, null, null, new pix_icon('i/files', ''));
}
return $frontpage;
}
示例2: load_course_settings
//.........这里部分代码省略.........
if (has_capability('gradereport/' . $plugin . ':view', $coursecontext)) {
//stop when the first visible plugin is found
$reportavailable = true;
break;
}
}
}
}
}
if ($reportavailable) {
$url = new moodle_url('/grade/report/index.php', array('id' => $course->id));
$gradenode = $coursenode->add(get_string('grades'), $url, self::TYPE_SETTING, null, 'grades', new pix_icon('i/grades', ''));
}
// Add outcome if permitted
if (!empty($CFG->enableoutcomes) && has_capability('moodle/course:update', $coursecontext)) {
$url = new moodle_url('/grade/edit/outcome/course.php', array('id' => $course->id));
$coursenode->add(get_string('outcomes', 'grades'), $url, self::TYPE_SETTING, null, 'outcomes', new pix_icon('i/outcomes', ''));
}
// Backup this course
if (has_capability('moodle/backup:backupcourse', $coursecontext)) {
$url = new moodle_url('/backup/backup.php', array('id' => $course->id));
$coursenode->add(get_string('backup'), $url, self::TYPE_SETTING, null, 'backup', new pix_icon('i/backup', ''));
}
// Restore to this course
if (has_capability('moodle/restore:restorecourse', $coursecontext)) {
$url = new moodle_url('/backup/restorefile.php', array('contextid' => $coursecontext->id));
$coursenode->add(get_string('restore'), $url, self::TYPE_SETTING, null, 'restore', new pix_icon('i/restore', ''));
}
// Import data from other courses
if (has_capability('moodle/restore:restoretargetimport', $coursecontext)) {
$url = new moodle_url('/backup/import.php', array('id' => $course->id));
$coursenode->add(get_string('import'), $url, self::TYPE_SETTING, null, 'import', new pix_icon('i/restore', ''));
}
// Publish course on a hub
if (has_capability('moodle/course:publish', $coursecontext)) {
$url = new moodle_url('/course/publish/index.php', array('id' => $course->id));
$coursenode->add(get_string('publish'), $url, self::TYPE_SETTING, null, 'publish', new pix_icon('i/publish', ''));
}
// Reset this course
if (has_capability('moodle/course:reset', $coursecontext)) {
$url = new moodle_url('/course/reset.php', array('id' => $course->id));
$coursenode->add(get_string('reset'), $url, self::TYPE_SETTING, null, null, new pix_icon('i/return', ''));
}
// Questions
require_once $CFG->dirroot . '/question/editlib.php';
question_extend_settings_navigation($coursenode, $coursecontext)->trim_if_empty();
if (has_capability('moodle/course:update', $coursecontext)) {
// Repository Instances
if (!$this->cache->cached('contexthasrepos' . $coursecontext->id)) {
require_once $CFG->dirroot . '/repository/lib.php';
$editabletypes = repository::get_editable_types($coursecontext);
$haseditabletypes = !empty($editabletypes);
unset($editabletypes);
$this->cache->set('contexthasrepos' . $coursecontext->id, $haseditabletypes);
} else {
$haseditabletypes = $this->cache->{'contexthasrepos' . $coursecontext->id};
}
if ($haseditabletypes) {
$url = new moodle_url('/repository/manage_instances.php', array('contextid' => $coursecontext->id));
$coursenode->add(get_string('repositories'), $url, self::TYPE_SETTING, null, null, new pix_icon('i/repository', ''));
}
}
// Manage files
if ($course->legacyfiles == 2 and has_capability('moodle/course:managefiles', $coursecontext)) {
// hidden in new courses and courses where legacy files were turned off
$url = new moodle_url('/files/index.php', array('contextid' => $coursecontext->id));
$coursenode->add(get_string('courselegacyfiles'), $url, self::TYPE_SETTING, null, 'coursefiles', new pix_icon('i/files', ''));
}
// Switch roles
$roles = array();
$assumedrole = $this->in_alternative_role();
if ($assumedrole !== false) {
$roles[0] = get_string('switchrolereturn');
}
if (has_capability('moodle/role:switchroles', $coursecontext)) {
$availableroles = get_switchable_roles($coursecontext);
if (is_array($availableroles)) {
foreach ($availableroles as $key => $role) {
if ($assumedrole == (int) $key) {
continue;
}
$roles[$key] = $role;
}
}
}
if (is_array($roles) && count($roles) > 0) {
$switchroles = $this->add(get_string('switchroleto'));
if (count($roles) == 1 && array_key_exists(0, $roles) || $assumedrole !== false) {
$switchroles->force_open();
}
$returnurl = $this->page->url;
$returnurl->param('sesskey', sesskey());
foreach ($roles as $key => $name) {
$url = new moodle_url('/course/switchrole.php', array('id' => $course->id, 'sesskey' => sesskey(), 'switchrole' => $key, 'returnurl' => $returnurl->out(false)));
$switchroles->add($name, $url, self::TYPE_SETTING, null, $key, new pix_icon('i/roles', ''));
}
}
// Return we are done
return $coursenode;
}
示例3: load_front_page_settings
/**
* This function loads all of the front page settings into the settings navigation.
* This function is called when the user is on the front page, or $COURSE==$SITE
* @param bool $forceopen (optional)
* @return navigation_node
*/
protected function load_front_page_settings($forceopen = false)
{
global $SITE, $CFG;
$course = clone $SITE;
$coursecontext = context_course::instance($course->id);
// Course context
$frontpage = $this->add(get_string('frontpagesettings'), null, self::TYPE_SETTING, null, 'frontpage');
if ($forceopen) {
$frontpage->force_open();
}
$frontpage->id = 'frontpagesettings';
if ($this->page->user_allowed_editing()) {
// Add the turn on/off settings
$url = new moodle_url('/course/view.php', array('id' => $course->id, 'sesskey' => sesskey()));
if ($this->page->user_is_editing()) {
$url->param('edit', 'off');
$editstring = get_string('turneditingoff');
} else {
$url->param('edit', 'on');
$editstring = get_string('turneditingon');
}
$frontpage->add($editstring, $url, self::TYPE_SETTING, null, null, new pix_icon('i/edit', ''));
}
if (has_capability('moodle/course:update', $coursecontext)) {
// Add the course settings link
$url = new moodle_url('/admin/settings.php', array('section' => 'frontpagesettings'));
$frontpage->add(get_string('editsettings'), $url, self::TYPE_SETTING, null, null, new pix_icon('i/settings', ''));
}
// add enrol nodes
enrol_add_course_navigation($frontpage, $course);
// Manage filters
if (has_capability('moodle/filter:manage', $coursecontext) && count(filter_get_available_in_context($coursecontext)) > 0) {
$url = new moodle_url('/filter/manage.php', array('contextid' => $coursecontext->id));
$frontpage->add(get_string('filters', 'admin'), $url, self::TYPE_SETTING, null, null, new pix_icon('i/filter', ''));
}
// View course reports.
if (has_capability('moodle/site:viewreports', $coursecontext)) {
// Basic capability for listing of reports.
$frontpagenav = $frontpage->add(get_string('reports'), null, self::TYPE_CONTAINER, null, 'frontpagereports', new pix_icon('i/stats', ''));
$coursereports = core_component::get_plugin_list('coursereport');
foreach ($coursereports as $report => $dir) {
$libfile = $CFG->dirroot . '/course/report/' . $report . '/lib.php';
if (file_exists($libfile)) {
require_once $libfile;
$reportfunction = $report . '_report_extend_navigation';
if (function_exists($report . '_report_extend_navigation')) {
$reportfunction($frontpagenav, $course, $coursecontext);
}
}
}
$reports = get_plugin_list_with_function('report', 'extend_navigation_course', 'lib.php');
foreach ($reports as $reportfunction) {
$reportfunction($frontpagenav, $course, $coursecontext);
}
}
// Backup this course
if (has_capability('moodle/backup:backupcourse', $coursecontext)) {
$url = new moodle_url('/backup/backup.php', array('id' => $course->id));
$frontpage->add(get_string('backup'), $url, self::TYPE_SETTING, null, null, new pix_icon('i/backup', ''));
}
// Restore to this course
if (has_capability('moodle/restore:restorecourse', $coursecontext)) {
$url = new moodle_url('/backup/restorefile.php', array('contextid' => $coursecontext->id));
$frontpage->add(get_string('restore'), $url, self::TYPE_SETTING, null, null, new pix_icon('i/restore', ''));
}
// Questions
require_once $CFG->libdir . '/questionlib.php';
question_extend_settings_navigation($frontpage, $coursecontext)->trim_if_empty();
// Manage files
if ($course->legacyfiles == 2 and has_capability('moodle/course:managefiles', $this->context)) {
//hiden in new installs
$url = new moodle_url('/files/index.php', array('contextid' => $coursecontext->id));
$frontpage->add(get_string('sitelegacyfiles'), $url, self::TYPE_SETTING, null, null, new pix_icon('i/folder', ''));
}
// Let plugins hook into frontpage navigation.
$pluginsfunction = get_plugins_with_function('extend_navigation_frontpage', 'lib.php');
foreach ($pluginsfunction as $plugintype => $plugins) {
foreach ($plugins as $pluginfunction) {
$pluginfunction($frontpage, $course, $coursecontext);
}
}
return $frontpage;
}
示例4: quiz_extend_settings_navigation
/**
* This function extends the settings navigation block for the site.
*
* It is safe to rely on PAGE here as we will only ever be within the module
* context when this is called
*
* @param settings_navigation $settings
* @param navigation_node $quiznode
*/
function quiz_extend_settings_navigation($settings, $quiznode) {
global $PAGE, $CFG;
// Require {@link questionlib.php}
// Included here as we only ever want to include this file if we really need to.
require_once($CFG->libdir . '/questionlib.php');
// We want to add these new nodes after the Edit settings node, and before the
// Locally assigned roles node. Of course, both of those are controlled by capabilities.
$keys = $quiznode->get_children_key_list();
$beforekey = null;
$i = array_search('modedit', $keys);
if ($i === false and array_key_exists(0, $keys)) {
$beforekey = $keys[0];
} else if (array_key_exists($i + 1, $keys)) {
$beforekey = $keys[$i + 1];
}
if (has_capability('mod/quiz:manageoverrides', $PAGE->cm->context)) {
$url = new moodle_url('/mod/quiz/overrides.php', array('cmid'=>$PAGE->cm->id));
$node = navigation_node::create(get_string('groupoverrides', 'quiz'),
new moodle_url($url, array('mode'=>'group')),
navigation_node::TYPE_SETTING, null, 'mod_quiz_groupoverrides');
$quiznode->add_node($node, $beforekey);
$node = navigation_node::create(get_string('useroverrides', 'quiz'),
new moodle_url($url, array('mode'=>'user')),
navigation_node::TYPE_SETTING, null, 'mod_quiz_useroverrides');
$quiznode->add_node($node, $beforekey);
}
if (has_capability('mod/quiz:manage', $PAGE->cm->context)) {
$node = navigation_node::create(get_string('editquiz', 'quiz'),
new moodle_url('/mod/quiz/edit.php', array('cmid'=>$PAGE->cm->id)),
navigation_node::TYPE_SETTING, null, 'mod_quiz_edit',
new pix_icon('t/edit', ''));
$quiznode->add_node($node, $beforekey);
}
if (has_capability('mod/quiz:preview', $PAGE->cm->context)) {
$url = new moodle_url('/mod/quiz/startattempt.php',
array('cmid'=>$PAGE->cm->id, 'sesskey'=>sesskey()));
$node = navigation_node::create(get_string('preview', 'quiz'), $url,
navigation_node::TYPE_SETTING, null, 'mod_quiz_preview',
new pix_icon('t/preview', ''));
$quiznode->add_node($node, $beforekey);
}
question_extend_settings_navigation($quiznode, $PAGE->cm->context)->trim_if_empty();
}
示例5: offlinequiz_extend_settings_navigation
/**
* This function extends the settings navigation block for the site.
*
* It is safe to rely on PAGE here as we will only ever be within the module
* context when this is called
*
* @param settings_navigation $settings
* @param navigation_node $offlinequiznode
*/
function offlinequiz_extend_settings_navigation($settings, $offlinequiznode)
{
global $PAGE, $CFG;
// Included here as we only ever want to include this file if we really need to.
require_once $CFG->libdir . '/questionlib.php';
// We want to add these new nodes after the Edit settings node, and before the
// Locally assigned roles node. Of course, both of those are controlled by capabilities.
$keys = $offlinequiznode->get_children_key_list();
$beforekey = null;
$i = array_search('modedit', $keys);
if ($i === false and array_key_exists(0, $keys)) {
$beforekey = $keys[0];
} else {
if (array_key_exists($i + 1, $keys)) {
$beforekey = $keys[$i + 1];
}
}
if (has_capability('mod/offlinequiz:manage', $PAGE->cm->context)) {
$node = navigation_node::create(get_string('groupquestions', 'offlinequiz'), new moodle_url('/mod/offlinequiz/edit.php', array('cmid' => $PAGE->cm->id)), navigation_node::TYPE_SETTING, null, 'mod_offlinequiz_edit', new pix_icon('i/questions', ''));
$offlinequiznode->add_node($node, $beforekey);
$node = navigation_node::create(get_string('createofflinequiz', 'offlinequiz'), new moodle_url('/mod/offlinequiz/createquiz.php', array('id' => $PAGE->cm->id)), navigation_node::TYPE_SETTING, null, 'mod_offlinequiz_createpdfs', new pix_icon('f/text', ''));
$offlinequiznode->add_node($node, $beforekey);
$node = navigation_node::create(get_string('participantslists', 'offlinequiz'), new moodle_url('/mod/offlinequiz/participants.php', array('id' => $PAGE->cm->id)), navigation_node::TYPE_SETTING, null, 'mod_offlinequiz_participants', new pix_icon('i/group', ''));
$offlinequiznode->add_node($node, $beforekey);
$node = navigation_node::create(get_string('results', 'offlinequiz'), new moodle_url('/mod/offlinequiz/report.php', array('id' => $PAGE->cm->id, 'mode' => 'overview')), navigation_node::TYPE_SETTING, null, 'mod_offlinequiz_results', new pix_icon('i/grades', ''));
$offlinequiznode->add_node($node, $beforekey);
}
question_extend_settings_navigation($offlinequiznode, $PAGE->cm->context)->trim_if_empty();
}
示例6: quiz_extend_settings_navigation
/**
* This function extends the settings navigation block for the site.
*
* It is safe to rely on PAGE here as we will only ever be within the module
* context when this is called
*
* @param settings_navigation $settings
* @param navigation_node $quiznode
*/
function quiz_extend_settings_navigation($settings, $quiznode) {
global $PAGE, $CFG;
/**
* Require {@link questionlib.php}
* Included here as we only ever want to include this file if we really need to.
*/
require_once($CFG->libdir . '/questionlib.php');
if (has_capability('mod/quiz:manageoverrides', $PAGE->cm->context)) {
$url = new moodle_url('/mod/quiz/overrides.php', array('cmid'=>$PAGE->cm->id));
$quiznode->add(get_string('groupoverrides', 'quiz'), new moodle_url($url, array('mode'=>'group')),
navigation_node::TYPE_SETTING, null, 'groupoverrides');
$quiznode->add(get_string('useroverrides', 'quiz'), new moodle_url($url, array('mode'=>'user')),
navigation_node::TYPE_SETTING, null, 'useroverrides');
}
if (has_capability('mod/quiz:manage', $PAGE->cm->context)) {
$url = new moodle_url('/mod/quiz/edit.php', array('cmid'=>$PAGE->cm->id));
$text = get_string('editquiz', 'quiz');
$quiznode->add($text, $url, navigation_node::TYPE_SETTING, null,
'mod_quiz_edit', new pix_icon('t/edit', ''));
}
if (has_capability('mod/quiz:preview', $PAGE->cm->context)) {
$url = new moodle_url('/mod/quiz/startattempt.php', array('cmid'=>$PAGE->cm->id, 'sesskey'=>sesskey()));
$quiznode->add(get_string('preview', 'quiz'), $url, navigation_node::TYPE_SETTING,
null, 'mod_quiz_preview', new pix_icon('t/preview', ''));
}
question_extend_settings_navigation($quiznode, $PAGE->cm->context)->trim_if_empty();
}