diff --git a/grade/import/xml/tests/behat/import.feature b/grade/import/xml/tests/behat/import.feature new file mode 100644 index 0000000000000..23fce0bf3004f --- /dev/null +++ b/grade/import/xml/tests/behat/import.feature @@ -0,0 +1,29 @@ +@gradeimport @gradeimport_xml @javascript @_file_upload +Feature: A teacher can import grades with a XML file or with an URL + In order to import grades using a XML file + As a teacher + I need to be able to upload a local XML file or to give a remote file URL + + Background: + Given the following "courses" exist: + | fullname | shortname | format | + | Course 1 | C1 | topics | + And the following "users" exist: + | username | firstname | lastname | email | + | teacher1 | Teacher | 1 | teacher1@example.com | + And the following "course enrolments" exist: + | user | course | role | + | teacher1 | C1 | editingteacher | + + Scenario: The remote file URL field is disabled when the file picker is not empty + Given I am on the "Course 1" "Course" page logged in as "teacher1" + And I navigate to "XML file" import page in the course gradebook + And I upload "lib/ddl/tests/fixtures/xmldb_table.xml" file to "File" filemanager + Then the "disabled" attribute of "input#id_url" "css_element" should contain "true" + + Scenario: The file picker is disabled when the remote file URL field is not empty + Given I am on the "Course 1" "Course" page logged in as "teacher1" + And I navigate to "XML file" import page in the course gradebook + And I set the following fields to these values: + | Remote file URL | https://example.com/grades.xml | + Then the "disabled" attribute of "input#id_userfile" "css_element" should contain "true" diff --git a/lib/form/form.js b/lib/form/form.js index c9cde31c89075..d886b1f2ab6a8 100644 --- a/lib/form/form.js +++ b/lib/form/form.js @@ -485,8 +485,8 @@ if (typeof M.form.dependencyManager === 'undefined') { } if (this.getAttribute('class').toLowerCase() == 'filepickerhidden') { // Check for filepicker status. - var elementname = this.getAttribute('name'); - if (elementname && M.form_filepicker.instances[elementname].fileadded) { + var elementid = this.getAttribute('id'); + if (elementid && M.form_filepicker.instances[elementid].fileadded) { lock = false; } else { lock = true; @@ -553,8 +553,8 @@ if (typeof M.form.dependencyManager === 'undefined') { } if (this.getAttribute('class').toLowerCase() == 'filepickerhidden') { // Check for filepicker status. - var elementname = this.getAttribute('name'); - if (elementname && M.form_filepicker.instances[elementname].fileadded) { + var elementid = this.getAttribute('id'); + if (elementid && M.form_filepicker.instances[elementid].fileadded) { lock = false; } else { lock = true; @@ -617,8 +617,8 @@ if (typeof M.form.dependencyManager === 'undefined') { } // Check for filepicker status. if (this.getAttribute('class').toLowerCase() == 'filepickerhidden') { - var elementname = this.getAttribute('name'); - if (elementname && M.form_filepicker.instances[elementname].fileadded) { + var elementid = this.getAttribute('id'); + if (elementid && M.form_filepicker.instances[elementid].fileadded) { lock = true; } else { lock = false;