From 0ff76e4aa880af2a0af0030cbe912d9a3e58e055 Mon Sep 17 00:00:00 2001 From: Rotimi Best Date: Thu, 10 Aug 2023 12:46:14 +0100 Subject: [PATCH] CLASSROOMIO-T-95: Upload to S3 and Muse AI --- package.json | 5 +- .../Lesson/Materials/Transcript.svelte | 25 +++ .../Lesson/Materials/Video/Index.svelte | 5 +- .../Lesson/Materials/Video/LocalVideo.svelte | 116 +++++++++---- .../Materials/Video/YoutubeVideo.svelte | 63 +++---- .../components/Lesson/Materials/index.svelte | 103 ++++++------ .../Course/components/Lesson/store/lessons.ts | 16 +- .../Navigation/NavExpandable.svelte | 4 +- .../components/CourseLandingPage/index.svelte | 9 +- src/lib/components/UserCard/index.svelte | 58 ------- src/lib/utils/functions/genUniqueId.js | 1 + src/lib/utils/services/courses/clone.ts | 2 +- src/lib/utils/services/courses/index.ts | 4 +- src/lib/utils/types/index.ts | 22 ++- src/routes/+layout.svelte | 4 +- src/routes/api/muse/transcript/+server.js | 42 +++++ src/routes/courses/[id]/+page.svelte | 3 +- .../[id]/lessons/[...lessonParams]/+page.js | 13 -- .../lessons/[...lessonParams]/+page.server.js | 157 ++++++++++++++++++ .../lessons/[...lessonParams]/+page.svelte | 12 +- .../courses/[id]/submissions/+page.svelte | 2 +- 21 files changed, 460 insertions(+), 206 deletions(-) create mode 100644 src/lib/components/Course/components/Lesson/Materials/Transcript.svelte delete mode 100644 src/lib/components/UserCard/index.svelte create mode 100644 src/lib/utils/functions/genUniqueId.js create mode 100644 src/routes/api/muse/transcript/+server.js delete mode 100644 src/routes/courses/[id]/lessons/[...lessonParams]/+page.js create mode 100644 src/routes/courses/[id]/lessons/[...lessonParams]/+page.server.js diff --git a/package.json b/package.json index a6575662..e8c924a3 100644 --- a/package.json +++ b/package.json @@ -13,6 +13,7 @@ "prepare": "svelte-kit sync" }, "dependencies": { + "@aws-sdk/client-s3": "^3.386.0", "@sentry/browser": "^7.61.0", "@sentry/integrations": "^7.61.0", "@sentry/tracing": "^7.61.0", @@ -25,10 +26,12 @@ "@types/pluralize": "0.0.30", "ai": "^2.1.31", "autoprefixer": "^10.4.14", + "axios": "^1.4.0", "body-parser": "^1.20.2", "canvas-confetti": "^1.6.0", "cookie-parser": "^1.4.6", "copy-to-clipboard": "^3.3.3", + "form-data": "^4.0.0", "hotkeys-js": "^3.11.2", "js-yaml": "^4.1.0", "lodash": "^4.17.21", @@ -47,8 +50,6 @@ "@babel/plugin-transform-runtime": "^7.22.9", "@babel/preset-env": "^7.22.9", "@babel/runtime": "^7.22.6", - "@fortawesome/free-brands-svg-icons": "^6.4.0", - "@fortawesome/free-regular-svg-icons": "^6.4.0", "@sveltejs/kit": "^1.22.4", "@tailwindcss/typography": "^0.5.9", "@types/lodash": "^4.14.196", diff --git a/src/lib/components/Course/components/Lesson/Materials/Transcript.svelte b/src/lib/components/Course/components/Lesson/Materials/Transcript.svelte new file mode 100644 index 00000000..74746667 --- /dev/null +++ b/src/lib/components/Course/components/Lesson/Materials/Transcript.svelte @@ -0,0 +1,25 @@ + + + + +

+ Natural Language Classifier uses advanced natural language processing and machine learning + techniques to create custom classification models. Users train their data and the service + predicts the appropriate category for the inputted text. +

+
+ +

+ Analyze text to extract meta-data from content such as concepts, entities, emotion, relations, + sentiment and more. +

+
+ +

+ Translate text, documents, and websites from one language to another. Create industry or + region-specific translations via the service's customization capability. +

+
+
diff --git a/src/lib/components/Course/components/Lesson/Materials/Video/Index.svelte b/src/lib/components/Course/components/Lesson/Materials/Video/Index.svelte index 745b81ed..57cc7798 100644 --- a/src/lib/components/Course/components/Lesson/Materials/Video/Index.svelte +++ b/src/lib/components/Course/components/Lesson/Materials/Video/Index.svelte @@ -3,6 +3,9 @@ import LocalVideo from './LocalVideo.svelte'; import * as CONSTANTS from './constants'; + export let lessonId = ''; + export let saveLesson = () => {}; + let tabs = CONSTANTS.videoTabs; let currentTab = tabs[0].value; @@ -34,7 +37,7 @@ {#if currentTab === 1} {:else} - + {/if} diff --git a/src/lib/components/Course/components/Lesson/Materials/Video/LocalVideo.svelte b/src/lib/components/Course/components/Lesson/Materials/Video/LocalVideo.svelte index ce254b0b..43adb296 100644 --- a/src/lib/components/Course/components/Lesson/Materials/Video/LocalVideo.svelte +++ b/src/lib/components/Course/components/Lesson/Materials/Video/LocalVideo.svelte @@ -1,45 +1,95 @@ -{#if isLoaded == false} +{#if isLoaded === false} -{:else if isBig && isUploaded == false} +{:else if isBig && isUploaded === false}
upload error @@ -52,7 +102,7 @@
-{:else if isWrongFormat && isUploaded == false} +{:else if isWrongFormat && isUploaded === false}
upload error @@ -72,17 +122,19 @@
- coursevideo +
-

Video.png

+

{fileInput?.files?.[0]?.name || uploadedFileUrl}

-
- -
{/if} diff --git a/src/lib/components/Course/components/Lesson/Materials/Video/YoutubeVideo.svelte b/src/lib/components/Course/components/Lesson/Materials/Video/YoutubeVideo.svelte index 587f83e9..c0b528f0 100644 --- a/src/lib/components/Course/components/Lesson/Materials/Video/YoutubeVideo.svelte +++ b/src/lib/components/Course/components/Lesson/Materials/Video/YoutubeVideo.svelte @@ -1,47 +1,49 @@ @@ -58,22 +60,23 @@

- Added : {($lesson?.materials?.video_url && $lesson.materials.video_url.trim().split(',').length) || 0} Videos + Videos added: + {$lesson?.materials?.videos.filter((v) => v.type === 'youtube' && isValidYouTubeLink(v.link)) + .length || 0} +

- {#each $lesson?.materials?.video_url && $lesson.materials.video_url - .trim() - .split(',') as videoLink, index} -
- - {videoLink} - - - removeVideo(index)}> - - -
+ {#each $lesson?.materials?.videos as video, index} + {#if video.type === 'youtube'} +
+ + {video.link} + + + removeVideo(index)}> + + +
+ {/if} {/each}
diff --git a/src/lib/components/Course/components/Lesson/Materials/index.svelte b/src/lib/components/Course/components/Lesson/Materials/index.svelte index a9f22bf7..22f0d7b2 100644 --- a/src/lib/components/Course/components/Lesson/Materials/index.svelte +++ b/src/lib/components/Course/components/Lesson/Materials/index.svelte @@ -1,11 +1,13 @@ - + @@ -236,34 +234,45 @@ - {#if mode === MODES.edit && videoUrls.length} - + {#if mode === MODES.edit && $lesson.materials.videos.length} + {/if} - - {#if videoUrls.length} + {#if $lesson.materials.videos.length}
- {#each videoUrls as url, index} + {#each $lesson.materials.videos as video, index} + {#if mode === MODES.edit} +
+ deleteLessonVideo(index)} + > + + +
+ {/if}
- {#if url.includes('youtube')} + {#key video.link}
-
+ {#if video.type === 'youtube'} +