Proyectos de Subversion Moodle

Rev

Ir a la última revisión | | Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
1 efrain 1
// This file is part of Moodle - http://moodle.org/
2
//
3
// Moodle is free software: you can redistribute it and/or modify
4
// it under the terms of the GNU General Public License as published by
5
// the Free Software Foundation, either version 3 of the License, or
6
// (at your option) any later version.
7
//
8
// Moodle is distributed in the hope that it will be useful,
9
// but WITHOUT ANY WARRANTY; without even the implied warranty of
10
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11
// GNU General Public License for more details.
12
//
13
// You should have received a copy of the GNU General Public License
14
// along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
15
 
16
/**
17
 * Contain the logic for the add random question modal.
18
 *
19
 * @module     mod_quiz/add_question_modal
20
 * @copyright  2023 Andrew Lyons <andrew@nicols.co.uk>
21
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
22
 */
23
 
24
import Modal from 'core/modal';
25
 
26
export default class AddQuestionModal extends Modal {
27
    configure(modalConfig) {
28
        // Add question modals are always large.
29
        modalConfig.large = true;
30
 
31
        // Always show on creation.
32
        modalConfig.show = true;
33
 
34
        // Apply question modal configuration.
35
        this.setContextId(modalConfig.contextId);
36
        this.setAddOnPageId(modalConfig.addOnPage);
37
 
38
        // Apply standard configuration.
39
        super.configure(modalConfig);
40
    }
41
 
42
    constructor(root) {
43
        super(root);
44
 
45
        this.contextId = null;
46
        this.addOnPageId = null;
47
    }
48
 
49
    /**
50
     * Save the Moodle context id that the question bank is being
51
     * rendered in.
52
     *
53
     * @method setContextId
54
     * @param {Number} id
55
     */
56
    setContextId(id) {
57
        this.contextId = id;
58
    }
59
 
60
    /**
61
     * Retrieve the saved Moodle context id.
62
     *
63
     * @method getContextId
64
     * @return {Number}
65
     */
66
    getContextId() {
67
        return this.contextId;
68
    }
69
 
70
    /**
71
     * Set the id of the page that the question should be added to
72
     * when the user clicks the add to quiz link.
73
     *
74
     * @method setAddOnPageId
75
     * @param {Number} id
76
     */
77
    setAddOnPageId(id) {
78
        this.addOnPageId = id;
79
    }
80
 
81
    /**
82
     * Returns the saved page id for the question to be added to.
83
     *
84
     * @method getAddOnPageId
85
     * @return {Number}
86
     */
87
    getAddOnPageId() {
88
        return this.addOnPageId;
89
    }
90
 
91
}