Skip to content

Commit 080c0e4

Browse files
committed
Update the renderer for the restructuring of PG.
The WeBWorK::PG module is now part of PG, and PG has its own environment so the webwork2 WeBWorK::PG module (and its derivatives) have been removed. The WeBWorK::Constants, WeBWorK::Debug, and WeBWork::CourseEnvironment modules and the webwork2 conf files are no longer needed and so are removed. The renderer uses the WeBWorK::PG::Environment module which is part of PG. Note that this adds one minor installation step for the renderer. The file conf/pg_config.yml must be copied to lib/PG/conf. Usually that file will work as is, but in some cases administrators may want to make changes to it. For example, the externalPrograms are the standard linux executables and in the standard locations. On some systems those may need to be changed. Most of the WeBWorK::Utils module has been removed. All that is left is the two methods that the renderer uses. In addition the renderer lib directory has been flattened. lib/WeBWorK/lib/WeBWorK is now just lib/WeBWorK. With this (among other things) the WEBWORK_ROOT environment variable is not needed. Note that $WeBWorK::Constants::PG_DIRECTORY is not available. $ENV{PG_ROOT} is used instead in the renderer code. Note that the unnecessary encoding and decoding of perl warnings has been removed. Also note that the references to drdrew42 have been changed to openwebwork.
1 parent ec3a7b8 commit 080c0e4

Some content is hidden

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

48 files changed

+529
-5144
lines changed

.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: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ lib/WeBWorK/bin/*
77
webwork-open-problem-library/
88
private/
99
tmp/*
10+
!tmp/.gitkeep
1011
logs/*.log
1112
node_modules
1213
node_modules/*

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 npm install
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: 42 additions & 32 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,41 @@ 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+
* `npm install`
55+
* install PG JavaScript dependencies
56+
* `cd lib/PG/htdocs`
57+
* `npm install`
58+
* start the app with `morbo ./script/render_app` or `morbo -l http://localhost:3000 ./script/render_app` if changing
59+
root url
5460
* access on `localhost:3000` by default or otherwise specified root url
5561

56-
# Editor Interface
62+
## Editor Interface
5763

5864
* point your browser at [`localhost:3000`](http://localhost:3000/)
5965
* select an output format (see below)
@@ -64,10 +70,12 @@ If using a local install instead of docker:
6470

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

67-
# Renderer API
73+
## Renderer API
74+
6875
Can be interfaced through `/render-api`
6976

7077
## Parameters
78+
7179
| Key | Type | Default Value | Required | Description | Notes |
7280
| --- | ---- | ------------- | -------- | ----------- | ----- |
7381
| 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. |
@@ -80,19 +88,21 @@ Can be interfaced through `/render-api`
8088
| format | string | '' | false | Determine how the response is formatted ('html' or 'json') ||
8189
| outputFormat | string (enum) | static | false | Determines how the problem should render, see below descriptions below | |
8290
| 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 |
91+
| showHints | number (boolean) | 1 | false | Whether or not to show hints | |
92+
| showSolutions | number (boolean) | 0 | false | Whether or not to show the solutions | |
93+
| permissionLevel | number | 0 | false | Deprecated. See below. |
94+
| isInstructor | number (boolean) | 0 | false | 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 |
8695
| problemNumber | number | 1 | false | We don't use this | |
8796
| 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 |
97+
| numIncorrect | number | 1000 | false | The number of incorrect attempts on this problem | |
8998
| 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 | |
9099
| answersSubmitted | number (boolean) | ? | false? | Determines whether to process form-data associated to the available input fields | |
91100
| showSummary | number (boolean) | ? | false? | Determines whether or not to show the summary result of processing the form-data associated with `answersSubmitted` above ||
92101
| showComments | number (boolean) | 0 | false | Renders author comment field at the end of the problem ||
93102
| includeTags | number (boolean) | 0 | false | Includes problem tags in the returned JSON | Only relevant when requesting `format: 'json'` |
94103

95104
## Output Format
105+
96106
| Key | Description |
97107
| ----- | ----- |
98108
| static | zero buttons, locked form fields (read-only) |
@@ -103,16 +113,16 @@ Can be interfaced through `/render-api`
103113
| practice | check answers + show answers buttons |
104114

105115
## Permission level
116+
106117
| Key | Value |
107118
| --- | ----- |
108119
| student | 0 |
109120
| prof | 10 |
110121
| admin | 20 |
111122

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
123+
## Permission logic summary
124+
125+
* `permissionLevel` is ignored if `isInstructor` is directly set.
126+
* If `permissionLevel >= 10`, then `isInstructor` will be set to true.
127+
* If `permissionLevel < 10`, then `isInstructor` will be set to false.
128+
* `permissionLevel` is not used to determine if hints or solutions are shown.

0 commit comments

Comments
 (0)