Skip to content
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
6 changes: 3 additions & 3 deletions converting.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,6 @@ those submissions when they're regraded.
Read every file in the question, including `info.json`, `question.html`, `server.py` and everything in
`tests/`. Stop and report back instead of converting if the question needs one of these:

- **Course libraries.** `externalGradingOptions.serverFilesCourse` or imports of course-wide
modules. The legacy grader put `/grade/serverFilesCourse` on the import path, and this grader
doesn't.
- **A custom grader image** or an `entrypoint` in `externalGradingOptions`.
- **Values the sandbox can't send back.** Tests can only receive values that can be serialized:
numbers, strings, `None`, lists, dicts, numpy arrays and scalars, pandas DataFrames and matplotlib
Expand Down Expand Up @@ -368,6 +365,9 @@ These differences from the legacy grader are easy to miss:
- **Default import blacklist.** `os`, `sys`, `subprocess`, `pathlib` and `shutil` are blocked unless
you set `import_blacklist`.
- **Syntax errors** make the submission ungradable instead of scoring 0.
- **Course libraries** from `externalGradingOptions.serverFilesCourse` are still on the import path.
If you set `import_whitelist`, list them in it. See
[Course Modules](quick_start.md#course-modules).

## 7. Test the conversion

Expand Down
23 changes: 23 additions & 0 deletions quick_start.md
Original file line number Diff line number Diff line change
Expand Up @@ -1008,6 +1008,29 @@ import helper_function as hf
> setting also doesn't make the rest of the tests folder private. `importlib` isn't blacklisted by
> default, so student code can load files in that folder by path.

#### Course Modules

To share a module between questions, put it in the course's `serverFilesCourse` folder and list it
in the question's `info.json`:

```json
"externalGradingOptions": {
"image": "prairielearn/grader-python-pytest:latest",
"serverFilesCourse": ["course_lib.py"]
}
```

PrairieLearn copies it to `/grade/serverFilesCourse`, which the grader images put on the import
path, as the legacy grader did. Tests, setup code and student code can then `import course_lib`.

- **Import restrictions:** if you set `import_whitelist`, list the module in it so that setup code
and student code can import it. Tests aren't restricted.
- **Ordinary modules:** unlike [helper modules](#helper-modules), these load like any installed
library, without the sandbox's restricted builtins.
- **Testing locally:** add the folder to `PYTHONPATH` when you run pytest.

> **Warning:** Student code can import these modules too, so they must not contain answers.

#### Data Files

In a workspace, code such as `np.loadtxt("pagerank_large.txt")` reads a file next to the notebook. To
Expand Down
Loading