Updating assignment 'publish' status via LTI API calls
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
yesterday
I am developing an LTI, and as part of that need to create assignments in Canvas. My LTI tool has a corresponding 'publish/unpublish' field for its items, and I would like to create/update Canvas Asignments with a matching field.
I have tried adding published: true or false to my payload, but this seems ignored.
How can I set the publish status via LTI api calls?
This is my existing code:
async updateAssignment(lineItemUrl, label, scoreMaximum, resourceId, startDate, dueDate,published) {
const payload = {
scoreMaximum,
label,
resourceId,
tag: "weblearn",
description: "Assignment created by Weblearn - please submit via the Weblearn platform.",
startDateTime: new Date(startDate).toISOString(),
endDateTime: new Date(dueDate).toISOString(),
published: Boolean(parseInt(published))
};
try {
const response = await this.makeAuthenticatedRequest(lineItemUrl, {
method: "PUT",
headers: {
"Content-Type": "application/vnd.ims.lis.v2.lineitem+json",
},
body: JSON.stringify(payload),
});
if (!response.ok) {
const error = await response.text();
throw new Error(`Failed to update assignment: ${error}`);
}
console.log("Assignment updated successfully");
return await response.json();
} catch (error) {
console.error("Error updating assignment:", error);
throw error;
}
}