Merge branch 'MDL-81397' of https://github.com/paulholden/moodle
[moodle.git] / analytics / classes / default_bulk_actions.php
blobdd4388ae30a7a3f03803d25b46cb68ba875b5530
1 <?php
2 // This file is part of Moodle - http://moodle.org/
3 //
4 // Moodle is free software: you can redistribute it and/or modify
5 // it under the terms of the GNU General Public License as published by
6 // the Free Software Foundation, either version 3 of the License, or
7 // (at your option) any later version.
8 //
9 // Moodle is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU General Public License for more details.
14 // You should have received a copy of the GNU General Public License
15 // along with Moodle. If not, see <http://www.gnu.org/licenses/>.
17 /**
18 * Default list of bulk actions to reuse across different targets as presets.
20 * @package core_analytics
21 * @copyright 2019 David Monllao {@link http://www.davidmonllao.com}
22 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
25 namespace core_analytics;
27 defined('MOODLE_INTERNAL') || die();
29 /**
30 * Default list of bulk actions to reuse across different targets as presets.
32 * @package core_analytics
33 * @copyright 2019 David Monllao {@link http://www.davidmonllao.com}
34 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
36 class default_bulk_actions {
38 /**
39 * Accepted prediction.
41 * @return \core_analytics\bulk_action
43 public static function accept() {
44 $attrs = [
45 'data-bulk-actionname' => prediction::ACTION_FIXED
46 ] + self::bulk_action_base_attrs();
48 return new bulk_action(prediction::ACTION_FIXED,
49 new \moodle_url(''), new \pix_icon('t/check', get_string('fixedack', 'analytics')),
50 get_string('fixedack', 'analytics'), false, $attrs, action::TYPE_POSITIVE);
53 /**
54 * The prediction is not applicable for this same (e.g. This student was unenrolled in the uni SIS).
56 * @return \core_analytics\bulk_action
58 public static function not_applicable() {
59 $attrs = [
60 'data-bulk-actionname' => prediction::ACTION_NOT_APPLICABLE
61 ] + self::bulk_action_base_attrs();
63 return new bulk_action(prediction::ACTION_NOT_APPLICABLE,
64 new \moodle_url(''), new \pix_icon('fp/cross', get_string('notapplicable', 'analytics'), 'theme'),
65 get_string('notapplicable', 'analytics'), false, $attrs, action::TYPE_NEUTRAL);
68 /**
69 * Incorrectly flagged prediction, useful for models based on data.
71 * @return \core_analytics\bulk_action
73 public static function incorrectly_flagged() {
74 $attrs = [
75 'data-bulk-actionname' => prediction::ACTION_INCORRECTLY_FLAGGED
76 ] + self::bulk_action_base_attrs();
78 return new bulk_action(prediction::ACTION_INCORRECTLY_FLAGGED,
79 new \moodle_url(''), new \pix_icon('i/incorrect', get_string('incorrectlyflagged', 'analytics')),
80 get_string('incorrectlyflagged', 'analytics'), false, $attrs, action::TYPE_NEGATIVE);
83 /**
84 * Useful prediction.
86 * @return \core_analytics\bulk_action
88 public static function useful() {
89 $attrs = [
90 'data-bulk-actionname' => prediction::ACTION_USEFUL
91 ] + self::bulk_action_base_attrs();
93 return new bulk_action(prediction::ACTION_USEFUL,
94 new \moodle_url(''), new \pix_icon('t/check', get_string('useful', 'analytics')),
95 get_string('useful', 'analytics'), false, $attrs, action::TYPE_POSITIVE);
99 /**
100 * Not useful prediction.
102 * @return \core_analytics\bulk_action
104 public static function not_useful() {
105 $attrs = [
106 'data-bulk-actionname' => prediction::ACTION_NOT_USEFUL
107 ] + self::bulk_action_base_attrs();
109 return new bulk_action(prediction::ACTION_NOT_USEFUL,
110 new \moodle_url(''), new \pix_icon('t/delete', get_string('notuseful', 'analytics')),
111 get_string('notuseful', 'analytics'), false, $attrs, action::TYPE_NEGATIVE);
115 * Common attributes for all the action renderables.
117 * @return array
119 private static function bulk_action_base_attrs() {
120 return [
121 'disabled' => 'disabled',
122 'data-toggle' => 'action',
123 'data-action' => 'toggle',