[HELP] html+js(in multi-files)+css >>> page in moodle

[HELP] html+js(in multi-files)+css >>> page in moodle

by Hoi Ki Wan -
Number of replies: 10
I have written some Maths exercises in a webpage using html+js(in multi-files)+css (Drag and drop and show the results instantly). I am now asked to integrate them into moodle as resources.
 
Is it possible to embed the page in a moodle page just like page resource?

I am new to moodle and now looking for any plugin or how to write a plugin for that. I have been keep studying the develop documents for quite a long period of time, but I still don't have any clue how to start with. It would great if anyone can give me some hints.

Thanks a lot.


Average of ratings: -
In reply to Hoi Ki Wan

Re: [HELP] html+js(in multi-files)+css >>> page in moodle

by Justin Hunt -
Picture of Particularly helpful Moodlers Picture of Plugin developers

The most direct way to do this would be to write a plugin, based on the most similar plugin already available in Moodle. 

But if its just JS and CSS, you might be able to avoid writing a new plugin, by either:

i) just loading your custom pages up in an iframe within a page

or

ii) using the generico filter to create a template for your pages.
See : https://moodle.org/plugins/view.php?plugin=filter_generico
And a demo course here: http://demo.poodll.com


But if you need gradebook integration, reporting or closer forms of integration with Moodle, then a plugin would be best.

Average of ratings: Useful (1)
In reply to Justin Hunt

Re: [HELP] html+js(in multi-files)+css >>> page in moodle

by Kevin Wiliarty -

Another possibility might be just to add all your files to a single "File" resource. Don't use the drag-and-drop method; instead turn editing on and use the activity/resource picker. Select "File" and then and all the files to the file picker. By default the first file is set to be the 'main' one, but if you delete the original main file you will be able to reassign that status to another file. If you set your HTML file as the main one and use relative paths to your <link> href's and <script> src's then the whole thing should work as you intend. You would have a link on the main course page that will open your HTML file where your scripts and CSS should apply.

Average of ratings: Useful (1)
In reply to Justin Hunt

Re: [HELP] html+js(in multi-files)+css >>> page in moodle

by Hoi Ki Wan -
I have found that the iframe is only working with IE, but it could not be shown in Firefox or Chrome.

How can I solve this problem???

Thanks again.
In reply to Hoi Ki Wan

Re: [HELP] html+js(in multi-files)+css >>> page in moodle

by Justin Hunt -
Picture of Particularly helpful Moodlers Picture of Plugin developers

Open up Chrome Developer Tools and look at the console tab. Do you see any interesting error messages in there? 

It might not be this. But one possibility is cross domain issues. If your iframe, and/or resources loaded within it, are from a different domain than the Moodle site you need to configure the non-moodle server to allow that.

See: http://en.wikipedia.org/wiki/Cross-origin_resource_sharing

In reply to Justin Hunt

Re: [HELP] html+js(in multi-files)+css >>> page in moodle

by Hoi Ki Wan -

Thanks Justin.


You are right. There is error message in Chrome:

Mixed Content: The page at 'https://localhost/moodle/course/view.php?id=3#section-0' was loaded over HTTPS, but requested an insecure resource 'http://kbcmmoodle.0-host.net/NumStep0.html'. This request has been blocked; the content must be served over HTTPS.


sad

In reply to Hoi Ki Wan

Re: [HELP] html+js(in multi-files)+css >>> page in moodle

by Justin Hunt -
Picture of Particularly helpful Moodlers Picture of Plugin developers

Ok. So since you are on localhost, the simplest way out is just to switch https off for the Moodle site. 

But if you want to use your 0-host.net site over https in production (or dev) you will need to setup ssl there, and then specify the src of your iframe to use the https url.

In reply to Justin Hunt

回應: Re: [HELP] html+js(in multi-files)+css >>> page in moodle

by Hoi Ki Wan -

Thanks Justin.

smile

In reply to Hoi Ki Wan

Re: 回應: Re: [HELP] html+js(in multi-files)+css >>> page in moodle

by Jesus Marquez -

Hi Hoi!

Where change http to https in the code?

Code theme?

Thanks!

In reply to Jesus Marquez

Re: 回應: Re: [HELP] html+js(in multi-files)+css >>> page in moodle

by Justin Hunt -
Picture of Particularly helpful Moodlers Picture of Plugin developers

If you just want to change the http/https part of the url from which your Moodle site is accessed, then you do that by editing the site's config.php file. Specifically the $CFG->wwwroot setting.

In reply to Hoi Ki Wan

回應: [HELP] html+js(in multi-files)+css >>> page in moodle

by Hoi Ki Wan -

Thank you so much Justin and Kevin.

smile