mirror of
https://github.com/moodle/moodle.git
synced 2025-03-14 04:30:15 +01:00
MDL-66074 mod_forum: Relocate the grader button
Also adding capability checks to the button.
This commit is contained in:
parent
aa04b722f3
commit
1d709d7678
@ -72,9 +72,6 @@
|
||||
{{/forum.capabilities.selfenrol}}
|
||||
{{/forum.capabilities.create}}
|
||||
|
||||
{{!TODO Add capability check}}
|
||||
<a class="btn btn-primary" href="" data-grade-action="launch">{{#str}}gradeusers, forum{{/str}}</a>
|
||||
|
||||
{{#state.hasdiscussions}}
|
||||
{{$discussion_top_pagination}}
|
||||
{{{ pagination }}}
|
||||
|
41
mod/forum/templates/grades/grade_button.mustache
Normal file
41
mod/forum/templates/grades/grade_button.mustache
Normal file
@ -0,0 +1,41 @@
|
||||
{{!
|
||||
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 mod_forum/grades/grade_button
|
||||
|
||||
Template which defines a forum post for sending in a single-post HTML email.
|
||||
|
||||
Classes required for JS:
|
||||
* none
|
||||
|
||||
Data attributes required for JS:
|
||||
* none
|
||||
|
||||
Example context (json):
|
||||
{
|
||||
}
|
||||
}}
|
||||
<a class="btn btn-primary" href="" data-grade-action="launch" {{!
|
||||
}}data-contextid="{{contextid}}" {{!
|
||||
}}data-cmid="{{cmid}}" {{!
|
||||
}}data-name="{{name}}" {{!
|
||||
}}data-group="{{groupid}}" {{!
|
||||
}}data-grading-component="{{gradingcomponent}}" {{!
|
||||
}}data-grading-component-subtype="{{gradingcomponentsubtype}}" {{!
|
||||
}}data-gradable-itemtype="forum" {{!
|
||||
}}{{#firstgradeduserid}}data-initialuserid="{{firstgradeduserid}}" {{/firstgradeduserid}}{{!
|
||||
}}>{{#str}}gradeusers, forum{{/str}}</a>
|
@ -22,6 +22,8 @@
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
use mod_forum\grades\forum_gradeitem;
|
||||
|
||||
require_once('../../config.php');
|
||||
|
||||
$managerfactory = mod_forum\local\container::get_manager_factory();
|
||||
@ -88,9 +90,27 @@ $PAGE->set_context($forum->get_context());
|
||||
$PAGE->set_title($forum->get_name());
|
||||
$PAGE->add_body_class('forumtype-' . $forum->get_type() . ' reset-style');
|
||||
$PAGE->set_heading($course->fullname);
|
||||
$PAGE->set_button(forum_search_form($course, $search));
|
||||
$PAGE->set_include_region_main_settings_in_header_actions(true);
|
||||
|
||||
$buttons = [];
|
||||
if ($capabilitymanager->can_grade($USER)) {
|
||||
$forumgradeitem = forum_gradeitem::load_from_forum_entity($forum);
|
||||
if ($forumgradeitem->is_grading_enabled()) {
|
||||
$groupid = groups_get_activity_group($cm, true) ?: null;
|
||||
$gradeobj = (object) [
|
||||
'contextid' => $forum->get_context()->id,
|
||||
'cmid' => $cmid,
|
||||
'name' => $forum->get_name(),
|
||||
'groupid' => $groupid,
|
||||
'gradingcomponent' => $forumgradeitem->get_grading_component_name(),
|
||||
'gradingcomponentsubtype' => $forumgradeitem->get_grading_component_subtype(),
|
||||
];
|
||||
$buttons[] = $OUTPUT->render_from_template('mod_forum/grades/grade_button', $gradeobj);
|
||||
}
|
||||
}
|
||||
$buttons[] = forum_search_form($course, $search);
|
||||
$PAGE->set_button(implode('', $buttons));
|
||||
|
||||
if ($istypesingle && $displaymode == FORUM_MODE_MODERN) {
|
||||
$PAGE->add_body_class('modern-display-mode reset-style');
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user