Merge branch 'MDL-80056-main' of https://github.com/Jayce0808/moodle
This commit is contained in:
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -67,6 +67,12 @@ export default class extends BulkActions {
|
||||
/** @type {boolean} Whether to show the set workflow state action. */
|
||||
#workflowState;
|
||||
|
||||
/** @type {boolean} Whether this assignment supports submissions. */
|
||||
#supportsSubmissions;
|
||||
|
||||
/** @type {boolean} Whether this assignment has submissions. */
|
||||
#hasSubmissions;
|
||||
|
||||
/**
|
||||
* Returns the instance of the class.
|
||||
*
|
||||
@@ -81,6 +87,8 @@ export default class extends BulkActions {
|
||||
* @param {boolean} options.markingallocation - Whether to show the set marking allocation action.
|
||||
* @param {Array} options.pluginoperations - The list of plugin operations.
|
||||
* @param {string} options.sesskey - The session key.
|
||||
* @param {boolean} options.supportssubmissions - Whether this assignment supports submissions.
|
||||
* @param {boolean} options.hassubmissions - Whether this assignment has submissions.
|
||||
* @returns {this} An instance of the anonymous class extending BulkActions.
|
||||
*/
|
||||
static init(options) {
|
||||
@@ -101,10 +109,13 @@ export default class extends BulkActions {
|
||||
* @param {boolean} options.markingallocation - Whether to show the set marking allocation action.
|
||||
* @param {Array} options.pluginoperations - The list of plugin operations.
|
||||
* @param {string} options.sesskey - The session key.
|
||||
* @param {boolean} options.hassubmissions - Whether this assignment has any submissions.
|
||||
* @param {boolean} options.supportssubmissions - Whether this assignment allows submissions.
|
||||
*/
|
||||
constructor({
|
||||
cmid, message, submissiondrafts, removesubmission, extend,
|
||||
grantattempt, workflowstate, markingallocation, pluginoperations, sesskey
|
||||
grantattempt, workflowstate, markingallocation, pluginoperations, sesskey,
|
||||
hassubmissions, supportssubmissions
|
||||
}) {
|
||||
super();
|
||||
this.#cmid = cmid;
|
||||
@@ -117,43 +128,51 @@ export default class extends BulkActions {
|
||||
this.#markingAllocation = markingallocation;
|
||||
this.#sesskey = sesskey;
|
||||
this.#pluginOperations = pluginoperations;
|
||||
this.#hasSubmissions = hassubmissions;
|
||||
this.#supportsSubmissions = supportssubmissions;
|
||||
}
|
||||
|
||||
getBulkActions() {
|
||||
const actions = [
|
||||
new GeneralAction(
|
||||
this.#cmid,
|
||||
this.#sesskey,
|
||||
'lock',
|
||||
getString('batchoperationlock', 'mod_assign'),
|
||||
Templates.renderPix('i/lock', 'core'),
|
||||
getString('locksubmissions', 'mod_assign'),
|
||||
getString('batchoperationconfirmlock', 'mod_assign'),
|
||||
getString('batchoperationlock', 'mod_assign'),
|
||||
),
|
||||
new GeneralAction(
|
||||
this.#cmid,
|
||||
this.#sesskey,
|
||||
'unlock',
|
||||
getString('batchoperationunlock', 'mod_assign'),
|
||||
Templates.renderPix('i/unlock', 'core'),
|
||||
getString('unlocksubmissions', 'mod_assign'),
|
||||
getString('batchoperationconfirmunlock', 'mod_assign'),
|
||||
getString('batchoperationunlock', 'mod_assign'),
|
||||
),
|
||||
new GeneralAction(
|
||||
this.#cmid,
|
||||
this.#sesskey,
|
||||
'downloadselected',
|
||||
getString('batchoperationdownloadselected', 'mod_assign'),
|
||||
Templates.renderPix('t/download', 'core'),
|
||||
getString('downloadselectedsubmissions', 'mod_assign'),
|
||||
getString('batchoperationconfirmdownloadselected', 'mod_assign'),
|
||||
getString('batchoperationdownloadselected', 'mod_assign'),
|
||||
),
|
||||
];
|
||||
|
||||
if (this.#removeSubmission) {
|
||||
const actions = [];
|
||||
if (this.#supportsSubmissions) {
|
||||
actions.push(
|
||||
new GeneralAction(
|
||||
this.#cmid,
|
||||
this.#sesskey,
|
||||
'lock',
|
||||
getString('batchoperationlock', 'mod_assign'),
|
||||
Templates.renderPix('i/lock', 'core'),
|
||||
getString('locksubmissions', 'mod_assign'),
|
||||
getString('batchoperationconfirmlock', 'mod_assign'),
|
||||
getString('batchoperationlock', 'mod_assign'),
|
||||
),
|
||||
new GeneralAction(
|
||||
this.#cmid,
|
||||
this.#sesskey,
|
||||
'unlock',
|
||||
getString('batchoperationunlock', 'mod_assign'),
|
||||
Templates.renderPix('i/unlock', 'core'),
|
||||
getString('unlocksubmissions', 'mod_assign'),
|
||||
getString('batchoperationconfirmunlock', 'mod_assign'),
|
||||
getString('batchoperationunlock', 'mod_assign'),
|
||||
),
|
||||
);
|
||||
}
|
||||
if (this.#supportsSubmissions && this.#hasSubmissions) {
|
||||
actions.push(
|
||||
new GeneralAction(
|
||||
this.#cmid,
|
||||
this.#sesskey,
|
||||
'downloadselected',
|
||||
getString('batchoperationdownloadselected', 'mod_assign'),
|
||||
Templates.renderPix('t/download', 'core'),
|
||||
getString('downloadselectedsubmissions', 'mod_assign'),
|
||||
getString('batchoperationconfirmdownloadselected', 'mod_assign'),
|
||||
getString('batchoperationdownloadselected', 'mod_assign'),
|
||||
),
|
||||
);
|
||||
}
|
||||
if (this.#removeSubmission && this.#supportsSubmissions && this.#hasSubmissions) {
|
||||
actions.push(new DeleteAction(this.#cmid, this.#sesskey));
|
||||
}
|
||||
|
||||
@@ -216,7 +235,6 @@ export default class extends BulkActions {
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
return actions;
|
||||
}
|
||||
|
||||
|
||||
@@ -4608,7 +4608,8 @@ class assign {
|
||||
$jsparams['markingallocation'] = !empty($this->get_instance()->markingallocation);
|
||||
$jsparams['cmid'] = $this->get_course_module()->id;
|
||||
$jsparams['sesskey'] = sesskey();
|
||||
|
||||
$jsparams['supportssubmissions'] = $this->is_any_submission_plugin_enabled();
|
||||
$jsparams['hassubmissions'] = $this->count_submissions() > 0;
|
||||
$PAGE->requires->js_call_amd('mod_assign/bulkactions/grading/bulk_actions', 'init', [$jsparams]);
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,49 @@
|
||||
@mod @mod_assign
|
||||
Feature: In an assignment, teachers can download submissions through the actions dropdown
|
||||
In order to download all submissions in an assignment
|
||||
As a teacher
|
||||
I need to have the option available in the actions dropdown menu
|
||||
|
||||
Background:
|
||||
Given the following "courses" exist:
|
||||
| fullname | shortname | category | groupmode |
|
||||
| Course 1 | C1 | 0 | 1 |
|
||||
And the following "users" exist:
|
||||
| username | firstname | lastname | email |
|
||||
| teacher1 | Teacher | 1 | teacher1@example.com |
|
||||
| student1 | Student | 1 | student1@example.com |
|
||||
And the following "course enrolments" exist:
|
||||
| user | course | role |
|
||||
| teacher1 | C1 | editingteacher |
|
||||
| student1 | C1 | student |
|
||||
|
||||
Scenario: The option to download all submissions is available when there are submissions.
|
||||
Given the following "activity" exists:
|
||||
| activity | assign |
|
||||
| course | C1 |
|
||||
| name | Test assignment name |
|
||||
| assignsubmission_onlinetext_enabled | 1 |
|
||||
And the following "mod_assign > submissions" exist:
|
||||
| assign | user | onlinetext |
|
||||
| Test assignment name | student1 | I'm the student first submission |
|
||||
And I am on the "Test assignment name" Activity page logged in as teacher1
|
||||
And I change window size to "large"
|
||||
When I navigate to "Submissions" in current page administration
|
||||
Then the "Download all submissions" item should exist in the "Actions" action menu
|
||||
|
||||
Scenario Outline: Option to download all submissions is unavailable if no submissions have been made.
|
||||
Given the following "activity" exists:
|
||||
| activity | assign |
|
||||
| course | C1 |
|
||||
| name | Test assignment name |
|
||||
| assignsubmission_onlinetext_enabled | <onlinetext_enabled> |
|
||||
| file_enabled | <file_enabled> |
|
||||
And I am on the "Test assignment name" Activity page logged in as teacher1
|
||||
And I change window size to "large"
|
||||
When I navigate to "Submissions" in current page administration
|
||||
Then the "Download all submissions" item should not exist in the "Actions" action menu
|
||||
|
||||
Examples:
|
||||
| onlinetext_enabled | file_enabled |
|
||||
| 1 | 0 |
|
||||
| 0 | 0 |
|
||||
@@ -0,0 +1,72 @@
|
||||
@mod @mod_assign
|
||||
Feature: In an assignment, teachers can perform bulk actions on submissions
|
||||
In order to manage submissions in bulk
|
||||
As a teacher
|
||||
I need the appropriate options available in the sticky footer
|
||||
|
||||
Background:
|
||||
Given the following "courses" exist:
|
||||
| fullname | shortname | category |
|
||||
| Course 1 | C1 | 0 |
|
||||
And the following "users" exist:
|
||||
| username | firstname | lastname | email |
|
||||
| teacher1 | Teacher | 1 | teacher1@example.com |
|
||||
| student1 | Student | 1 | student1@example.com |
|
||||
| manager1 | Manager | 1 | manager1@example.com |
|
||||
And the following "role assigns" exist:
|
||||
| user | role | contextlevel | reference |
|
||||
| manager1 | coursecreator | system | |
|
||||
And the following "role capability" exists:
|
||||
| role | manager |
|
||||
| mod/assign:editothersubmission | allow |
|
||||
And the following "course enrolments" exist:
|
||||
| user | course | role |
|
||||
| teacher1 | C1 | editingteacher |
|
||||
| student1 | C1 | student |
|
||||
| manager1 | C1 | manager |
|
||||
|
||||
@javascript
|
||||
Scenario Outline: Appropriate bulk actions should be available when there are submissions.
|
||||
Given the following "activity" exists:
|
||||
| activity | assign |
|
||||
| course | C1 |
|
||||
| name | Test assignment name |
|
||||
| assignsubmission_onlinetext_enabled | 1 |
|
||||
And the following "mod_assign > submissions" exist:
|
||||
| assign | user | onlinetext |
|
||||
| Test assignment name | student1 | I'm the student first submission |
|
||||
And I am on the "Test assignment name" Activity page logged in as <user>
|
||||
And I change window size to "large"
|
||||
When I navigate to "Submissions" in current page administration
|
||||
And I click on "Select all" "checkbox"
|
||||
Then I should <download_visibility> "Download" in the "sticky-footer" "region"
|
||||
And I should <lock_visibility> "Lock" in the "sticky-footer" "region"
|
||||
And I should <unlock_visibility> "Unlock" in the "sticky-footer" "region"
|
||||
And I should <delete_visibility> "Delete" in the "sticky-footer" "region"
|
||||
|
||||
Examples:
|
||||
| user | download_visibility | lock_visibility | unlock_visibility | delete_visibility |
|
||||
| manager1 | see | see | see | see |
|
||||
| teacher1 | see | see | see | not see |
|
||||
|
||||
@javascript
|
||||
Scenario Outline: Appropriate bulk actions should be available if no submissions have been made.
|
||||
Given the following "activity" exists:
|
||||
| activity | assign |
|
||||
| course | C1 |
|
||||
| name | Test assignment name |
|
||||
| assignsubmission_onlinetext_enabled | <onlinetext_enabled> |
|
||||
| assignsubmission_file_enabled | <file_enabled> |
|
||||
And I am on the "Test assignment name" Activity page logged in as teacher1
|
||||
And I change window size to "large"
|
||||
When I navigate to "Submissions" in current page administration
|
||||
And I click on "Select all" "checkbox" in the "#submissions" "css_element"
|
||||
Then I should <download_visibility> "Download" in the "sticky-footer" "region"
|
||||
And I should <lock_visibility> "Lock" in the "sticky-footer" "region"
|
||||
And I should <unlock_visibility> "Unlock" in the "sticky-footer" "region"
|
||||
And I should <delete_visibility> "Delete" in the "sticky-footer" "region"
|
||||
|
||||
Examples:
|
||||
| onlinetext_enabled | file_enabled | download_visibility | lock_visibility | unlock_visibility | delete_visibility |
|
||||
| 1 | 0 | not see | see | see | not see |
|
||||
| 0 | 0 | not see | not see | not see | not see |
|
||||
Reference in New Issue
Block a user