Embed a Page written in PHP or with Javascript

Embed a Page written in PHP or with Javascript

by Hoi Ki Wan -
Number of replies: 2
I have written some simple quizzes in PHP and some in html+javascript. I would like to know if it is possible for me to embed it into course like adding page resources.

Thanks.
Average of ratings: -
In reply to Hoi Ki Wan

Re: Embed a Page written in PHP or with Javascript

by reeve strife -

Also need to do this.

did you have any luck with this so far?

In reply to Hoi Ki Wan

Re: Embed a Page written in PHP or with Javascript

by reeve strife -

If your code does not contain PHP, just html you can upload a "mini site" zipped file, as file resource, and then unzip it (moodle can do this) this will then be served as a mini site.

see this discussion:

https://moodle.org/mod/forum/discuss.php?d=36408

but this does not work for PHP mini site.

You can add a mini php site in the  /local/yourfolder/

with php script like this, to give context to moodle

<?php

require_once('../../config.php');

$PAGE->set_context(get_system_context());
$PAGE->set_pagelayout('admin');
$PAGE->set_title("Your title");
$PAGE->set_heading("Blank page");
$PAGE->set_url($CFG->wwwroot.'/blank_page.php');

echo $OUTPUT->header();
echo "Hello World";

if (isloggedin()) {
echo "you are logged in!!!!!";
global $USER;
$userid = $USER->id;
echo $userid;
}
echo $OUTPUT->footer();

?>


and then add a hyperlink resource on your course to this page,

however, then anyone can still access this course material, even if they are not subscribed to this specific course.... this is where i am stuck now


Average of ratings: Useful (1)