Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 0 additions & 62 deletions classes/local/ui/teacher_mode_hider.php

This file was deleted.

2 changes: 1 addition & 1 deletion db/install.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
<FIELD NAME="gradeenabled" TYPE="int" LENGTH="2" NOTNULL="true" DEFAULT="1" SEQUENCE="false" COMMENT="Master grading switch (DEC-0029): 1=activity is graded (detect iDevices, gradebook columns, reports); 0=not graded (no grade items, no reports, behaves like a plain resource)."/>
<FIELD NAME="maxattempt" TYPE="int" LENGTH="10" NOTNULL="true" DEFAULT="0" SEQUENCE="false" COMMENT="Max attempts per user (DEC-0007 phase 2): 0=unlimited."/>
<FIELD NAME="reviewmode" TYPE="int" LENGTH="4" NOTNULL="true" DEFAULT="1" SEQUENCE="false" COMMENT="Student attempt review (DEC-0007 phase 2): 0=never, 1=always, 2=after completion."/>
<FIELD NAME="teachermodevisible" TYPE="int" LENGTH="2" NOTNULL="true" DEFAULT="0" SEQUENCE="false" COMMENT="If 1, show eXeLearning's in-package teacher-mode toggle (#teacher-mode-toggler-wrapper); if 0 (default) inject CSS to hide it (mod_exeweb parity)."/>
<FIELD NAME="teachermodevisible" TYPE="int" LENGTH="2" NOTNULL="true" DEFAULT="0" SEQUENCE="false" COMMENT="If 1, append the eXeLearning package's ?exe-teacher=1 URL parameter so its teacher-layer selector is available; if 0 (default) the package is served unchanged with teacher content hidden."/>
<FIELD NAME="timecreated" TYPE="int" LENGTH="10" NOTNULL="true" DEFAULT="0" SEQUENCE="false"/>
<FIELD NAME="timemodified" TYPE="int" LENGTH="10" NOTNULL="true" DEFAULT="0" SEQUENCE="false"/>
<FIELD NAME="usermodified" TYPE="int" LENGTH="10" NOTNULL="true" DEFAULT="0" SEQUENCE="false"/>
Expand Down
12 changes: 7 additions & 5 deletions db/upgrade.php
Original file line number Diff line number Diff line change
Expand Up @@ -273,11 +273,13 @@ function xmldb_exelearning_upgrade($oldversion) {
upgrade_mod_savepoint(true, 2026052900, 'exelearning');
}

// Stage 8 (2026052901): teachermodevisible changes meaning. It used to gate
// the Moodle "Try as a student" preview banner; now it controls eXeLearning's
// in-package teacher-mode toggle (#teacher-mode-toggler-wrapper), hidden by
// default via injected CSS (mod_exeweb parity). Lower the default 1 -> 0 and
// reset existing rows to the new default so the toggle is hidden by default.
// Stage 8 (2026052901): teachermodevisible changes meaning and defaults to 0.
// It used to gate the Moodle "Try as a student" preview banner; it now controls
// whether the eXeLearning teacher-layer selector is shown in the embedded package
// (default off = no selector, teacher content hidden). When on, the plugin appends
// the package's own ?exe-teacher=1 URL parameter (set in view.php) so the selector
// is available to every viewer; the plugin no longer injects CSS into the package.
// Lower the default 1 -> 0 and reset existing rows to the new default.
if ($oldversion < 2026052901) {
$instance = new xmldb_table('exelearning');

Expand Down
4 changes: 2 additions & 2 deletions lang/ca/exelearning.php
Original file line number Diff line number Diff line change
Expand Up @@ -398,8 +398,8 @@
$string['stylesuploaded'] = '~Estils pujats';
$string['stylesuploaded_empty'] = '~Encara no hi ha estils pujats.';
$string['stylesuploaded_hint'] = '~Activeu o desactiveu els estils pujats. Desmarqueu-los per amagar-los de l\'editor; elimineu-los per esborrar-los definitivament.';
$string['teachermodevisible'] = '~Mostra el selector de capa docent d\'eXeLearning';
$string['teachermodevisible_help'] = '~Els paquets eXeLearning poden incloure un selector de «capa docent» que revela el contingut marcat només per a professors. Quan aquest ajust està desactivat (per defecte), aquest selector s\'amaga a la vista de l\'activitat injectant CSS al paquet, de manera que els estudiants mai no el veuen. Activeu-lo perquè el selector aparegui al recurs.';
$string['teachermodevisible'] = 'Mostrar el selector de capa docent';
$string['teachermodevisible_help'] = 'Si es desactiva, el selector de capa docent s\'ocultarà al contingut eXeLearning incrustat.';
$string['unsavedchanges'] = 'Teniu canvis sense desar. Esteu segurs que voleu tancar?';
$string['updateavailable'] = 'Actualització disponible';
$string['viewattemptsreport'] = '~Visualitza l\'informe d\'intents';
Expand Down
4 changes: 2 additions & 2 deletions lang/en/exelearning.php
Original file line number Diff line number Diff line change
Expand Up @@ -394,8 +394,8 @@
$string['stylesuploaded'] = 'Uploaded styles';
$string['stylesuploaded_empty'] = 'No uploaded styles yet.';
$string['stylesuploaded_hint'] = 'Enable or disable uploaded styles. Uncheck to hide a style from the editor; delete to remove it permanently.';
$string['teachermodevisible'] = 'Show eXeLearning teacher-mode toggle';
$string['teachermodevisible_help'] = 'eXeLearning packages can include a "teacher mode" toggle that reveals content marked for teachers only. When this setting is disabled (the default), that toggle is hidden in the activity view by injecting CSS into the package, so students never see it. Enable it to let the toggle appear in the resource.';
$string['teachermodevisible'] = 'Show teacher layer selector';
$string['teachermodevisible_help'] = 'If disabled, the teacher layer selector is hidden in the embedded eXeLearning content.';
$string['unsavedchanges'] = 'You have unsaved changes. Are you sure you want to close?';
$string['updateavailable'] = 'Update available';
$string['viewattemptsreport'] = 'View attempts report';
Expand Down
2 changes: 1 addition & 1 deletion lang/es/exelearning.php
Original file line number Diff line number Diff line change
Expand Up @@ -399,7 +399,7 @@
$string['stylesuploaded_empty'] = 'Todavía no hay estilos subidos.';
$string['stylesuploaded_hint'] = 'Activa o desactiva los estilos subidos. Desmárcalos para ocultarlos del editor; elimínalos para borrarlos definitivamente.';
$string['teachermodevisible'] = 'Mostrar el selector de capa docente';
$string['teachermodevisible_help'] = '~Los paquetes eXeLearning pueden incluir un selector de «capa docente» que revela el contenido marcado solo para profesores. Cuando este ajuste está desactivado (por defecto), ese selector se oculta en la vista de la actividad inyectando CSS en el paquete, de modo que los estudiantes nunca lo ven. Actívelo para que el selector aparezca en el recurso.';
$string['teachermodevisible_help'] = 'Si se desactiva, se ocultará el selector de capa docente en el contenido eXeLearning embebido.';
$string['unsavedchanges'] = 'Tiene cambios sin guardar. ¿Está seguro de que desea cerrar?';
$string['updateavailable'] = 'Actualización disponible';
$string['viewattemptsreport'] = '~Ver informe de intentos';
Expand Down
4 changes: 2 additions & 2 deletions lang/eu/exelearning.php
Original file line number Diff line number Diff line change
Expand Up @@ -398,8 +398,8 @@
$string['stylesuploaded'] = '~Igotako estiloak';
$string['stylesuploaded_empty'] = '~Oraindik ez dago igotako estilorik.';
$string['stylesuploaded_hint'] = '~Gaitu edo desgaitu igotako estiloak. Desmarkatu editoretik ezkutatzeko; ezabatu betiko kentzeko.';
$string['teachermodevisible'] = '~Erakutsi eXeLearning irakasle-modu hautagailua';
$string['teachermodevisible_help'] = '~eXeLearning paketeek «irakasle-modua» hautagailu bat eduki dezakete, irakasleentzat soilik markatutako edukia agertzen duena. Ezarpen hau desgaituta dagoenean (lehenetsia), hautagailu hori jardueraren ikuspegian ezkutatzen da paketean CSS txertatuz, ikasleek inoiz ez dezaten ikus. Gaitu ezazu hautagailua baliabidean ager dadin.';
$string['teachermodevisible'] = 'Erakutsi irakasle-geruza hautatzailea';
$string['teachermodevisible_help'] = 'Desaktibatuta badago, irakasle-geruza hautatzailea ezkutatuko da eXeLearning eduki txertatuan.';
$string['unsavedchanges'] = 'Gorde gabeko aldaketak dituzu. Ziur zaude itxi nahi duzula?';
$string['updateavailable'] = 'Eguneraketa eskuragarri';
$string['viewattemptsreport'] = '~Ikusi saialdien txostena';
Expand Down
4 changes: 2 additions & 2 deletions lang/gl/exelearning.php
Original file line number Diff line number Diff line change
Expand Up @@ -398,8 +398,8 @@
$string['stylesuploaded'] = '~Estilos subidos';
$string['stylesuploaded_empty'] = '~Aínda non hai estilos subidos.';
$string['stylesuploaded_hint'] = '~Active ou desactive os estilos subidos. Desmárqueos para ocultalos do editor; elimíneos para borralos definitivamente.';
$string['teachermodevisible'] = '~Amosar o selector de capa docente de eXeLearning';
$string['teachermodevisible_help'] = '~Os paquetes eXeLearning poden incluír un selector de «capa docente» que revela o contido marcado só para profesores. Cando este axuste está desactivado (por defecto), ese selector ocúltase na vista da actividade inxectando CSS no paquete, de xeito que os estudantes nunca o ven. Actíveo para que o selector apareza no recurso.';
$string['teachermodevisible'] = 'Amosar o selector de capa docente';
$string['teachermodevisible_help'] = 'Se se desactiva, ocultarase o selector de capa docente no contido eXeLearning embebido.';
$string['unsavedchanges'] = 'Ten cambios sen gardar. Está seguro de que desexa pechar?';
$string['updateavailable'] = 'Actualización dispoñible';
$string['viewattemptsreport'] = '~Ver informe de intentos';
Expand Down
13 changes: 0 additions & 13 deletions lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -728,19 +728,6 @@ function exelearning_extract_stored_package(int $contextid, int $revision): void
\mod_exelearning\local\package_manager::extract_stored($contextid, $revision);
}

/**
* Hide eXeLearning's teacher-mode toggle (#teacher-mode-toggler-wrapper) inside
* the package iframe (mod_exeweb parity). Queues parent-page JS that injects a
* <style> into the iframe's content document once it loads. The iframe is
* same-origin (served via pluginfile.php), so this DOM access is allowed.
*
* @param string $iframeid The id attribute of the package iframe.
* @return void
*/
function exelearning_require_teacher_mode_hider(string $iframeid): void {
\mod_exelearning\local\ui\teacher_mode_hider::require_for_iframe($iframeid);
}

/**
* Injects SCORM wrapper script tags into the <head> of index.html and all
* html/<slug>.html pages of the extracted package.
Expand Down
6 changes: 4 additions & 2 deletions mod_form.php
Original file line number Diff line number Diff line change
Expand Up @@ -226,8 +226,10 @@ public function definition() {
$mform->disabledIf($gradefield, 'gradeenabled', 'notchecked');
}

// Appearance: whether to show the teacher preview/grading toggle in the
// activity view (mod_exeweb parity). Default on.
// Appearance: whether to show the eXeLearning teacher-layer selector in the
// embedded package. The package hides teacher-only content by default; when this
// is on the plugin appends the package's supported ?exe-teacher=1 URL parameter so
// the selector is available to every viewer. Default off.
$mform->addElement(
'header',
'appearancesection',
Expand Down
27 changes: 27 additions & 0 deletions tests/behat/mod_exelearning.feature
Original file line number Diff line number Diff line change
Expand Up @@ -142,3 +142,30 @@ Feature: View a mod_exelearning activity and its attempts report
And I am on the "Evaluable unit" "exelearning activity" page logged in as teacher1
When I follow "View attempts report"
Then I should see "Download report data as"

# Teacher-layer selector (upstream exelearning#1772, server-rendered, no @javascript):
# eXeLearning packages hide teacher-only content by default and expose a selector to
# show it via the package's own ?exe-teacher=1 URL parameter. The plugin appends that
# parameter to the iframe src whenever the per-activity "Show teacher layer selector"
# setting (teachermodevisible) is on — for any viewer. The iframe src is server-rendered,
# so the non-JS driver can assert on it directly.
Scenario: A teacher sees the exe-teacher parameter when the setting is on
Given the following "activities" exist:
| activity | name | course | idnumber | teachermodevisible |
| exelearning | Teacher reveal | C1 | exetr | 1 |
And I am on the "Teacher reveal" "exelearning activity" page logged in as teacher1
Then the "src" attribute of "iframe#exelearningobject" "css_element" should contain "exe-teacher=1"

Scenario: A teacher does not see the exe-teacher parameter when the reveal is off
Given the following "activities" exist:
| activity | name | course | idnumber | teachermodevisible |
| exelearning | Teacher noreveal | C1 | exetn | 0 |
And I am on the "Teacher noreveal" "exelearning activity" page logged in as teacher1
Then the "src" attribute of "iframe#exelearningobject" "css_element" should not contain "exe-teacher"

Scenario: A student also sees the exe-teacher parameter when the setting is on
Given the following "activities" exist:
| activity | name | course | idnumber | teachermodevisible |
| exelearning | Teacher student vw | C1 | exets | 1 |
And I am on the "Teacher student vw" "exelearning activity" page logged in as student1
Then the "src" attribute of "iframe#exelearningobject" "css_element" should contain "exe-teacher=1"
10 changes: 0 additions & 10 deletions tests/lib_callbacks_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,11 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
* @covers ::exelearning_view
* @covers ::exelearning_get_grade_item_names
* @covers ::exelearning_require_teacher_mode_hider
* @covers ::exelearning_pluginfile
* @covers ::exelearning_extend_settings_navigation
* @covers ::exelearning_navigation_before_key
* @covers ::exelearning_update_instance
* @covers \mod_exelearning\local\urls
* @covers \mod_exelearning\local\ui\teacher_mode_hider
*/
final class lib_callbacks_test extends advanced_testcase {
/**
Expand Down Expand Up @@ -89,14 +87,6 @@ public function test_get_grade_item_names(): void {
$this->assertSame('Item #99', $names[12]);
}

/**
* exelearning_require_teacher_mode_hider() enqueues page JS without error.
*/
public function test_require_teacher_mode_hider(): void {
$this->resetAfterTest();
$this->assertNull(exelearning_require_teacher_mode_hider('exelearningobject'));
}

/**
* exelearning_pluginfile() gates the package area behind manageactivities, so
* a plain student cannot download the source package.
Expand Down
20 changes: 13 additions & 7 deletions view.php
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,15 @@
'/',
'index.html'
);
// Make the in-package teacher-layer selector available via the package's own URL
// parameter (eXeLearning core hides teacher content by default and exposes a
// selector to show it with ?exe-teacher=1; see upstream exelearning#1772). This
// replaces the former CSS injection that hid the selector (mod_exeweb parity): the
// plugin no longer mutates the package. The per-activity teachermodevisible setting
// alone controls it — when on, the selector is offered to every viewer; no role gate.
if (!empty($exelearning->teachermodevisible)) {
$iframeurl->param('exe-teacher', '1');
}
// Deep-link from the gradebook (issue #13 #4, DEC-0023): grade.php maps a
// clicked grade item's itemnumber to its iDevice objectid and forwards it
// here. Exported iDevices render as <article id="<odeIdeviceId>">, so a URL
Expand Down Expand Up @@ -488,13 +497,10 @@
'style' => 'border: 1px solid var(--bs-border-color, #dee2e6); border-radius: .5rem;',
]);

// Hide eXeLearning's teacher-mode toggle inside the package (mod_exeweb
// parity): when teachermodevisible=0, inject CSS into the iframe content to
// hide #teacher-mode-toggler-wrapper. The iframe is same-origin (served via
// pluginfile.php) so the parent can reach its content document.
if (empty($exelearning->teachermodevisible)) {
exelearning_require_teacher_mode_hider('exelearningobject');
}
// Teacher-only content is hidden by default inside the eXeLearning package and
// revealed via the ?exe-teacher=1 URL parameter appended to the iframe src above
// when the teachermodevisible setting is on. The plugin no longer injects CSS into
// the package to hide the teacher-layer selector (mod_exeweb parity retired).
}

echo $OUTPUT->footer();
Loading