Customize Student Assignments with Special Syntax¶
Lab.Computer uses special syntax markers to generate student‑ready assignments from instructor notebooks. These markers control which content is hidden, replaced with stubs, or preserved as‑is.
- Hidden: Instructor solutions or sensitive tests
- Replaced: Student solution placeholders inserted in code cells
- Preserved: Supporting content such as instructions or read‑only cells
This ensures that student copies conceal instructor solutions, provide stubs for student responses, and control autograder test visibility.
Marking Solution Regions (Autograded Answer Cells)¶
Wrap instructor solutions with solution markers:
- Start:
### BEGIN SOLUTION - End:
### END SOLUTION

During assignment generation, content between these markers is replaced with a default student stub:
# YOUR CODE HERE raise NotImplementedError

Example (Python)
Instructor code:
def squares(n): """Return list of squares from 1 to n.""" ### BEGIN SOLUTION if n < 1: raise ValueError("n must be >= 1") return [i**2 for i in range(1, n+1)] ### END SOLUTION
Student version after generation:
def squares(n): """Return list of squares from 1 to n.""" # YOUR CODE HERE raise NotImplementedError
Language‑Specific Syntax¶
Use comment syntax matching the notebook kernel:
- Python:
### BEGIN/END SOLUTION - JavaScript:
// BEGIN/END SOLUTION
Note: If markers are missing, nbgrader replaces the entire cell with the generic placeholder:
# YOUR ANSWER HERE
Implementing Hidden Tests (Autograder Test Cells)¶
To conceal tests partially or fully, use hidden test markers:
- Start:
# BEGIN HIDDEN TESTS - End:
# END HIDDEN TESTS

- Visible tests: Students can view and run them (formative).
- Hidden tests: Used for final evaluation and edge‑case validation (summative).
Example
def test_squares_function(): assert squares(1) == [1] # BEGIN HIDDEN TESTS assert squares(5) == [1, 4, 9, 16, 25] import pytest with pytest.raises(ValueError): squares(0) # END HIDDEN TESTS
Partially hidden tests allow students to validate some aspects of their code without revealing all test logic.