mirror of
https://github.com/moodle/moodle.git
synced 2025-06-03 22:55:39 +02:00
MDL-72873 core_grades: Add general tertiary navigation
This commit is contained in:
parent
508fe3937e
commit
d1a0e4a95c
49
grade/classes/output/action_bar.php
Normal file
49
grade/classes/output/action_bar.php
Normal 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;
|
||||||
|
}
|
191
grade/classes/output/general_action_bar.php
Normal file
191
grade/classes/output/general_action_bar.php
Normal file
@ -0,0 +1,191 @@
|
|||||||
|
<?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 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 {
|
||||||
|
$urlselect = $this->get_action_selector();
|
||||||
|
|
||||||
|
if (is_null($urlselect)) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
|
return [
|
||||||
|
'generalnavselector' => $urlselect->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 \url_select|null The URL select object.
|
||||||
|
*/
|
||||||
|
private function get_action_selector(): ?\url_select {
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
return new \url_select($menu, $this->activeurl->out(false), null, 'gradesactionselect');
|
||||||
|
}
|
||||||
|
}
|
118
grade/lib.php
118
grade/lib.php
@ -25,6 +25,9 @@
|
|||||||
require_once($CFG->libdir . '/gradelib.php');
|
require_once($CFG->libdir . '/gradelib.php');
|
||||||
require_once($CFG->dirroot . '/grade/export/lib.php');
|
require_once($CFG->dirroot . '/grade/export/lib.php');
|
||||||
|
|
||||||
|
use \core_grades\output\action_bar;
|
||||||
|
use \core_grades\output\general_action_bar;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This class iterates over all users that are graded in a course.
|
* This class iterates over all users that are graded in a course.
|
||||||
* Returns detailed info about users and their grades.
|
* Returns detailed info about users and their grades.
|
||||||
@ -966,31 +969,29 @@ class grade_plugin_info {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Prints the page headers, breadcrumb trail, page heading, (optional) dropdown navigation menu and
|
* Prints the page headers, breadcrumb trail, page heading, (optional) navigation and for any gradebook page.
|
||||||
* (optional) navigation tabs for any gradebook page. All gradebook pages MUST use these functions
|
* All gradebook pages MUST use these functions in favour of the usual print_header(), print_header_simple(),
|
||||||
* in favour of the usual print_header(), print_header_simple(), print_heading() etc.
|
* print_heading() etc.
|
||||||
* !IMPORTANT! Use of tabs.php file in gradebook pages is forbidden unless tabs are switched off at
|
|
||||||
* the site level for the gradebook ($CFG->grade_navmethod = GRADE_NAVMETHOD_DROPDOWN).
|
|
||||||
*
|
*
|
||||||
* @param int $courseid Course id
|
* @param int $courseid Course id
|
||||||
* @param string $active_type The type of the current page (report, settings,
|
* @param string $active_type The type of the current page (report, settings,
|
||||||
* import, export, scales, outcomes, letters)
|
* import, export, scales, outcomes, letters)
|
||||||
* @param string $active_plugin The plugin of the current page (grader, fullview etc...)
|
* @param string|null $active_plugin The plugin of the current page (grader, fullview etc...)
|
||||||
* @param string $heading The heading of the page. Tries to guess if none is given
|
* @param string|bool $heading The heading of the page. Tries to guess if none is given
|
||||||
* @param boolean $return Whether to return (true) or echo (false) the HTML generated by this function
|
* @param boolean $return Whether to return (true) or echo (false) the HTML generated by this function
|
||||||
* @param string $bodytags Additional attributes that will be added to the <body> tag
|
* @param string|bool $buttons Additional buttons to display on the page
|
||||||
* @param string $buttons Additional buttons to display on the page
|
* @param boolean $shownavigation should the gradebook navigation be shown?
|
||||||
* @param boolean $shownavigation should the gradebook navigation drop down (or tabs) be shown?
|
* @param string|null $headerhelpidentifier The help string identifier if required.
|
||||||
* @param string $headerhelpidentifier The help string identifier if required.
|
* @param string|null $headerhelpcomponent The component for the help string.
|
||||||
* @param string $headerhelpcomponent The component for the help string.
|
* @param stdClass|null $user The user object for use with the user context header.
|
||||||
* @param stdClass $user The user object for use with the user context header.
|
* @param actionbar|null $actionbar The actions bar which will be displayed on the page if $shownavigation is set
|
||||||
*
|
* to true. If $actionbar is not explicitly defined, the general action bar
|
||||||
|
* (\core_grades\output\general_action_bar) will be used by default.
|
||||||
* @return string HTML code or nothing if $return == false
|
* @return string HTML code or nothing if $return == false
|
||||||
*/
|
*/
|
||||||
function print_grade_page_head($courseid, $active_type, $active_plugin=null,
|
function print_grade_page_head(int $courseid, string $active_type, ?string $active_plugin = null, $heading = false,
|
||||||
$heading = false, $return=false,
|
bool $return = false, $buttons = false, bool $shownavigation = true, ?string $headerhelpidentifier = null,
|
||||||
$buttons=false, $shownavigation=true, $headerhelpidentifier = null, $headerhelpcomponent = null,
|
?string $headerhelpcomponent = null, ?stdClass $user = null, ?action_bar $actionbar = null) {
|
||||||
$user = null) {
|
|
||||||
global $CFG, $OUTPUT, $PAGE;
|
global $CFG, $OUTPUT, $PAGE;
|
||||||
|
|
||||||
// Put a warning on all gradebook pages if the course has modules currently scheduled for background deletion.
|
// Put a warning on all gradebook pages if the course has modules currently scheduled for background deletion.
|
||||||
@ -1024,6 +1025,8 @@ function print_grade_page_head($courseid, $active_type, $active_plugin=null,
|
|||||||
}
|
}
|
||||||
$PAGE->set_title(get_string('grades') . ': ' . $stractive_type);
|
$PAGE->set_title(get_string('grades') . ': ' . $stractive_type);
|
||||||
$PAGE->set_heading($title);
|
$PAGE->set_heading($title);
|
||||||
|
$PAGE->set_secondary_active_tab('grades');
|
||||||
|
|
||||||
if ($buttons instanceof single_button) {
|
if ($buttons instanceof single_button) {
|
||||||
$buttons = $OUTPUT->render($buttons);
|
$buttons = $OUTPUT->render($buttons);
|
||||||
}
|
}
|
||||||
@ -1049,53 +1052,46 @@ function print_grade_page_head($courseid, $active_type, $active_plugin=null,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ($shownavigation) {
|
if ($shownavigation) {
|
||||||
$navselector = null;
|
$renderer = $PAGE->get_renderer('core_grades');
|
||||||
if ($courseid != SITEID &&
|
// If the navigation action bar is not explicitly defined, use the general (default) action bar.
|
||||||
($CFG->grade_navmethod == GRADE_NAVMETHOD_COMBO || $CFG->grade_navmethod == GRADE_NAVMETHOD_DROPDOWN)) {
|
if (!$actionbar) {
|
||||||
// It's absolutely essential that this grade plugin selector is shown after the user header. Just ask Fred.
|
$actionbar = new general_action_bar($PAGE->context, $PAGE->url, $active_type, $active_plugin);
|
||||||
$navselector = print_grade_plugin_selector($plugin_info, $active_type, $active_plugin, true);
|
|
||||||
if ($return) {
|
|
||||||
$returnval .= $navselector;
|
|
||||||
} else if (!isset($user)) {
|
|
||||||
echo $navselector;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$output = '';
|
|
||||||
// Add a help dialogue box if provided.
|
|
||||||
if (isset($headerhelpidentifier)) {
|
|
||||||
$output = $OUTPUT->heading_with_help($heading, $headerhelpidentifier, $headerhelpcomponent);
|
|
||||||
} else {
|
|
||||||
if (isset($user)) {
|
|
||||||
$output = $OUTPUT->context_header(
|
|
||||||
array(
|
|
||||||
'heading' => html_writer::link(new moodle_url('/user/view.php', array('id' => $user->id,
|
|
||||||
'course' => $courseid)), fullname($user)),
|
|
||||||
'user' => $user,
|
|
||||||
'usercontext' => context_user::instance($user->id)
|
|
||||||
), 2
|
|
||||||
) . $navselector;
|
|
||||||
} else {
|
|
||||||
$output = $OUTPUT->heading($heading);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($return) {
|
if ($return) {
|
||||||
$returnval .= $output;
|
$returnval .= $renderer->render_action_bar($actionbar);
|
||||||
} else {
|
} else {
|
||||||
echo $output;
|
echo $renderer->render_action_bar($actionbar);
|
||||||
}
|
|
||||||
|
|
||||||
if ($courseid != SITEID &&
|
|
||||||
($CFG->grade_navmethod == GRADE_NAVMETHOD_COMBO || $CFG->grade_navmethod == GRADE_NAVMETHOD_TABS)) {
|
|
||||||
$returnval .= grade_print_tabs($active_type, $active_plugin, $plugin_info, $return);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$returnval .= print_natural_aggregation_upgrade_notice($courseid,
|
$output = '';
|
||||||
context_course::instance($courseid),
|
// Add a help dialogue box if provided.
|
||||||
$PAGE->url,
|
if (isset($headerhelpidentifier)) {
|
||||||
$return);
|
$output = $OUTPUT->heading_with_help($heading, $headerhelpidentifier, $headerhelpcomponent);
|
||||||
|
} else {
|
||||||
|
if (isset($user)) {
|
||||||
|
$output = $OUTPUT->context_header(
|
||||||
|
array(
|
||||||
|
'heading' => html_writer::link(new moodle_url('/user/view.php', array('id' => $user->id,
|
||||||
|
'course' => $courseid)), fullname($user)),
|
||||||
|
'user' => $user,
|
||||||
|
'usercontext' => context_user::instance($user->id)
|
||||||
|
), 2
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
$output = $OUTPUT->heading($heading);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($return) {
|
||||||
|
$returnval .= $output;
|
||||||
|
} else {
|
||||||
|
echo $output;
|
||||||
|
}
|
||||||
|
|
||||||
|
$returnval .= print_natural_aggregation_upgrade_notice($courseid, context_course::instance($courseid), $PAGE->url,
|
||||||
|
$return);
|
||||||
|
|
||||||
if ($return) {
|
if ($return) {
|
||||||
return $returnval;
|
return $returnval;
|
||||||
|
40
grade/renderer.php
Normal file
40
grade/renderer.php
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
<?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/>.
|
||||||
|
|
||||||
|
defined('MOODLE_INTERNAL') || die;
|
||||||
|
|
||||||
|
use \core_grades\output\action_bar;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Renderer class for the grade 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 core_grades_renderer extends plugin_renderer_base {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Renders the action bar for a given page.
|
||||||
|
*
|
||||||
|
* @param action_bar $actionbar
|
||||||
|
* @return string The HTML output
|
||||||
|
*/
|
||||||
|
public function render_action_bar(action_bar $actionbar): string {
|
||||||
|
$data = $actionbar->export_for_template($this);
|
||||||
|
return $this->render_from_template($actionbar->get_template(), $data);
|
||||||
|
}
|
||||||
|
}
|
@ -108,7 +108,11 @@ if ($table->is_downloading()) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Print header.
|
// Print header.
|
||||||
print_grade_page_head($COURSE->id, 'report', 'history', get_string('pluginname', 'gradereport_history'), false, '');
|
$actionbar = new \core_grades\output\general_action_bar($context,
|
||||||
|
new moodle_url('/grade/report/history/index.php', ['id' => $courseid]), 'report', 'history');
|
||||||
|
print_grade_page_head($COURSE->id, 'report', 'history', get_string('pluginname',
|
||||||
|
'gradereport_history'), false, false, true, null, null,
|
||||||
|
null, $actionbar);
|
||||||
$mform->display();
|
$mform->display();
|
||||||
|
|
||||||
if ($showreport) {
|
if ($showreport) {
|
||||||
|
@ -90,6 +90,9 @@ $USER->grade_last_report[$course->id] = 'overview';
|
|||||||
// First make sure we have proper final grades.
|
// First make sure we have proper final grades.
|
||||||
grade_regrade_final_grades_if_required($course);
|
grade_regrade_final_grades_if_required($course);
|
||||||
|
|
||||||
|
$actionbar = new \core_grades\output\general_action_bar($context,
|
||||||
|
new moodle_url('/grade/report/overview/index.php', ['id' => $courseid]), 'report', 'overview');
|
||||||
|
|
||||||
if (has_capability('moodle/grade:viewall', $context) && $courseid != SITEID) {
|
if (has_capability('moodle/grade:viewall', $context) && $courseid != SITEID) {
|
||||||
// Please note this would be extremely slow if we wanted to implement this properly for all teachers.
|
// Please note this would be extremely slow if we wanted to implement this properly for all teachers.
|
||||||
$groupmode = groups_get_course_groupmode($course); // Groups are being used
|
$groupmode = groups_get_course_groupmode($course); // Groups are being used
|
||||||
@ -110,8 +113,8 @@ if (has_capability('moodle/grade:viewall', $context) && $courseid != SITEID) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (empty($userid)) {
|
if (empty($userid)) {
|
||||||
// Add tabs
|
print_grade_page_head($courseid, 'report', 'overview', false, false, false,
|
||||||
print_grade_page_head($courseid, 'report', 'overview');
|
true, null, null, null, $actionbar);
|
||||||
|
|
||||||
groups_print_course_menu($course, $gpr->get_return_url('index.php?id='.$courseid, array('userid'=>0)));
|
groups_print_course_menu($course, $gpr->get_return_url('index.php?id='.$courseid, array('userid'=>0)));
|
||||||
|
|
||||||
@ -124,7 +127,8 @@ if (has_capability('moodle/grade:viewall', $context) && $courseid != SITEID) {
|
|||||||
} else { // Only show one user's report
|
} else { // Only show one user's report
|
||||||
$report = new grade_report_overview($userid, $gpr, $context);
|
$report = new grade_report_overview($userid, $gpr, $context);
|
||||||
print_grade_page_head($courseid, 'report', 'overview', get_string('pluginname', 'gradereport_overview') .
|
print_grade_page_head($courseid, 'report', 'overview', get_string('pluginname', 'gradereport_overview') .
|
||||||
' - ' . fullname($report->user), false, false, true, null, null, $report->user);
|
' - ' . fullname($report->user), false, false, true, null, null,
|
||||||
|
$report->user, $actionbar);
|
||||||
groups_print_course_menu($course, $gpr->get_return_url('index.php?id='.$courseid, array('userid'=>0)));
|
groups_print_course_menu($course, $gpr->get_return_url('index.php?id='.$courseid, array('userid'=>0)));
|
||||||
|
|
||||||
if ($user_selector) {
|
if ($user_selector) {
|
||||||
@ -170,7 +174,8 @@ if (has_capability('moodle/grade:viewall', $context) && $courseid != SITEID) {
|
|||||||
}
|
}
|
||||||
} else { // We have a course context. We must be navigating from the gradebook.
|
} else { // We have a course context. We must be navigating from the gradebook.
|
||||||
print_grade_page_head($courseid, 'report', 'overview', get_string('pluginname', 'gradereport_overview')
|
print_grade_page_head($courseid, 'report', 'overview', get_string('pluginname', 'gradereport_overview')
|
||||||
. ' - ' . fullname($report->user));
|
. ' - ' . fullname($report->user), false, false, true, null, null,
|
||||||
|
$report->user, $actionbar);
|
||||||
if ($report->fill_table()) {
|
if ($report->fill_table()) {
|
||||||
echo '<br />' . $report->print_table(true);
|
echo '<br />' . $report->print_table(true);
|
||||||
}
|
}
|
||||||
|
@ -130,10 +130,16 @@ if ($data = data_submitted()) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
$PAGE->set_pagelayout('report');
|
$PAGE->set_pagelayout('report');
|
||||||
|
|
||||||
|
$actionbar = new \core_grades\output\general_action_bar($context,
|
||||||
|
new moodle_url('/grade/report/singleview/index.php', ['id' => $courseid]), 'report', 'singleview');
|
||||||
|
|
||||||
if ($itemtype == 'user') {
|
if ($itemtype == 'user') {
|
||||||
print_grade_page_head($course->id, 'report', 'singleview', $reportname, false, false, true, null, null, $report->screen->item);
|
print_grade_page_head($course->id, 'report', 'singleview', $reportname, false, false,
|
||||||
|
true, null, null, $report->screen->item, $actionbar);
|
||||||
} else {
|
} else {
|
||||||
print_grade_page_head($course->id, 'report', 'singleview', $reportname);
|
print_grade_page_head($course->id, 'report', 'singleview', $reportname, false, false,
|
||||||
|
true, null, null, null, $actionbar);
|
||||||
}
|
}
|
||||||
|
|
||||||
$graderrightnav = $graderleftnav = null;
|
$graderrightnav = $graderleftnav = null;
|
||||||
|
55
grade/templates/general_action_bar.mustache
Normal file
55
grade/templates/general_action_bar.mustache
Normal file
@ -0,0 +1,55 @@
|
|||||||
|
{{!
|
||||||
|
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/>.
|
||||||
|
}}
|
||||||
|
{{!
|
||||||
|
@template core_grades/general_action_bar
|
||||||
|
|
||||||
|
The general actions bar for navigating through the gradebook pages.
|
||||||
|
|
||||||
|
Context variables required for this template:
|
||||||
|
* generalnavselector - The data object containing the required properties to render the general navigation selector.
|
||||||
|
|
||||||
|
Example context (json):
|
||||||
|
{
|
||||||
|
"generalnavselector": {
|
||||||
|
"id": "url_select12345",
|
||||||
|
"action": "https://example.com/get",
|
||||||
|
"classes": "urlselect",
|
||||||
|
"formid": "gradesactionselect",
|
||||||
|
"sesskey": "sesskey",
|
||||||
|
"label": "",
|
||||||
|
"helpicon": false,
|
||||||
|
"showbutton": null,
|
||||||
|
"options": [{
|
||||||
|
"name": "View", "isgroup": true, "options":
|
||||||
|
[
|
||||||
|
{"name": "Grader report", "isgroup": false, "value": "/grade/report/grader/index.php"}
|
||||||
|
]},
|
||||||
|
{"name": "Setup", "isgroup": true, "options":
|
||||||
|
[
|
||||||
|
{"name": "Gradebook setup", "isgroup": false, "value": "/grade/edit/tree/index.php"}
|
||||||
|
]}],
|
||||||
|
"disabled": false,
|
||||||
|
"title": null
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}}
|
||||||
|
<div class="container-fluid mb-4">
|
||||||
|
<div class="row">
|
||||||
|
<div class="d-flex">
|
||||||
|
{{#generalnavselector}}
|
||||||
|
{{>core/url_select}}
|
||||||
|
{{/generalnavselector}}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
@ -737,6 +737,7 @@ $string['setgradeletters'] = 'Set grade letters';
|
|||||||
$string['setpreferences'] = 'Set preferences';
|
$string['setpreferences'] = 'Set preferences';
|
||||||
$string['setting'] = 'Setting';
|
$string['setting'] = 'Setting';
|
||||||
$string['settings'] = 'Settings';
|
$string['settings'] = 'Settings';
|
||||||
|
$string['setup'] = 'Setup';
|
||||||
$string['setweights'] = 'Set weights';
|
$string['setweights'] = 'Set weights';
|
||||||
$string['showanalysisicon'] = 'Show grade analysis icon';
|
$string['showanalysisicon'] = 'Show grade analysis icon';
|
||||||
$string['showanalysisicon_desc'] = 'Whether to show grade analysis icon by default. If the activity module supports it, the grade analysis icon links to a page with more detailed explanation of the grade and how it was obtained.';
|
$string['showanalysisicon_desc'] = 'Whether to show grade analysis icon by default. If the activity module supports it, the grade analysis icon links to a page with more detailed explanation of the grade and how it was obtained.';
|
||||||
|
Loading…
x
Reference in New Issue
Block a user