From c3386a497cab0848d4244d843d20a07394949442 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?I=C3=B1igo=20Zendegi?= Date: Fri, 3 May 2024 08:01:44 +0200 Subject: [PATCH] MDL-81733 lesson: Support filters on lesson activity link --- mod/lesson/locallib.php | 6 ++++-- mod/lesson/mod_form.php | 3 ++- mod/lesson/tests/behat/lesson_navigation.feature | 15 ++++++++++++--- 3 files changed, 18 insertions(+), 6 deletions(-) diff --git a/mod/lesson/locallib.php b/mod/lesson/locallib.php index 40cefdf9bc684..2003f0b8ac2a1 100644 --- a/mod/lesson/locallib.php +++ b/mod/lesson/locallib.php @@ -2299,8 +2299,10 @@ public function link_for_activitylink() { $instancename = $DB->get_field($modname, 'name', array('id' => $module->instance)); if ($instancename) { return html_writer::link(new moodle_url('/mod/'.$modname.'/view.php', - array('id' => $this->properties->activitylink)), get_string('activitylinkname', - 'lesson', $instancename), array('class' => 'centerpadded lessonbutton standardbutton pr-3')); + ['id' => $this->properties->activitylink]), + get_string('activitylinkname', 'lesson', + format_string($instancename, true, ['context' => $this->get_context()])), + ['class' => 'centerpadded lessonbutton standardbutton pr-3']); } } } diff --git a/mod/lesson/mod_form.php b/mod/lesson/mod_form.php index eb421e75d0ea2..d48047e57dd67 100644 --- a/mod/lesson/mod_form.php +++ b/mod/lesson/mod_form.php @@ -163,7 +163,8 @@ function definition() { if ($module = get_coursemodule_from_instance($mod->modname, $mod->instance, $COURSE->id)) { // Exclude this lesson, if it's already been saved. if (!isset($this->_cm->id) || $this->_cm->id != $mod->id) { - $modinstances[$mod->id] = $mod->modname.' - '.$module->name; + $modinstances[$mod->id] = get_string('pluginname', $mod->modname).' - '. + format_string($module->name, true, ['context' => $this->context]); } } } diff --git a/mod/lesson/tests/behat/lesson_navigation.feature b/mod/lesson/tests/behat/lesson_navigation.feature index d329ba753d4d2..0cf3b9c398ef3 100644 --- a/mod/lesson/tests/behat/lesson_navigation.feature +++ b/mod/lesson/tests/behat/lesson_navigation.feature @@ -17,10 +17,13 @@ Feature: In a lesson activity, students can navigate through a series of pages i | teacher1 | C1 | editingteacher | | student1 | C1 | student | And the following "activities" exist: - | activity | name | course | idnumber | - | lesson | Test lesson name | C1 | lesson1 | + | activity | name | course | idnumber | + | lesson | Test lesson name | C1 | lesson1 | + | page | A page (EN)Orri bat (EU) | C1 | PAGE1 | Scenario: Student navigation with pages and questions + Given the "multilang" filter is "on" + And the "multilang" filter applies to "content and headings" Given the following "mod_lesson > pages" exist: | lesson | qtype | title | content | | Test lesson name | content | First page name | First page contents | @@ -33,7 +36,11 @@ Feature: In a lesson activity, students can navigate through a series of pages i | Second page name | Next page | | Next page | 0 | | Hardest question ever | 2 | Correct answer | End of lesson | 1 | | Hardest question ever | 1 | Incorrect answer | Second page name | 0 | - When I am on the "Test lesson name" "lesson activity" page logged in as student1 + When I am on the "Test lesson name" "lesson activity editing" page logged in as teacher1 + And I expand all fieldsets + And I set the field "Link to next activity" to "Page - A page (EN)" + And I press "Save and display" + And I am on the "Test lesson name" "lesson activity" page logged in as student1 Then I should see "First page contents" And I press "Next page" And I should see "Second page contents" @@ -60,6 +67,8 @@ Feature: In a lesson activity, students can navigate through a series of pages i And I press "Continue" And I should see "Congratulations - end of lesson reached" And I should see "Your score is 0 (out of 1)." + And I should see "Go to A page (EN)" + And I should not see "Orri bat (EU)" Scenario: Student reattempts a question until out of attempts Given the following "mod_lesson > page" exist: