-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathview.php
More file actions
68 lines (59 loc) · 2.72 KB
/
Copy pathview.php
File metadata and controls
68 lines (59 loc) · 2.72 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
<?php
/**
* This file is part of local_olximport, an Open edX OLX course importer for Moodle/Totara
*
* Copyright (C) 2026 onwards Muhammad Omer Nawaz, Arbisoft
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* @author Muhammad Omer Nawaz, Arbisoft <omer.nawaz@arbisoft.com>
* @package local_olximport
*/
use local_olximport\compat;
use local_olximport\model\import_run;
require(__DIR__ . '/../../config.php');
// Shows one import run's status, the course it produced once known, and the import log. Imports
// happen in a background adhoc task, so a run may still be queued/running when this is first
// viewed — the page auto-refreshes until it isn't.
//
// Reuses index.php's registered admin external page (same capability check, same admin-tree
// section) rather than a separate nav entry — passing this page's own URL as $actualurl so
// breadcrumbs and the active nav highlight match the real URL rather than index.php's.
$id = required_param('id', PARAM_INT);
compat::admin_page_setup(
'local_olximport_import',
(new moodle_url('/local/olximport/view.php', ['id' => $id]))->out(false)
);
$run = import_run::load_by_id($id);
$title = get_string('reportheading', 'local_olximport');
$PAGE->set_title($title);
$PAGE->set_heading($title);
$log_entries = array_map(static fn(string $text): array => ['text' => $text], $run->log_entries);
$courseurl = $run->courseid
? (new moodle_url('/course/view.php', ['id' => $run->courseid]))->out(false)
: false;
echo $OUTPUT->header();
// See the equivalent comment in index.php: this theme's admin layout doesn't render
// $PAGE->heading itself, so the visible heading has to be emitted explicitly.
echo $OUTPUT->heading($title);
echo $OUTPUT->render_from_template('local_olximport/report_page', [
'filename' => $run->filename,
'statuslabel' => get_string('status' . $run->status, 'local_olximport'),
'autorefresh' => in_array($run->status, [import_run::STATUS_QUEUED, import_run::STATUS_RUNNING], true),
'courseurl' => $courseurl,
'errormessage' => $run->errormessage ?: false,
'haslog' => (bool) $log_entries,
'logentries' => $log_entries,
]);
echo $OUTPUT->footer();