Merge branch '76314-forum-fix-forumtype-and-groupmode-validation-401' of https://github.com/DSI-Universite-Rennes2/moodle into MOODLE_401_STABLE

This commit is contained in:
Jun Pataleta 2023-02-13 11:38:55 +08:00
commit 301fa85c26
3 changed files with 22 additions and 0 deletions

View File

@ -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';

View File

@ -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');

View File

@ -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"