cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Community Member

API: Mark Student Attendance

Hi admins and community,

We're trying to make an automated attendance system using NFC student cards. Is there a way to either:

 * Programmatically interface with the Attendance module provided by Canvas, using the REST API

 * Failing that, programmatically submit a mark for a student on an assessment (using an attendance assessment)

Alternatively, let me know if there are any better options available.

Thanks!

Luke

Tags (3)
11 Replies
Highlighted
Surveyor

You can certainly do the second one.  You can create an assignment with type No Submission and then send marks with the "Grade or comment on a submission" endpoint,  see:  Submissions - Canvas LMS REST API Documentation 

I think the Attendance module from Instructure is an LTI tool, so you won't be able to interface to it with Canvas REST API.  If the tool had its own REST API, then you could do it.

Highlighted
Community Member

Thanks! I gave that a shot, and it's throwing back a 500 error. I don't have permission to view the error log, so I can't debug what's going wrong.

The request I'm sending is as follows:

PUT /api/v1/courses/[Course ID]/assignments/[Assignment ID]/submissions/sis_user_id:[Student ID]

{

   "submission": {
      "posted_grade": 1
   }

}

Any idea why this would be erroring?

Edit: I'm also on a test instance of a course, if that makes a difference.

0 Kudos
Highlighted
Surveyor

I cannot see anything obviously wrong.

How are you actually doing the PUT (language, curl, postman, etc.)?

What happens if you do a GET on the same URL?

0 Kudos
Highlighted
Community Member

I'm using Python requests. I switched from JSON to the submission[posted_grade]=1 format, and it no longer 500s, but nothing seems to be updated.

On a GET request, the following [anonymized] data is returned:

{'assignment_id': [Assignment ID],
'attempt': None,
'body': None,
'cached_due_date': None,
'entered_grade': None,
'entered_score': None,
'excused': False,
'extra_attempts': None,
'grade': None,
'grade_matches_current_submission': True,
'graded_at': '2019-02-07T01:15:51Z',
'grader_id': [Grader ID],
'grading_period_id': None,
'id': [ID],
'late': False,
'late_policy_status': None,
'missing': False,
'points_deducted': None,
'preview_url': [URL],
'score': None,
'seconds_late': 0,
'submission_type': None,
'submitted_at': None,
'url': None,
'user_id': [User ID],
'workflow_state': 'graded'}

0 Kudos
Highlighted
Surveyor

Can you try a simple command-line curl:

  curl $server/api/v1/courses/123/assignments/4567/submissions/sis_user_id:8910 \
    -X PUT \
    -H "Authorization: Bearer $token" \
    -F "submission[posted_grade]=1"

0 Kudos
Highlighted
Community Member

Strange - that seemed to work; looks like it's Python's requests module playing up.

0 Kudos
Highlighted
Community Member

Fixed it - I manually set the Content-Type: multipart/form-data header.

Highlighted
Navigator

The Roll-Call Attendance is an LTI and I haven't seen an API for it. I'm torn between wanting an API for Roll-Call and wanting a replacement for Roll-Call.

What I did when I needed to extract attendance information from it was to get a sessionless launch url for the Roll-Call attendance as an admin. Then I started that non-session, requested the page from the admin settings that allows you to request a form and then send populated the form and submitted it. Since those requests are handled in the background and notification is by email when it's ready, I set up an account that would receive those messages and then request the file, parse it, and write the information to a local database.

I did not try to send attendance information to Roll Call and I would discourage anyone who has their own attendance system from doing so and just keep track of the information themselves. Sending a grade to Canvas for attendance from your system is a much, much, much, ..., much easier process.

0 Kudos
Highlighted
Learner II

Dang.  We need a REST API to extract this data to pull into our homegrown SIS for attendance alerts kinda soon.  Nothing exists huh?

0 Kudos