first commit

This commit is contained in:
CHIEFSOFT\ameye
2024-09-30 18:11:26 -04:00
commit e592ca6823
27270 changed files with 5002257 additions and 0 deletions
+49
View File
@@ -0,0 +1,49 @@
<?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/>.
namespace core_grades\output;
use templatable;
use renderable;
/**
* The base class for the action bar in the gradebook pages.
*
* @package core_grades
* @copyright 2021 Mihail Geshoski <mihail@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
abstract class action_bar implements templatable, renderable {
/** @var \context $context The context object. */
protected $context;
/**
* The class constructor.
*
* @param \context $context The context object.
*/
public function __construct(\context $context) {
$this->context = $context;
}
/**
* Returns the template for the actions bar.
*
* @return string
*/
abstract public function get_template(): string;
}
@@ -0,0 +1,65 @@
<?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/>.
namespace core_grades\output;
use moodle_url;
/**
* Renderable class for the action bar elements in the gradebook course outcomes page.
*
* @package core_grades
* @copyright 2021 Mihail Geshoski <mihail@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class course_outcomes_action_bar extends action_bar {
/**
* Returns the template for the action bar.
*
* @return string
*/
public function get_template(): string {
return 'core_grades/course_outcomes_action_bar';
}
/**
* Export the data for the mustache template.
*
* @param \renderer_base $output renderer to be used to render the action bar elements.
* @return array
*/
public function export_for_template(\renderer_base $output): array {
if ($this->context->contextlevel !== CONTEXT_COURSE) {
return [];
}
$courseid = $this->context->instanceid;
// Get the data used to output the general navigation selector.
$generalnavselector = new general_action_bar($this->context,
new moodle_url('/grade/edit/outcome/course.php', ['id' => $courseid]), 'outcome', 'course');
$data = $generalnavselector->export_for_template($output);
if (has_capability('moodle/grade:manageoutcomes', $this->context)) {
// Add a button to the action bar with a link to the 'manage outcomes' page.
$manageoutcomeslink = new moodle_url('/grade/edit/outcome/index.php', ['id' => $courseid]);
$manageoutcomesbutton = new \single_button($manageoutcomeslink, get_string('manageoutcomes', 'grades'),
'get', \single_button::BUTTON_PRIMARY);
$data['manageoutcomesbutton'] = $manageoutcomesbutton->export_for_template($output);
}
return $data;
}
}
+103
View File
@@ -0,0 +1,103 @@
<?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/>.
namespace core_grades\output;
use moodle_url;
/**
* Renderable class for the action bar elements in the gradebook export pages.
*
* @package core_grades
* @copyright 2021 Mihail Geshoski <mihail@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class export_action_bar extends action_bar {
/** @var string $activeplugin The plugin of the current export grades page (xml, ods, ...). */
protected $activeplugin;
/**
* The class constructor.
*
* @param \context $context The context object.
* @param null $unused This parameter has been deprecated since 4.1 and should not be used anymore.
* @param string $activeplugin The plugin of the current export grades page (xml, ods, ...).
*/
public function __construct(\context $context, $unused, string $activeplugin) {
if ($unused !== null) {
debugging('Deprecated argument passed to ' . __FUNCTION__, DEBUG_DEVELOPER);
}
parent::__construct($context);
$this->activeplugin = $activeplugin;
}
/**
* Returns the template for the action bar.
*
* @return string
*/
public function get_template(): string {
return 'core_grades/export_action_bar';
}
/**
* Export the data for the mustache template.
*
* @param \renderer_base $output renderer to be used to render the action bar elements.
* @return array
*/
public function export_for_template(\renderer_base $output): array {
if ($this->context->contextlevel !== CONTEXT_COURSE) {
return [];
}
$courseid = $this->context->instanceid;
// Get the data used to output the general navigation selector.
$generalnavselector = new general_action_bar($this->context,
new moodle_url('/grade/export/index.php', ['id' => $courseid]), 'export', $this->activeplugin);
$data = $generalnavselector->export_for_template($output);
// Get all grades export plugins. If there isn't any available export plugins there is no need to create and
// display the exports navigation selector menu. Therefore, return only the current data.
if (!$exports = \grade_helper::get_plugins_export($courseid)) {
return $data;
}
// If exports key management is enabled, always display this item at the end of the list.
if (array_key_exists('keymanager', $exports)) {
$keymanager = $exports['keymanager'];
unset($exports['keymanager']);
$exports['keymanager'] = $keymanager;
}
$exportsmenu = [];
$exportactiveurl = null;
// Generate the data for the exports navigation selector menu.
foreach ($exports as $export) {
$exportsmenu[$export->link->out()] = $export->string;
if ($export->id == $this->activeplugin) {
$exportactiveurl = $export->link->out();
}
}
// This navigation selector menu will contain the links to all available grade export plugin pages.
$exportsurlselect = new \core\output\select_menu('exportas', $exportsmenu, $exportactiveurl);
$exportsurlselect->set_label(get_string('exportas', 'grades'));
$data['exportselector'] = $exportsurlselect->export_for_template($output);
return $data;
}
}
@@ -0,0 +1,62 @@
<?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/>.
namespace core_grades\output;
use moodle_url;
/**
* Renderable class for the action bar elements in the gradebook exports key manager page.
*
* @package core_grades
* @copyright 2021 Mihail Geshoski <mihail@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class export_key_manager_action_bar extends action_bar {
/**
* Returns the template for the action bar.
*
* @return string
*/
public function get_template(): string {
return 'core_grades/export_key_manager_action_bar';
}
/**
* Export the data for the mustache template.
*
* @param \renderer_base $output renderer to be used to render the action bar elements.
* @return array
*/
public function export_for_template(\renderer_base $output): array {
if ($this->context->contextlevel !== CONTEXT_COURSE) {
return [];
}
$courseid = $this->context->instanceid;
// Get the data used to output the general navigation selector and exports navigation selector.
$exportnavselectors = new export_action_bar($this->context, null, 'keymanager');
$data = $exportnavselectors->export_for_template($output);
// Add a button to the action bar with a link to the 'add user key' page.
$adduserkeylink = new moodle_url('/grade/export/key.php', ['courseid' => $courseid]);
$adduserkeybutton = new \single_button($adduserkeylink, get_string('adduserkey', 'userkey'),
'get', \single_button::BUTTON_PRIMARY);
$data['adduserkeybutton'] = $adduserkeybutton->export_for_template($output);
return $data;
}
}
@@ -0,0 +1,73 @@
<?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/>.
namespace core_grades\output;
use moodle_url;
/**
* Renderable class for the action bar elements in the gradebook publish export page.
*
* @package core_grades
* @copyright 2021 Mihail Geshoski <mihail@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class export_publish_action_bar extends action_bar {
/** @var string $activeplugin The plugin of the current export grades page (xml, ods, ...). */
protected $activeplugin;
/**
* The class constructor.
*
* @param \context $context The context object.
* @param string $activeplugin The plugin of the current export grades page (xml, ods, ...).
*/
public function __construct(\context $context, string $activeplugin) {
parent::__construct($context);
$this->activeplugin = $activeplugin;
}
/**
* Returns the template for the action bar.
*
* @return string
*/
public function get_template(): string {
return 'core_grades/export_publish_action_bar';
}
/**
* Export the data for the mustache template.
*
* @param \renderer_base $output renderer to be used to render the action bar elements.
* @return array
*/
public function export_for_template(\renderer_base $output): array {
if ($this->context->contextlevel !== CONTEXT_COURSE) {
return [];
}
$courseid = $this->context->instanceid;
// Add a back button to the action bar.
$backlink = new moodle_url("/grade/export/{$this->activeplugin}/index.php", ['id' => $courseid]);
$backbutton = new \single_button($backlink, get_string('back'), 'get');
return [
'backbutton' => $backbutton->export_for_template($output)
];
}
}
+195
View File
@@ -0,0 +1,195 @@
<?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/>.
namespace core_grades\output;
use moodle_url;
use core\output\select_menu;
/**
* Renderable class for the general action bar in the gradebook pages.
*
* This class is responsible for rendering the general navigation select menu in the gradebook pages.
*
* @package core_grades
* @copyright 2021 Mihail Geshoski <mihail@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class general_action_bar extends action_bar {
/** @var moodle_url $activeurl The URL that should be set as active in the URL selector element. */
protected $activeurl;
/**
* The type of the current gradebook page (report, settings, import, export, scales, outcomes, letters).
*
* @var string $activetype
*/
protected $activetype;
/** @var string $activeplugin The plugin of the current gradebook page (grader, fullview, ...). */
protected $activeplugin;
/**
* The class constructor.
*
* @param \context $context The context object.
* @param moodle_url $activeurl The URL that should be set as active in the URL selector element.
* @param string $activetype The type of the current gradebook page (report, settings, import, export, scales,
* outcomes, letters).
* @param string $activeplugin The plugin of the current gradebook page (grader, fullview, ...).
*/
public function __construct(\context $context, moodle_url $activeurl, string $activetype, string $activeplugin) {
parent::__construct($context);
$this->activeurl = $activeurl;
$this->activetype = $activetype;
$this->activeplugin = $activeplugin;
}
/**
* Export the data for the mustache template.
*
* @param \renderer_base $output renderer to be used to render the action bar elements.
* @return array
*/
public function export_for_template(\renderer_base $output): array {
$selectmenu = $this->get_action_selector();
if (is_null($selectmenu)) {
return [];
}
return [
'generalnavselector' => $selectmenu->export_for_template($output),
];
}
/**
* Returns the template for the action bar.
*
* @return string
*/
public function get_template(): string {
return 'core_grades/general_action_bar';
}
/**
* Returns the URL selector object.
*
* @return \select_menu|null The URL select object.
*/
private function get_action_selector(): ?select_menu {
if ($this->context->contextlevel !== CONTEXT_COURSE) {
return null;
}
$courseid = $this->context->instanceid;
$plugininfo = grade_get_plugin_info($courseid, $this->activetype, $this->activeplugin);
$menu = [];
$viewgroup = [];
$setupgroup = [];
$moregroup = [];
foreach ($plugininfo as $plugintype => $plugins) {
// Skip if the plugintype value is 'strings'. This particular item only returns an array of strings
// which we do not need.
if ($plugintype == 'strings') {
continue;
}
// If $plugins is actually the definition of a child-less parent link.
if (!empty($plugins->id)) {
$string = $plugins->string;
if (!empty($plugininfo[$this->activetype]->parent)) {
$string = $plugininfo[$this->activetype]->parent->string;
}
$menu[$plugins->link->out(false)] = $string;
continue;
}
foreach ($plugins as $key => $plugin) {
// Depending on the plugin type, include the plugin to the appropriate item group for the URL selector
// element.
switch ($plugintype) {
case 'report':
$viewgroup[$plugin->link->out(false)] = $plugin->string;
break;
case 'settings':
$setupgroup[$plugin->link->out(false)] = $plugin->string;
break;
case 'scale':
// We only need the link to the 'view scales' page, otherwise skip and continue to the next
// plugin.
if ($key !== 'view') {
continue 2;
}
$moregroup[$plugin->link->out(false)] = get_string('scales');
break;
case 'outcome':
// We only need the link to the 'outcomes used in course' page, otherwise skip and continue to
// the next plugin.
if ($key !== 'course') {
continue 2;
}
$moregroup[$plugin->link->out(false)] = get_string('outcomes', 'grades');
break;
case 'letter':
// We only need the link to the 'view grade letters' page, otherwise skip and continue to the
// next plugin.
if ($key !== 'view') {
continue 2;
}
$moregroup[$plugin->link->out(false)] = get_string('gradeletters', 'grades');
break;
case 'import':
$link = new moodle_url('/grade/import/index.php', ['id' => $courseid]);
// If the link to the grade import options is already added to the group, skip and continue to
// the next plugin.
if (array_key_exists($link->out(false), $moregroup)) {
continue 2;
}
$moregroup[$link->out(false)] = get_string('import', 'grades');
break;
case 'export':
$link = new moodle_url('/grade/export/index.php', ['id' => $courseid]);
// If the link to the grade export options is already added to the group, skip and continue to
// the next plugin.
if (array_key_exists($link->out(false), $moregroup)) {
continue 2;
}
$moregroup[$link->out(false)] = get_string('export', 'grades');
break;
}
}
}
if (!empty($viewgroup)) {
$menu[][get_string('view')] = $viewgroup;
}
if (!empty($setupgroup)) {
$menu[][get_string('setup', 'grades')] = $setupgroup;
}
if (!empty($moregroup)) {
$menu[][get_string('moremenu')] = $moregroup;
}
$selectmenu = new select_menu('gradesactionselect', $menu, $this->activeurl->out(false));
$selectmenu->set_label(get_string('gradebooknavigationmenu', 'grades'), ['class' => 'sr-only']);
return $selectmenu;
}
}
@@ -0,0 +1,61 @@
<?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/>.
namespace core_grades\output;
use moodle_url;
/**
* Renderable class for the action bar elements in the grade letters page.
*
* @package core_grades
* @copyright 2021 Mihail Geshoski <mihail@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class grade_letters_action_bar extends action_bar {
/**
* Returns the template for the action bar.
*
* @return string
*/
public function get_template(): string {
return 'core_grades/grade_letters_action_bar';
}
/**
* Export the data for the mustache template.
*
* @param \renderer_base $output renderer to be used to render the action bar elements.
* @return array
*/
public function export_for_template(\renderer_base $output): array {
$data = [];
// If in the course context, we should display the general navigation selector in gradebook.
if ($this->context->contextlevel === CONTEXT_COURSE) {
// Get the data used to output the general navigation selector.
$generalnavselector = new general_action_bar($this->context, new moodle_url('/grade/edit/letter/index.php',
['id' => $this->context->id]), 'letter', 'view');
$data = $generalnavselector->export_for_template($output);
}
// Add a button to the action bar with a link to the 'edit grade letters' page.
$editbuttonlink = new moodle_url('/grade/edit/letter/index.php', ['id' => $this->context->id, 'edit' => 1]);
$editbutton = new \single_button($editbuttonlink, get_string('edit'), 'get', \single_button::BUTTON_PRIMARY);
$data['editbutton'] = $editbutton->export_for_template($output);
return $data;
}
}
@@ -0,0 +1,108 @@
<?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/>.
namespace core_grades\output;
use moodle_url;
use html_writer;
/**
* Renderable class for the action bar elements in the gradebook setup pages.
*
* @package core_grades
* @copyright 2021 Mihail Geshoski <mihail@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class gradebook_setup_action_bar extends action_bar {
/**
* Returns the template for the action bar.
*
* @return string
*/
public function get_template(): string {
return 'core_grades/gradebook_setup_action_bar';
}
/**
* Export the data for the mustache template.
*
* @param \renderer_base $output renderer to be used to render the action bar elements.
* @return array
*/
public function export_for_template(\renderer_base $output): array {
global $CFG;
if ($this->context->contextlevel !== CONTEXT_COURSE) {
return [];
}
$courseid = $this->context->instanceid;
// Get the data used to output the general navigation selector.
$generalnavselector = new general_action_bar($this->context,
new moodle_url('/grade/edit/tree/index.php', ['id' => $courseid]), 'settings', 'setup');
$data = $generalnavselector->export_for_template($output);
$actions = [];
$additemurl = new moodle_url('#');
// Add a button to the action bar dropdown with a link to the 'add grade item' modal.
$actions[] = new \action_menu_link_secondary(
$additemurl,
null,
get_string('additem', 'grades'),
[
'data-courseid' => $courseid,
'data-itemid' => -1,
'data-trigger' => 'add-item-form',
'data-gprplugin' => 'tree',
]
);
// If outcomes are enabled, add a button to the action bar dropdown with a link to the 'add outcome item' modal.
if (!empty($CFG->enableoutcomes) && count(\grade_outcome::fetch_all_available($courseid)) > 0) {
// Add a button to the action bar dropdown with a link to the 'add outcome item' modal.
$actions[] = new \action_menu_link_secondary(
$additemurl,
null,
get_string('addoutcomeitem', 'grades'),
[
'data-courseid' => $courseid,
'data-itemid' => -1,
'data-trigger' => 'add-outcome-form',
'data-gprplugin' => 'tree',
]
);
}
// Add a button to the action bar dropdown with a link to the 'add category' modal.
$actions[] = new \action_menu_link_secondary(
$additemurl,
null,
get_string('addcategory', 'grades'),
[
'data-courseid' => $courseid,
'data-category' => -1,
'data-trigger' => 'add-category-form',
'data-gprplugin' => 'tree',
]
);
$addmenu = new \action_menu($actions);
$addmenu->set_menu_trigger(get_string('add'), 'btn font-weight-bold');
$data['addmenu'] = $addmenu->export_for_template($output);
return $data;
}
}
+103
View File
@@ -0,0 +1,103 @@
<?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/>.
namespace core_grades\output;
use moodle_url;
/**
* Renderable class for the action bar elements in the gradebook import pages.
*
* @package core_grades
* @copyright 2021 Mihail Geshoski <mihail@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class import_action_bar extends action_bar {
/** @var string $activeplugin The plugin of the current import grades page (xml, csv, ...). */
protected $activeplugin;
/**
* The class constructor.
*
* @param \context $context The context object.
* @param null $unused This parameter has been deprecated since 4.1 and should not be used anymore.
* @param string $activeplugin The plugin of the current import grades page (xml, csv, ...).
*/
public function __construct(\context $context, $unused, string $activeplugin) {
if ($unused !== null) {
debugging('Deprecated argument passed to ' . __FUNCTION__, DEBUG_DEVELOPER);
}
parent::__construct($context);
$this->activeplugin = $activeplugin;
}
/**
* Returns the template for the action bar.
*
* @return string
*/
public function get_template(): string {
return 'core_grades/import_action_bar';
}
/**
* Export the data for the mustache template.
*
* @param \renderer_base $output renderer to be used to render the action bar elements.
* @return array
*/
public function export_for_template(\renderer_base $output): array {
if ($this->context->contextlevel !== CONTEXT_COURSE) {
return [];
}
$courseid = $this->context->instanceid;
// Get the data used to output the general navigation selector.
$generalnavselector = new general_action_bar($this->context,
new moodle_url('/grade/import/index.php', ['id' => $courseid]), 'import', $this->activeplugin);
$data = $generalnavselector->export_for_template($output);
// Get all grades import plugins. If there isn't any available import plugins there is no need to create and
// display the imports navigation selector menu. Therefore, return only the current data.
if (!$imports = \grade_helper::get_plugins_import($courseid)) {
return $data;
}
// If imports key management is enabled, always display this item at the end of the list.
if (array_key_exists('keymanager', $imports)) {
$keymanager = $imports['keymanager'];
unset($imports['keymanager']);
$imports['keymanager'] = $keymanager;
}
$importsmenu = [];
$importactiveurl = null;
// Generate the data for the imports navigation selector menu.
foreach ($imports as $import) {
$importsmenu[$import->link->out()] = $import->string;
if ($import->id == $this->activeplugin) {
$importactiveurl = $import->link->out();
}
}
// This navigation selector menu will contain the links to all available grade export plugin pages.
$importsurlselect = new \core\output\select_menu('importas', $importsmenu, $importactiveurl);
$importsurlselect->set_label(get_string('importas', 'grades'));
$data['importselector'] = $importsurlselect->export_for_template($output);
return $data;
}
}
@@ -0,0 +1,62 @@
<?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/>.
namespace core_grades\output;
use moodle_url;
/**
* Renderable class for the action bar elements in the gradebook import key manager page.
*
* @package core_grades
* @copyright 2021 Mihail Geshoski <mihail@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class import_key_manager_action_bar extends action_bar {
/**
* Returns the template for the action bar.
*
* @return string
*/
public function get_template(): string {
return 'core_grades/import_key_manager_action_bar';
}
/**
* Export the data for the mustache template.
*
* @param \renderer_base $output renderer to be used to render the action bar elements.
* @return array
*/
public function export_for_template(\renderer_base $output): array {
if ($this->context->contextlevel !== CONTEXT_COURSE) {
return [];
}
$courseid = $this->context->instanceid;
// Get the data used to output the general navigation selector and imports navigation selector.
$importnavselectors = new import_action_bar($this->context, null, 'keymanager');
$data = $importnavselectors->export_for_template($output);
// Add a button to the action bar with a link to the 'add user key' page.
$adduserkeylink = new moodle_url('/grade/import/key.php', ['courseid' => $courseid]);
$adduserkeybutton = new \single_button($adduserkeylink, get_string('adduserkey', 'userkey'),
'get', \single_button::BUTTON_PRIMARY);
$data['adduserkeybutton'] = $adduserkeybutton->export_for_template($output);
return $data;
}
}
@@ -0,0 +1,95 @@
<?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/>.
namespace core_grades\output;
use moodle_url;
/**
* Renderable class for the action bar elements in the manage outcomes page.
*
* @package core_grades
* @copyright 2021 Mihail Geshoski <mihail@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class manage_outcomes_action_bar extends action_bar {
/** @var bool $hasoutcomes Whether there are existing outcomes. */
protected $hasoutcomes;
/**
* The class constructor.
*
* @param \context $context The context object.
* @param bool $hasoutcomes Whether there are existing outcomes.
*/
public function __construct(\context $context, bool $hasoutcomes) {
parent::__construct($context);
$this->hasoutcomes = $hasoutcomes;
}
/**
* Returns the template for the action bar.
*
* @return string
*/
public function get_template(): string {
return 'core_grades/manage_outcomes_action_bar';
}
/**
* Export the data for the mustache template.
*
* @param \renderer_base $output renderer to be used to render the action bar elements.
* @return array
*/
public function export_for_template(\renderer_base $output): array {
$data = [];
$courseid = 0;
// Display the following buttons only if the user is in course gradebook.
if ($this->context->contextlevel === CONTEXT_COURSE) {
$courseid = $this->context->instanceid;
// Add a button to the action bar with a link to the 'course outcomes' page.
$backlink = new moodle_url('/grade/edit/outcome/course.php', ['id' => $courseid]);
$backbutton = new \single_button($backlink, get_string('back'), 'get');
$data['backbutton'] = $backbutton->export_for_template($output);
// Add a button to the action bar with a link to the 'import outcomes' page. The import outcomes
// functionality is currently only available in the course context.
$importoutcomeslink = new moodle_url('/grade/edit/outcome/import.php', ['courseid' => $courseid]);
$importoutcomesbutton = new \single_button($importoutcomeslink, get_string('importoutcomes', 'grades'),
'get');
$data['importoutcomesbutton'] = $importoutcomesbutton->export_for_template($output);
}
// Add a button to the action bar with a link to the 'add new outcome' page.
$addoutcomelink = new moodle_url('/grade/edit/outcome/edit.php', ['courseid' => $courseid]);
$addoutcomebutton = new \single_button($addoutcomelink, get_string('outcomecreate', 'grades'),
'get', \single_button::BUTTON_PRIMARY);
$data['addoutcomebutton'] = $addoutcomebutton->export_for_template($output);
if ($this->hasoutcomes) {
// Add a button to the action bar which enables export of all existing outcomes.
$exportoutcomeslink = new moodle_url('/grade/edit/outcome/export.php',
['id' => $courseid, 'sesskey' => sesskey()]);
$exportoutcomesbutton = new \single_button($exportoutcomeslink, get_string('exportalloutcomes', 'grades'),
'get');
$data['exportoutcomesbutton'] = $exportoutcomesbutton->export_for_template($output);
}
return $data;
}
}
@@ -0,0 +1,64 @@
<?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/>.
namespace core_grades\output;
use moodle_url;
/**
* Renderable class for the action bar elements in the gradebook scales page.
*
* @package core_grades
* @copyright 2021 Mihail Geshoski <mihail@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class scales_action_bar extends action_bar {
/**
* Returns the template for the action bar.
*
* @return string
*/
public function get_template(): string {
return 'core_grades/scales_action_bar';
}
/**
* Export the data for the mustache template.
*
* @param \renderer_base $output renderer to be used to render the action bar elements.
* @return array
*/
public function export_for_template(\renderer_base $output): array {
$data = [];
$courseid = 0;
// If in the course context, we should display the general navigation selector in gradebook.
if ($this->context->contextlevel === CONTEXT_COURSE) {
$courseid = $this->context->instanceid;
// Get the data used to output the general navigation selector.
$generalnavselector = new general_action_bar($this->context,
new moodle_url('/grade/edit/scale/index.php', ['id' => $courseid]), 'scale', 'scale');
$data = $generalnavselector->export_for_template($output);
}
// Add a button to the action bar with a link to the 'add new scale' page.
$addnewscalelink = new moodle_url('/grade/edit/scale/edit.php', ['courseid' => $courseid]);
$addnewscalebutton = new \single_button($addnewscalelink, get_string('scalescustomcreate'),
'get', \single_button::BUTTON_PRIMARY);
$data['addnewscalebutton'] = $addnewscalebutton->export_for_template($output);
return $data;
}
}