celtic-project / Rating-PHP

Example LTI tool
GNU General Public License v3.0
10 stars 6 forks source link

Same instance (resource link) for all instances of the lti inside my module/course? #5

Closed xcesaralejandro closed 3 years ago

xcesaralejandro commented 3 years ago

Hello, I have tried to add Rating Lti as a module item, thinking that there can be multiple instances of the LTI within the course with totally independent data, but this data is actually mixed between the instances and by more instances that I add in my database data is all summarized in a single item (ResourceLink).

First of all, when I want to add the LTI from the platform resource list I get a run of the tool instead of getting a configuration panel or something similar image

image

I can only add an instance if I manually define the initiation url image

If I add two module items (Rating 01, Rating 02) with your tool I would expect each one to work independently, but actually if I add a new item in one resource (Rating 01), I still see what is added in the other (Rating 02) image

The added platform is under the umbrella of LTI 1.3

spvickers commented 3 years ago

This should certainly not be the case, as you suspected. It suggests to me that both module items are sending the same value for the resource_link_id parameter. Are you able to check this?

xcesaralejandro commented 3 years ago

Indeed, in both cases the resource link has the same id and the rest of the attributes are null, another interesting detail is that the resource link id I think is inherited from the context, since it is the same id. I have checked this directly on the return token.

"https://purl.imsglobal.org/spec/lti/claim/resource_link": { "id": "4bf41d1142fb04f857442847b560bfc713547560", "description": null, "title": null, "validation_context": null, "errors": { "errors": {} } }

"https://purl.imsglobal.org/spec/lti/claim/context": { "id": "4bf41d1142fb04f857442847b560bfc713547560", "label": "Curso", "title": "Curso de prueba", "type": [ "http://purl.imsglobal.org/vocab/lis/v2/course#CourseOffering" ], "validation_context": null, "errors": { "errors": {} } },

Although the module resource has a name assigned, I am not receiving it, so I think that the platform (canvas) is not considering the Lti as a course resource, rather only as a general course context. Given that selecting Rating Lti from the list of external tools opens the application instead of a configuration screen (which one would expect) I suspect that perhaps some feature may be missing within the tool, or in your experience it may be because have I configured something wrong?

spvickers commented 3 years ago

Perhaps there is a SameSite cookie issue. If you're not already, try opening the tool in a new window/tab. Or check with a different browser. Or try turning off the SameSite cookie check in your browser.

xcesaralejandro commented 3 years ago

I've checked in totally different tabs and browsers, purging any caches that might be interfering, turning off samesite and still the data is crossed.

In a way it is logical, because the JWT is returning the same resource link for all my instances (Null and with the context id) for more instances that I add.

How can a cookie affect a launch instance made by the same platform?

spvickers commented 3 years ago

My thinking was that the cookie might be causing a different context to be used which affected the data being passed in the LTI message.

Anyway, since the same resource link ID is being passed in the messages, the Rating app is working correctly - if you are not expecting the links in Canvas to have the same ID then the issue lies there. Perhaps it is caused by how you created the links, but this sounds like an issue to raise in the Canvas community.

xcesaralejandro commented 3 years ago

I had the doubt if it was really a problem with the tool or not, since when selecting other tools from the list of applications available in canvas, they automatically assign a Url and resource name, or, failing that, they open a modal that allows configuring aspects of the tool, while Rating LTI launches the application execution within that modal (As seen in the previous image). I thought that maybe I need to configure some extra endpoint or return some configuration object from the tool when you want to add the tool as a module item, and once you have that it would return the correct instance of resource link.

It would be very useful if you can confirm to me that the LTI should have its unique Resource Link instance just by adding the tool from a link, and that this may be a canvas issue.

In the meantime you can close this issue, if I find a solution or information later I will come to share it, in case it is useful in the future.

Reference images when I want to add other tools as module item: image

spvickers commented 3 years ago

As far as I am aware every LTI link added in Canvas should be given its own unique resource link ID; this is an essential feature of LTI. In some cases an LMS may allow a link to be duplicated and fr both to have the same resource link ID; in that case they represent alternative links to the same resource in the LTI tool. How you add an LTI link in Canvas will depend upon what placements you have defined for the tool.