Merge branch 'MDL-32105-401' of https://github.com/Chocolate-lightning/moodle into MOODLE_401_STABLE

This commit is contained in:
Andrew Nicols 2023-01-03 15:32:04 +08:00
commit 72f4f8ec7c
3 changed files with 41 additions and 0 deletions

View File

@ -107,6 +107,13 @@ class mod_glossary_entry_form extends moodleform {
$id = (int)$data['id'];
$data['concept'] = trim($data['concept']);
$aliases = explode("\r\n", trim($data['aliases']));
foreach ($aliases as $alias) {
// Check if the alias is just a single character and that it doesn't match reserved symbols.
if (strlen(trim($alias)) == 1 && preg_match('/[$-\/:-?{-~!"^_`\[\]]/', trim($alias))) {
$errors['aliases'] = get_string('errreservedkeywords', 'glossary');
}
}
if ($id) {
//We are updating an entry, so we compare current session user with

View File

@ -166,6 +166,7 @@ $string['errconceptalreadyexists'] = 'This concept already exists. No duplicates
$string['errdeltimeexpired'] = 'You can\'t delete this. Time expired!';
$string['erredittimeexpired'] = 'The editing time for this entry has expired.';
$string['errorparsingxml'] = 'Errors occurred while parsing the file. Make sure it is valid XML syntax.';
$string['errreservedkeywords'] = 'Some/All of the entered keywords cannot be used as they are reserved.';
$string['eventcategorycreated'] = 'Category has been created';
$string['eventcategorydeleted'] = 'Category has been deleted';
$string['eventcategoryupdated'] = 'Category has been updated';

View File

@ -0,0 +1,33 @@
@mod @mod_glossary @javascript
Feature: Create a glossary entry. As a user
I should be able to enter an entry without
using reserved keywords
Background:
Given the following "users" exist:
| username | firstname | lastname | email |
| teacher1 | Teacher | 1 | teacher1@example.com |
| student1 | Student | 1 | student1@example.com |
And the following "courses" exist:
| fullname | shortname | format |
| Course 1 | C1 | topics |
And the following "course enrolments" exist:
| user | course | role |
| teacher1 | C1 | editingteacher |
| student1 | C1 | student |
And I log in as "teacher1"
And I am on "Course 1" course homepage with editing mode on
And I add a "Glossary" to section "1" and I fill the form with:
| Name | Test glossary |
| Description | A glossary about dreams! |
And I log out
Scenario: Glossary entry edition of custom tags works as expected
Given I am on the "Test glossary" "glossary activity" page logged in as "teacher1"
And I press "Add entry"
And I set the following fields to these values:
| Concept | Dummy first entry |
| Definition | Dream is the start of a journey |
| Keyword(s) | " |
And I press "Save changes"
Then I should see "Some/All of the entered keywords cannot be used as they are reserved."