From e24356411377d66b984146ae16844bf410fcaa61 Mon Sep 17 00:00:00 2001 From: Em_Dev Date: Mon, 13 May 2024 19:35:06 +0100 Subject: [PATCH] feat: grade exercise with AI (#296) * working on the UI of the grading * working on the grading function of the radio and checkboxes * ai grading fully implemented with dummy functions for generating scores * working on the openai response * working on the openai response * finished with the ai_grading * finished with the ai_grading * creating new migration file * working on reviews * updated the translations * improvements --------- Co-authored-by: Rotimi Best --- .../Lesson/Exercise/EditMode.svelte | 4 +- .../Lesson/Exercise/MarkExerciseModal.svelte | 251 ++++++++++++++---- .../components/Lesson/Exercise/Preview.svelte | 14 +- .../Lesson/Exercise/ViewMode.svelte | 56 ++-- .../components/Lesson/Exercise/constants.js | 17 +- .../components/Lesson/Exercise/index.svelte | 10 +- .../components/Lesson/Exercises/index.svelte | 2 +- .../Course/components/Lesson/store/answers.js | 3 +- .../components/PricingSection.svelte | 4 +- .../Courses/components/Card/index.svelte | 4 - .../src/lib/components/Form/Select.svelte | 2 +- .../src/lib/components/Form/TextField.svelte | 14 +- .../src/lib/components/Modal/index.svelte | 6 +- .../src/lib/components/PageNav/index.svelte | 9 +- .../Question/CheckboxQuestion/index.svelte | 26 +- .../src/lib/components/Question/Grade.svelte | 37 +-- .../Question/RadioQuestion/index.svelte | 28 +- .../lib/components/Question/ReasonBox.svelte | 53 ++++ .../Question/TextareaQuestion/index.svelte | 28 +- .../components/QuestionContainer/index.svelte | 4 +- .../src/lib/utils/services/courses/index.ts | 2 +- .../lib/utils/services/submissions/index.ts | 13 +- .../src/lib/utils/translations/de.json | 17 +- .../src/lib/utils/translations/en.json | 15 ++ .../src/lib/utils/translations/es.json | 17 +- .../src/lib/utils/translations/fr.json | 15 +- .../src/lib/utils/translations/hi.json | 17 +- .../src/lib/utils/translations/pt.json | 17 +- .../src/lib/utils/translations/ru.json | 17 +- .../src/lib/utils/translations/vi.json | 15 +- .../api/completion/gradingprompt/+server.js | 51 ++++ .../lessons/[...lessonParams]/+page.svelte | 3 +- .../courses/[id]/submissions/+page.svelte | 19 +- apps/dashboard/static/ai.svg | 6 + apps/dashboard/static/comment.svg | 37 +++ packages/shared/src/plans/data.json | 4 +- .../migrations/20240509080635_ai_grading.sql | 1 + 37 files changed, 688 insertions(+), 150 deletions(-) create mode 100644 apps/dashboard/src/lib/components/Question/ReasonBox.svelte create mode 100644 apps/dashboard/src/routes/api/completion/gradingprompt/+server.js create mode 100644 apps/dashboard/static/ai.svg create mode 100644 apps/dashboard/static/comment.svg create mode 100644 supabase/migrations/20240509080635_ai_grading.sql diff --git a/apps/dashboard/src/lib/components/Course/components/Lesson/Exercise/EditMode.svelte b/apps/dashboard/src/lib/components/Course/components/Lesson/Exercise/EditMode.svelte index 0e651afb..9866fc84 100644 --- a/apps/dashboard/src/lib/components/Course/components/Lesson/Exercise/EditMode.svelte +++ b/apps/dashboard/src/lib/components/Course/components/Lesson/Exercise/EditMode.svelte @@ -161,7 +161,7 @@ class="w-[50px]" bind:selected={question.question_type.id} on:change={(e) => { - const id = parseInt(e.target.value); + const id = parseInt(e.target?.value); question.question_type = QUESTION_TYPES.find((q) => q.id === id); question.is_dirty = true; }} @@ -176,7 +176,7 @@