instructure / canvas-lms

The open LMS by Instructure, Inc.
https://github.com/instructure/canvas-lms/wiki
GNU Affero General Public License v3.0
5.6k stars 2.48k forks source link

Deleting a line item not working #1511

Closed SAHellauer closed 4 years ago

SAHellauer commented 5 years ago

Summary:

I have been working on our company's LTI 1.3 Advantage Integration. I am able to create and update line items but am running into an issue when trying to delete line items https://canvas.instructure.com/doc/api/line_items.html#method.lti/ims/line_items.destroy.

I receive a 204 - Empty response back and the line item does not get deleted in Canvas.

Steps to reproduce:

  1. Create a line item https://canvas.instructure.com/doc/api/line_items.html#method.lti/ims/line_items.create
  2. Try deleting the line item you just created https://canvas.instructure.com/doc/api/line_items.html#method.lti/ims/line_items.destroy

Expected behavior:

Deletes existing Line Item

Actual behavior:

Not deleting existing Line Item and returns a 204 - Empty Response

westonkd commented 4 years ago

Thanks for raising this issue @SAHellauer! I plan to investigate today to see what' s going on.

westonkd commented 4 years ago

@SAHellauer Alrighty, I just finished some testing and have a quick question for you:

To check if a line item is deleted, are you using the line item index endpoint to check, or are you checking to see if a grade is removed from a submission in the UI? (I'm trying to determine if there is a mismatch between the two).

To test this out I did the following:

  1. Create a line item via the API
  2. Attempt to delete the line item via API
  3. Get a list of line items via the API

In step 3 I see that the line item I created in step one is not present in the response, so things worked correctly for me.

I'll post my request details in just a sec. Would you mind checking them to see if there are any differences from what you were attempting? Thanks!

westonkd commented 4 years ago

Create Line Item

Request URL

https://mycanvas.instructure.com/api/lti/courses/4/line_items

Request Headers

Content-Type: application/json

Authorization: Bearer eyj0...

Request Body

{
    "scoreMaximum":"100",
    "label":"test 2",
    "resourceId":"198",
    "tag":"test",
    "https://canvas.instructure.com/lti/submission_type":{
        "type":"none",
        "external_tool_url":"https://mytool.com/launch"
    }
 }

Response

{
    "id": "https://mycanvas.instructure.com/api/lti/courses/4/line_items/22",
    "scoreMaximum": 100,
    "label": "test 2",
    "resourceId": "198",
    "tag": "test",
    "https://canvas.instructure.com/lti/submission_type": {
        "type": "none",
        "external_tool_url": "https://mytool.com/launch"
    }
}

Delete Line Item

Request URL

https://mycanvas.instructure.com/api/lti/courses/4/line_items/22

Request Headers

Content-Type: application/json

Authoirzation: Bearer eyj0...

Request Body

no request body

Response

204

List Line Items

Request URL

https://canvas.instructure.com/api/lti/courses/4/line_items/

Request Headers

Content-Type: application/json

Authoirzation: Bearer eyj0...

Response

[]

Access Token Details

These properties can be checked by decoding your access token

scopes

https://purl.imsglobal.org/spec/lti-ags/scope/lineitem https://purl.imsglobal.org/spec/lti-ags/scope/result.readonly https://purl.imsglobal.org/spec/lti-ags/scope/score https://canvas.instructure.com/lti/feature_flags/scope/show https://purl.imsglobal.org/spec/lti-nrps/scope/contextmembership.readonly https://canvas.instructure.com/lti/public_jwk/scope/update

SAHellauer commented 4 years ago

@westonkd After deleting the line item I am checking to see if the actual grade column is removed from the grade-book in Canvas and it remained. I have't tested this in a few weeks but I will again.

westonkd commented 4 years ago

Thanks! I'll test that scenario. I think I may know what's going on

westonkd commented 4 years ago

TL;DR: Rather than deleting the Line Item, post a new Score with a gradingProgress of notReady and no score.

Ok, so there are a few records in play here. You may already be familiar with this, but I'll outline them here just for clarity. First, the Line Item which is tied to an Assignment. You can post Scores to the Line Item to create Results (Submissions) that show up in the Canvas gradebook.

It sounds like you are attempting to delete a Result from Canvas that was previously posted by your tool. Deleting the Line Item via API actually does delete the Line Item record. Deleting a Line Item, however, does not affect Results you previously posted, so that won't get you what you are looking for.

Instead, the IMS docs for the Assignment and Grade services suggest posting a new Score to the line item with no score and gradingProgress: NotReady (see IMS AGS spec section 2.5.4)

Does that sound like what you are after?

SAHellauer commented 4 years ago

It does sound like what I was trying to accomplish. Thanks for the information! @westonkd