MDL-50246 quiz: Add selected questions to quiz btn disabled 0 selected
authorLuca Bösch <luca.boesch@bfh.ch>
Fri, 15 Dec 2017 16:20:30 +0000 (17:20 +0100)
committerLuca Bösch <luca.boesch@bfh.ch>
Fri, 22 Dec 2017 08:25:12 +0000 (09:25 +0100)
mod/quiz/tests/behat/editing_add.feature
question/yui/build/moodle-question-qbankmanager/moodle-question-qbankmanager-debug.js
question/yui/build/moodle-question-qbankmanager/moodle-question-qbankmanager-min.js
question/yui/build/moodle-question-qbankmanager/moodle-question-qbankmanager.js
question/yui/src/qbankmanager/js/qbankmanager.js

index 46fe193..5b1b9a5 100644 (file)
@@ -195,6 +195,9 @@ Feature: Edit quiz page - adding things
     And I navigate to "Edit quiz" in current page administration
     And I open the "last" add to quiz menu
     And I follow "from question bank"
+    Then the "Add selected questions to the quiz" "button" should be disabled
+    And I click on "Essay 03" "checkbox"
+    Then the "Add selected questions to the quiz" "button" should be enabled
     And I click on "Add to quiz" "link" in the "Essay 03" "table_row"
     Then I should see "Editing quiz: Quiz 1"
     And I should see "Essay 03" on quiz page "1"
index 21bdba7..bad45e0 100644 (file)
Binary files a/question/yui/build/moodle-question-qbankmanager/moodle-question-qbankmanager-debug.js and b/question/yui/build/moodle-question-qbankmanager/moodle-question-qbankmanager-debug.js differ
index 7bbc3f3..2cbf9fb 100644 (file)
Binary files a/question/yui/build/moodle-question-qbankmanager/moodle-question-qbankmanager-min.js and b/question/yui/build/moodle-question-qbankmanager/moodle-question-qbankmanager-min.js differ
index 21bdba7..bad45e0 100644 (file)
Binary files a/question/yui/build/moodle-question-qbankmanager/moodle-question-qbankmanager.js and b/question/yui/build/moodle-question-qbankmanager/moodle-question-qbankmanager.js differ
index 7b8e58f..c4058ad 100644 (file)
@@ -43,6 +43,15 @@ var manager = {
      */
     _header: null,
 
+    /**
+     * A reference to the add to quiz button.
+     *
+     * @property _addbutton
+     * @type Node
+     * @private
+     */
+    _addbutton: null,
+
     /**
      * The ID of the first checkbox on the page.
      *
@@ -69,6 +78,15 @@ var manager = {
         });
 
         this._header.on('click', this._headerClick, this);
+        this._header.on('click', this._questionClick, this);
+
+        this._addbutton = Y.one('.modulespecificbuttonscontainer input[name="add"]');
+
+        this._addbutton.setAttrs({
+            disabled: true
+        });
+
+        Y.one('.categoryquestionscontainer').delegate('change', this._questionClick, 'td.checkbox input[type="checkbox"]', this);
 
         // Store the first checkbox details.
         var table = this._header.ancestor('table');
@@ -96,6 +114,19 @@ var manager = {
         }
 
         this._header.set('checked', false);
+    },
+
+    /**
+     * Handle toggling of a question checkbox.
+     *
+     * @method _questionClick
+     * @private
+     */
+    _questionClick: function() {
+        var areChecked = Y.all('td.checkbox input[type="checkbox"]:checked').size();
+        this._addbutton.setAttrs({
+            disabled: (areChecked === 0)
+        });
     }
 };