Moodle 2.1 stripping id tag from embed code - Please help

Moodle 2.1 stripping id tag from embed code - Please help

by Jacob Givand -
Number of replies: 6

Hello.

I have embed code that I'm putting in Moodle 2.1 from Wolfram Alpha. It is stripping the id tag when I save so the widget does not display. Here is the original html:

<script id="WolframAlphaScript" src="http://www.wolframalpha.com/input/embed/?type=medium" type="text/javascript"></script>

Here is what it looks like after saving:

<script src="http://www.wolframalpha.com/input/embed/?type=medium" type="text/javascript"></script>

I have tried changing site admin>security>site policies in some different areas but had no luck. I've attached a picture of the settings I've experimented with. Any advice will be greatly appreciated.

Attachment Moodle 2.1 Site Policy Settings.gif
Average of ratings: -
In reply to Jacob Givand

Re: Moodle 2.1 stripping id tag from embed code - Please help

by Tim Hunt -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

This is a minor security thing. Since ids have to be unique within a page, a user could potentially break Moodle by typing some input with an id that is the same as one that Moodle users.

Do you really need the id on the script tag?

In reply to Tim Hunt

Re: Moodle 2.1 stripping id tag from embed code - Please help

by Jacob Givand -

I don't know enough about html to make it work otherwise. I'm using the html generated by Wolfram Alpha.

If I embed the same html in our Moodle 1.9 installation, it works fine since it leaves it alone. If I remove the id tag in our Moodle 1.9 (to emulate what 2.1 is doing), it won't display there either.

As background, we are developing some math and science courses and Wolfram Alpha's widgets and such will greatly enhance our courses.

Thanks for any help you can provide.

In reply to Jacob Givand

Re: Moodle 2.1 stripping id tag from embed code - Please help

by Mauno Korpelainen -

Jacob,

if you disable the editor from your user profile (When editing text -> Use standard web forms) you can add those script tags with Wolfram alpha id ( http://www.wolframalpha.com/addtoyoursite.html ).

It looks like in this case editor is stripping id because it is not a valid attribute for script element...

Average of ratings: Useful (1)
In reply to Jacob Givand

Re: Moodle 2.1 stripping id tag from embed code - Please help

by Mauno Korpelainen -

That script actually creates an iframe and embeds http://www.wolframalpha.com/Calculate/embed/medium.jsp inside it. So if you don't want to disable editor from your profile (and enable it again) you could also use

<object type="text/html" data="http://www.wolframalpha.com/Calculate/embed/medium.jsp" style="height:86px;width:230px;border:0;overflow:hidden"></object>

that is all valid code but still allowed only in trusted content... so maybe the best option is to disable editor before adding the script tags with id. smile

In reply to Mauno Korpelainen

Re: Moodle 2.1 stripping id tag from embed code - Please help

by Jacob Givand -

Many thanks to all. The best option (to me) is to disable the editor in the profile settings. It is especially good because any user/course builder can do it without administrative access.

In reply to Jacob Givand

Re: Moodle 2.1 stripping id tag from embed code - Please help

by Jacob Givand -

Thanks. Temporarily editing the profile settings was the way to go for me. I appreciate all your help!