Skip to content

Update the renderer for the restructuring of PG in openwebwork/pg#709 #7

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

Merged
merged 1 commit into from
May 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .gitattributes
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
lib/WeBWorK/htdocs/** linguist-vendored
public/** linguist-vendored
*.pl linguist-language=Perl
2 changes: 0 additions & 2 deletions .github/CODEOWNERS

This file was deleted.

2 changes: 1 addition & 1 deletion .github/workflows/createContainer.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: Github Packages Release
on:
push:
branches:
- master
- main
- development
tags:
- v*
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ lib/WeBWorK/bin/*
webwork-open-problem-library/
private/
tmp/*
!tmp/.gitkeep
logs/*.log
node_modules
node_modules/*
Expand Down
16 changes: 11 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
FROM ubuntu:20.04
LABEL org.opencontainers.image.source=https://github.com/drdrew42/renderer
MAINTAINER drdrew42
LABEL org.opencontainers.image.source=https://github.com/openwebwork/renderer

WORKDIR /usr/app
ARG DEBIAN_FRONTEND=noninteractive
Expand All @@ -11,10 +10,8 @@ RUN apt-get update \
apt-utils \
git \
gcc \
npm \
make \
curl \
nodejs \
dvipng \
openssl \
libc-dev \
Expand Down Expand Up @@ -43,6 +40,9 @@ RUN apt-get update \
libmath-random-secure-perl \
libdata-structure-util-perl \
liblocale-maketext-lexicon-perl \
libyaml-libyaml-perl \
&& curl -fsSL https://deb.nodesource.com/setup_16.x | bash - \
&& apt-get install -y --no-install-recommends --no-install-suggests nodejs \
&& apt-get clean \
&& rm -fr /var/lib/apt/lists/* /tmp/*

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

COPY . .

RUN cd lib/WeBWorK/htdocs && npm install && cd ../../..
RUN cp render_app.conf.dist render_app.conf

RUN cp conf/pg_config.yml lib/PG/conf/pg_config.yml

RUN npm install

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

EXPOSE 3000

Expand Down
14 changes: 9 additions & 5 deletions Dockerfile_with_OPL
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
FROM ubuntu:20.04
LABEL org.opencontainers.image.source=https://github.com/drdrew42/renderer
MAINTAINER drdrew42
LABEL org.opencontainers.image.source=https://github.com/openwebwork/renderer

WORKDIR /usr/app
ARG DEBIAN_FRONTEND=noninteractive
Expand All @@ -11,10 +10,8 @@ RUN apt-get update \
apt-utils \
git \
gcc \
npm \
make \
curl \
nodejs \
dvipng \
openssl \
libc-dev \
Expand Down Expand Up @@ -43,6 +40,9 @@ RUN apt-get update \
libmath-random-secure-perl \
libdata-structure-util-perl \
liblocale-maketext-lexicon-perl \
libyaml-libyaml-perl \
&& curl -fsSL https://deb.nodesource.com/setup_16.x | bash - \
&& apt-get install -y --no-install-recommends --no-install-suggests nodejs \
&& apt-get clean \
&& rm -fr /var/lib/apt/lists/* /tmp/*

Expand All @@ -64,7 +64,11 @@ COPY . .

RUN cp render_app.conf.dist render_app.conf

RUN cd lib/WeBWorK/htdocs && npm install && cd ../../..
RUN cp conf/pg_config.yml lib/PG/conf/pg_config.yml

RUN npm install

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

EXPOSE 3000

Expand Down
74 changes: 42 additions & 32 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
# WeBWorK Standalone Problem Renderer & Editor

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

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

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

## DOCKER CONTAINER INSTALL ###
* [https://github.com/openwebwork/webwork2](https://github.com/openwebwork/webwork2)

```
## DOCKER CONTAINER INSTALL

```bash
mkdir volumes
mkdir container
git clone https://github.com/openwebwork/webwork-open-problem-library volumes/webwork-open-problem-library
git clone --recursive https://github.com/drdrew42/renderer container/
git clone --recursive https://github.com/openwebwork/renderer container/
docker build --tag renderer:1.0 ./container

docker run -d \
Expand All @@ -25,35 +25,41 @@ docker run -d \
renderer:1.0
```

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:
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:

```
```bash
--mount type=bind,source=/pathToYourLocalContentRoot,target=/usr/app/private \
```

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.
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.

```
```bash
--mount type=bind,source=/pathToYour/render_app.conf,target=/usr/app/render_app.conf \
```

## LOCAL INSTALL ###
## LOCAL INSTALL

If using a local install instead of docker:

* Clone the renderer and its submodules: `git clone --recursive https://github.com/drdrew42/renderer`
* Clone the renderer and its submodules: `git clone --recursive https://github.com/openwebwork/renderer`
* Enter the project directory: `cd renderer`
* Install perl dependencies listed in Dockerfile (CPANMinus recommended)
* Install Perl dependencies listed in Dockerfile (CPANMinus recommended)
* clone webwork-open-problem-library into the provided stub ./webwork-open-problem-library
- `git clone https://github.com/openwebwork/webwork-open-problem-library ./webwork-open-problem-library`
* `git clone https://github.com/openwebwork/webwork-open-problem-library ./webwork-open-problem-library`
* copy `render_app.conf.dist` to `render_app.conf` and make any desired modifications
* install other dependencies
- `cd lib/WeBWorK/htdocs`
- `npm install`
* start the app with `morbo ./script/render_app` or `morbo -l http://localhost:3000 ./script/render_app` if changing root url
* copy `conf/pg_config.yml` to `lib/PG/pg_config.yml` and make any desired modifications
* install third party JavaScript dependencies
* `npm install`
* install PG JavaScript dependencies
* `cd lib/PG/htdocs`
* `npm install`
* start the app with `morbo ./script/render_app` or `morbo -l http://localhost:3000 ./script/render_app` if changing
root url
* access on `localhost:3000` by default or otherwise specified root url

# Editor Interface
## Editor Interface

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

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

# Renderer API
## Renderer API

Can be interfaced through `/render-api`

## Parameters

| Key | Type | Default Value | Required | Description | Notes |
| --- | ---- | ------------- | -------- | ----------- | ----- |
| 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. |
Expand All @@ -80,19 +88,21 @@ Can be interfaced through `/render-api`
| format | string | '' | false | Determine how the response is formatted ('html' or 'json') ||
| outputFormat | string (enum) | static | false | Determines how the problem should render, see below descriptions below | |
| language | string | en | false | Language to render the problem in (if supported) | |
| 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' |
| 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' |
| 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 |
| showHints | number (boolean) | 1 | false | Whether or not to show hints | |
| showSolutions | number (boolean) | 0 | false | Whether or not to show the solutions | |
| permissionLevel | number | 0 | false | Deprecated. See below. |
| 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 |
| problemNumber | number | 1 | false | We don't use this | |
| numCorrect | number | 0 | false | The number of correct attempts on a problem | |
| numIncorrect | number | 1000 | false | the number of incorrect attempts on this problem | Relevant for triggering hints that are not immediately available |
| numIncorrect | number | 1000 | false | The number of incorrect attempts on this problem | |
| 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 | |
| answersSubmitted | number (boolean) | ? | false? | Determines whether to process form-data associated to the available input fields | |
| showSummary | number (boolean) | ? | false? | Determines whether or not to show the summary result of processing the form-data associated with `answersSubmitted` above ||
| showComments | number (boolean) | 0 | false | Renders author comment field at the end of the problem ||
| includeTags | number (boolean) | 0 | false | Includes problem tags in the returned JSON | Only relevant when requesting `format: 'json'` |

## Output Format

| Key | Description |
| ----- | ----- |
| static | zero buttons, locked form fields (read-only) |
Expand All @@ -103,16 +113,16 @@ Can be interfaced through `/render-api`
| practice | check answers + show answers buttons |

## Permission level

| Key | Value |
| --- | ----- |
| student | 0 |
| prof | 10 |
| admin | 20 |

## Permission logic summary for hints and solutions
* If `permissionLevel >= 10`, then hints and solutions will be rendered - no exceptions.
* If `permissionLevel < 10`, then:
- solutions (if they are provided in the pg source code) will be rendered if and only if `showSolutions` is true.
- hints (if they are provided in the pg source code) will be rendered if and only if:
+ `showHints` is true, and
+ `numCorrect + numIncorrect > n` where `n` is set by the pg sourcce code being rendered
## Permission logic summary

* `permissionLevel` is ignored if `isInstructor` is directly set.
* If `permissionLevel >= 10`, then `isInstructor` will be set to true.
* If `permissionLevel < 10`, then `isInstructor` will be set to false.
* `permissionLevel` is not used to determine if hints or solutions are shown.
Loading