Reveal teacher content via eXeLearning's ?exe-teacher URL param, retire CSS injection#65
Reveal teacher content via eXeLearning's ?exe-teacher URL param, retire CSS injection#65erseco wants to merge 5 commits into
Conversation
… of CSS injection eXeLearning core now hides teacher-only content by default and reveals it via the package's own ?exe-teacher=1 URL parameter (upstream exelearning#1772). Consume that contract here and retire the plugin's parent-side teacher-mode CSS injection, which coupled the plugin to the package internals. exeweb_display_embed() now appends ?exe-teacher=1 to the iframe content URL only for users who can manage the activity AND when the per-activity setting opts in; students never receive the parameter and always see the student view. The decision is a pure, unit-tested helper, exeweb_should_reveal_teacher_content(). Removed: - exeweb_require_teacher_mode_hider_for_iframe() and its call in exeweb_display_embed() (injected CSS into the embedded iframe contentDocument to hide #teacher-mode-toggler-wrapper). The teachermodevisible field is kept (mod_form default 1, lib.php displayoptions) and repurposed: it now gates whether teachers see eXeLearning's teacher content revealed in the embedded view (combined with the manageactivities capability). Updated the lang help (en + the hand-maintained es) to the new meaning; the exeweb_is_teacher_mode_visible() docblock too. Tests: - tests/locallib_test.php covers the new helper across the truth table and exeweb_is_teacher_mode_visible() default/stored behaviour. - tests/behat/teacher_mode.feature adds server-rendered scenarios asserting the iframe src contains/omits exe-teacher for teacher (on/off) and student.
Drop the capability gate. The per-activity teachermodevisible setting alone controls whether the package's own ?exe-teacher=1 selector is offered, and it is offered to every viewer (students included) when on. Remove the now-trivial exeweb_should_reveal_teacher_content() helper and its unit test, restore the original "Show teacher layer selector" translations, and update the Behat scenario (a student also gets the parameter when the setting is on).
ignaciogros
left a comment
There was a problem hiding this comment.
Although the "Show teacher layer selector" option is enabled, the content URL, whether opened in an iframe, a new window, or a popup, does not include the exe-teacher=1 parameter.
The same result occurs for both administrator and student roles.
Could you please check the solution?
Thanks.
…ot only embed PR #65 flagged only the embedded-iframe URL with eXeLearning's ?exe-teacher=1 reveal parameter. The popup, open and direct-redirect paths build the package content URL separately and dropped it, so the in-package teacher-layer selector never appeared in those display modes (reported by @ignaciogros). Centralize the rule in exeweb_apply_teacher_mode_param() and apply it at every content-URL build site: - exeweb_display_embed() embed iframe (routed through the helper, unchanged) - exeweb_get_clicktoopen() popup/open links (new optional $exeweb argument) - exeweb_print_workaround() popup window.open() URL - view.php redirect block (student popup/open path) Tests: - locallib_test: unit-test the helper and the click-to-open link - teacher_mode.feature: add popup scenarios and fix the embed scenarios to use the real display value (1 = embed; 5 is open, which renders no iframe)
|
Thanks @ignaciogros — you were right that the parameter was missing outside the embedded iframe. Root cause: Fix (912e8dd): centralized the rule in Verified on a local Moodle 5.0, setting on vs off, content URL in each display mode:
On the embed/iframe case specifically: it was already appending the parameter (the renderer passes I also fixed the Behat scenarios, which used |
What
eXeLearning core now hides teacher-only content by default and exposes an in-package selector to show it via the
?exe-teacher=1URL parameter (upstream exelearning/exelearning#1972, fixes exelearning/exelearning#1772). This consumes that contract and retires the plugin's parent-side teacher-mode CSS injection. Mirrors the mod_exelearning (#86) change.Changes
locallib.php: removedexeweb_require_teacher_mode_hider_for_iframe()(injected CSS into the embedded iframe).exeweb_display_embed()now appends?exe-teacher=1to the iframe content URL wheneverexeweb_is_teacher_mode_visible($exeweb)is true — for every viewer.teachermodevisiblesetting keeps its original "Show teacher layer selector" label/help (en/es), homogeneous with the other plugins.Notes
main. No schema change, no version bump.Testing
php -lclean. Unit + Behat updated: the iframe src carriesexe-teacher=1when the setting is on (including for a student) and omits it when off. PHPUnit/Behat need a Moodle CI site.Moodle Playground Preview
The changes in this pull request can be previewed and tested using a Moodle Playground instance.
ℹ️ The eXeLearning editor is fetched from the shared release and unpacked into the plugin when the playground boots, so the first load may take a few extra seconds. ELPX upload, viewer and preview work normally.