简体   繁体   中英

Microsoft Graph API - GET Grading 'maxPoints' for Assignment

I'm using the Microsoft Graph API with Laravel and attempting to pull a classes assignments with their grading points - the maxPoints property. The endpoint for this is /education/classes/{classID}/assignments

I can successfully call the data and dump it which returns the following data.

[
  "id" => "*****-****-****-****-*********"
  "classId" => "*****-****-****-****-*********"
  "displayName" => "Encryption and Decryption"
  "dueDateTime" => "2018-10-29T12:30:00Z"
  "status" => "assigned"
  "grading" => [
    "@odata.type" => "#microsoft.graph.educationAssignmentPointsGradeType"
    "maxPoints" => 100
  ]
]

The grading gets returned with its odata type set to the type EducationAssignmentPointsGradeType class and the maxPoints property is available. This is where I get stuck. I then loop through the data in the view using:

@foreach($assignments as $assignment)
  {{ $assignment->getGrading()->getMaxPoints() }} 
@endforeach

However this returns the following error:

Call to undefined method Microsoft\Graph\Beta\Model\EducationAssignmentGradeType::getMaxPoints()

The getGrading() method is of type EducationAssignmentGradeType . I'm not sure how to fetch maxPoints from this however, as the EducationAssignmentGradeType class has no methods in it. The EducationAssignmentPointsGradeType class however, has the getMaxPoints method available.

How would I go about calling the getMaxPoints method?

I believe your problem here is that the Microsoft Graph SDK only supports /v1.0 and Assignments is currently only available in the /beta endpoint.

You seem to be using the Beta models but my experience with these have been, at best, hit-or-miss. Looking at the EducationAssignmentGradeType model , it doesn't look like the models have been updated since maxPoints was rolled out to the beta (it's also missing points in the EducationAssignmentPointsGrade model as well.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM