Proyectos de Subversion Moodle

Rev

| Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
6 ariadna 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.
13
//
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/>.
16
 
17
/**
18
 * Update reactions and difficulty track settings on a course module then redirect.
19
 *
20
 * @package    block_point_view
21
 * @copyright  2023 Astor Bizard
22
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
23
 */
24
 
25
require_once(__DIR__ . '/../../../config.php');
26
 
27
require_login();
28
require_sesskey();
29
 
30
global $DB;
31
 
32
if (optional_param('submitbutton', false, PARAM_RAW) !== false
33
        && optional_param('cancel', false, PARAM_RAW) === false) {
34
    $blockinstanceid = required_param('blockinstanceid', PARAM_INT);
35
 
36
    $contextid = $DB->get_record('block_instances', [ 'id' => $blockinstanceid ])->parentcontextid;
37
    require_capability('moodle/block:edit', context::instance_by_id($contextid));
38
 
39
    $cmid = required_param('cmid', PARAM_INT);
40
 
41
    $blockrecord = $DB->get_record('block_instances', [ 'id' => $blockinstanceid, 'blockname' => 'point_view' ]);
42
 
43
    if ($blockrecord !== false) {
44
        $blockinstance = block_instance('point_view', $blockrecord);
45
        // Params are optional because some instances have reactions or tracks disabled.
46
        if (($reactions = optional_param('enablereactions', null, PARAM_BOOL)) !== null) {
47
            $blockinstance->config->{'moduleselectm' . $cmid} = $reactions ? $cmid : 0;
48
        }
49
        if (($track = optional_param('difficultytrack', null, PARAM_INT)) !== null) {
50
            $blockinstance->config->{'difficulty_' . $cmid} = $track;
51
        }
52
        $blockinstance->instance_config_commit();
53
    }
54
}
55
 
56
redirect(required_param('returnurl', PARAM_RAW));