1
+ YUI . add ( 'moodle-qtype_wq-question_chooser_qbank' , function ( Y , NAME ) {
2
+
3
+ // Namespace for Wiris Quizzes.
4
+ M . qtype_wq = M . qtype_wq || { } ;
5
+ // Question chooser class.
6
+ M . qtype_wq . question_chooser = {
7
+ /**
8
+ * Array with all the real Wiris Quizzes questions.
9
+ * */
10
+ wirisquestions : null ,
11
+ /**
12
+ * Start point.
13
+ * */
14
+ init : function ( ) {
15
+ this . wirisSection ( ) ;
16
+ } ,
17
+ /**
18
+ * Moves all Wiris Quizzes questions under node_before and populates the array
19
+ * this.wirisquestions.
20
+ * @param {node } nodeBefore - Previous node.
21
+ */
22
+ moveWirisQuestions : function ( nodeBefore ) {
23
+ var wirisdivs = [ ] ;
24
+ Y . all ( 'div.option' ) . each ( function ( node ) {
25
+ var input = node . one ( 'input' ) ;
26
+ if (
27
+ input &&
28
+ input . getAttribute ( 'value' ) &&
29
+ input . getAttribute ( 'value' ) . indexOf ( 'wiris' ) !== - 1
30
+ ) {
31
+ nodeBefore . insert ( node , 'after' ) ;
32
+ nodeBefore = node ;
33
+ wirisdivs . push ( node ) ;
34
+ }
35
+ } ) ;
36
+ this . wirisquestions = wirisdivs ;
37
+ } ,
38
+ /**
39
+ * Unused function. Join all Wiris Quizzes questions in a section after
40
+ * QUESTIONS and before OTHER.
41
+ * */
42
+ wirisSection : function ( ) {
43
+ var label = Y . one ( 'label[for=qtype_qtype_wq]' ) ;
44
+ label = label ? label : Y . one ( 'label[for=item_qtype_wq]' ) ;
45
+ if ( label ) {
46
+ // Convert qtype option into section title and move to the bottom.
47
+ var wq = label . ancestor ( 'div' ) ;
48
+ var name = wq . one ( 'span.typename' ) . remove ( false ) ;
49
+ wq . one ( 'label' ) . remove ( true ) ;
50
+ wq . append ( name ) . addClass ( 'moduletypetitle' ) ;
51
+ var container = wq . ancestor ( ) ;
52
+ wq . remove ( ) ;
53
+ container . insertBefore ( wq , container . one ( 'div.separator' ) ) ;
54
+ container . insertBefore ( Y . Node . create ( '<div class="separator"/>' ) , wq ) ;
55
+ // Move all Wiris qtypes under title.
56
+ this . moveWirisQuestions ( wq ) ;
57
+ }
58
+ }
59
+ } ;
60
+
61
+
62
+ } , '@VERSION@' , { "requires" : [ "moodle-qbank_editquestion-chooser" ] } ) ;
0 commit comments