1
0
mirror of https://github.com/moodle/moodle.git synced 2025-04-25 10:26:17 +02:00

MDL-79610 courseformat: Fix availability restrictions rendering

When duplicating a course module, availability restrictions was not rendering
properly. That happened because 'editing' was not being exported for template
for a single course module. This patch adds 'editing' to the cm exported data.
This commit is contained in:
Mikel Martín 2023-11-22 09:28:59 +01:00
parent 6374475dc3
commit d94b14d396
2 changed files with 16 additions and 0 deletions
availability/tests/behat
course/format/classes/output/local/content

@ -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"

@ -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.