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

Cannot retrieve rubric selected answers from submissions (using api v1 json return)

Jump to solution

Greetings!

I am having a bit of trouble with canvas. For some reason I cannot get rubric data (neither scores or selected answers) for assignment peer review submissions. Some of the students did answer the peer review rubric questions, but when I use the following format:

GET /api/v1/courses/:course_id/assignments/:assignment_id/submissions?include[]=rubric_assessment

I can get and see all the saved submission comments from php using pretty much the same thing as the below code block, however, when I inspect the return using "include[]=rubric_assessment" I don't get any selected rubric answers. I do see some data coming back about the submissions, but no rubric responses. Am I missing something? I don't think the rubric is actually being used for grading but I can see the selected answered rubric questions in the peer reviews when I log in with firefox (I am assigned as a teacher for the course). Could that be the problem? (Edited Post: fixed some minor mistakes that were in the post but not in the actual code being used).


function json_get($full_url, $grab_json=true)
{
  global $canvas_api_token;

  $append_char = "&";
  if (strstr($full_url, "?")===false)
  {
    $append_char = "?";
  }
  $full_url .= $append_char . "access_token=" . $canvas_api_token;
 
  $ch = curl_init();
  curl_setopt($ch, CURLOPT_URL, $full_url);
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
  curl_setopt($ch, CURLOPT_HTTPHEADER,
      array('X-Requested-With: XMLHttpRequest', 'Content-Type: application/json; charset=utf-8'));
  }
  $result = curl_exec($ch);
  $http_code = curl_getinfo($ch);
  curl_close($ch);
  if ($result && $grab_json)
  {
    return json_decode($result, true);
  }
  else if ($result)
  {  
    return $result;
  }
  return $http_code;
}

$result1 = json_get("https://$canvas_url/api/v1/courses/$course_id/assignments/$assignment_id/submissions?include[]=rubric_assessment", false);
$result2 = json_get("https://$canvas_url/api/v1/courses/$course_id/assignments/$assignment_id/submissions?include[]=submission_comments&include[]=user&per_page=1000000", false);

file_put_contents($fname1, print_r($result1, true));
file_put_contents($fname2, print_r($result2, true));

0 Kudos
1 Solution

Accepted Solutions
James
Navigator

 @eb4636  

The peer review information is available through a non-API (like you would make from a browser) call to /courses/:course_id/gradebook/speed_grader.json with a query parameter of assignment_id. It comes back with a lot of information as it's the metadata that SpeedGrader needs for all of the students.

You can put add that pathname and querystring into your browser, copy all of it except for the while(1); at the beginning and then you'll have your JSON.

I do not remember seeing peer review data available through any API call, but I haven't looked in several years either.

The include[]=rubric_assessments is the teacher's assessment, not peer reviews.

View solution in original post

1 Reply
James
Navigator

 @eb4636  

The peer review information is available through a non-API (like you would make from a browser) call to /courses/:course_id/gradebook/speed_grader.json with a query parameter of assignment_id. It comes back with a lot of information as it's the metadata that SpeedGrader needs for all of the students.

You can put add that pathname and querystring into your browser, copy all of it except for the while(1); at the beginning and then you'll have your JSON.

I do not remember seeing peer review data available through any API call, but I haven't looked in several years either.

The include[]=rubric_assessments is the teacher's assessment, not peer reviews.

View solution in original post