mirror of
https://github.com/moodle/moodle.git
synced 2025-04-22 08:55:15 +02:00
MDL-45758 tool_monitor: Peer review changes
This commit is contained in:
parent
758793d889
commit
75cae53b7b
@ -165,6 +165,7 @@ class eventlist {
|
||||
public static function get_all_eventlist($withoutcomponent = false) {
|
||||
if ($withoutcomponent) {
|
||||
$return = array_merge(self::get_core_eventlist(), self::get_non_core_eventlist($withoutcomponent));
|
||||
array_multisort($return, SORT_NATURAL);
|
||||
} else {
|
||||
$return = array_merge(array('core' => self::get_core_eventlist()),
|
||||
self::get_non_core_eventlist($withoutcomponent = false));
|
||||
|
@ -1,104 +0,0 @@
|
||||
<?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/>.
|
||||
|
||||
/**
|
||||
* Common methods that are needed both in rule and subscription class.
|
||||
*
|
||||
* @package tool_monitor
|
||||
* @copyright 2014 onwards Ankit Agarwal <ankit.agrr@gmail.com>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
namespace tool_monitor;
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
require_once($CFG->dirroot . '/lib/moodlelib.php');
|
||||
|
||||
/**
|
||||
* Common methods that are needed both in rule and subscription class.
|
||||
*
|
||||
* @since Moodle 2.8
|
||||
* @package tool_monitor
|
||||
* @copyright 2014 onwards Ankit Agarwal <ankit.agrr@gmail.com>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
trait helper_trait {
|
||||
|
||||
/**
|
||||
* Method to get event name.
|
||||
*
|
||||
* @return string
|
||||
* @throws \coding_exception
|
||||
*/
|
||||
public function get_event_name() {
|
||||
$eventclass = $this->eventname;
|
||||
if (class_exists($eventclass)) {
|
||||
return $eventclass::get_name();
|
||||
}
|
||||
return get_string('eventnotfound', 'tool_monitor');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get filter description.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function get_filters_description() {
|
||||
$a = new \stdClass();
|
||||
$a->freq = $this->frequency;
|
||||
$mins = $this->timewindow / MINSECS; // Convert seconds to minutes.
|
||||
$a->mins = $mins;
|
||||
return get_string('freqdesc', 'tool_monitor', $a);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get properly formatted name of the rule associated.
|
||||
*
|
||||
* @param \context $context context where this name would be displayed.
|
||||
*
|
||||
* @return string Formatted name of the rule.
|
||||
*/
|
||||
public function get_name(\context $context) {
|
||||
return format_text($this->name, FORMAT_HTML, array('context' => $context));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get properly formatted description of the rule associated.
|
||||
*
|
||||
* @param \context $context context where this description would be displayed.
|
||||
*
|
||||
* @return string Formatted description of the rule.
|
||||
*/
|
||||
public function get_description(\context $context) {
|
||||
return format_text($this->description, $this->descriptionformat, array('context' => $context));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get name of the plugin associated with this rule
|
||||
*
|
||||
* @return string Plugin name.
|
||||
*/
|
||||
public function get_plugin_name() {
|
||||
if ($this->plugin === 'core') {
|
||||
$string = get_string('core', 'tool_monitor');
|
||||
} else if (get_string_manager()->string_exists('pluginname', $this->plugin)) {
|
||||
$string = get_string('pluginname', $this->plugin);
|
||||
} else {
|
||||
$string = $this->plugin;
|
||||
}
|
||||
return $string;
|
||||
}
|
||||
}
|
@ -157,11 +157,11 @@ class renderable extends \table_sql implements \renderable {
|
||||
if ($this->hassystemcap || ($rule->courseid !== 0)) {
|
||||
// There might be site rules which the user can not manage.
|
||||
$editurl = new \moodle_url($CFG->wwwroot. '/admin/tool/monitor/edit.php', array('ruleid' => $rule->id,
|
||||
'courseid' => $rule->courseid));
|
||||
'courseid' => $rule->courseid, 'sesskey' => sesskey()));
|
||||
$copyurl = new \moodle_url($CFG->wwwroot. '/admin/tool/monitor/managerules.php',
|
||||
array('ruleid' => $rule->id, 'action' => 'copy', 'courseid' => $this->courseid));
|
||||
array('ruleid' => $rule->id, 'action' => 'copy', 'courseid' => $this->courseid, 'sesskey' => sesskey()));
|
||||
$deleteurl = new \moodle_url($CFG->wwwroot. '/admin/tool/monitor/managerules.php', array('ruleid' => $rule->id,
|
||||
'action' => 'delete', 'courseid' => $rule->courseid));
|
||||
'action' => 'delete', 'courseid' => $rule->courseid, 'sesskey' => sesskey()));
|
||||
|
||||
$icon = $OUTPUT->render(new \pix_icon('t/edit', get_string('editrule', 'tool_monitor')));
|
||||
$manage .= \html_writer::link($editurl, $icon, array('class' => 'action-icon'));
|
||||
|
@ -124,7 +124,7 @@ class subs extends \table_sql implements \renderable {
|
||||
|
||||
$a = $sub->get_name($this->context);
|
||||
$deleteurl = new \moodle_url($CFG->wwwroot. '/admin/tool/monitor/index.php', array('subscriptionid' => $sub->id,
|
||||
'action' => 'unsubscribe', 'courseid' => $this->courseid));
|
||||
'action' => 'unsubscribe', 'courseid' => $this->courseid, 'sesskey' => sesskey()));
|
||||
$action = new \component_action('click', 'M.util.show_confirm_dialog', array('message' => get_string('subareyousure',
|
||||
'tool_monitor', $a)));
|
||||
$icon = $OUTPUT->action_link($deleteurl,
|
||||
|
@ -35,7 +35,6 @@ defined('MOODLE_INTERNAL') || die();
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class rule {
|
||||
use helper_trait;
|
||||
|
||||
/**
|
||||
* @var \stdClass The rule object form database.
|
||||
@ -118,7 +117,7 @@ class rule {
|
||||
}
|
||||
}
|
||||
$url = new \moodle_url($CFG->wwwroot. '/admin/tool/monitor/index.php', array('courseid' => $courseid, 'ruleid' => $this->id,
|
||||
'action' => 'subscribe'));
|
||||
'action' => 'subscribe', 'sesskey' => sesskey()));
|
||||
return new \single_select($url, 'cmid', $options, '', $nothing = array('' => 'choosedots'));
|
||||
}
|
||||
|
||||
@ -180,4 +179,69 @@ class rule {
|
||||
}
|
||||
throw new \coding_exception('Invalid call to get_mform_set_data.');
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get event name.
|
||||
*
|
||||
* @return string
|
||||
* @throws \coding_exception
|
||||
*/
|
||||
public function get_event_name() {
|
||||
$eventclass = $this->eventname;
|
||||
if (class_exists($eventclass)) {
|
||||
return $eventclass::get_name();
|
||||
}
|
||||
return get_string('eventnotfound', 'tool_monitor');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get filter description.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function get_filters_description() {
|
||||
$a = new \stdClass();
|
||||
$a->freq = $this->frequency;
|
||||
$mins = $this->timewindow / MINSECS; // Convert seconds to minutes.
|
||||
$a->mins = $mins;
|
||||
return get_string('freqdesc', 'tool_monitor', $a);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get properly formatted name of the rule associated.
|
||||
*
|
||||
* @param \context $context context where this name would be displayed.
|
||||
*
|
||||
* @return string Formatted name of the rule.
|
||||
*/
|
||||
public function get_name(\context $context) {
|
||||
return format_text($this->name, FORMAT_HTML, array('context' => $context));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get properly formatted description of the rule associated.
|
||||
*
|
||||
* @param \context $context context where this description would be displayed.
|
||||
*
|
||||
* @return string Formatted description of the rule.
|
||||
*/
|
||||
public function get_description(\context $context) {
|
||||
return format_text($this->description, $this->descriptionformat, array('context' => $context));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get name of the plugin associated with this rule
|
||||
*
|
||||
* @return string Plugin name.
|
||||
*/
|
||||
public function get_plugin_name() {
|
||||
if ($this->plugin === 'core') {
|
||||
$string = get_string('core', 'tool_monitor');
|
||||
} else if (get_string_manager()->string_exists('pluginname', $this->plugin)) {
|
||||
$string = get_string('pluginname', $this->plugin);
|
||||
} else {
|
||||
$string = $this->plugin;
|
||||
}
|
||||
return $string;
|
||||
}
|
||||
}
|
||||
|
@ -35,7 +35,6 @@ defined('MOODLE_INTERNAL') || die();
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class subscription {
|
||||
use helper_trait;
|
||||
/**
|
||||
* @var \stdClass
|
||||
*/
|
||||
@ -93,4 +92,69 @@ class subscription {
|
||||
|
||||
return $string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get event name.
|
||||
*
|
||||
* @return string
|
||||
* @throws \coding_exception
|
||||
*/
|
||||
public function get_event_name() {
|
||||
$eventclass = $this->eventname;
|
||||
if (class_exists($eventclass)) {
|
||||
return $eventclass::get_name();
|
||||
}
|
||||
return get_string('eventnotfound', 'tool_monitor');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get filter description.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function get_filters_description() {
|
||||
$a = new \stdClass();
|
||||
$a->freq = $this->frequency;
|
||||
$mins = $this->timewindow / MINSECS; // Convert seconds to minutes.
|
||||
$a->mins = $mins;
|
||||
return get_string('freqdesc', 'tool_monitor', $a);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get properly formatted name of the rule associated.
|
||||
*
|
||||
* @param \context $context context where this name would be displayed.
|
||||
*
|
||||
* @return string Formatted name of the rule.
|
||||
*/
|
||||
public function get_name(\context $context) {
|
||||
return format_text($this->name, FORMAT_HTML, array('context' => $context));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get properly formatted description of the rule associated.
|
||||
*
|
||||
* @param \context $context context where this description would be displayed.
|
||||
*
|
||||
* @return string Formatted description of the rule.
|
||||
*/
|
||||
public function get_description(\context $context) {
|
||||
return format_text($this->description, $this->descriptionformat, array('context' => $context));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get name of the plugin associated with this rule
|
||||
*
|
||||
* @return string Plugin name.
|
||||
*/
|
||||
public function get_plugin_name() {
|
||||
if ($this->plugin === 'core') {
|
||||
$string = get_string('core', 'tool_monitor');
|
||||
} else if (get_string_manager()->string_exists('pluginname', $this->plugin)) {
|
||||
$string = get_string('pluginname', $this->plugin);
|
||||
} else {
|
||||
$string = $this->plugin;
|
||||
}
|
||||
return $string;
|
||||
}
|
||||
}
|
||||
|
@ -68,6 +68,7 @@ echo $OUTPUT->header();
|
||||
|
||||
// Create/delete subscription if needed.
|
||||
if (!empty($action)) {
|
||||
require_sesskey();
|
||||
switch ($action) {
|
||||
case 'subscribe' :
|
||||
$rule = \tool_monitor\rule_manager::get_rule($ruleid);
|
||||
@ -104,7 +105,9 @@ if (!empty($totalrules)) {
|
||||
if (has_capability('tool/monitor:managerules', $context)) {
|
||||
$manageurl = new moodle_url("/admin/tool/monitor/managerules.php", array('courseid' => $courseid));
|
||||
$a = html_writer::link($manageurl, get_string('managerules', 'tool_monitor'));
|
||||
echo html_writer::tag('span', get_string('manageruleslink', 'tool_monitor', $a));
|
||||
$link = " ";
|
||||
$link .= html_writer::tag('span', get_string('manageruleslink', 'tool_monitor', $a));
|
||||
echo $link;
|
||||
}
|
||||
}
|
||||
echo $OUTPUT->footer();
|
||||
|
@ -49,7 +49,7 @@ $string['moduleinstance'] = 'Module instance';
|
||||
$string['manage'] = 'Manage';
|
||||
$string['managesubscriptions'] = 'Manage subscriptions';
|
||||
$string['managerules'] = 'Manage rules';
|
||||
$string['messageheader'] = 'Customize your notification message';
|
||||
$string['messageheader'] = 'Customise your notification message';
|
||||
$string['messageprovider:notification'] = 'Notifications of rule subscriptions';
|
||||
$string['messagetemplate'] = 'Message template';
|
||||
$string['messagetemplate_help'] = 'This is the content of the message that will be sent to users, when the given conditions of the rule are met. You are allowed to use following templates in this.
|
||||
|
@ -66,6 +66,7 @@ echo $OUTPUT->header();
|
||||
|
||||
// Copy/delete rule if needed.
|
||||
if (!empty($action) && $ruleid) {
|
||||
require_sesskey();
|
||||
$rule = \tool_monitor\rule_manager::get_rule($ruleid);
|
||||
if ($rule->can_manage_rule()) {
|
||||
switch ($action) {
|
||||
|
@ -3773,12 +3773,6 @@ class settings_navigation extends navigation_node {
|
||||
}
|
||||
}
|
||||
|
||||
// Let admin tools hook into course navigation.
|
||||
$tools = get_plugin_list_with_function('tool', 'extend_navigation_course', 'lib.php');
|
||||
foreach ($tools as $toolfunction) {
|
||||
$toolfunction($coursenode, $course, $coursecontext);
|
||||
}
|
||||
|
||||
// Add view grade report is permitted
|
||||
$reportavailable = false;
|
||||
if (has_capability('moodle/grade:viewall', $coursecontext)) {
|
||||
@ -3897,6 +3891,13 @@ class settings_navigation extends navigation_node {
|
||||
$switchroles->add($name, $url, self::TYPE_SETTING, null, $key, new pix_icon('i/switchrole', ''));
|
||||
}
|
||||
}
|
||||
|
||||
// Let admin tools hook into course navigation.
|
||||
$tools = get_plugin_list_with_function('tool', 'extend_navigation_course', 'lib.php');
|
||||
foreach ($tools as $toolfunction) {
|
||||
$toolfunction($coursenode, $course, $coursecontext);
|
||||
}
|
||||
|
||||
// Return we are done
|
||||
return $coursenode;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user