Proyectos de Subversion Moodle

Rev

Rev 1 | Mostrar el archivo completo | | | Autoría | Ultima modificación | Ver Log |

Rev 1 Rev 1441
Línea 29... Línea 29...
29
 * @package    report_insights
29
 * @package    report_insights
30
 * @copyright  2017 David Monllao {@link http://www.davidmonllao.com}
30
 * @copyright  2017 David Monllao {@link http://www.davidmonllao.com}
31
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
31
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
32
 */
32
 */
33
class external extends external_api {
33
class external extends external_api {
34
 
-
 
35
    /**
-
 
36
     * set_notuseful_prediction parameters.
-
 
37
     *
-
 
38
     * @return external_function_parameters
-
 
39
     * @since  Moodle 3.4
-
 
40
     */
-
 
41
    public static function set_notuseful_prediction_parameters() {
-
 
42
        return new external_function_parameters(
-
 
43
            array(
-
 
44
                'predictionid' => new external_value(PARAM_INT, 'The prediction id', VALUE_REQUIRED)
-
 
45
            )
-
 
46
        );
-
 
47
    }
-
 
48
 
-
 
49
    /**
-
 
50
     * Flags a prediction as fixed so no need to display it any more.
-
 
51
     *
-
 
52
     * @param int $predictionid
-
 
53
     * @return array an array of warnings and a boolean
-
 
54
     * @since  Moodle 3.4
-
 
55
     */
-
 
56
    public static function set_notuseful_prediction($predictionid) {
-
 
57
 
-
 
58
        $params = self::validate_parameters(self::set_notuseful_prediction_parameters(), array('predictionid' => $predictionid));
-
 
59
 
-
 
60
        list($model, $prediction, $context) = self::validate_prediction($params['predictionid']);
-
 
61
 
-
 
62
        $prediction->action_executed(\core_analytics\prediction::ACTION_NOT_USEFUL, $model->get_target());
-
 
63
 
-
 
64
        $success = true;
-
 
65
        return array('success' => $success, 'warnings' => array());
-
 
66
    }
-
 
67
 
-
 
68
    /**
-
 
69
     * set_notuseful_prediction return
-
 
70
     *
-
 
71
     * @return \core_external\external_description
-
 
72
     * @since  Moodle 3.4
-
 
73
     */
-
 
74
    public static function set_notuseful_prediction_returns() {
-
 
75
        return new external_single_structure(
-
 
76
            array(
-
 
77
                'success' => new external_value(PARAM_BOOL, 'True if the prediction was successfully flagged as not useful.'),
-
 
78
                'warnings' => new external_warnings(),
-
 
79
            )
-
 
80
        );
-
 
81
    }
-
 
82
 
-
 
83
    /**
-
 
84
     * Deprecated in favour of action_executed.
-
 
85
     */
-
 
86
    public static function set_notuseful_prediction_is_deprecated() {
-
 
87
        return true;
-
 
88
    }
-
 
89
 
-
 
90
    /**
-
 
91
     * set_fixed_prediction parameters.
-
 
92
     *
-
 
93
     * @return external_function_parameters
-
 
94
     * @since  Moodle 3.4
-
 
95
     */
-
 
96
    public static function set_fixed_prediction_parameters() {
-
 
97
        return new external_function_parameters(
-
 
98
            array(
-
 
99
                'predictionid' => new external_value(PARAM_INT, 'The prediction id', VALUE_REQUIRED)
-
 
100
            )
-
 
101
        );
-
 
102
    }
-
 
103
 
-
 
104
    /**
-
 
105
     * Flags a prediction as fixed so no need to display it any more.
-
 
106
     *
-
 
107
     * @param int $predictionid
-
 
108
     * @return array an array of warnings and a boolean
-
 
109
     * @since  Moodle 3.4
-
 
110
     */
-
 
111
    public static function set_fixed_prediction($predictionid) {
-
 
112
 
-
 
113
        $params = self::validate_parameters(self::set_fixed_prediction_parameters(), array('predictionid' => $predictionid));
-
 
114
 
-
 
115
        list($model, $prediction, $context) = self::validate_prediction($params['predictionid']);
-
 
116
 
-
 
117
        $prediction->action_executed(\core_analytics\prediction::ACTION_FIXED, $model->get_target());
-
 
118
 
-
 
119
        $success = true;
-
 
120
        return array('success' => $success, 'warnings' => array());
-
 
121
    }
-
 
122
 
-
 
123
    /**
-
 
124
     * set_fixed_prediction return
-
 
125
     *
-
 
126
     * @return \core_external\external_description
-
 
127
     * @since  Moodle 3.4
-
 
128
     */
-
 
129
    public static function set_fixed_prediction_returns() {
-
 
130
        return new external_single_structure(
-
 
131
            array(
-
 
132
                'success' => new external_value(PARAM_BOOL, 'True if the prediction was successfully flagged as fixed.'),
-
 
133
                'warnings' => new external_warnings(),
-
 
134
            )
-
 
135
        );
-
 
136
    }
-
 
137
 
-
 
138
    /**
-
 
139
     * Deprecated in favour of action_executed.
-
 
140
     */
-
 
141
    public static function set_fixed_prediction_is_deprecated() {
-
 
142
        return true;
-
 
143
    }
-
 
144
 
-
 
145
    /**
34
    /**
146
     * action_executed parameters.
35
     * action_executed parameters.
147
     *
36
     *
148
     * @return external_function_parameters
37
     * @return external_function_parameters
149
     * @since  Moodle 3.8
38
     * @since  Moodle 3.8