Proyectos de Subversion Moodle

Rev

| Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
1 efrain 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
 * Class for exporting a question icon from an stdClass.
19
 *
20
 * @package    core_question
21
 * @copyright  2018 Ryan Wyllie <ryan@moodle.com>
22
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
23
 */
24
namespace core_question\external;
25
defined('MOODLE_INTERNAL') || die();
26
 
27
require_once($CFG->dirroot . '/question/engine/bank.php');
28
 
29
/**
30
 * Class for exporting a question from an stdClass.
31
 *
32
 * @copyright  2018 Ryan Wyllie <ryan@moodle.com>
33
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
34
 */
35
class question_icon_exporter extends \core\external\exporter {
36
 
37
    /**
38
     * Constructor.
39
     *
40
     * @param \stdClass $question
41
     * @param array $related The related data.
42
     */
43
    public function __construct(\stdClass $question, $related = []) {
44
        $qtype = \question_bank::get_qtype($question->qtype, false);
45
 
46
        parent::__construct((object) [
47
            'key' => 'icon',
48
            'component' => $qtype->plugin_name(),
49
            'alttext' => $qtype->local_name()
50
        ], $related);
51
    }
52
 
53
    /**
54
     * Set the moodle context as a required related object.
55
     *
56
     * @return array Required related objects.
57
     */
58
    protected static function define_related() {
59
        return ['context' => '\\context'];
60
    }
61
 
62
    /**
63
     * Return the list of properties.
64
     *
65
     * @return array
66
     */
67
    protected static function define_properties() {
68
        return [
69
            'key' => ['type' => PARAM_TEXT],
70
            'component' => ['type' => PARAM_COMPONENT],
71
            'alttext' => ['type' => PARAM_TEXT],
72
        ];
73
    }
74
}