Programs related to assignments and their grades

While looking at importing grades from another records system in Canvas I decided to write some simply programs to make an assignment, use two earlier programs to get information on users and assignments, and then make a program to set a grade for an assignment for a student in a course.

Assigning a grade to a user for an assignment

We will start with the last of these programs, as it shows what can be done:


    

Download assign_grade_for_assignment.py course_id assignment_id user_id grade [comment]

takes in the relevant values and assigned the indicated grade for the user in the gradebook. An example of this is an assignment with a letter grade:

Assignment with letter grade

 

Executing the program with:

./assign_grade_for_assignment.py 751 26090 75130 "A" "dummy value"

results in:

Assignment of an "A" to the test user

Getting the parameters to run the above program

So how did we know it was course number 751 (this is a sandbox that I was using) - simply look at the URL when visiting your target course.

How do we know the user_id of our target user? 

I used another program to list the users in the course with:

./
    

Download users-in-course.py 751

We can find all the assignment and their corresponding assignment_id with:

./
    

Download list-assignments.py 751

What about numeric values for the grade?

If we make an assignment with "Display Grade as" set to "Points":

Assignment with points

Now we can execute the program with a floating point value:

./assign_grade_for_assignment.py 751 26090 75130 98.25 "dummy value"/pre>

and we can now see the new numeric grade:

Assignment with a numeric grade

The comments actually do appear, as one can see below:

Grade details with comments