Skip to content

Adding Python Assignments

Syed Owais Ali Chishti edited this page Oct 29, 2017 · 2 revisions

This system was specifically design for Python assignment where input for the code were taken using Pytest and Pytest-timeout was used for timeout purpose. Each test case gets it own timeout mean if there are three test case and timeout is 3 seconds this indicate that each test case can run for max 3 seconds and cumulatively 9 seconds in total for all three test cases.

Adding Assignment

Assignment can be added via assignment page.

Assignment Page Link: http://[ip-address]:8000/admin/AutoGrade/assignment/

Add Assignment Link: http://[ip-address]:8000/admin/AutoGrade/assignment/add/

Assignment Page

Add Assignment

More...

Assignment Fields

  1. Course: Select the course in which this assignment goes to.
  2. Title: Awesome title of the Assignment
  3. Description: Awesome description of the Description
  4. Instructor Test (File): This include Pytest (test case file), which includes test case which are executed after student submit their assignment. Sample of Instructor test file is added in next session.
  5. Student Test (File): This include Pytest (test case file), which are attached with student assignment file which are sent to the student for local testing (eg. python run.py local). Sample of Student test file is added in next session.
  6. Assignment File (File): This file is the main file in which student will add there code. This is the file which is executed.
  7. Total Points: Point for the whole assignment. These points are divided by total number of test case when calculated score for single use.
  8. Timeout: How long can single test case can run.
  9. Open Date: When this assignment will be opened. Timezone of the AutoGrader can be set in AutoGr/settings.py.
  10. Due Date: When this assignment will accept submission from students.
  11. Date Published: Auto field, this is automatically filled when assignment is added.
  12. Other Files (File): This field can contains other files which will be added in student zip file eg. Assignment PDF or document file.

Sample Assignment File

def code_holder(num1, num2):
    v = 0 

    #### YOUR CODE GOES HERE #### 
    #### make sure you save the return value in the variable: v 
    v = num1 + num2

    #### DO NOT WRITE AFTER THIS LINE 

    return v 

Sample Instructor Test File

from a01 import code_holder 

def test_third():
    assert code_holder(15, 39) == 54

def test_array():
    v1 = [1, 2, 3] 
    v2 = [2, 3, 4] 

    for i in range(0, len(v1)): 
        v1x = v1[i] 
        v2x = v2[i] 
        assert code_holder(v1x, v2x) == v1x + v2x  

Sample Student Test File

from a01 import code_holder 

def test_answer():
    assert code_holder(1, 2) == 3

def test_second():
    assert code_holder(0, 0) == 0