Skip to content

Commit

Permalink
Add import form to tabs
Browse files Browse the repository at this point in the history
  • Loading branch information
bwalkerl committed Sep 13, 2024
1 parent 6daa2e5 commit 632228d
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 deletions.
6 changes: 6 additions & 0 deletions classes/output/tabs.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,12 @@ public function export_for_template(\renderer_base $output): array {
'title' => get_string('report_page_groups', 'tool_excimer'),
'text' => get_string('tab_page_groups', 'tool_excimer'),
],
[
'id' => 'import',
'link' => [['link' => new \moodle_url('/admin/tool/excimer/import.php')]],
'title' => get_string('import_profile', 'tool_excimer'),
'text' => get_string('tab_import', 'tool_excimer'),
],
],
];

Expand Down
10 changes: 5 additions & 5 deletions import.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,13 @@
// Check for caps.
require_capability('moodle/site:config', context_system::instance());

$overviewurl = new moodle_url('/admin/category.php?category=tool_excimer_reports');
$url = new moodle_url('/admin/tool/excimer/import.php');
$PAGE->set_url($url);

$customdata = [];
$form = new import_form($PAGE->url->out(false), $customdata);
if ($form->is_cancelled()) {
redirect($overviewurl);
redirect($url);
}

if (($data = $form->get_data())) {
Expand All @@ -58,7 +57,7 @@
if (empty($id)) {
// Failed to save the imported profile.
\core\notification::error(get_string('import_error', 'tool_excimer'));
redirect($overviewurl);
redirect($url);
}

// The import was a success, so redirect to the imported profile.
Expand All @@ -81,8 +80,9 @@
$PAGE->set_heading(get_string('pluginname', 'tool_excimer'));
echo $OUTPUT->header();

// Output headings.
echo $OUTPUT->heading($heading);
$renderer = $PAGE->get_renderer('tool_excimer');
$tabs = new tool_excimer\output\tabs($url);
echo $renderer->render_tabs($tabs);

// And display the form, and its validation errors if there are any.
$form->display();
Expand Down
1 change: 1 addition & 0 deletions lang/en/tool_excimer.php
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@
$string['unfinished'] = 'Unfinished';
$string['tab_page_groups'] = 'Page Groups';
$string['tab_page_course'] = 'Courses';
$string['tab_import'] = 'Import';

// Month Selector.
$string['displaying_month'] = 'Displaying month';
Expand Down

0 comments on commit 632228d

Please sign in to comment.