This commit is contained in:
Markos Gogoulos
2026-03-02 09:41:33 +02:00
parent 5ac0515d05
commit 45774fbc8c
19 changed files with 50 additions and 61 deletions

View File

@@ -49,33 +49,3 @@ export function getLtiContextId(): string | null {
return null;
}
}
export function associateMediaWithLtiCategory(mediaId: string): void {
const ltiContextId = getLtiContextId();
if (!ltiContextId || !mediaId) {
return;
}
const csrfMatch = document.cookie.match(/(?:^|;\s*)csrftoken=([^;]+)/);
const csrfToken = csrfMatch ? csrfMatch[1] : '';
fetch('/api/v1/media/user/bulk_actions', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'X-CSRFToken': csrfToken,
},
body: JSON.stringify({
action: 'add_to_category',
media_ids: [mediaId],
lti_context_id: ltiContextId,
}),
}).then(response => {
if (!response.ok) {
console.warn('[MediaCMS LTI] Failed to associate media with course category:', response.statusText);
}
}).catch(error => {
console.warn('[MediaCMS LTI] Failed to associate media with course category:', error);
});
}