CLASSROOMIO-T-214: Add comments feature in lesson

This commit is contained in:
Rotimi Best
2023-10-08 15:34:37 +01:00
parent 0f01e8e574
commit 4f783cbc7c
28 changed files with 411 additions and 398 deletions
+1 -1
View File
@@ -21,7 +21,7 @@ const instruction = {
export async function POST({ request }) {
const { prompt } = await request.json();
const { courseTitle, lessonTitle, type } = prompt;
const { courseTitle, lessonTitle, type } = JSON.parse(prompt);
const response = await openai.createChatCompletion({
model: 'gpt-3.5-turbo',
messages: [
@@ -73,7 +73,8 @@
prevLessonId = lessonId;
const totalExercises = lessonData?.totalExercises?.[0] && lessonData.totalExercises[0].count;
setLesson(lessonData, totalExercises || 0);
const totalComments = lessonData?.totalComments?.[0] && lessonData.totalComments[0].count;
setLesson(lessonData, totalExercises || 0, totalComments || 0);
isFetching = false;
}
@@ -171,7 +172,7 @@
isLoading = false;
};
function setLesson(lessonData, totalExercises: number) {
function setLesson(lessonData, totalExercises: number, totalComments: number) {
if (!lessonData) return;
let lesson_completion: LessonCompletion[] = [];
@@ -184,7 +185,12 @@
...l,
id: data.lessonId,
totalExercises,
materials: lessonData,
totalComments: totalComments,
materials: {
videos: lessonData.videos,
note: lessonData.note,
slide_url: lessonData.slide_url
},
lesson_completion
}));
}
@@ -317,10 +323,10 @@
{/if}
<button
class="px-2 my-2 pr-4 border-t-0 border-b-0 border-l-0 border border-gray-300 flex items-center"
on:click={() => handleAppClick(APPS_CONSTANTS.APPS.LIVE_CHAT)}
on:click={() => handleAppClick(APPS_CONSTANTS.APPS.COMMENTS)}
>
<SendAlt size={24} class="carbon-icon" />
<span class="ml-1">{$lesson.comments}</span>
<span class="ml-1">{$lesson.totalComments}</span>
</button>
<button class="px-2 my-2" on:click={markLessonComplete} disabled={isMarkingComplete}>
{#if getIsLessonComplete($lesson.lesson_completion, $profile.id)}
+2 -3
View File
@@ -1,5 +1,4 @@
<script>
import { marked } from 'marked';
import { goto } from '$app/navigation';
import pluralize from 'pluralize';
import TrashCanIcon from 'carbon-icons-svelte/lib/TrashCan.svelte';
@@ -334,7 +333,7 @@
</div>
{:else}
<section class="prose prose-sm sm:prose p-2">
{@html marked(question.body)}
{@html question.body}
</section>
{/if}
</div>
@@ -377,7 +376,7 @@
{/if}
</header>
<article class="prose prose-sm sm:prose p-2">
{@html marked(comment.comment)}
{@html comment.comment}
</article>
</div>
</div>
@@ -1,5 +1,4 @@
<script>
import { marked } from 'marked';
import pluralize from 'pluralize';
import TrashCanIcon from 'carbon-icons-svelte/lib/TrashCan.svelte';
import { SkeletonPlaceholder, SkeletonText } from 'carbon-components-svelte';
@@ -336,7 +335,7 @@
</div>
{:else}
<section class="prose prose-sm sm:prose p-2">
{@html marked(question.body)}
{@html question.body}
</section>
{/if}
</div>
@@ -379,7 +378,7 @@
{/if}
</header>
<article class="prose prose-sm sm:prose p-2">
{@html marked(comment.comment)}
{@html comment.comment}
</article>
</div>
</div>