diff --git a/availability/tests/behat/edit_availability.feature b/availability/tests/behat/edit_availability.feature index c5e1aa032d8..b7d18668ce2 100644 --- a/availability/tests/behat/edit_availability.feature +++ b/availability/tests/behat/edit_availability.feature @@ -264,3 +264,16 @@ Feature: edit_availability And I should not see "Content" And I should see "Collapse all" And I should not see "Expand all" + + @javascript + Scenario: Edit activity availability button is shown after duplicating an activity + # Setting a restriction up + Given I am on the "MyForum" "forum activity editing" page logged in as teacher1 + And I expand all fieldsets + And I press "Add restriction..." + And I click on "Date" "button" in the "Add restriction..." "dialogue" + When I press "Save and return to course" + And I turn editing mode on + And I duplicate "MyForum" activity + # Testing edit restrictions link + Then "Edit restrictions" "link" should exist in the "MyForum (copy)" "core_availability > Activity availability" diff --git a/course/format/classes/output/local/content/cm.php b/course/format/classes/output/local/content/cm.php index 89063a63937..ed237ef40ba 100644 --- a/course/format/classes/output/local/content/cm.php +++ b/course/format/classes/output/local/content/cm.php @@ -107,6 +107,8 @@ class cm implements named_templatable, renderable { * @return stdClass data context for a mustache template */ public function export_for_template(renderer_base $output): stdClass { + global $PAGE; + $mod = $this->mod; $displayoptions = $this->displayoptions; @@ -118,6 +120,7 @@ class cm implements named_templatable, renderable { 'textclasses' => $displayoptions['textclasses'], 'classlist' => [], 'cmid' => $mod->id, + 'editing' => $PAGE->user_is_editing(), ]; // Add partial data segments.