Skip to content

Commit 478ce9d

Browse files
authored
Merge pull request #17 from drdrew42/feature/pg-2.19
Feature/pg 2.19
2 parents 808830a + 3e12655 commit 478ce9d

103 files changed

Lines changed: 7124 additions & 10795 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.gitattributes

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,2 @@
1-
lib/WeBWorK/htdocs/** linguist-vendored
21
public/** linguist-vendored
32
*.pl linguist-language=Perl

.github/CODEOWNERS

Lines changed: 0 additions & 2 deletions
This file was deleted.

.github/workflows/createContainer.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ name: Github Packages Release
33
on:
44
push:
55
branches:
6-
- master
6+
- main
77
- development
88
tags:
99
- v*

.gitignore

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,23 @@
11
*.DS_Store
22
render_app.conf
3+
lib/.pls-tmp-*
34
lib/WeBWorK/htdocs/tmp/renderer/gif/*
45
lib/WeBWorK/htdocs/tmp/renderer/images/*
56
lib/WeBWorK/htdocs/DATA/*.json
67
lib/WeBWorK/bin/*
78
webwork-open-problem-library/
89
private/
910
tmp/*
10-
logs/*.log
11+
!tmp/.gitkeep
12+
logs/*
13+
1114
node_modules
12-
node_modules/*
15+
public/**/*.min.js
16+
public/**/*.min.css
17+
public/static-assets.json
18+
1319
*.o
1420
*.pm.tdy
1521
*.bs
22+
*.pid
1623
.idea/

Dockerfile

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
FROM ubuntu:20.04
2-
LABEL org.opencontainers.image.source=https://github.com/drdrew42/renderer
3-
MAINTAINER drdrew42
2+
LABEL org.opencontainers.image.source=https://github.com/openwebwork/renderer
43

54
WORKDIR /usr/app
65
ARG DEBIAN_FRONTEND=noninteractive
@@ -11,10 +10,8 @@ RUN apt-get update \
1110
apt-utils \
1211
git \
1312
gcc \
14-
npm \
1513
make \
1614
curl \
17-
nodejs \
1815
dvipng \
1916
openssl \
2017
libc-dev \
@@ -43,6 +40,9 @@ RUN apt-get update \
4340
libmath-random-secure-perl \
4441
libdata-structure-util-perl \
4542
liblocale-maketext-lexicon-perl \
43+
libyaml-libyaml-perl \
44+
&& curl -fsSL https://deb.nodesource.com/setup_16.x | bash - \
45+
&& apt-get install -y --no-install-recommends --no-install-suggests nodejs \
4646
&& apt-get clean \
4747
&& rm -fr /var/lib/apt/lists/* /tmp/*
4848

@@ -51,7 +51,13 @@ RUN cpanm install Mojo::Base Statistics::R::IO::Rserve Date::Format Future::Asyn
5151

5252
COPY . .
5353

54-
RUN cd lib/WeBWorK/htdocs && npm install && cd ../../..
54+
RUN cp render_app.conf.dist render_app.conf
55+
56+
RUN cp conf/pg_config.yml lib/PG/conf/pg_config.yml
57+
58+
RUN cd public/ && npm install && cd ..
59+
60+
RUN cd lib/PG/htdocs && npm install && cd ../../..
5561

5662
EXPOSE 3000
5763

Dockerfile_with_OPL

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
FROM ubuntu:20.04
2-
LABEL org.opencontainers.image.source=https://github.com/drdrew42/renderer
3-
MAINTAINER drdrew42
2+
LABEL org.opencontainers.image.source=https://github.com/openwebwork/renderer
43

54
WORKDIR /usr/app
65
ARG DEBIAN_FRONTEND=noninteractive
@@ -11,10 +10,8 @@ RUN apt-get update \
1110
apt-utils \
1211
git \
1312
gcc \
14-
npm \
1513
make \
1614
curl \
17-
nodejs \
1815
dvipng \
1916
openssl \
2017
libc-dev \
@@ -43,6 +40,9 @@ RUN apt-get update \
4340
libmath-random-secure-perl \
4441
libdata-structure-util-perl \
4542
liblocale-maketext-lexicon-perl \
43+
libyaml-libyaml-perl \
44+
&& curl -fsSL https://deb.nodesource.com/setup_16.x | bash - \
45+
&& apt-get install -y --no-install-recommends --no-install-suggests nodejs \
4646
&& apt-get clean \
4747
&& rm -fr /var/lib/apt/lists/* /tmp/*
4848

@@ -64,7 +64,11 @@ COPY . .
6464

6565
RUN cp render_app.conf.dist render_app.conf
6666

67-
RUN cd lib/WeBWorK/htdocs && npm install && cd ../../..
67+
RUN cp conf/pg_config.yml lib/PG/conf/pg_config.yml
68+
69+
RUN npm install
70+
71+
RUN cd lib/PG/htdocs && npm install && cd ../../..
6872

6973
EXPOSE 3000
7074

README.md

Lines changed: 140 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
# WeBWorK Standalone Problem Renderer & Editor
22

3-
![Commit Activity](https://img.shields.io/github/commit-activity/m/drdrew42/renderer?style=plastic)
4-
![License](https://img.shields.io/github/license/drdrew42/renderer?style=plastic)
5-
3+
![Commit Activity](https://img.shields.io/github/commit-activity/m/openwebwork/renderer?style=plastic)
4+
![License](https://img.shields.io/github/license/openwebwork/renderer?style=plastic)
65

76
This is a PG Renderer derived from the WeBWorK2 codebase
8-
* https://github.com/openwebwork/WeBWorK2
97

10-
## DOCKER CONTAINER INSTALL ###
8+
* [https://github.com/openwebwork/webwork2](https://github.com/openwebwork/webwork2)
119

12-
```
10+
## DOCKER CONTAINER INSTALL
11+
12+
```bash
1313
mkdir volumes
1414
mkdir container
1515
git clone https://github.com/openwebwork/webwork-open-problem-library volumes/webwork-open-problem-library
16-
git clone --recursive https://github.com/drdrew42/renderer container/
16+
git clone --recursive https://github.com/openwebwork/renderer container/
1717
docker build --tag renderer:1.0 ./container
1818

1919
docker run -d \
@@ -25,35 +25,43 @@ docker run -d \
2525
renderer:1.0
2626
```
2727

28-
If you have non-OPL content, it can be mounted as a volume at `/usr/app/private` by adding the following line to the `docker run` command:
28+
If you have non-OPL content, it can be mounted as a volume at `/usr/app/private` by adding the following line to the
29+
`docker run` command:
2930

30-
```
31+
```bash
3132
--mount type=bind,source=/pathToYourLocalContentRoot,target=/usr/app/private \
3233
```
3334

34-
A default configuration file is included in the container, but it can be overridden by mounting a replacement at the application root. This is necessary if, for example, you want to run the container in `production` mode.
35+
A default configuration file is included in the container, but it can be overridden by mounting a replacement at the
36+
application root. This is necessary if, for example, you want to run the container in `production` mode.
3537

36-
```
38+
```bash
3739
--mount type=bind,source=/pathToYour/render_app.conf,target=/usr/app/render_app.conf \
3840
```
3941

40-
## LOCAL INSTALL ###
42+
## LOCAL INSTALL
4143

4244
If using a local install instead of docker:
4345

44-
* Clone the renderer and its submodules: `git clone --recursive https://github.com/drdrew42/renderer`
46+
* Clone the renderer and its submodules: `git clone --recursive https://github.com/openwebwork/renderer`
4547
* Enter the project directory: `cd renderer`
46-
* Install perl dependencies listed in Dockerfile (CPANMinus recommended)
48+
* Install Perl dependencies listed in Dockerfile (CPANMinus recommended)
4749
* clone webwork-open-problem-library into the provided stub ./webwork-open-problem-library
48-
- `git clone https://github.com/openwebwork/webwork-open-problem-library ./webwork-open-problem-library`
50+
* `git clone https://github.com/openwebwork/webwork-open-problem-library ./webwork-open-problem-library`
4951
* copy `render_app.conf.dist` to `render_app.conf` and make any desired modifications
50-
* install other dependencies
51-
- `cd lib/WeBWorK/htdocs`
52-
- `npm install`
53-
* start the app with `morbo ./script/render_app` or `morbo -l http://localhost:3000 ./script/render_app` if changing root url
52+
* copy `conf/pg_config.yml` to `lib/PG/pg_config.yml` and make any desired modifications
53+
* install third party JavaScript dependencies
54+
* `cd private/`
55+
* `npm install`
56+
* `cd ..`
57+
* install PG JavaScript dependencies
58+
* `cd lib/PG/htdocs`
59+
* `npm install`
60+
* start the app with `morbo ./script/render_app` or `morbo -l http://localhost:3000 ./script/render_app` if changing
61+
root url
5462
* access on `localhost:3000` by default or otherwise specified root url
5563

56-
# Editor Interface
64+
## Editor Interface
5765

5866
* point your browser at [`localhost:3000`](http://localhost:3000/)
5967
* select an output format (see below)
@@ -64,55 +72,115 @@ If using a local install instead of docker:
6472

6573
![image](https://user-images.githubusercontent.com/3385756/129100124-72270558-376d-4265-afe2-73b5c9a829af.png)
6674

67-
# Renderer API
68-
Can be interfaced through `/render-api`
69-
70-
## Parameters
71-
| Key | Type | Default Value | Required | Description | Notes |
72-
| --- | ---- | ------------- | -------- | ----------- | ----- |
73-
| problemSourceURL | string | null | true if `sourceFilePath` and `problemSource` are null | The URL from which to fetch the problem source code | Takes precedence over `problemSource` and `sourceFilePath`. A request to this URL is expected to return valid pg source code in base64 encoding. |
74-
| problemSource | string (base64 encoded) | null | true if `problemSourceURL` and `sourceFilePath` are null | The source code of a problem to be rendered | Takes precedence over `sourceFilePath`. |
75-
| sourceFilePath | string | null | true if `problemSource` and `problemSourceURL` are null | The path to the file that contains the problem source code | Can begin with Library/ or Contrib/, in which case the renderer will automatically adjust the path relative to the webwork-open-problem-library root. Path may also begin with `private/` for local, non-OPL content. |
76-
| problemSeed | number | NA | true | The seed to determine the randomization of a problem | |
77-
| psvn | number | 123 | false | used for consistent randomization between problems | |
78-
| formURL | string | /render-api | false | the URL for form submission | |
79-
| baseURL | string | / | false | the URL for relative paths | |
80-
| format | string | '' | false | Determine how the response is formatted ('html' or 'json') ||
81-
| outputFormat | string (enum) | static | false | Determines how the problem should render, see below descriptions below | |
82-
| language | string | en | false | Language to render the problem in (if supported) | |
83-
| showHints | number (boolean) | 1 | false | Whether or not to show hints (restrictions apply) | Irrelevant if `permissionLevel >= 10`, in which case `showHints` is regarded as automatically 'true' |
84-
| showSolutions | number (boolean) | 0 | false | Whether or not to show the solutions (restrictions apply) | Irrelevant if `permissionLevel >= 10`, in which case `showSolutions` is regarded as automatically 'true' |
85-
| permissionLevel | number | 0 | false | Affects the rendering of hints and solutions. Also controls display of scaffold problems (possibly more) | See the levels we use below |
86-
| problemNumber | number | 1 | false | We don't use this | |
87-
| numCorrect | number | 0 | false | The number of correct attempts on a problem | |
88-
| numIncorrect | number | 1000 | false | the number of incorrect attempts on this problem | Relevant for triggering hints that are not immediately available |
89-
| processAnswers | number (boolean) | 1 | false | Determines whether or not answer json is populated, and whether or not problem_result and problem_state are non-empty | |
90-
| answersSubmitted | number (boolean) | ? | false? | Determines whether to process form-data associated to the available input fields | |
91-
| showSummary | number (boolean) | ? | false? | Determines whether or not to show the summary result of processing the form-data associated with `answersSubmitted` above ||
92-
| showComments | number (boolean) | 0 | false | Renders author comment field at the end of the problem ||
93-
| includeTags | number (boolean) | 0 | false | Includes problem tags in the returned JSON | Only relevant when requesting `format: 'json'` |
94-
95-
## Output Format
96-
| Key | Description |
97-
| ----- | ----- |
98-
| static | zero buttons, locked form fields (read-only) |
99-
| nosubmit | zero buttons, editable (for exams, save problem state and submit all together) |
100-
| single | one submit button (intended for graded content) |
101-
| classic | preview + submit buttons |
102-
| simple | preview + submit + show answers buttons |
103-
| practice | check answers + show answers buttons |
104-
105-
## Permission level
106-
| Key | Value |
107-
| --- | ----- |
108-
| student | 0 |
109-
| prof | 10 |
110-
| admin | 20 |
111-
112-
## Permission logic summary for hints and solutions
113-
* If `permissionLevel >= 10`, then hints and solutions will be rendered - no exceptions.
114-
* If `permissionLevel < 10`, then:
115-
- solutions (if they are provided in the pg source code) will be rendered if and only if `showSolutions` is true.
116-
- hints (if they are provided in the pg source code) will be rendered if and only if:
117-
+ `showHints` is true, and
118-
+ `numCorrect + numIncorrect > n` where `n` is set by the pg sourcce code being rendered
75+
## Server Configuration
76+
77+
Modification of `baseURL` may be necessary to separate multiple services running on `SITE_HOST`, and will be used to extend `SITE_HOST`. The result of this extension will serve as the root URL for accessing the renderer (and any supplementary assets it may need to provide in support of a rendered problem). If `baseURL` is an absolute URL, it will be used verbatim -- userful if the renderer is running behind a load balancer.
78+
79+
By default, `formURL` will further extend `baseURL`, and serve as the form-data target for user interactions with problems rendered by this service. If `formURL` is an absolute URL, it will be used verbatim -- useful if your implementation intends to sit in between the user and the renderer.
80+
81+
## Renderer API
82+
83+
Can be accessed by POST to `{SITE_HOST}{baseURL}{formURL}`.
84+
85+
By default, `localhost:3000/render-api`.
86+
87+
### **REQUIRED PARAMETERS**
88+
89+
The bare minimum of parameters that must be included are:
90+
* the code for the problem, so, **ONE** of the following (in order of precedence):
91+
* `problemSource` (raw pg source code, _can_ be base64 encoded)
92+
* `sourceFilePath` (relative to OPL `Library/`, `Contrib/`; or in `private/`)
93+
* `problemSourceURL` (fetch the pg source from remote server)
94+
* a "seed" value for consistent randomization
95+
* `problemSeed` (integer)
96+
97+
| Key | Type | Description | Notes |
98+
| --- | ---- | ----------- | ----- |
99+
| problemSource | string (possibly base64 encoded) | The source code of a problem to be rendered | Takes precedence over `sourceFilePath`. |
100+
| sourceFilePath | string | The path to the file that contains the problem source code | Renderer will automatically adjust `Library/` and `Contrib/` relative to the webwork-open-problem-library root. Path may also begin with `private/` for local, non-OPL content. |
101+
| problemSourceURL | string | The URL from which to fetch the problem source code | Takes precedence over `problemSource` and `sourceFilePath`. A request to this URL is expected to return valid pg source code in base64 encoding. |
102+
| problemSeed | number | The seed that determines the randomization of a problem | |
103+
104+
**ALL** other request parameters are optional.
105+
106+
### Infrastructure Parameters
107+
108+
The defaults for these parameters are set in `render_app.conf`, but these can be overridden on a per-request basis.
109+
110+
| Key | Type | Default Value | Description | Notes |
111+
| --- | ---- | ------------- | ----------- | ----- |
112+
| baseURL | string | '/' (as set in `render_app.conf`) | the URL for relative paths | |
113+
| formURL | string | '/render-api' (as set in `render_app.conf`) | the URL for form submission | |
114+
115+
### Display Parameters
116+
117+
#### Formatting
118+
119+
Parameters that control the structure and templating of the response.
120+
121+
| Key | Type | Default Value | Description | Notes |
122+
| --- | ---- | ------------- | ----------- | ----- |
123+
| language | string | en | Language to render the problem in (if supported) | affects the translation of template strings, _not_ actual problem content |
124+
| _format | string | 'html' | Determine how the response is _structured_ ('html' or 'json') | usually 'html' if the user is directly interacting with the renderer, 'json' if your CMS sits between user and renderer |
125+
| outputFormat | string | 'default' | Determines how the problem should be formatted | 'default', 'static', 'PTX', 'raw', or |
126+
| displayMode | string | 'MathJax' | How to prepare math content for display | 'MathJax' or 'ptx' |
127+
128+
#### User Interactions
129+
130+
Control how the user is allowed to interact with the rendered problem.
131+
132+
Requesting `outputFormat: 'static'` will prevent any buttons from being included in the rendered output, regardless of the following options.
133+
134+
| Key | Type | Default Value | Description | Notes |
135+
| --- | ---- | ------------- | ----------- | ----- |
136+
| hidePreviewButton | number (boolean) | false | "Preview My Answers" is enabled by default | |
137+
| hideCheckAnswersButton | number (boolean) | false | "Submit Answers" is enabled by default | |
138+
| showCorrectAnswersButton | number (boolean) | `isInstructor` | "Show Correct Answers" is disabled by default, enabled if `isInstructor` is true (see below) | |
139+
140+
#### Content
141+
142+
Control what is shown to the user: hints, solutions, attempt results, scores, etc.
143+
144+
| Key | Type | Default Value | Description | Notes |
145+
| --- | ---- | ------------- | ----------- | ----- |
146+
| permissionLevel | number | 0 | **DEPRECATED.** Use `isInstructor` instead. |
147+
| isInstructor | number (boolean) | 0 | Is the user viewing the problem an instructor or not. | Used by PG to determine if scaffolds can be allowed to be open among other things |
148+
| showHints | number (boolean) | 1 | Whether or not to show hints | |
149+
| showSolutions | number (boolean) | `isInstructor` | Whether or not to show the solutions | |
150+
| hideAttemptsTable | number (boolean) | 0 | Hide the table of answer previews/results/messages | If you have a replacement for flagging the submitted entries as correct/incorrect |
151+
| showSummary | number (boolean) | 1 | Determines whether or not to show a summary of the attempt underneath the table | Only relevant if the Attempts Table is shown `hideAttemptsTable: false` (default) |
152+
| showComments | number (boolean) | 0 | Renders author comment field at the end of the problem | |
153+
| showFooter | number (boolean) | 0 | Show version information and WeBWorK copyright footer | |
154+
| includeTags | number (boolean) | 0 | Includes problem tags in the returned JSON | Only relevant when requesting `_format: 'json'` |
155+
156+
## Using JWTs
157+
158+
There are three JWT structures that the Renderer uses, each containing its predecessor:
159+
* problemJWT
160+
* sessionJWT
161+
* answerJWT
162+
163+
### ProblemJWT
164+
165+
This JWT encapsulates the request parameters described above, under the API heading. Any value set in the JWT cannot be overridden by form-data. For example, if the problemJWT includes `isInstructor: 0`, then any subsequent interaction with the problem rendered by this JWT cannot override this setting by including `isInstructor: 1` in the form-data.
166+
167+
### SessionJWT
168+
169+
This JWT encapsulates a user's attempt on a problem, including:
170+
* the text and LaTeX versions of each answer entry
171+
* count of incorrect attempts (stopping after a correct attempt, or after `showCorrectAnswers` is used)
172+
* the problemJWT
173+
174+
If stored (see next), this JWT can be submitted as the sole request parameter, and the response will effectively restore the users current state of interaction with the problem (as of their last submission).
175+
176+
### AnswerJWT
177+
178+
If the initial problemJWT contains a value for `JWTanswerURL`, this JWT will be generated and sent to the specified URL. The answerJWT is the only content provided to the URL. The renderer is intended to to be user-agnostic. It is recommended that the JWTanswerURL specify the unique identifier for the user/problem combination. (e.g. `JWTanswerURL: 'https://db.yoursite.org/grades-api/:user_problem_id'`)
179+
180+
For security purposes, this parameter is only accepted when included as part of a JWT.
181+
182+
This JWT encapsulates the status of the user's interaction with the problem.
183+
* score
184+
* sessionJWT
185+
186+
The goal here is to update the `JWTanswerURL` with the score and "state" for the user. If you have uses for additional information, please feel free to suggest as a GitHub Issue.

0 commit comments

Comments
 (0)