WeBWorK Main Forum

Embed WW problem in HTML

Embed WW problem in HTML

by Brittni Lorton -
Number of replies: 6

I am not getting any success using the information found here: https://michaelgage.blogspot.com/2015/06/whether-writing-full-text-book-or-just.html 

That website itself isn't showing the sample embedded WW problem either. Is there an update to how to do this somewhere that maybe I missed?

To be clear, I have attempted that same html snippet using my own course on my server and get the same issue. I have ensured the user has login-proctor permissions. Here is a brief sample html code here for reference. Perhaps this is an html thing, and not a WW thing. But maybe someone here can give me some guidance?

<!DOCTYPE html>

<html  lang="en">

<body>

<header id="title-block-header">

<h1 class="title">Skills Check</h1>

</header>

<p> A test webwork problem </p>

<iframe height="600" src="https://webwork.ccd.edu/webwork2/CCD_Math_Testing/html2xml?

&amp;answersSubmitted=0

&amp;sourceFilePath=Library/ma122DB/set4/s3_2_25.pg

&amp;problemSeed=12

&amp;displayMode=MathJax

&amp;courseID=CCD_Math_Testing

&amp;userID=Anonymous

&amp;course_password=Anonymous

&amp;outputformat=simple" width="540">

</iframe>

</body>

</html>

In reply to Brittni Lorton

Re: Embed WW problem in HTML

by Glenn Rice -

Remove the course id from the primary url.  The html2xml route is not course specific.

Also, make sure that your actual link does not include the "amp;" after any of the ampersands.  (That may have been added when that was pasted here though.)

So the link should be

https://webwork.ccd.edu/webwork2/html2xml?sourceFilePath=Library/ma122DB/set4/s3_2_25.pg&problemSeed=12&displayMode=MathJax&courseID=CCD_Math_Testing&userID=Anonymous&course_password=Anonymous&outputformat=simple

Note that if you are using WeBWorK 2.18 or newer, you should not use the deprecated html2xml endpoint.  Instead you should use the render_rpc endpoint.  The syntax is simliar, but a little different.  It would be

https://webwork.ccd.edu/webwork2/html2xml?sourceFilePath=Library/ma122DB/set4/s3_2_25.pg&problemSeed=12&displayMode=MathJax&courseID=CCD_Math_Testing&user=Anonymous&passwd=Anonymous&outputformat=simple

The primary difference is that it uses the usual webwork2 authentication parameters.

Note that for both the Anonymous user must have the permission level of login_proctor (or higher) for this to work.

In reply to Glenn Rice

Re: Embed WW problem in HTML

by Brittni Lorton -
The "amp;" was a product of my copy and paste, it is not in my actual link.

I tried removing the course id from the primary url, and that still did not work.

I am running WW 2.15
In reply to Glenn Rice

Re: Embed WW problem in HTML

by Brittni Lorton -
I thought something might have changed in the embed code since even the blog post on https://michaelgage.blogspot.com/2015/06/whether-writing-full-text-book-or-just.html is not showing the embedded WW problem. I am getting that same 'refused to connect' error that is showing on this site.

I double checked that our server_root_url is correctly set as suggested here https://webwork.maa.org/moodle/mod/forum/discuss.php?d=4485

Any other ideas why I am still getting a 'refused to connect' issue with both my WW server as well as the demo.webwork.rochester.edu?
In reply to Brittni Lorton

Re: Embed WW problem in HTML

by Glenn Rice -
There was one other issue with your original link that you posted. The first url parameter needs to be separated from the primary part of the url by a question mark instead of an ampersand. All of the url parameters after that are separated by ampersands.

The other thing to check is the user that you are using. As I mentioned, that user must have permission level of login_proctor or higher. Also check the case of the user's username and password. Is is actually "Anonomous" or is it "anonymous". I just tested the link

https://webwork.ccd.edu/webwork2/html2xml?sourceFilePath=Library/ma122DB/set4/s3_2_25.pg&problemSeed=12&displayMode=MathJax&courseID=CCD_Math_Testing&userID=anonymous&course_password=anonymous&outputformat=simple

on your server and it works.
In reply to Glenn Rice

Re: Embed WW problem in HTML

by Brittni Lorton -
Yes I did fix that to be the question mark and not the ampersand ( and while I've been testing this, I did change that user to be lower case anonymous, sorry about that!). Same 'refused to connect' issue.

Yes, that link works by itself, but inside the iframe it doesn't. I can't figure out why it suddenly stops working inside an iframe and I don't know another way to get this embedded inside my html file.

Currently I have this attached .html and it is still giving me the 'refused to connect' error, even though the link 

https://webwork.ccd.edu/webwork2/html2xml?sourceFilePath=Library/ma122DB/set4/s3_2_25.pg&problemSeed=12&displayMode=MathJax&courseID=CCD_Math_Testing&userID=anonymous&course_password=anonymous&outputformat=simple

works just fine.  
In reply to Brittni Lorton

Re: Embed WW problem in HTML

by Glenn Rice -

This may be a cross origin issue.  Is the html file that includes this iframe being served from the same server, or is it located on another server?  If it is on another server, then you will need to set the "Access-Control-Allow-Origin" header to "*".  This can be done in the /opt/webwork/webwork2/conf/webwork.apache2-config.dist file.  Add

<IfModule mod_headers.c>
    <Location /webwork2/html2xml>
        Header set Access-Control-Allow-Origin "*"
    </Location>
    <Location /webwork2_files>
        Header set Access-Control-Allow-Origin "*"
    </Location>
</IfModule>

to the end of that file.

You will also need to make sure that the apache2 headers module is enabled.  This can be accomplished with "sudo a2enmod headers".