diff --git a/lib/editor/tiny/plugins/equation/db/access.php b/lib/editor/tiny/plugins/equation/db/access.php new file mode 100644 index 00000000000..025b275a00e --- /dev/null +++ b/lib/editor/tiny/plugins/equation/db/access.php @@ -0,0 +1,35 @@ +. + +/** + * Capabilities for the tiny_equation plugin. + * + * @package tiny_equation + * @copyright 2025 David Woloszyn + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ + +defined('MOODLE_INTERNAL') || die(); + +$capabilities = [ + 'tiny/equation:use' => [ + 'captype' => 'read', + 'contextlevel' => CONTEXT_USER, + 'archetypes' => [ + 'user' => CAP_ALLOW, + ], + ], +]; diff --git a/lib/editor/tiny/plugins/equation/lang/en/tiny_equation.php b/lib/editor/tiny/plugins/equation/lang/en/tiny_equation.php index 15344fe3311..4ca40eb86c7 100644 --- a/lib/editor/tiny/plugins/equation/lang/en/tiny_equation.php +++ b/lib/editor/tiny/plugins/equation/lang/en/tiny_equation.php @@ -25,6 +25,7 @@ $string['buttontitle'] = 'Equation editor'; $string['cursorinfo'] = 'An arrow indicates the position that new elements from the element library will be inserted.'; $string['editequation'] = 'Edit equation using TeX'; +$string['equation:use'] = 'Use TinyMCE equation editor'; $string['librarygroup1'] = 'Operators'; $string['librarygroup1_desc'] = 'TeX commands listed on the operators tab.'; $string['librarygroup2'] = 'Arrows'; diff --git a/lib/editor/tiny/plugins/equation/tests/behat/equation.feature b/lib/editor/tiny/plugins/equation/tests/behat/equation.feature index 9db1640761c..e6f7acd9313 100644 --- a/lib/editor/tiny/plugins/equation/tests/behat/equation.feature +++ b/lib/editor/tiny/plugins/equation/tests/behat/equation.feature @@ -34,3 +34,39 @@ Feature: Equation editor Then the field "Edit equation using" matches value " \pi " And I click on "Save equation" "button" And the field "Description" matches value "

\( \pi \)

" + + @javascript + Scenario: Permissions can be configured to control access to equation editor + Given the following "users" exist: + | username | firstname | lastname | email | + | teacher1 | Teacher | 1 | teacher1@example.com | + | teacher2 | Teacher | 2 | teacher2@example.com | + And the following "courses" exist: + | fullname | shortname | format | + | Course 1 | C1 | topics | + And the following "roles" exist: + | name | shortname | description | archetype | + | Custom teacher | custom1 | Limited permissions | editingteacher | + And the following "course enrolments" exist: + | user | course | role | + | teacher1 | C1 | editingteacher | + | teacher2 | C1 | custom1 | + And the following "activity" exists: + | activity | assign | + | course | C1 | + | name | Test assignment | + And the following "permission overrides" exist: + | capability | permission | role | contextlevel | reference | + | tiny/equation:use | Prohibit | custom1 | Course | C1 | + # Check plugin access as a role with prohibited permissions. + And I log in as "teacher2" + And I am on the "Test assignment" Activity page + And I navigate to "Settings" in current page administration + When I click on the "Insert" menu item for the "Activity instructions" TinyMCE editor + Then I should not see "Equation editor" + # Check plugin access as a role with allowed permissions. + And I log in as "teacher1" + And I am on the "Test assignment" Activity page + And I navigate to "Settings" in current page administration + And I click on the "Insert" menu item for the "Activity instructions" TinyMCE editor + And I should see "Equation editor" diff --git a/lib/editor/tiny/plugins/equation/version.php b/lib/editor/tiny/plugins/equation/version.php index eebc0be8b18..abfa0496b27 100644 --- a/lib/editor/tiny/plugins/equation/version.php +++ b/lib/editor/tiny/plugins/equation/version.php @@ -24,6 +24,6 @@ defined('MOODLE_INTERNAL') || die(); -$plugin->version = 2024121800; +$plugin->version = 2025012300; $plugin->requires = 2024100100; $plugin->component = 'tiny_equation';