From ca42ec08a7a48270e0aaa8ad4605013f99bcfd94 Mon Sep 17 00:00:00 2001 From: Paul Holden Date: Wed, 15 May 2024 14:55:38 +0100 Subject: [PATCH] MDL-81904 mod_feedback: show export questions only if any present. --- mod/feedback/classes/output/edit_action_bar.php | 16 ++++++++++------ mod/feedback/tests/behat/export_import.feature | 1 + 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/mod/feedback/classes/output/edit_action_bar.php b/mod/feedback/classes/output/edit_action_bar.php index a0b35430fa0..c2467358c4b 100644 --- a/mod/feedback/classes/output/edit_action_bar.php +++ b/mod/feedback/classes/output/edit_action_bar.php @@ -53,6 +53,8 @@ class edit_action_bar extends base_action_bar { * @return array */ public function get_items(): array { + global $DB; + $url = new moodle_url('/mod/feedback/view.php', ['id' => $this->cmid]); $items['left'][]['actionlink'] = new action_link($url, get_string('back'), null, ['class' => 'btn btn-secondary']); @@ -82,12 +84,14 @@ class edit_action_bar extends base_action_bar { 'typ', feedback_load_feedback_items_options()); $items['left'][]['singleselect'] = $select; - $exporturl = new moodle_url('/mod/feedback/export.php', $this->urlparams + ['action' => 'exportfile']); - $items['export'] = new action_link( - $exporturl, - get_string('export_questions', 'feedback'), - null, - ['class' => 'btn btn-secondary']); + if ($DB->record_exists('feedback_item', ['feedback' => $this->feedback->id])) { + $items['export'] = new action_link( + new moodle_url('/mod/feedback/export.php', $this->urlparams + ['action' => 'exportfile']), + get_string('export_questions', 'feedback'), + null, + ['class' => 'btn btn-secondary'], + ); + } } } diff --git a/mod/feedback/tests/behat/export_import.feature b/mod/feedback/tests/behat/export_import.feature index 3b9159c4bfc..a01851b13ad 100644 --- a/mod/feedback/tests/behat/export_import.feature +++ b/mod/feedback/tests/behat/export_import.feature @@ -24,6 +24,7 @@ Feature: Exporting and importing feedbacks Scenario: Export sample feedback and compare with the fixture When I am on the "Learning experience" "feedback activity" page logged in as teacher And I click on "Edit questions" "link" in the "[role=main]" "css_element" + And "Export questions" "link" should not exist in the ".tertiary-navigation" "css_element" And I add a "Information" question to the feedback with: | Question | this is an information question | | Label | info |