Proyectos de Subversion Moodle

Rev

Rev 1 | | Comparar con el anterior | 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;
11 efrain 33
        modalConfig.removeOnClose = true;
1 efrain 34
 
35
        // Apply question modal configuration.
36
        this.setContextId(modalConfig.contextId);
37
        this.setAddOnPageId(modalConfig.addOnPage);
38
 
39
        // Apply standard configuration.
40
        super.configure(modalConfig);
41
    }
42
 
43
    constructor(root) {
44
        super(root);
45
 
46
        this.contextId = null;
47
        this.addOnPageId = null;
48
    }
49
 
50
    /**
51
     * Save the Moodle context id that the question bank is being
52
     * rendered in.
53
     *
54
     * @method setContextId
55
     * @param {Number} id
56
     */
57
    setContextId(id) {
58
        this.contextId = id;
59
    }
60
 
61
    /**
62
     * Retrieve the saved Moodle context id.
63
     *
64
     * @method getContextId
65
     * @return {Number}
66
     */
67
    getContextId() {
68
        return this.contextId;
69
    }
70
 
71
    /**
72
     * Set the id of the page that the question should be added to
73
     * when the user clicks the add to quiz link.
74
     *
75
     * @method setAddOnPageId
76
     * @param {Number} id
77
     */
78
    setAddOnPageId(id) {
79
        this.addOnPageId = id;
80
    }
81
 
82
    /**
83
     * Returns the saved page id for the question to be added to.
84
     *
85
     * @method getAddOnPageId
86
     * @return {Number}
87
     */
88
    getAddOnPageId() {
89
        return this.addOnPageId;
90
    }
91
 
92
}