Skip to content

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

URL Parameters ​

ParameterRequiredDefaultDescription
asg_idYes—Gradescope assignment ID
file_nameNoprogram.pyFilename for submission
starterNo—Starter code template file
emailNo—Pre-fill student email
stud_idNo—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.py

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

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

Multiple Assignments ​

Create separate D2L quiz questions for each Gradescope assignment:

Example: Lab Series ​

LabAssignment IDStarter FileEmbed URL
Lab 16617143lab1_starter.py?asg_id=6617143&starter=lab1_starter.py
Lab 26617144lab2_starter.py?asg_id=6617144&starter=lab2_starter.py
Lab 36617145lab3_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
    pass

File Naming Conventions ​

TypeConventionExample
Starter code{assignment}_starter.pylab1_starter.py
Submission{assignment}.py or program.pylab1.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:

  1. Test the starter code loads — Open the URL and verify template appears
  2. Test code execution — Run the starter code (should work or show expected errors)
  3. Test submission — Submit a correct solution and verify it reaches Gradescope
  4. Test grading — Confirm Gradescope autograder scores correctly

Next Steps ​

Released under the MIT License.