Repository navigation
How Courses Work
PyICs has two kinds of files: tasks and courses. Knowing what each one stores saves you from most surprises later.
A task file is self-contained. It stores:
| Field | What it is |
|---|---|
name |
The task's name, also its name in the course |
instructions |
Shown in the app's header while the task is open |
help |
The hints, revealed one at a time with h |
ex_files, exercise_code
|
The paths of the exercise files, and their starter code |
sol_files, solution_code
|
The paths of the solution files, and their contents |
tests |
The configured tests, serialized |
sections |
For notebooks: which part of the notebook the task is about (see Jupyter Notebooks) |
Two things follow from this:
-
The contents of the files are copied into the task file when you create or edit it. Changing
dfs.pyon disk afterwards doesn't change the task. Runpyics edit_taskand choose Update for the file to store the new version (see Creating Tasks). - Paths are stored relative to the task file. Moving the task together with its files keeps it working.
A course manifest is small. It maps task names to task files, in order, and keeps the student's progress:
{
"name": "Search Algorithms",
"tasks": {
"Depth-First Search": {"__pathlib__": ".tasks/dfs.pyicstask.json"},
"Breadth-First Search": {"__pathlib__": ".tasks/bfs.pyicstask.json"}
},
"progress": [0, 0]
}Other fields you may see:
-
free_navigation:truelets students move on before solving a task (Creating Courses). -
slug,version,description,tags,requires,requires_pyics: added bypyics packfor distribution (Distributing Courses).
The app finds courses by their file extension, in the working directory and up to two directories below it (.venv, .git and the like are skipped).
The demo course in the repository uses this layout, and it works well:
search-algorithms/
├── search_course.pyicscourse.json # the course manifest
├── .tasks/
│ ├── dfs.pyicstask.json # one file per task
│ └── bfs.pyicstask.json
├── .exercises/ # starter code; on students' machines, their work
│ ├── dfs.py
│ └── bfs.py
├── .solutions/ # your solutions
│ ├── dfs.py
│ └── bfs.py
└── data/ # files the exercises read (ship them with --include)
The dot-directories keep the course directory tidy for students: they see the manifest, and the app links them to the exercise file they need. Notebooks are an exception: keep exercise notebooks in a visible directory, because JupyterLab doesn't open files in hidden directories by default (see Jupyter Notebooks).
If you keep courses in git, consider ignoring the generated directories on the student side. The PyICs repository ignores .exercises/ and .solutions/, since the task files hold their contents anyway.
When a student opens a task:
- Its exercise files are created from the stored starter code, unless they already exist. Existing exercise files hold the student's work and are never overwritten.
- Its solution files are created too, and always rewritten from the task file.
- The tests run on the exercise files, and again every time one of them is saved.
Progress is checked from the exercise files: a task whose saved exercise files pass all its (non-soft) tests is solved. To start a task over, a student deletes its exercise file; it is recreated on the next open.
Solutions reach students unless you leave them out. Since solution files are written next to the exercises, pack graded courses with
pyics pack --no_solutions(Distributing Courses). Even then, the task file contains your tests and their expected values, so don't treat tests as secret.
Careful when you run your own course in its authoring directory. Solution files are rewritten from the task file whenever a task opens. If you edited a solution on disk and haven't stored it with
pyics edit_taskyet, opening the task in the app replaces your edit with the stored version. Test your course from a copy, or from a pulled archive (see Creating Courses: trying it out).
Tests run in the same Python interpreter as PyICs, in the directory of the exercise file. That means:
- Relative paths in student code, like
open("edges.csv"), work as they do when students run the file themselves. - Packages your course uses (e.g.
numpy) must be installed in the environment where PyICs runs. Declare them in the course so that students are told (see Distributing Courses: dependencies). - An exercise file can import modules next to it.
Next: Creating Tasks.
PyICs instructor wiki · Generated from the wiki/ directory of the repository: edit the pages there, not here. · Report a problem