Creating Assignments
Detailed guide for setting up assignments with starter code and custom configurations.
Assignment URL Structure
The code editor accepts URL parameters to configure each assignment:
https://your-server.com/codemirror-demo.html?asg_id=6617143&file_name=lab1.py&starter=lab1_starter.pyURL Parameters
| Parameter | Required | Default | Description |
|---|---|---|---|
asg_id | Yes | — | Gradescope assignment ID |
file_name | No | program.py | Filename for submission |
starter | No | — | Starter code template file |
email | No | — | Pre-fill student email |
stud_id | No | — | Student ID |
Creating Starter Code
Starter code helps students by providing:
- Function stubs to complete
- Comments explaining requirements
- Test cases to verify their solution
Step 1: Create the Template File
Create a .py file in the starters/ folder on your server:
bash
# On the server
nano starters/lab1_starter.pyStep 2: Write the Template
python
# Lab 1: Calculate Total
# Complete the function below
def calculate_total(items):
"""
Calculate the total price of all items.
Args:
items: A list of prices (floats)
Returns:
The sum of all prices
"""
# TODO: Write your code here
pass
# Test your function
if __name__ == "__main__":
test_items = [10.99, 5.50, 3.25]
result = calculate_total(test_items)
print(f"Total: ${result}")
# Expected output: Total: $19.74Step 3: Reference in URL
Add starter=lab1_starter.py to your embed URL:
https://your-server.com/codemirror-demo.html?asg_id=6617143&starter=lab1_starter.pyMultiple Assignments
Create separate D2L quiz questions for each Gradescope assignment:
Example: Lab Series
| Lab | Assignment ID | Starter File | Embed URL |
|---|---|---|---|
| Lab 1 | 6617143 | lab1_starter.py | ?asg_id=6617143&starter=lab1_starter.py |
| Lab 2 | 6617144 | lab2_starter.py | ?asg_id=6617144&starter=lab2_starter.py |
| Lab 3 | 6617145 | lab3_starter.py | ?asg_id=6617145&starter=lab3_starter.py |
Starter Code Best Practices
Do Include
- Clear function signatures with type hints
- Docstrings explaining expected behavior
- Example test cases
- Comments marking where students should write code
Don't Include
- Complete solutions (obviously!)
- Complex imports students don't need
- Confusing boilerplate
Example: Good Starter
python
def find_maximum(numbers: list) -> int:
"""
Find the maximum value in a list of numbers.
Args:
numbers: A list of integers
Returns:
The largest integer in the list
Example:
>>> find_maximum([3, 1, 4, 1, 5, 9])
9
"""
# Your code here
passFile Naming Conventions
| Type | Convention | Example |
|---|---|---|
| Starter code | {assignment}_starter.py | lab1_starter.py |
| Submission | {assignment}.py or program.py | lab1.py |
Embedding in D2L
Quiz Question HTML
html
<p><strong>Lab 1: Calculate Total</strong></p>
<p>Complete the <code>calculate_total</code> function to sum all prices in a list.</p>
<iframe
src="https://your-server.com/codemirror-demo.html?asg_id=6617143&file_name=lab1.py&starter=lab1_starter.py"
width="100%"
height="600px"
frameborder="0">
</iframe>
<p><em>Click "Submit Code" when finished. Your code will be automatically graded.</em></p>Testing Your Assignment
Before deploying to students:
- Test the starter code loads — Open the URL and verify template appears
- Test code execution — Run the starter code (should work or show expected errors)
- Test submission — Submit a correct solution and verify it reaches Gradescope
- Test grading — Confirm Gradescope autograder scores correctly
Next Steps
- HTTPS Configuration — Required for D2L embedding
- Troubleshooting — Common setup issues