Hide Teacher Mode content by default in exports#1972
Conversation
…RL param Teacher-only content (blocks and iDevices) is now hidden by default in exported packages and in the preview, and the in-page self-serve toggle is hidden too. Hosts (WordPress, Moodle, Omeka-S) reveal teacher content by appending ?exe-teacher=1 to the content URL (aliases true/yes, plus ?teacher-mode=1) — no injected CSS/JS. ?exe-teacher=0 forces the student view; ?exe-teacher-toggler=1 shows the self-serve toggle. The reveal is applied by an early <head> script (flicker-free) and propagated onto in-package navigation links so it survives multi-page navigation. Adds an authoring hint on the "Teacher only" property warning it is hidden by default. This is a presentation mode, not access control. Closes #1772
Bundle ReportChanges will increase total bundle size by 28 bytes (0.0%) ⬆️. This is within the configured threshold ✅ Detailed changes
Affected Assets, Files, and Routes:view changes for bundle: app-bundleAssets Changed:
|
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1972 +/- ##
==========================================
+ Coverage 92.08% 92.10% +0.01%
==========================================
Files 372 372
Lines 79675 79703 +28
==========================================
+ Hits 73369 73407 +38
+ Misses 6306 6296 -10
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. |
The in-app authoring preview now loads the viewer with ?exe-teacher=1 so the author sees their teacher-only content while editing (the author is the teacher). Exported packages stay hidden by default; only this in-app preview opts in. Updates the previewPanel viewer URLs (SW preview + open-in-new-tab), the previewPanel tests, the E2E spec (preview defaults to teacher mode; the parameter still forces the student view), and the docs/changelog.
|
Follow-up commit (316c46f): eXeLearning's own authoring preview now reveals Teacher Mode by default — the preview panel loads the viewer with |
?exe-teacher=1 (alias ?teacher-mode=1, legacy ?exe-teacher-toggler=1) now makes the in-page Teacher Mode toggle AVAILABLE; it no longer reveals content on its own. The toggle is OFF by default and remembers the viewer's choice in localStorage — the viewer activates it to reveal teacher content. Without the parameter there is no toggle and teacher content stays hidden (student view). The authoring preview keeps appending ?exe-teacher=1, so the toggle is available while editing (off by default), consistent with a normal export opened with the parameter. Updates exe_export.js bootstrap, its tests, the E2E spec, the previewPanel comments, and the docs/changelog.
…S injection eXeLearning packages hide teacher-only content by default and expose an in-page "teacher layer" selector through the ?exe-teacher=1 URL parameter (upstream exelearning/exelearning#1972, fixes exelearning/exelearning#1772). The plugin now appends that parameter to the embed instead of injecting CSS/JS into the package. - Shortcode (public/class-shortcodes.php): append ?exe-teacher=1 when teacher_mode or teacher_mode_visible is on; drop the toggler-hiding and activate-on-load inline scripts from render_preview_script. - Block (includes/class-elp-upload-block.php): append ?exe-teacher=1 in build_preview_url when teacherModeVisible is on; remove teacher_mode_hide_script. - Relabel the block control to "Show teacher layer selector" with homogeneous help; refresh the admin shortcode reference, SHORTCODES.md and readme.txt. - i18n: translate the three changed strings across all 10 catalogs; rebuild .mo and the elp-upload.js .json. - Tests: rewrite the teacher-mode shortcode/block tests for the URL-param model.
…hidden-by-default-opt-in-to-reveal
…hidden-by-default-opt-in-to-reveal
…hidden-by-default-opt-in-to-reveal
…hidden-by-default-opt-in-to-reveal
pabloamayab
left a comment
There was a problem hiding this comment.
LGTM!!! Now I'm going to review Moodle extensions
…injection (#58) * fix(teacher-mode): reveal via core ?exe-teacher URL param, drop CSS/JS injection eXeLearning packages hide teacher-only content by default and expose an in-page "teacher layer" selector through the ?exe-teacher=1 URL parameter (upstream exelearning/exelearning#1972, fixes exelearning/exelearning#1772). The plugin now appends that parameter to the embed instead of injecting CSS/JS into the package. - Shortcode (public/class-shortcodes.php): append ?exe-teacher=1 when teacher_mode or teacher_mode_visible is on; drop the toggler-hiding and activate-on-load inline scripts from render_preview_script. - Block (includes/class-elp-upload-block.php): append ?exe-teacher=1 in build_preview_url when teacherModeVisible is on; remove teacher_mode_hide_script. - Relabel the block control to "Show teacher layer selector" with homogeneous help; refresh the admin shortcode reference, SHORTCODES.md and readme.txt. - i18n: translate the three changed strings across all 10 catalogs; rebuild .mo and the elp-upload.js .json. - Tests: rewrite the teacher-mode shortcode/block tests for the URL-param model. * Default the teacher-layer selector to OFF (align with #1772 opt-in)

Summary
teacher-onlyclass on blocks and iDevices) by default in exported packages and in the preview.?exe-teacher=1(alsotrue/yes, the generic alias?teacher-mode=1, and the legacy?exe-teacher-toggler=1), and it is OFF by default — the viewer activates it to reveal teacher content (state remembered inlocalStorage). The parameter never reveals content on its own.Context
Fixes #1772.
Previously the only way to reveal teacher content was a self-serve toggle shown to everyone (any student could flip it), which is why every host plugin injected CSS to hide it. Now the toggle is hidden by default and appears only when the host opts in via the URL parameter.
Host integrations switch by changing the URL only:
index.htmlindex.html?exe-teacher=1Implementation
public/app/common/exe_export.js(teacherMode), loaded in<head>for every export format and the preview:bootstrap()runs at parse time: it sets_showTogglerfrom a truthy parameter and, when the toggle is available, restores the viewer's stored on/off choice flicker-free (addsmode-teacherto<html>only iflocalStoragesays on). It never reveals on its own.init()renders the toggle only when the parameter made it available and.teacher-onlycontent exists; the toggle's change handler adds/removesmode-teacherand persists the choice.base.css(html:not(.mode-teacher) .js .teacher-only { display:none !important }) is unchanged.previewPanel.js) loads the viewer with?exe-teacher=1, so the toggle is available while editing (still off by default).helpfield on bothteacherOnlydefinitions insrc/routes/config-params.ts.Notes
?exe-teacher=1only exposes a toggle; it is not authentication and not a security boundary. Truly sensitive answer keys need a separate authenticated/password-gated feature.Testing
public/app/common/exe_export.test.js(Vitest): the parameter sets_showToggler(incl. aliases), does not reveal on its own, restores the revealed state fromlocalStorageonly when the toggle is available, and the toggle's render/checked/change behavior.test/integration/teacher-mode-toggle.spec.ts(Bun): teacher-only class + the base.css hide rule in the exported HTML.test/e2e/playwright/specs/teacher-mode-url-param.spec.ts(Playwright): the SW-served preview's runtime makes the toggle available (_showToggler) with?exe-teacher=1, and not without it.src/routes/config-params.spec.ts: the authoring hint is present and translation-prefixed.Full suite green:
make test-unit(7375), full frontend Vitest (13352),make test-integration(721), the E2E spec, andmake fix.Why host plugins get simpler (and where this is heading)
Because teacher-mode visibility is now driven purely by the package's own
?exe-teacher=1URL parameter, the host plugins (WordPress, Moodle ×3, Omeka-S) drop the CSS/JS they used to inject into the embedded package to hide the toggle — they only change the iframe URL. Beyond that cleanup, this advances the longer-term goal of isolating embedded resource content from the host: with the host no longer reaching into the package DOM, the resource can later be sandboxed / served cross-origin without losing teacher-mode control. The consuming plugin PRs (kept blocked until this one merges): wp-exelearning#58, omeka-s-exelearning#23, mod_exeweb#65, mod_exescorm#81, mod_exelearning#86.