When creating a copy of course, the resource link ids change for the contents in the new copied course and LTI launch fails.
I need previous Resource Link Id of the contents for a Copied course while launching LTI for the new copied course so that I can map the new content with the older ones.
You may need to involve the API to get that. You can get the courseIds of the previous courses using the LTI variable substitutions. In particular, see Canvas.course.previousContextIds, Canvas.course.previousContextIds.recursive, and Canvas.course.previousCourseIds.
Then you could use the API to go into those previous courses and hopefully get the information that you need.
The use of the API is documented in the link I provided. There's a note at near the top that says:
There are currently over 80 substitutions available. Many of the substitutions simply give access to additional user and context information. An LTI tool can request things like SIS ids, names, an avatar image, and an email address. Other variable substitutions assist tools with accessibility (prefersHighContrast), course copy (previousCourseIds), and masquerading users. Additionally, when we don't provide enough information or customization directly through LTI, tools can request everything they need to use the Canvas API for an even richer experience.
I am using variable substitution for Canvas.course.previousContextIds, Canvas.course.previousContextIds.recursive, Canvas.course.previousCourseIds but, these give me ids of course from which i have created new copy, but I am not able to identify the particular assignment when launching LTI, as the course contains multiple assignments.
To be able to map the new assignment with the older one(from which the copy has been created), I need the resource_link_id of the previous assignment, which I am not supplied. I looked into Canvas API as well, but no such field is present where I can get previous resource_link_Id or the resource_link_id_history.
Have you tried getting the list of assignments in a course through the API? There are original_course_id, original_assignment_id, original_assignment_name, and original_quiz_id properties that may refer to where they came from. I say may because it when I do a "copy to" to share a course directly, they are all null. However, if you are lucky enough to have them, then using the original course_id and assignment_id, you could go into that course and load that assignment, and then get the resource_link_id from the external_tool_tag_attributes property.
There's another way that might work, depending on how your links are set up. Last week, I created individual external tool links to assignments in a vendor's site. As long as I am linking into the same content on their end, the link stays the same. Each one looks like <instance>/lti/assess?assignment_id=5f28dda9c11c3f4132b5555e, where the assignment_id varies but is unique for each assignment. If your links have a common format like that, then you could get the assignments for both the previous course course and the current course and look through them matching up the external_tool_tag_attributes.url property. The external_tool_tag_attributes.resource_link_id would then give you both the current and previous resource_link_id.
I tried getting the list of assignments in a course through the API, but as mentioned original_course_id, original_assignment_id, original_assignment_name, and original_quiz_id were null. Also, external_tool_tag_attributes.url property is same for assignments in my case.
Is there any other way to get previous resource link id of the copied assignment.?
Any chance of downloading the assignments from each course and matching them off their names or content?
For example, I was editing one of my assignments this morning where I linked to a lesson in the Canvas Guide in the old community and it no longer worked -- despite multiple statements from people that it works for them. I'm looking to make a crossreference from links in the old community to links in the new community so that I can search for old links and update them to the new links.
The URLs are different. The information from the old community is limited. All I have to go on is that the title is the same in both places.
Given enough time, I think I could do it. Given the number of links I have in my courses to the Canvas Guides and the fact that classes start on Monday and I have a lot of stuff to do before then, it would be quicker to manually search for them while I wait for Canvas to get them all updated.
I never was quite clear why exactly you needed the old resource links and may have been confused about who you are. Are you coming at this from the Canvas side or the LTI side or both? Early on, I thought you were representing the LTI since you were asking about getting the contexts. Now I'm not so sure.
Maybe having a clearer understanding of the purpose would allow insight into different ways to get at the information.
I come from LTI side. I need resource link id because i am mapping my data with resource link id for a given assignment, when that assignment is launched using external LTI link. But when that course is copied and the same assignment is again launched from copied course, its gives me a new resource link id, and I am unable to identify which data was mapped with its original assignment. As same data should be visible for both assignments i.e in original course and in copied course.
The approach to match the assignment names can be done but it again comes with a limitation if a user changes the assignment name before launching the external LTI for the copied course. I would be left with no parameter to match.
I haven't done much with writing LTIs, so I may be way off here. Keep that in mind as you read it.
I don't remember seeing LTIs needing this level of integration so it makes me wonder if you're making it harder than it needs to be.
It also sounds like whoever is giving you access to their system is giving you a lot of access, which is probably why I was getting confused about which side you're coming from. Normally LTI's don't need that level of access to function, they can operate within each course without having to rely on information from other courses. Typically you do not need the internal IDs from Canvas unless you need a high level of integration with information that is only available through the API and I'm not seeing that here (at least not yet).
How did you do the original mapping? That is, how did you decide that assignment X in Canvas needed content Y from the LTI in the first place?
I remember using one LTI many years ago that had a single URL for all of the assignments, but I had to go into the system and configure the assignment before each one. It was a classroom response system that could only have one response session open at the time (all I was paying for).
Since then, when I have setup LTIs in my courses, they vendor provides a mapping for me. That is, I create the content in their system and import it into Canvas. Either that or I go into Canvas and link to the content manually by creating external tools with query parameters that link to the LTI content like the pattern I showed earlier. Then, when it's copied, it doesn't matter because it links to the same content on the LTI side and the LTI vendor doesn't need access to Canvas API directly (which is good since some institutions really make you crack down on that).
If they gave you the keys to the kingdom, it may be that you could go into their courses and modify the external tool links to add a query parameter and then do that now before they've changed assignment names. Then when they copy it in the future, it remains the same. That is not something I would be comfortable with an LTI vendor doing in my course, though, so you would want to coordinate with the local Canvas admin.
Some other people who have done more with LTI may want to chime in. Some of them monitor the main question section, but there are many who hang out in the Developer Group.
I haven't quite figured out the new community software yet, but it looks like if you go to Group Hub and choose Developer Group that you can post questions there. In the old community, you could share content between groups and I just don't know if that's possible now. I'm not sure if this is the easiest way, but once you get to to the Developer Group, under "Content" on the right you need to click on Forums, and then it will pop up with an "Ask a question" button.
Also, I think I saw someone move a thread the other day, so I'll tag @Stefanie and get her take on what the best way to get the Developer's Group involved is.
The solution for this proposed by IMS involves the $ResourceLink.id.history custom parameter substitution variable (see https://www.imsglobal.org/lti-course-copy-road-nowhere) but I don't think Canvas is one of the platforms which has implemented it. Sorry this does not help you here, but it might do should you also be using other platforms.