Skip to content

Update to pg 2.17#89

Merged
drdrew42 merged 2 commits into
drdrew42:developfrom
drgrice1:update-to-pg-2.17
Jul 21, 2022
Merged

Update to pg 2.17#89
drdrew42 merged 2 commits into
drdrew42:developfrom
drgrice1:update-to-pg-2.17

Conversation

@drgrice1

@drgrice1 drgrice1 commented Jul 19, 2022

Copy link
Copy Markdown
Contributor

Update the standalone renderer to use pg version 2.17.

The entire lib/WeBWorK/htdocs directory has been removed. The few files that are needed by the standalone renderer are now in public/Problem and public/PGCodeMirror.

To make this work, static file handling had to be revises. See lib/RenderApp/Controller/StaticFiles.pm. Basically, the only files that are served from webwork2_files are CAPA_graphics files (now served directly from Contrib/CAPA/CAPA_graphics) or tmp files (served from a directory in the app root name tmp). PG files are served from the pg_files location (files are in lib/PG/htdocs).

A getAssetURL method is in lib/WeBWorK/lib/WeBWorK/Utils.pm much like webwork2's method handles the correct redirection of the pg_files.

Note that codemirror is no longer serving their javascript and css files. So temporarily this has add an npm install step in the root directory of the renderer. A vendor link in public makes those files available. We can either switch to another CDN to serve those files or go with this. I much prefer this. CDN's are not reliable. I think it would be best to switch all third party javascript to using this approach.

Note that MathQuill is now optional much the same way as in #83, but the default is that it is enabled. Of course, the standalone renderer no longer adds MathQuill itself as PG now does that.

I recommend running git diff develop :^lib/WeBWorK/htdocs* from this branch to see the changes without the lengthy list of deletions from the lib/WeBWorK/htdocs directory.

there that are still needed by the standalone renderer when rendering a
problem.  Requests to webwork2_files are redirected as appropriate by
the renderer.  Most go to PG/htdocs.
@drgrice1
drgrice1 requested a review from drdrew42 as a code owner July 19, 2022 03:03
@drgrice1

Copy link
Copy Markdown
Contributor Author

Note 35 files were changed/added outside of the lib/WeBWorK/htdocs directory. So that means the other 2981 are just the files deleted from lib/WeBWorK/htdocs.

@drdrew42 drdrew42 mentioned this pull request Jul 19, 2022
@taniwallach

taniwallach commented Jul 21, 2022

Copy link
Copy Markdown
Contributor

I am trying to test this via Docker. (I set up a 2 stage build process, so that the base system is fixed, as I kept getting errors.)

I added lines to install node 16 to the (stage 1) Dockerfile (before the apt-get clean line) as was done in the Dockerfile for webwork2

    && curl -fsSL https://deb.nodesource.com/setup_16.x | bash - \
    && apt-get install -y --no-install-recommends --no-install-suggests nodejs \

and added libyaml-libyaml-perl to the installs (otherwise there is a failure when the app gets started).

I changed the line with the npm install to

RUN cd lib/PG/htdocs && npm install && cd ../../..

as that seems to be where it should be run.

However, the npm install was failing.

npm ERR! code 128
npm ERR! An unknown git error occurred
npm ERR! command git --no-replace-objects ls-remote ssh://git@github.com/openwebwork/mathquill.git
npm ERR! fatal: not a git repository: /usr/app/lib/PG/../../.git/modules/lib/PG

npm ERR! A complete log of this run can be found in:
npm ERR!     /root/.npm/_logs/2022-07-21T12_07_00_409Z-debug-0.log
The command '/bin/sh -c cd lib/PG/htdocs && npm install && cd ../../..' returned a non-zero code: 128

So far, the only workaround I have found is to remove .git from the .dockerignore file, as that would put the whole .git directory tree into the image, and then the npm install works. This is not an ideal solution.

I also needed to add an npm install in the main /usr/app directory (for the codemirror dependency), so changed the line with the npm install to

RUN cd lib/PG/htdocs && npm install && cd ../../.. && npm install

Once I managed to get an image created and to run - I can see problems, etc.

@taniwallach

Copy link
Copy Markdown
Contributor

@drgrice1 - Bravo. After overcoming the Docker build problems - the basic functionality certainly seems to work on quite a few problems I tried, including problems using scaffold.pl and right to left problems seem to be working quite well also. I was pleasantly surprised to discover that the MathQuill toolbar appears automatically on the far left instead of the far right when navbar.js is modified to add formData.set("language", "heb"); to the various forms submitted (forcing the system to use the Hebrew translations).

In my current usage with the older version of the renderer I worked around the fact that the MQ toolbar was on the far right (often hiding input boxes) by adding the CSS below via a locally added rtl.css file which also overrode the old bootstrap's float:left on check-boxes and radio buttons. None of those right-to-left support hacks seem necessary any longer.

div.problem-content[dir="rtl"] {
  margin-right: 33pt;
}

@drdrew42

Copy link
Copy Markdown
Owner

@taniwallach I'm not sure if you saw the comment on openwebwork#2, but we're shifting over to the openwebwork fork as the 'main' target for development and release. I'll continue to use this fork for my own development, and future updates will all go through openwebwork instead of here. 👍

For now, I'm going to merge this one here -- would you mind also approving the PR on openwebwork#2? 🙏

@drdrew42
drdrew42 merged commit c88dcbc into drdrew42:develop Jul 21, 2022
@taniwallach

Copy link
Copy Markdown
Contributor

@taniwallach I'm not sure if you saw the comment on openwebwork#2, but we're shifting over to the openwebwork fork as the 'main' target for development and release. I'll continue to use this fork for my own development, and future updates will all go through openwebwork instead of here. +1

For now, I'm going to merge this one here -- would you mind also approving the PR on openwebwork#2? pray

Thanks for pointing that out. Would it be possible to change the ownership of this (root level) repository on GitHub to openwebwork, so the openwebwork was the "primary"? It might be necessary to first delete the current openwebwork fork, but that really did not yet have much activity? I would assume you could then create a new personal fork, but then the tree of forks would be more natural for the future.

There seems to be a requirement that you have "repository creation permissions in the receiving organization" when you make the transfer. See: https://docs.github.com/en/repositories/creating-and-managing-repositories/transferring-a-repository

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants