本文整理汇总了PHP中navigation_node::get_children_key_list方法的典型用法代码示例。如果您正苦于以下问题:PHP navigation_node::get_children_key_list方法的具体用法?PHP navigation_node::get_children_key_list怎么用?PHP navigation_node::get_children_key_list使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类navigation_node
的用法示例。
在下文中一共展示了navigation_node::get_children_key_list方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: test_node_remove
public function test_node_remove()
{
$this->setup_node();
$remove1 = $this->node->add('child to remove 1', null, navigation_node::TYPE_CUSTOM, null, 'remove1');
$remove2 = $this->node->add('child to remove 2', null, navigation_node::TYPE_CUSTOM, null, 'remove2');
$remove3 = $remove2->add('child to remove 3', null, navigation_node::TYPE_CUSTOM, null, 'remove3');
$this->assertInstanceOf('navigation_node', $remove1);
$this->assertInstanceOf('navigation_node', $remove2);
$this->assertInstanceOf('navigation_node', $remove3);
$this->assertInstanceOf('navigation_node', $this->node->get('remove1'));
$this->assertInstanceOf('navigation_node', $this->node->get('remove2'));
$this->assertInstanceOf('navigation_node', $remove2->get('remove3'));
// Remove element and make sure this is no longer a child.
$this->assertTrue($remove1->remove());
$this->assertFalse($this->node->get('remove1'));
$this->assertFalse(in_array('remove1', $this->node->get_children_key_list(), true));
// Make sure that we can insert element after removal.
$insertelement = navigation_node::create('extra element 4', null, navigation_node::TYPE_CUSTOM, null, 'element4');
$this->node->add_node($insertelement, 'remove2');
$this->assertNotEmpty($this->node->get('element4'));
// Remove more elements.
$this->assertTrue($this->node->get('remove2')->remove());
$this->assertFalse($this->node->get('remove2'));
// Make sure that we can add element after removal.
$this->node->add('extra element 5', null, navigation_node::TYPE_CUSTOM, null, 'element5');
$this->assertNotEmpty($this->node->get('element5'));
$this->assertTrue($remove2->get('remove3')->remove());
$this->assertFalse($this->node->get('remove1'));
$this->assertFalse($this->node->get('remove2'));
}
示例2: questionnaire_extend_settings_navigation
/**
* Adds module specific settings to the settings block
*
* @param settings_navigation $settings The settings navigation object
* @param navigation_node $questionnairenode The node to add module settings to
*/
function questionnaire_extend_settings_navigation(settings_navigation $settings, navigation_node $questionnairenode)
{
global $PAGE, $DB, $USER, $CFG;
$individualresponse = optional_param('individualresponse', false, PARAM_INT);
$rid = optional_param('rid', false, PARAM_INT);
// Response id.
$currentgroupid = optional_param('group', 0, PARAM_INT);
// Group id.
require_once $CFG->dirroot . '/mod/questionnaire/questionnaire.class.php';
$context = $PAGE->cm->context;
$cmid = $PAGE->cm->id;
$cm = $PAGE->cm;
$course = $PAGE->course;
if (!($questionnaire = $DB->get_record("questionnaire", array("id" => $cm->instance)))) {
print_error('invalidcoursemodule');
}
$courseid = $course->id;
$questionnaire = new questionnaire(0, $questionnaire, $course, $cm);
if ($survey = $DB->get_record('questionnaire_survey', array('id' => $questionnaire->sid))) {
$owner = trim($survey->owner) == trim($courseid);
} else {
$survey = false;
$owner = true;
}
// 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 = $questionnairenode->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/questionnaire:manage', $context) && $owner) {
$url = '/mod/questionnaire/qsettings.php';
$node = navigation_node::create(get_string('advancedsettings'), new moodle_url($url, array('id' => $cmid)), navigation_node::TYPE_SETTING, null, 'advancedsettings', new pix_icon('t/edit', ''));
$questionnairenode->add_node($node, $beforekey);
}
if (has_capability('mod/questionnaire:editquestions', $context) && $owner) {
$url = '/mod/questionnaire/questions.php';
$node = navigation_node::create(get_string('questions', 'questionnaire'), new moodle_url($url, array('id' => $cmid)), navigation_node::TYPE_SETTING, null, 'questions', new pix_icon('t/edit', ''));
$questionnairenode->add_node($node, $beforekey);
}
if (has_capability('mod/questionnaire:preview', $context) && $owner) {
$url = '/mod/questionnaire/preview.php';
$node = navigation_node::create(get_string('preview_label', 'questionnaire'), new moodle_url($url, array('id' => $cmid)), navigation_node::TYPE_SETTING, null, 'preview', new pix_icon('t/preview', ''));
$questionnairenode->add_node($node, $beforekey);
}
if ($questionnaire->user_can_take($USER->id)) {
$url = '/mod/questionnaire/complete.php';
$node = navigation_node::create(get_string('answerquestions', 'questionnaire'), new moodle_url($url, array('id' => $cmid)), navigation_node::TYPE_SETTING, null, '', new pix_icon('i/info', 'answerquestions'));
$questionnairenode->add_node($node, $beforekey);
}
$usernumresp = $questionnaire->count_submissions($USER->id);
if ($questionnaire->capabilities->readownresponses && $usernumresp > 0) {
$url = '/mod/questionnaire/myreport.php';
$node = navigation_node::create(get_string('yourresponses', 'questionnaire'), new moodle_url($url, array('instance' => $questionnaire->id, 'userid' => $USER->id, 'byresponse' => 0, 'action' => 'summary')), navigation_node::TYPE_SETTING, null, 'yourresponses');
$myreportnode = $questionnairenode->add_node($node, $beforekey);
$summary = $myreportnode->add(get_string('summary', 'questionnaire'), new moodle_url('/mod/questionnaire/myreport.php', array('instance' => $questionnaire->id, 'userid' => $USER->id, 'byresponse' => 0, 'action' => 'summary')));
$byresponsenode = $myreportnode->add(get_string('viewbyresponse', 'questionnaire'), new moodle_url('/mod/questionnaire/myreport.php', array('instance' => $questionnaire->id, 'userid' => $USER->id, 'byresponse' => 1, 'action' => 'vresp')));
$allmyresponsesnode = $myreportnode->add(get_string('myresponses', 'questionnaire'), new moodle_url('/mod/questionnaire/myreport.php', array('instance' => $questionnaire->id, 'userid' => $USER->id, 'byresponse' => 0, 'action' => 'vall')));
if ($questionnaire->capabilities->downloadresponses) {
$downloadmyresponsesnode = $myreportnode->add(get_string('downloadtext'), new moodle_url('/mod/questionnaire/report.php', array('instance' => $questionnaire->id, 'user' => $USER->id, 'action' => 'dwnpg', 'group' => $currentgroupid)));
}
}
$numresp = $questionnaire->count_submissions();
// Number of responses in currently selected group (or all participants etc.).
if (isset($SESSION->questionnaire->numselectedresps)) {
$numselectedresps = $SESSION->questionnaire->numselectedresps;
} else {
$numselectedresps = $numresp;
}
// If questionnaire is set to separate groups, prevent user who is not member of any group
// to view All responses.
$canviewgroups = true;
$groupmode = groups_get_activity_groupmode($cm, $course);
if ($groupmode == 1) {
$canviewgroups = groups_has_membership($cm, $USER->id);
}
if ($questionnaire->capabilities->readallresponseanytime && $numresp > 0 && $owner && $numselectedresps > 0 || $questionnaire->capabilities->readallresponses && $numresp > 0 && $canviewgroups && ($questionnaire->resp_view == QUESTIONNAIRE_STUDENTVIEWRESPONSES_ALWAYS || $questionnaire->resp_view == QUESTIONNAIRE_STUDENTVIEWRESPONSES_WHENCLOSED && $questionnaire->is_closed() || $questionnaire->resp_view == QUESTIONNAIRE_STUDENTVIEWRESPONSES_WHENANSWERED && $usernumresp > 0) && $questionnaire->is_survey_owner()) {
$url = '/mod/questionnaire/report.php';
$node = navigation_node::create(get_string('viewallresponses', 'questionnaire'), new moodle_url($url, array('instance' => $questionnaire->id, 'action' => 'vall')), navigation_node::TYPE_SETTING, null, 'vall');
$reportnode = $questionnairenode->add_node($node, $beforekey);
if ($questionnaire->capabilities->viewsingleresponse) {
$summarynode = $reportnode->add(get_string('summary', 'questionnaire'), new moodle_url('/mod/questionnaire/report.php', array('instance' => $questionnaire->id, 'action' => 'vall')));
} else {
$summarynode = $reportnode;
}
$defaultordernode = $summarynode->add(get_string('order_default', 'questionnaire'), new moodle_url('/mod/questionnaire/report.php', array('instance' => $questionnaire->id, 'action' => 'vall', 'group' => $currentgroupid)));
$ascendingordernode = $summarynode->add(get_string('order_ascending', 'questionnaire'), new moodle_url('/mod/questionnaire/report.php', array('instance' => $questionnaire->id, 'action' => 'vallasort', 'group' => $currentgroupid)));
$descendingordernode = $summarynode->add(get_string('order_descending', 'questionnaire'), new moodle_url('/mod/questionnaire/report.php', array('instance' => $questionnaire->id, 'action' => 'vallarsort', 'group' => $currentgroupid)));
//.........这里部分代码省略.........
示例3: 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();
}
示例4: vpl_extend_settings_navigation
function vpl_extend_settings_navigation(settings_navigation $settings, navigation_node $vplnode)
{
global $CFG, $PAGE, $USER;
if (!isset($PAGE->cm->id)) {
return;
}
$cmid = $PAGE->cm->id;
$context = context_module::instance($cmid);
$manager = has_capability(VPL_MANAGE_CAPABILITY, $context);
$setjails = has_capability(VPL_SETJAILS_CAPABILITY, $context);
if ($manager) {
$userid = optional_param('userid', NULL, PARAM_INT);
$strbasic = get_string('basic', VPL);
$strtestcases = get_string('testcases', VPL);
$strexecutionoptions = get_string('executionoptions', VPL);
$menustrexecutionoptions = get_string('menuexecutionoptions', VPL);
$strrequestedfiles = get_string('requestedfiles', VPL);
$strexecution = get_string('execution', VPL);
$vplindex = get_string('modulenameplural', VPL);
$klist = $vplnode->get_children_key_list();
if (count($klist) > 1) {
$fkn = $klist[1];
} else {
$fkn = null;
}
$parms = array('id' => $PAGE->cm->id);
$node = $vplnode->create($strtestcases, new moodle_url('/mod/vpl/forms/testcasesfile.php', array('id' => $PAGE->cm->id, 'edit' => 3)), navigation_node::TYPE_SETTING);
$vplnode->add_node($node, $fkn);
$node = $vplnode->create($strexecutionoptions, new moodle_url('/mod/vpl/forms/executionoptions.php', $parms), navigation_node::TYPE_SETTING);
$vplnode->add_node($node, $fkn);
$node = $vplnode->create($strrequestedfiles, new moodle_url('/mod/vpl/forms/requiredfiles.php', $parms), navigation_node::TYPE_SETTING);
$vplnode->add_node($node, $fkn);
$advance = $vplnode->create(get_string('advancedsettings'), null, navigation_node::TYPE_CONTAINER);
$vplnode->add_node($advance, $fkn);
$strexecutionlimits = get_string('maxresourcelimits', VPL);
$strexecutionfiles = get_string('executionfiles', VPL);
$menustrexecutionfiles = get_string('menuexecutionfiles', VPL);
$menustrexecutionlimits = get_string('menuresourcelimits', VPL);
$strvariations = get_string('variations', VPL);
$strexecutionkeepfiles = get_string('keepfiles', VPL);
$strexecutionlimits = get_string('maxresourcelimits', VPL);
$strcheckjails = get_string('check_jail_servers', VPL);
$strsetjails = get_string('local_jail_servers', VPL);
$menustrexecutionkeepfiles = get_string('menukeepfiles', VPL);
$menustrcheckjails = get_string('menucheck_jail_servers', VPL);
$menustrsetjails = get_string('menulocal_jail_servers', VPL);
$advance->add($strexecutionfiles, new moodle_url('/mod/vpl/forms/executionfiles.php', $parms), navigation_node::TYPE_SETTING);
$advance->add($strexecutionlimits, new moodle_url('/mod/vpl/forms/executionlimits.php', $parms), navigation_node::TYPE_SETTING);
$advance->add($strexecutionkeepfiles, new moodle_url('/mod/vpl/forms/executionkeepfiles.php', $parms), navigation_node::TYPE_SETTING);
$advance->add($strvariations, new moodle_url('/mod/vpl/forms/variations.php', $parms), navigation_node::TYPE_SETTING);
$advance->add($strcheckjails, new moodle_url('/mod/vpl/views/checkjailservers.php', $parms), navigation_node::TYPE_SETTING);
if ($setjails) {
$advance->add($strsetjails, new moodle_url('/mod/vpl/forms/local_jail_servers.php', $parms), navigation_node::TYPE_SETTING);
}
$testact = $vplnode->create(get_string('test', VPL), null, navigation_node::TYPE_CONTAINER);
$vplnode->add_node($testact, $fkn);
$strdescription = get_string('description', VPL);
$strsubmission = get_string('submission', VPL);
$stredit = get_string('edit', VPL);
$parmsuser = array('id' => $PAGE->cm->id, 'userid' => $USER->id);
$strsubmissionview = get_string('submissionview', VPL);
$testact->add($strsubmission, new moodle_url('/mod/vpl/forms/submission.php', $parms), navigation_node::TYPE_SETTING);
$testact->add($stredit, new moodle_url('/mod/vpl/forms/edit.php', $parms), navigation_node::TYPE_SETTING);
$testact->add($strsubmissionview, new moodle_url('/mod/vpl/forms/submissionview.php', $parms), navigation_node::TYPE_SETTING);
$testact->add(get_string('grade'), new moodle_url('/mod/vpl/forms/gradesubmission.php', $parmsuser), navigation_node::TYPE_SETTING);
$testact->add(get_string('previoussubmissionslist', VPL), new moodle_url('/mod/vpl/views/previoussubmissionslist.php', $parmsuser), navigation_node::TYPE_SETTING);
$nodeindex = $vplnode->create($vplindex, new moodle_url('/mod/vpl/index.php', array('id' => $PAGE->cm->course)), navigation_node::TYPE_SETTING);
$vplnode->add_node($nodeindex, $fkn);
}
}
示例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: assign_extend_settings_navigation
/**
* extend an assigment navigation settings
*
* @param settings_navigation $settings
* @param navigation_node $navref
* @return void
*/
function assign_extend_settings_navigation(settings_navigation $settings, navigation_node $navref)
{
global $PAGE, $DB;
// 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 = $navref->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];
}
}
$cm = $PAGE->cm;
if (!$cm) {
return;
}
$context = $cm->context;
$course = $PAGE->course;
if (!$course) {
return;
}
if (has_capability('mod/assign:manageoverrides', $PAGE->cm->context)) {
$url = new moodle_url('/mod/assign/overrides.php', array('cmid' => $PAGE->cm->id));
$node = navigation_node::create(get_string('groupoverrides', 'assign'), new moodle_url($url, array('mode' => 'group')), navigation_node::TYPE_SETTING, null, 'mod_assign_groupoverrides');
$navref->add_node($node, $beforekey);
$node = navigation_node::create(get_string('useroverrides', 'assign'), new moodle_url($url, array('mode' => 'user')), navigation_node::TYPE_SETTING, null, 'mod_assign_useroverrides');
$navref->add_node($node, $beforekey);
}
// Link to gradebook.
if (has_capability('gradereport/grader:view', $cm->context) && has_capability('moodle/grade:viewall', $cm->context)) {
$link = new moodle_url('/grade/report/grader/index.php', array('id' => $course->id));
$linkname = get_string('viewgradebook', 'assign');
$node = $navref->add($linkname, $link, navigation_node::TYPE_SETTING);
}
// Link to download all submissions.
if (has_any_capability(array('mod/assign:grade', 'mod/assign:viewgrades'), $context)) {
$link = new moodle_url('/mod/assign/view.php', array('id' => $cm->id, 'action' => 'grading'));
$node = $navref->add(get_string('viewgrading', 'assign'), $link, navigation_node::TYPE_SETTING);
$link = new moodle_url('/mod/assign/view.php', array('id' => $cm->id, 'action' => 'downloadall'));
$node = $navref->add(get_string('downloadall', 'assign'), $link, navigation_node::TYPE_SETTING);
}
if (has_capability('mod/assign:revealidentities', $context)) {
$dbparams = array('id' => $cm->instance);
$assignment = $DB->get_record('assign', $dbparams, 'blindmarking, revealidentities');
if ($assignment && $assignment->blindmarking && !$assignment->revealidentities) {
$urlparams = array('id' => $cm->id, 'action' => 'revealidentities');
$url = new moodle_url('/mod/assign/view.php', $urlparams);
$linkname = get_string('revealidentities', 'assign');
$node = $navref->add($linkname, $url, navigation_node::TYPE_SETTING);
}
}
}
示例7: lesson_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 $lessonnode
*/
function lesson_extend_settings_navigation($settings, $lessonnode)
{
global $PAGE, $DB;
// 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 = $lessonnode->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/lesson:manageoverrides', $PAGE->cm->context)) {
$url = new moodle_url('/mod/lesson/overrides.php', array('cmid' => $PAGE->cm->id));
$node = navigation_node::create(get_string('groupoverrides', 'lesson'), new moodle_url($url, array('mode' => 'group')), navigation_node::TYPE_SETTING, null, 'mod_lesson_groupoverrides');
$lessonnode->add_node($node, $beforekey);
$node = navigation_node::create(get_string('useroverrides', 'lesson'), new moodle_url($url, array('mode' => 'user')), navigation_node::TYPE_SETTING, null, 'mod_lesson_useroverrides');
$lessonnode->add_node($node, $beforekey);
}
if (has_capability('mod/lesson:edit', $PAGE->cm->context)) {
$url = new moodle_url('/mod/lesson/view.php', array('id' => $PAGE->cm->id));
$lessonnode->add(get_string('preview', 'lesson'), $url);
$editnode = $lessonnode->add(get_string('edit', 'lesson'));
$url = new moodle_url('/mod/lesson/edit.php', array('id' => $PAGE->cm->id, 'mode' => 'collapsed'));
$editnode->add(get_string('collapsed', 'lesson'), $url);
$url = new moodle_url('/mod/lesson/edit.php', array('id' => $PAGE->cm->id, 'mode' => 'full'));
$editnode->add(get_string('full', 'lesson'), $url);
}
if (has_capability('mod/lesson:viewreports', $PAGE->cm->context)) {
$reportsnode = $lessonnode->add(get_string('reports', 'lesson'));
$url = new moodle_url('/mod/lesson/report.php', array('id' => $PAGE->cm->id, 'action' => 'reportoverview'));
$reportsnode->add(get_string('overview', 'lesson'), $url);
$url = new moodle_url('/mod/lesson/report.php', array('id' => $PAGE->cm->id, 'action' => 'reportdetail'));
$reportsnode->add(get_string('detailedstats', 'lesson'), $url);
}
if (has_capability('mod/lesson:grade', $PAGE->cm->context)) {
$url = new moodle_url('/mod/lesson/essay.php', array('id' => $PAGE->cm->id));
$lessonnode->add(get_string('manualgrading', 'lesson'), $url);
}
}
示例8: customcert_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 $customcertnode
*/
function customcert_extend_settings_navigation(settings_navigation $settings, navigation_node $customcertnode)
{
global $PAGE;
$keys = $customcertnode->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/customcert:manage', $PAGE->cm->context)) {
$node = navigation_node::create(get_string('editcustomcert', 'customcert'), new moodle_url('/mod/customcert/edit.php', array('cmid' => $PAGE->cm->id)), navigation_node::TYPE_SETTING, null, 'mod_customcert_edit', new pix_icon('t/edit', ''));
$customcertnode->add_node($node, $beforekey);
}
return $customcertnode->trim_if_empty();
}
示例9: geogebra_extend_settings_navigation
/**
* Extends the settings navigation with the geogebra settings
*
* This function is called when the context for the page is a geogebra module. This is not called by AJAX
* so it is safe to rely on the $PAGE.
*
* @param settings_navigation $settingsnav {@link settings_navigation}
* @param navigation_node $geogebranode {@link navigation_node}
*/
function geogebra_extend_settings_navigation(settings_navigation $settingsnav, navigation_node $geogebranode = null)
{
global $PAGE;
$keys = $geogebranode->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('moodle/grade:viewall', $PAGE->context)) {
$node = navigation_node::create(get_string('preview_geogebra', 'geogebra'), new moodle_url('/mod/geogebra/view.php', array('id' => $PAGE->cm->id, 'action' => 'preview')), navigation_node::TYPE_SETTING, null, 'mod_preview_geogebra_preview', new pix_icon('i/preview', ''));
$geogebranode->add_node($node, $beforekey);
$url = new moodle_url('/mod/geogebra/report.php', array('id' => $PAGE->cm->id));
$reportnode = $geogebranode->add_node(navigation_node::create(get_string('results', 'geogebra'), $url, navigation_node::TYPE_SETTING, null, null, new pix_icon('i/report', '')), $beforekey);
//}
}
示例10: treasurehunt_extend_settings_navigation
/**
* Extends the settings navigation with the treasurehunt settings
*
* This function is called when the context for the page is a treasurehunt module. This is not called by AJAX
* so it is safe to rely on the $PAGE.
*
* @param settings_navigation $settingsnav complete settings navigation tree
* @param navigation_node $treasurehuntnode treasurehunt administration node
*/
function treasurehunt_extend_settings_navigation(settings_navigation $settingsnav, navigation_node $treasurehuntnode = null)
{
global $PAGE;
// 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 = $treasurehuntnode->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/treasurehunt:managetreasurehunt', $PAGE->cm->context)) {
$node = navigation_node::create(get_string('edittreasurehunt', 'treasurehunt'), new moodle_url('/mod/treasurehunt/edit.php', array('id' => $PAGE->cm->id)), navigation_node::TYPE_SETTING, null, 'mod_treasurehunt_edit', new pix_icon('t/edit', ''));
$treasurehuntnode->add_node($node, $beforekey);
}
}
示例11: rcontent_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 $node
* @return void
*/
function rcontent_extend_settings_navigation($settings, $node)
{
global $CFG, $PAGE, $DB;
// 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 = $node->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_any_capability(array('mod/rcontent:viewreport'), $PAGE->cm->context)) {
require_once $CFG->dirroot . '/mod/rcontent/report/reportlib.php';
$url = new moodle_url('/mod/rcontent/report.php', array('id' => $PAGE->cm->id));
$reportnode = $node->add_node(navigation_node::create(get_string('results', 'rcontent'), $url, navigation_node::TYPE_SETTING, null, null, new pix_icon('i/report', '')), $beforekey);
$reportlist = rcontent_report_list();
if (!empty($reportlist)) {
foreach ($reportlist as $report) {
$url = new moodle_url('/mod/rcontent/report/' . $report . '/index.php', array('id' => $PAGE->cm->id));
$reportnode->add_node(navigation_node::create(get_string($report, 'rcontent_' . $report), $url, navigation_node::TYPE_SETTING, null, 'rcontent_report_' . $report, new pix_icon('i/item', '')));
}
} else {
if (file_exists($CFG->dirroot . '/blocks/rgrade/rgrade_table.php')) {
$rcontent = $DB->get_record('rcontent', array('id' => $PAGE->cm->instance));
if ($rcontent->bookid) {
$reportnode->add_node(navigation_node::create(get_string('rgrade', 'block_rgrade'), new moodle_url('/blocks/rgrade/rgrade_table.php', array('courseid' => $PAGE->course->id, 'bookid' => $rcontent->bookid)), navigation_node::TYPE_SETTING, null, 'rcontent_report_rgrade', new pix_icon('i/item', '')));
}
}
}
}
}
示例12: questionnaire_extend_settings_navigation
/**
* Adds module specific settings to the settings block
*
* @param settings_navigation $settings The settings navigation object
* @param navigation_node $questionnairenode The node to add module settings to
*
* $settings is unused, but API requires it. Suppress PHPMD warning.
*
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
function questionnaire_extend_settings_navigation(settings_navigation $settings, navigation_node $questionnairenode)
{
global $PAGE, $DB, $USER, $CFG;
$individualresponse = optional_param('individualresponse', false, PARAM_INT);
$rid = optional_param('rid', false, PARAM_INT);
// Response id.
$currentgroupid = optional_param('group', 0, PARAM_INT);
// Group id.
require_once $CFG->dirroot . '/mod/questionnaire/questionnaire.class.php';
$context = $PAGE->cm->context;
$cmid = $PAGE->cm->id;
$cm = $PAGE->cm;
$course = $PAGE->course;
if (!($questionnaire = $DB->get_record("questionnaire", array("id" => $cm->instance)))) {
print_error('invalidcoursemodule');
}
$courseid = $course->id;
$questionnaire = new questionnaire(0, $questionnaire, $course, $cm);
if ($owner = $DB->get_field('questionnaire_survey', 'owner', array('id' => $questionnaire->sid))) {
$owner = trim($owner) == trim($courseid);
} else {
$owner = true;
}
// On view page, currentgroupid is not yet sent as an optional_param, so get it.
$groupmode = groups_get_activity_groupmode($cm, $course);
if ($groupmode > 0 && $currentgroupid == 0) {
$currentgroupid = groups_get_activity_group($questionnaire->cm);
if (!groups_is_member($currentgroupid, $USER->id)) {
$currentgroupid = 0;
}
}
// 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 = $questionnairenode->get_children_key_list();
$beforekey = null;
$i = array_search('modedit', $keys);
if ($i === false && array_key_exists(0, $keys)) {
$beforekey = $keys[0];
} else {
if (array_key_exists($i + 1, $keys)) {
$beforekey = $keys[$i + 1];
}
}
if (has_capability('mod/questionnaire:manage', $context) && $owner) {
$url = '/mod/questionnaire/qsettings.php';
$node = navigation_node::create(get_string('advancedsettings'), new moodle_url($url, array('id' => $cmid)), navigation_node::TYPE_SETTING, null, 'advancedsettings', new pix_icon('t/edit', ''));
$questionnairenode->add_node($node, $beforekey);
}
if (has_capability('mod/questionnaire:editquestions', $context) && $owner) {
$url = '/mod/questionnaire/questions.php';
$node = navigation_node::create(get_string('questions', 'questionnaire'), new moodle_url($url, array('id' => $cmid)), navigation_node::TYPE_SETTING, null, 'questions', new pix_icon('t/edit', ''));
$questionnairenode->add_node($node, $beforekey);
}
if (has_capability('mod/questionnaire:preview', $context)) {
$url = '/mod/questionnaire/preview.php';
$node = navigation_node::create(get_string('preview_label', 'questionnaire'), new moodle_url($url, array('id' => $cmid)), navigation_node::TYPE_SETTING, null, 'preview', new pix_icon('t/preview', ''));
$questionnairenode->add_node($node, $beforekey);
}
if ($questionnaire->user_can_take($USER->id)) {
$url = '/mod/questionnaire/complete.php';
if ($questionnaire->user_has_saved_response($USER->id)) {
$args = ['id' => $cmid, 'resume' => 1];
$text = get_string('resumesurvey', 'questionnaire');
} else {
$args = ['id' => $cmid];
$text = get_string('answerquestions', 'questionnaire');
}
$node = navigation_node::create($text, new moodle_url($url, $args), navigation_node::TYPE_SETTING, null, '', new pix_icon('i/info', 'answerquestions'));
$questionnairenode->add_node($node, $beforekey);
}
$usernumresp = $questionnaire->count_submissions($USER->id);
if ($questionnaire->capabilities->readownresponses && $usernumresp > 0) {
$url = '/mod/questionnaire/myreport.php';
if ($usernumresp > 1) {
$urlargs = array('instance' => $questionnaire->id, 'userid' => $USER->id, 'byresponse' => 0, 'action' => 'summary', 'group' => $currentgroupid);
$node = navigation_node::create(get_string('yourresponses', 'questionnaire'), new moodle_url($url, $urlargs), navigation_node::TYPE_SETTING, null, 'yourresponses');
$myreportnode = $questionnairenode->add_node($node, $beforekey);
$urlargs = array('instance' => $questionnaire->id, 'userid' => $USER->id, 'byresponse' => 0, 'action' => 'summary', 'group' => $currentgroupid);
$myreportnode->add(get_string('summary', 'questionnaire'), new moodle_url($url, $urlargs));
$urlargs = array('instance' => $questionnaire->id, 'userid' => $USER->id, 'byresponse' => 1, 'action' => 'vresp', 'group' => $currentgroupid);
$byresponsenode = $myreportnode->add(get_string('viewindividualresponse', 'questionnaire'), new moodle_url($url, $urlargs));
$urlargs = array('instance' => $questionnaire->id, 'userid' => $USER->id, 'byresponse' => 0, 'action' => 'vall', 'group' => $currentgroupid);
$myreportnode->add(get_string('myresponses', 'questionnaire'), new moodle_url($url, $urlargs));
if ($questionnaire->capabilities->downloadresponses) {
$urlargs = array('instance' => $questionnaire->id, 'user' => $USER->id, 'action' => 'dwnpg', 'group' => $currentgroupid);
$myreportnode->add(get_string('downloadtext'), new moodle_url('/mod/questionnaire/report.php', $urlargs));
}
} else {
$urlargs = array('instance' => $questionnaire->id, 'userid' => $USER->id, 'byresponse' => 1, 'action' => 'vresp', 'group' => $currentgroupid);
$node = navigation_node::create(get_string('yourresponse', 'questionnaire'), new moodle_url($url, $urlargs), navigation_node::TYPE_SETTING, null, 'yourresponse');
//.........这里部分代码省略.........