-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
MDL-63944 Questions Bank: Select all checkbox should be checked
When checkbox item be chosen then "Select All" be chosen. When "Select All" be chosen then all checkbox item be chosen.
- Loading branch information
Showing
10 changed files
with
188 additions
and
442 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,128 @@ | ||
// This file is part of Moodle - http://moodle.org/ | ||
// | ||
// Moodle is free software: you can redistribute it and/or modify | ||
// it under the terms of the GNU General Public License as published by | ||
// the Free Software Foundation, either version 3 of the License, or | ||
// (at your option) any later version. | ||
// | ||
// Moodle is distributed in the hope that it will be useful, | ||
// but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
// GNU General Public License for more details. | ||
// | ||
// You should have received a copy of the GNU General Public License | ||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>. | ||
|
||
/** | ||
* A javascript module to handle question ajax actions. | ||
* | ||
* @module core_question/qbankmanager | ||
* @class qbankmanager | ||
* @package core_question | ||
* @copyright 2018 The Open University | ||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later | ||
*/ | ||
define(['jquery', 'core/str', 'core/notification'], function($, str, notification) { | ||
|
||
return { | ||
/** | ||
* A reference to the header checkbox. | ||
* | ||
* @property _strings | ||
* @type Node | ||
* @private | ||
*/ | ||
_strings: null, | ||
|
||
/** | ||
* A reference to the add to quiz button. | ||
* | ||
* @property _buttons | ||
* @type Node | ||
* @private | ||
*/ | ||
_buttons: null, | ||
|
||
/** | ||
* Set up the Question Bank Manager. | ||
* | ||
* @method init | ||
*/ | ||
init: function() { | ||
// Find the header checkbox, and set the initial values. | ||
var header = $('#qbheadercheckbox'); | ||
if (header.length == 0) { | ||
return; | ||
} | ||
var self = this; | ||
str.get_strings([ | ||
{key: 'selectall', component: 'moodle'}, | ||
{key: 'deselectall', component: 'moodle'}, | ||
]).then(function(strings) { | ||
self._strings = strings; | ||
header.attr({ | ||
disabled: false, | ||
checked: self._getSizeChecked() != 0, | ||
title: strings[0] | ||
}); | ||
header.click(self, self._headerClick); | ||
|
||
self._buttons = $(".modulespecificbuttonscontainer input, .modulespecificbuttonscontainer select," + | ||
" .modulespecificbuttonscontainer link, .modulespecificbuttonscontainer link"); | ||
|
||
self._buttons.attr('disabled', self._getSizeChecked() == 0); | ||
|
||
if (self._buttons.length > 0) { | ||
$('.categoryquestionscontainer') | ||
.delegate('td.checkbox input[type="checkbox"]', 'change', self, self._questionClick); | ||
} | ||
return; | ||
}).fail(notification.exception); | ||
}, | ||
|
||
/** | ||
* Handle toggling of the header checkbox. | ||
* | ||
* @method _headerClick | ||
* @param {Event} event of element. | ||
* @private | ||
*/ | ||
_headerClick: function(event) { | ||
var self = event.data; | ||
var header = $('#qbheadercheckbox'); | ||
var isCheckedHeader = header.is(':checked'); | ||
var indexStringTitle = isCheckedHeader ? 1 : 0; | ||
|
||
$("#categoryquestions tbody [type=checkbox]").prop("checked", isCheckedHeader); | ||
self._buttons.attr('disabled', self._getSizeChecked() === 0); | ||
header.attr('title', self._strings[indexStringTitle]); | ||
}, | ||
|
||
/** | ||
* Handle toggling of a question checkbox. | ||
* | ||
* @method _questionClick | ||
* @param {Event} event of element. | ||
* @private | ||
*/ | ||
_questionClick: function(event) { | ||
var self = event.data; | ||
var header = $('#qbheadercheckbox'); | ||
var areChecked = self._getSizeChecked(); | ||
var lengthCheckbox = $("#categoryquestions tbody [type=checkbox]").length; | ||
var ischeckboxHeader = (areChecked != 0) && areChecked == lengthCheckbox; | ||
|
||
header.prop('checked', ischeckboxHeader); | ||
self._buttons.attr('disabled', (areChecked === 0)); | ||
}, | ||
/** | ||
* Get size all row checked of table. | ||
* @method _getSizeChecked | ||
* @return {Number} | ||
* @private | ||
*/ | ||
_getSizeChecked: function() { | ||
return $('#categoryquestions td.checkbox input[type="checkbox"]:checked').length; | ||
} | ||
}; | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
@core @core_question | ||
Feature: The questions in the question bank can be selected in various ways | ||
In selected to do something for questions | ||
As a teacher | ||
I want to choose them to move, delete it. | ||
|
||
Background: | ||
Given the following "users" exist: | ||
| username | firstname | lastname | email | | ||
| teacher1 | Teacher | 1 | teacher1@example.com | | ||
And the following "courses" exist: | ||
| fullname | shortname | format | | ||
| Course 1 | C1 | weeks | | ||
And the following "course enrolments" exist: | ||
| user | course | role | | ||
| teacher1 | C1 | editingteacher | | ||
And the following "question categories" exist: | ||
| contextlevel | reference | name | | ||
| Course | C1 | Test questions | | ||
And the following "questions" exist: | ||
| questioncategory | qtype | name | user | questiontext | | ||
| Test questions | essay | A question 1 name | admin | Question 1 text | | ||
| Test questions | essay | B question 2 name | teacher1 | Question 2 text | | ||
| Test questions | numerical | C question 3 name | teacher1 | Question 3 text | | ||
And I log in as "teacher1" | ||
And I am on "Course 1" course homepage | ||
And I navigate to "Questions" node in "Course administration > Question bank" | ||
|
||
@javascript | ||
Scenario: The question text can be chosen all in the list of questions | ||
Given the field "Select all" matches value "" | ||
When I click on "Select all" "checkbox" | ||
Then the field "A question 1 name" matches value "1" | ||
And the field "B question 2 name" matches value "1" | ||
And the field "C question 3 name" matches value "1" | ||
When I click on "Select all" "checkbox" | ||
Then the field "A question 1 name" matches value "" | ||
And the field "B question 2 name" matches value "" | ||
And the field "C question 3 name" matches value "" | ||
|
||
@javascript | ||
Scenario: The question text can be chosen in the list of questions | ||
Given the field "Select all" matches value "" | ||
When I click on "A question 1 name" "checkbox" | ||
Then the field "Select all" matches value "" | ||
When I click on "B question 2 name" "checkbox" | ||
And I click on "C question 3 name" "checkbox" | ||
Then the field "Select all" matches value "1" | ||
|
||
@javascript | ||
Scenario: The action button can be disabled when the question not be chosen in the list of questions | ||
Given the "Delete" "button" should be disabled | ||
And the "Move to >>" "button" should be disabled | ||
When I click on "Select all" "checkbox" | ||
Then the "Delete" "button" should be enabled | ||
And the "Move to >>" "button" should be enabled |
142 changes: 0 additions & 142 deletions
142
question/yui/build/moodle-question-qbankmanager/moodle-question-qbankmanager-debug.js
This file was deleted.
Oops, something went wrong.
1 change: 0 additions & 1 deletion
1
question/yui/build/moodle-question-qbankmanager/moodle-question-qbankmanager-min.js
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.