Proyectos de Subversion Moodle

Rev

| Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
1 efrain 1
YUI.add('moodle-question-chooser', function (Y, NAME) {
2
 
3
// This file is part of Moodle - http://moodle.org/
4
//
5
// Moodle is free software: you can redistribute it and/or modify
6
// it under the terms of the GNU General Public License as published by
7
// the Free Software Foundation, either version 3 of the License, or
8
// (at your option) any later version.
9
//
10
// Moodle is distributed in the hope that it will be useful,
11
// but WITHOUT ANY WARRANTY; without even the implied warranty of
12
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
// GNU General Public License for more details.
14
//
15
// You should have received a copy of the GNU General Public License
16
// along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
17
 
18
/**
19
 * JavaScript required by the question type chooser pop-up.
20
 *
21
 * @module moodle-question-chooser
22
 */
23
 
24
Y.log("The moodle-question-chooser module has been deprecated. " +
25
    "Please use moodle-qbank_editquestion-chooser instead.", 'moodle-core-notification', 'warn');
26
 
27
var SELECTORS = {
28
    CREATENEWQUESTION: 'div.createnewquestion',
29
    CREATENEWQUESTIONFORM: 'div.createnewquestion form',
30
    CHOOSERDIALOGUE: 'div.chooserdialoguebody',
31
    CHOOSERHEADER: 'div.choosertitle'
32
};
33
 
34
function Chooser() {
35
    Chooser.superclass.constructor.apply(this, arguments);
36
}
37
 
38
Y.extend(Chooser, M.core.chooserdialogue, {
39
    initializer: function() {
40
        Y.all('form').each(function(node) {
41
            if (/question\/addquestion\.php/.test(node.getAttribute('action'))) {
42
                node.on('submit', this.displayQuestionChooser, this);
43
            }
44
        }, this);
45
    },
46
    displayQuestionChooser: function(e) {
47
        var dialogue = Y.one(SELECTORS.CREATENEWQUESTION + ' ' + SELECTORS.CHOOSERDIALOGUE),
48
            header = Y.one(SELECTORS.CREATENEWQUESTION + ' ' + SELECTORS.CHOOSERHEADER);
49
 
50
        if (this.container === null) {
51
            // Setup the dialogue, and then prepare the chooser if it's not already been set up.
52
            this.setup_chooser_dialogue(dialogue, header, {});
53
            this.prepare_chooser();
54
        }
55
 
56
        // Update all of the hidden fields within the questionbank form.
57
        var originForm = e.target.ancestor('form', true),
58
            targetForm = this.container.one('form'),
59
            hiddenElements = originForm.all('input[type="hidden"]');
60
 
61
        targetForm.all('input.customfield').remove();
62
        hiddenElements.each(function(field) {
63
            targetForm.appendChild(field.cloneNode())
64
                .removeAttribute('id')
65
                .addClass('customfield');
66
        });
67
 
68
        // Display the chooser dialogue.
69
        this.display_chooser(e);
70
    }
71
}, {
72
    NAME: 'questionChooser'
73
});
74
 
75
M.question = M.question || {};
76
M.question.init_chooser = function(config) {
77
    return new Chooser(config);
78
};
79
 
80
 
81
}, '@VERSION@', {"requires": ["moodle-core-chooserdialogue"]});