mirror of
https://github.com/moodle/moodle.git
synced 2025-01-18 22:08:20 +01:00
MDL-76314 forum: add form check to prevent combining wrong parameters
Form validation prevents combining the forum type "single discussion" and the group mode "separate groups".
This commit is contained in:
parent
0780e87f06
commit
9f3baf8c4f
@ -95,6 +95,8 @@ $string['cannotfavourite'] = 'Sorry, but you do not have the permission to star
|
||||
$string['cannottrack'] = 'Could not stop tracking that forum';
|
||||
$string['cannotunsubscribe'] = 'Could not unsubscribe you from that forum';
|
||||
$string['cannotupdatepost'] = 'You can not update this post';
|
||||
$string['cannotuseseperategroupsandsingletopic'] = 'Separate groups cannot be used with single discussion topic';
|
||||
$string['cannotusesingletopicandseperategroups'] = 'Single discussion topic cannot be used with separate groups';
|
||||
$string['cannotviewpostyet'] = 'You can\'t read other students\' posts in this discussion yet because you haven\'t posted.';
|
||||
$string['cannotviewusersposts'] = 'There are no posts made by this user that you are able to view.';
|
||||
$string['cleanreadtime'] = 'Mark old posts as read hour';
|
||||
|
@ -341,6 +341,11 @@ class mod_forum_mod_form extends moodleform_mod {
|
||||
public function validation($data, $files) {
|
||||
$errors = parent::validation($data, $files);
|
||||
|
||||
if ($data['type'] === 'single' && $data['groupmode'] == SEPARATEGROUPS) {
|
||||
$errors['type'] = get_string('cannotusesingletopicandseperategroups', 'forum');
|
||||
$errors['groupmode'] = get_string('cannotuseseperategroupsandsingletopic', 'forum');
|
||||
}
|
||||
|
||||
if ($data['duedate'] && $data['cutoffdate']) {
|
||||
if ($data['duedate'] > $data['cutoffdate']) {
|
||||
$errors['cutoffdate'] = get_string('cutoffdatevalidation', 'forum');
|
||||
|
@ -44,3 +44,18 @@ Feature: Add forum activities and discussions
|
||||
And I should see "empty.txt"
|
||||
And I follow "Edit"
|
||||
And the field "Attachment" matches value "empty.txt"
|
||||
|
||||
@javascript
|
||||
Scenario: Test forum settings validation
|
||||
Given the following "courses" exist:
|
||||
| fullname | shortname | category |
|
||||
| Course 1 | C1 | 0 |
|
||||
And I log in as "admin"
|
||||
And I am on "Course 1" course homepage with editing mode on
|
||||
And I add a "Forum" to section "0" and I fill the form with:
|
||||
| Forum name | Test forum |
|
||||
| Forum type | single |
|
||||
| Group mode | 1 |
|
||||
When I press "Save and display"
|
||||
Then I should see "Separate groups cannot be used with single discussion topic"
|
||||
And I should see "Single discussion topic cannot be used with separate groups"
|
||||
|
Loading…
x
Reference in New Issue
Block a user