-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlib.php
More file actions
142 lines (118 loc) · 3.96 KB
/
lib.php
File metadata and controls
142 lines (118 loc) · 3.96 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Add page to admin menu.
*
* @package local
* @subpackage dataseteditor
* @copyright 2013-2015 Daniel Seemuth
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
defined('MOODLE_INTERNAL') || die;
require_once(dirname(__FILE__) . '/defines.php');
require_once(dirname(__FILE__) . '/locallib.php');
function local_dataseteditor_add_navigation_nodes($topnode, $urlparams) {
$categoryid = optional_param('categoryid', 0, PARAM_INT);
if ($categoryid > 0) {
$indextype = navigation_node::TYPE_CONTAINER;
} else {
$indextype = navigation_node::TYPE_CUSTOM;
}
$indexnode = $topnode->add(
get_string('pluginname', 'local_dataseteditor'),
new moodle_url(
LOCAL_DATASETEDITOR_PLUGINPREFIX.'/categories.php',
$urlparams
),
$indextype
);
if ($categoryid > 0) {
$urlparams['categoryid'] = $categoryid;
$indexnode->add(
get_string('editwildcards', 'local_dataseteditor'),
new moodle_url(
LOCAL_DATASETEDITOR_PLUGINPREFIX.'/wildcards.php',
$urlparams
)
);
$indexnode->add(
get_string('editdataset', 'local_dataseteditor'),
new moodle_url(
LOCAL_DATASETEDITOR_PLUGINPREFIX.'/dataset.php',
$urlparams
)
);
$indexnode->add(
get_string('exportdataset', 'local_dataseteditor'),
new moodle_url(
LOCAL_DATASETEDITOR_PLUGINPREFIX.'/export_dataset.php',
$urlparams
)
);
$indexnode->add(
get_string('importdataset', 'local_dataseteditor'),
new moodle_url(
LOCAL_DATASETEDITOR_PLUGINPREFIX.'/import_dataset.php',
$urlparams
)
);
}
}
function local_dataseteditor_extends_settings_navigation($settings, $denode) {
global $PAGE;
/* First ensure that we should show navigation nodes. */
if ($PAGE->course === null) {
return;
}
$courseid = $PAGE->course->id;
if ($PAGE->context === null) {
return;
}
if (! has_capability(
LOCAL_DATASETEDITOR_VIEW_CAPABILITY,
$PAGE->context)
) {
return;
}
$urlparams = array('courseid' => $courseid);
if ($PAGE->context->contextlevel == CONTEXT_MODULE) {
if ($PAGE->cm !== null) {
if (local_dataseteditor_applicable_module($PAGE->cm->modname)) {
$urlparams['cmid'] = $PAGE->context->instanceid;
}
}
}
/* Find the Course administration and Quiz administration blocks. */
$topnodes = array();
foreach ($settings->children as $node) {
if (
($node->key == 'courseadmin') ||
($node->text == get_string('pluginadministration', 'quiz'))
) {
$topnodes[] = $node;
}
}
foreach ($topnodes as $topnode) {
/* Find question bank node, if it exists. */
$questionbank = null;
foreach ($topnode->children as $node) {
if ($node->text == get_string('questionbank', 'question')) {
local_dataseteditor_add_navigation_nodes($node, $urlparams);
break;
}
}
}
}