-
-
Notifications
You must be signed in to change notification settings - Fork 165
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add css files requested by problems to gateway quizzes #1258
Add css files requested by problems to gateway quizzes #1258
Conversation
2a7ea3e
to
d8c04b6
Compare
01022b0
to
97ed202
Compare
the template. Add the method for adding css files passed from PG in gateway quizzes to that method. Also make it so that js and css files can be added that are not in the css or js subdirectories, but any sub-directory of htdocs on the server. Generally clean up the coding of those methods.
97ed202
to
c0b31e9
Compare
@taniwallach: What is the comment in the release notes that is needed for this? |
@drgrice1 From the code are you trying to do this as well with js files. I scoured the OPL and only found some js files that are loaded with sage cells--and getting errors with these--I'll investigate more. I'm also not finding any problems that load a css file. I've found a bunch that embed css with the |
These are new methods that were recently added, and there are no problems in the OPL that use either of them except for applet problems that use the ADD_JS_FILE method indirectly via the AppletObjects.pl macro. You could test the ADD_JS_FILE method using the problem Library/FortLewis/Authoring/Templates/IntegralCalc/GeoGebra1/GeoGebra1.pg. Make sure to also check out openwebwork/pg#549 or this won't work. At this point nothing uses the ADD_CSS_FILE method, but you could test this by calling ADD_CSS_FILE from a problem and loading a css file. |
A number of thing I just noticed:
to
since it appears that you need to specify the subdirectory now. I had to add
doesn't work because of the string interpolation of the
has the following HTML:
and there is no |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This works for me. I tested with
$pg{specialPGEnvironmentVars}{extra_css_files} = [ 'css/rtl.css' ];
set in a course.conf
file which worked properly.
I also tested openwebwork/pg#549 together with this PR which makes use of ADD_JS_FILE
and added the js
header, and the relevant files load.
I also did a small test adding
ADD_CSS_FILE('css/fak1.css');
ADD_JS_FILE('js/fake2.js');
to a PG file asking for nonexistent files.
The nonexistent css file triggers a comment in the HTML output (as designed)
<!-- css/fake1.css is not available in htdocs/ on this server -->
so no load attempt is made of the non-existent file.
The nonexistent js file does get requested in the HTML file
<script src="js/fake2.js" type="text/javascript"></script>
but as it is not available, it fails to be loaded by the browser. In my case, I found in the browser developer tools console a report:
Loading failed for the <script> with source “http://localhost:8080/webwork2/Madar_devel/testEng/3/js/fake2.js”.
In any case - I think this almost ready to merge.
I think the correction I proposed in drgrice1/pg#1 fixes the documentation in the source code comments which @pstaabp reported.
When a nonexistent JS file is requested using the local switch, like:
ADD_JS_FILE('js/fake3.js',1);
it does produce a comment in the HTML code, ex:
<!-- js/fake3.js is not available in htdocs/ on this server -->
I made drgrice1/pg#1 to @drgrice1's branch to fix those 2 issues.
I think, based on the documentation, that you need to set the
|
I think you can use
to avoid the |
Both methods accept an additional argument that determines if the first argument is a file located in the htdocs directory or an external url. The documentation is updated there. Here the application of the the generated lists takes that additional argument into account. Currently that argument is not used for files added from a course.conf (or other settings file). It is assumed those are in htdocs. Also if the addtional argument is not provided or is 0 (or falsy) then it is also assumed the file is in htdocs.
@pstaabp: I think you were missing the second argument of the ADD_JS_FILE method. If that argument was 0 (or not given) it was assumed that the full url was given (a third party js file located on another server), and if that argument was 1 then it was assumed to be in the htdocs directory. In my last commit I reversed the polarity of that second argument. So now if the argument is 0 (or not given) then it is assumed to be in the htdocs directory. Furthermore, I added that argument to the ADD_CSS_FILE method. This maintains the usage of the ADD_CSS_FILE method from before, and makes the ADD_JS_FILE usage consistent with that as you were expecting. |
That anyone who already made use of the new |
@taniwallach: That doesn't make sense though as these methods were not in the previous release. |
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In my last commit I reversed the polarity of that second argument. So now if the argument is 0 (or not given) then it is assumed to be in the htdocs directory. Furthermore, I added that argument to the ADD_CSS_FILE method. This maintains the usage of the ADD_CSS_FILE method from before, and makes the ADD_JS_FILE usage consistent with that as you were expecting.
I just tested quickly with the revised version of this and the changes to PG made in openwebwork/pg#549.
I think the revised default to assume additions come from htdocs
is a good decision for both functions in PG. Thanks @drgrice1.
I think this is ready to merge.
@pstaabp - If you can test and it is OK - please merge this and openwebwork/pg#549. |
You are correct. ADD_CSS_FILE was in WW 2.15. I am mistaken. Also, publicity for these methods would be good. |
Yes, but we all have limited time available... for now I made an issue at openwebwork/docs#14 and eventually, hopefully, it will be done. |
I was just confirming the validity of the |
Again, I didn't read carefully the comment at the beginning of the line. Everything looks good now. @drgrice1 thanks for adding the documentation and making ADD_CSS_FILE consistent with ADD_JS_FILE 👍 |
Add the method for adding css files passed from PG problems via ADD_CSS_FILE or via the extra_css_files key of the specialPGEnvironmentVars hash to gateway quizzes.
Also make it so that js and css files can be added that are not in the css or js sub-directories, but any subdirectory of htdocs on the server.
Generally clean up the coding of those methods.