Kumi
17e8bc0c18
Modified script.js to dynamically include the activity name in the content button text using a data attribute. Updated view.php to pass the activity name to the script for better contextual display of the content button. This enhancement improves the user experience by making the button's label more meaningful and relevant.
38 lines
1.3 KiB
PHP
38 lines
1.3 KiB
PHP
<?php
|
|
|
|
require_once(dirname(dirname(dirname(__FILE__))) . '/config.php');
|
|
require_once(dirname(__FILE__) . '/lib.php');
|
|
|
|
$id = optional_param('id', 0, PARAM_INT); // Course Module ID
|
|
$n = optional_param('n', 0, PARAM_INT); // exp360 instance ID
|
|
|
|
if ($id) {
|
|
$cm = get_coursemodule_from_id('exp360', $id, 0, false, MUST_EXIST);
|
|
$course = $DB->get_record('course', array('id' => $cm->course), '*', MUST_EXIST);
|
|
$exp360 = $DB->get_record('exp360', array('id' => $cm->instance), '*', MUST_EXIST);
|
|
} else if ($n) {
|
|
$exp360 = $DB->get_record('exp360', array('id' => $n), '*', MUST_EXIST);
|
|
$course = $DB->get_record('course', array('id' => $exp360->course), '*', MUST_EXIST);
|
|
$cm = get_coursemodule_from_instance('exp360', $exp360->id, $course->id, false, MUST_EXIST);
|
|
} else {
|
|
print_error('You must specify a course_module ID or an instance ID');
|
|
}
|
|
|
|
require_login($course, true, $cm);
|
|
|
|
$PAGE->set_url('/mod/exp360/view.php', array('id' => $cm->id));
|
|
$PAGE->set_title(format_string($exp360->name));
|
|
$PAGE->set_heading(format_string($course->fullname));
|
|
|
|
echo $OUTPUT->header();
|
|
|
|
$content_id = $exp360->content_id;
|
|
$activity_name = $exp360->name;
|
|
|
|
echo "<script
|
|
data-activity-id='$content_id'
|
|
data-activity-name='$activity_name'
|
|
src='/mod/exp360/script.js'>
|
|
</script>";
|
|
|
|
echo $OUTPUT->footer();
|