Skip to content

Commit f31f7ef

Browse files
author
Rafael Becerra
committed
INT-16127: Modify duplicated id's to avoid problems on the selects for open forums settings grade category
1 parent 7f02637 commit f31f7ef

File tree

2 files changed

+39
-11
lines changed

2 files changed

+39
-11
lines changed

mod_form.php

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@ function definition() {
238238
$mform->disabledIf('advancedgradingmethod_'.$areaname, 'gradetype', 'neq', HSUFORUM_GRADETYPE_MANUAL);
239239
}
240240
}
241-
$mform->disabledIf('gradepass', 'gradetype', 'neq', HSUFORUM_GRADETYPE_MANUAL);
241+
$mform->disabledIf('gradepass_hsuforum', 'gradetype', 'neq', HSUFORUM_GRADETYPE_MANUAL);
242242

243243
$reflection = new ReflectionClass($mform);
244244
$property = $reflection->getProperty('_hideifs');
@@ -252,7 +252,7 @@ function definition() {
252252
$property->setValue($mform, $dependencies);
253253
}
254254
}
255-
$mform->disabledIf('gradecat', 'gradetype', 'eq', HSUFORUM_GRADETYPE_NONE);
255+
$mform->disabledIf('gradecat_hsuforum', 'gradetype', 'eq', HSUFORUM_GRADETYPE_NONE);
256256
//-------------------------------------------------------------------------------
257257
// buttons
258258
$this->add_action_buttons();
@@ -338,24 +338,24 @@ public function standard_hsuforum_grading_coursemodule_elements() {
338338
}
339339

340340
if ($this->_features->gradecat) {
341-
$mform->addElement('select', 'gradecat',
341+
$mform->addElement('select', 'gradecat_hsuforum',
342342
get_string('gradecategoryonmodform', 'grades'),
343343
grade_get_categories_menu($COURSE->id, $this->_outcomesused));
344-
$mform->addHelpButton('gradecat', 'gradecategoryonmodform', 'grades');
344+
$mform->addHelpButton('gradecat_hsuforum', 'gradecategoryonmodform', 'grades');
345345
if (!$this->_features->rating) {
346-
$mform->hideIf('gradecat', 'grade[modgrade_type]', 'eq', 'none');
346+
$mform->hideIf('gradecat_hsuforum', 'grade[modgrade_type]', 'eq', 'none');
347347
}
348348
}
349349

350350
// Grade to pass.
351-
$mform->addElement('text', 'gradepass', get_string('gradepass', 'grades'));
352-
$mform->addHelpButton('gradepass', 'gradepass', 'grades');
353-
$mform->setDefault('gradepass', '');
354-
$mform->setType('gradepass', PARAM_RAW);
351+
$mform->addElement('text', 'gradepass_hsuforum', get_string('gradepass', 'grades'));
352+
$mform->addHelpButton('gradepass_hsuforum', 'gradepass', 'grades');
353+
$mform->setDefault('gradepass_hsuforum', '');
354+
$mform->setType('gradepass_hsuforum', PARAM_RAW);
355355
if (!$this->_features->rating) {
356-
$mform->hideIf('gradepass', 'grade[modgrade_type]', 'eq', 'none');
356+
$mform->hideIf('gradepass_hsuforum', 'grade[modgrade_type]', 'eq', 'none');
357357
} else {
358-
$mform->hideIf('gradepass', 'assessed', 'eq', '0');
358+
$mform->hideIf('gradepass_hsuforum', 'assessed', 'eq', '0');
359359
}
360360
}
361361
}

tests/behat/add_forum.feature

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,3 +45,31 @@ Feature: Add Open Forum activities and discussions
4545
And I follow "Edit"
4646
And I follow "Use advanced editor and additional options"
4747
And the field "Attachment" matches value "empty.txt"
48+
49+
@javascript
50+
Scenario: Display the grade category select according to the grade type options
51+
Given the following "users" exist:
52+
| username | firstname | lastname | email |
53+
| teacher1 | Teacher | 1 | teacher1@example.com |
54+
And the following "courses" exist:
55+
| fullname | shortname | category |
56+
| Course 1 | C1 | 0 |
57+
And the following "course enrolments" exist:
58+
| user | course | role |
59+
| teacher1 | C1 | editingteacher |
60+
And I log in as "teacher1"
61+
And I am on "Course 1" course homepage with editing mode on
62+
And I add a "Open Forum" to section "1" and I fill the form with:
63+
| Forum name | Test forum name |
64+
| Forum type | Standard forum for general use |
65+
| Description | Test forum description |
66+
And I follow "Test forum name"
67+
And I click on "#region-main-settings-menu .dropdown-toggle>.icon" "css_element"
68+
And I follow "Edit settings"
69+
And I click on "#page-mod-hsuforum-mod #id_modstandardratings a[aria-controls='id_modstandardratings']" "css_element"
70+
And I set the field with xpath "//body[@id='page-mod-hsuforum-mod']//fieldset[@id='id_modstandardratings']//select[@id='id_assessed']" to "Average of ratings"
71+
And the "disabled" attribute of "#page-mod-hsuforum-mod #id_modstandardgrade > div.fcontainer.clearfix > div:nth-child(3) div[data-fieldtype='select'] select[name='gradecat_hsuforum']" "css_element" should contain "disabled"
72+
And I click on "#page-mod-hsuforum-mod #id_modstandardgrade a[aria-controls='id_modstandardgrade']" "css_element"
73+
And I set the field with xpath "//body[@id='page-mod-hsuforum-mod']//fieldset[@id='id_modstandardgrade']//select[@id='id_gradetype']" to "Manual"
74+
# This final step is only to verify that the user can select something after the Manual option is chosen for grade type.
75+
And I set the field with xpath "//body[@id='page-mod-hsuforum-mod']//fieldset[@id='id_modstandardgrade']//select[@id='id_gradecat_hsuforum']" to "Uncategorised"

0 commit comments

Comments
 (0)