forked from CustomAppsSA-Team/GRAiDY-Plugins-2025
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcourse.php
65 lines (51 loc) · 1.99 KB
/
course.php
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
<style>
.activity-header{
display: none !important;
}
</style>
<?php
/**
* Displays Graidy portal in an iframe, tied to a specific course ID.
*
* URL format: /local/graidy/course.php?id=COURSEID
*
* @package local_graidy
*/
require_once(__DIR__ . '/../../config.php');
// Get the course ID from the URL.
//$courseid = required_param('id', PARAM_INT);
$courseid = required_param('courseid', PARAM_INT); // Required course ID.
// Load the course object.
$course = get_course($courseid);
require_login($course);
$context = context_course::instance($courseid);
$PAGE->set_context($context);
// Setup the context for this course.
debugging("Context type: " . $context->contextlevel . ", Instance ID: " . $context->instanceid);
// Setup the page URL, title, and heading.
$PAGE->set_url('/local/graidy/course.php', ['id' => $courseid]);
// Example: You could use $course->fullname as the page heading/title.
$PAGE->set_title(get_string('pluginname', 'local_graidy'));
$PAGE->set_heading($course->fullname);
// Get base portal URL from plugin settings, or fallback.
$baseurl = get_config('local_graidy', 'baseurl');
if (empty($baseurl)) {
// Fallback or handle error.
$baseurl = 'https:/portal.graidy.tech';
}
// Determine which path to load in the iframe (dashboard, etc.).
$path = optional_param('path', 'dashboard', PARAM_ALPHANUMEXT);
// Construct the full iframe URL.
$iframeurl = rtrim($baseurl, '/') . '/' . $path;
// Output the page header.
echo $OUTPUT->header();
// Embed your iframe or content here.
// 1. Get the GRAiDY base URL from plugin settings.
$graidybaseurl = get_config('local_graidy', 'baseurl');
$organizationtoken = get_config('local_graidy', 'organizationtoken');
$token = local_graidy_get_or_create_token($USER->id);
$iframeurl = $graidybaseurl . '/moodle/plugin/course/' . $courseid . '/' . $USER->id . '/' . $token . '/' . $organizationtoken;
$output = $PAGE->get_renderer('local_graidy');
echo $output->render_iframe($iframeurl);
// Finish the page.
echo $OUTPUT->footer();