diff --git a/components/DialogSlot.vue b/components/DialogSlot.vue new file mode 100644 index 0000000..31e4db8 --- /dev/null +++ b/components/DialogSlot.vue @@ -0,0 +1,56 @@ + + + diff --git a/components/form/Quiz.vue b/components/form/Quiz.vue new file mode 100644 index 0000000..0ff6e28 --- /dev/null +++ b/components/form/Quiz.vue @@ -0,0 +1,326 @@ + + + diff --git a/composables/dialogSlot.ts b/composables/dialogSlot.ts new file mode 100644 index 0000000..218e6df --- /dev/null +++ b/composables/dialogSlot.ts @@ -0,0 +1,2 @@ +export const useDialogSlot = () => useState("dialogSlot", () => false); +export const useDialogCreateSubtask = () => useState("dialogCreateSubtask", () => false); diff --git a/composables/quizzes.ts b/composables/quizzes.ts new file mode 100644 index 0000000..61f0227 --- /dev/null +++ b/composables/quizzes.ts @@ -0,0 +1,49 @@ +import { useState } from "#app"; +import { Quiz } from "~/types/courseTypes"; +import { GET } from "./fetch"; + +export const useSubTasksInQuiz = () => useState("subTasksInQuiz", () => []); +export const useSubTaskAndSolutionInQuiz = () => useState("subTaskAndSolutionInQuiz", () => null); + +export async function getSubTasksInQuiz(taskId: any, creator: any = "") { + try { + let query = ""; + + if (!!creator) { + query = `/challenges/tasks/${taskId}/multiple_choice?creator=${creator}`; + } else { + query = `/challenges/tasks/${taskId}/multiple_choice`; + } + const res = await GET(query); + const subTasksInQuiz = useSubTasksInQuiz(); + subTasksInQuiz.value = res ?? []; + + return [res, null]; + } catch (error) { + return [null, error]; + } +} + +export async function updateSubTaskInQuizForAdmin(taskId: any, subTaskId: any, body: any) { + try { + const res = await PATCH(`/challenges/tasks/${taskId}/multiple_choice/${subTaskId}`, body); + const user: any = useUser(); + await getSubTasksInQuiz(taskId, user?.value.id ?? ""); + + return [res, null]; + } catch (error) { + return [null, error]; + } +} + +export async function getSubTaskAndSolutionInQuiz(taskId: any, subTaskId: any) { + try { + const res = await GET(`/challenges/tasks/${taskId}/multiple_choice/${subTaskId}/solution`); + const subTaskAndSolutionInQuiz = useSubTaskAndSolutionInQuiz(); + subTaskAndSolutionInQuiz.value = res ?? null; + + return [res, null]; + } catch (error) { + return [null, error]; + } +} diff --git a/locales/de.json b/locales/de.json index e5ef3fb..65733a3 100644 --- a/locales/de.json +++ b/locales/de.json @@ -153,6 +153,9 @@ } }, "Inputs": { + "Option": "Option", + "Correct": "Richtig", + "Question": "Frage", "EmailOrUsername": "E-Mail-Adresse oder Spitzname", "Password": "Passwort", "CompanyId": "Firmen-ID", @@ -184,6 +187,7 @@ "MFACode": "6-stelliger MFA-Code" }, "Buttons": { + "UpdateQuiz": "Quiz aktualisieren", "Incorrect": "Falsch", "Correct": "Richtig", "Safe": "Sicher", @@ -206,6 +210,8 @@ "EditJob": "Job bearbeiten", "EditCompany": "Firma bearbeiten", "CreateCompany": "Neue Firma erstellen", + "adjustTask": "Aufgabe anpassen", + "markAsRevised": "Aufgabe als überarbeitet markieren", "rejectReport": "Bericht zurückweisen", "deleteTask": "Aufgabe löschen", "blockReporter": "Reporter blockieren", diff --git a/locales/en-US.json b/locales/en-US.json index 0518ec8..a77915a 100644 --- a/locales/en-US.json +++ b/locales/en-US.json @@ -5,6 +5,8 @@ "LoginForm": "Please enter your credentials" }, "Headings": { + "Option": "Option", + "Correct": "Correct", "ManageReport": "Manage Report", "userEnabled": "User aktiviert", "userDisabled": "User deaktiviert", @@ -187,6 +189,7 @@ "MFACode": "MFA 6 digit Code" }, "Buttons": { + "UpdateQuiz": "Update Quiz", "Incorrect": "Incorrect", "Correct": "Correct", "Safe": "Safe", @@ -209,6 +212,8 @@ "EditJob": "Edit Job", "EditCompany": "Edit Company", "CreateCompany": "Create New Company", + "adjustTask": "Adjust Task", + "markAsRevised": "Mark task as revised", "rejectReport": "Reject Report", "deleteTask": "Delete Task", "blockReporter": "Block reporter", diff --git a/package-lock.json b/package-lock.json index 59f5614..3dbde57 100644 --- a/package-lock.json +++ b/package-lock.json @@ -6,6 +6,7 @@ "": { "hasInstallScript": true, "dependencies": { + "@headlessui/vue": "^1.7.23", "@heroicons/vue": "^2.2.0", "@typescript-eslint/parser": "^8.34.0", "async-mutex": "^0.5.0", @@ -1120,6 +1121,20 @@ "integrity": "sha512-MDWhGtE+eHw5JW7lq4qhc5yRLS11ERl1c7Z6Xd0a58DozHES6EnNNwUWbMiG4J9Cgj053Bhk8zvlhFYKVhULwg==", "license": "MIT" }, + "node_modules/@headlessui/vue": { + "version": "1.7.23", + "resolved": "https://registry.npmjs.org/@headlessui/vue/-/vue-1.7.23.tgz", + "integrity": "sha512-JzdCNqurrtuu0YW6QaDtR2PIYCKPUWq28csDyMvN4zmGccmE7lz40Is6hc3LA4HFeCI7sekZ/PQMTNmn9I/4Wg==", + "dependencies": { + "@tanstack/vue-virtual": "^3.0.0-beta.60" + }, + "engines": { + "node": ">=10" + }, + "peerDependencies": { + "vue": "^3.2.0" + } + }, "node_modules/@heroicons/vue": { "version": "2.2.0", "resolved": "https://registry.npmjs.org/@heroicons/vue/-/vue-2.2.0.tgz", @@ -4538,6 +4553,30 @@ "dev": true, "license": "CC0-1.0" }, + "node_modules/@tanstack/virtual-core": { + "version": "3.13.9", + "resolved": "https://registry.npmjs.org/@tanstack/virtual-core/-/virtual-core-3.13.9.tgz", + "integrity": "sha512-3jztt0jpaoJO5TARe2WIHC1UQC3VMLAFUW5mmMo0yrkwtDB2AQP0+sh10BVUpWrnvHjSLvzFizydtEGLCJKFoQ==", + "funding": { + "type": "github", + "url": "https://github.com/sponsors/tannerlinsley" + } + }, + "node_modules/@tanstack/vue-virtual": { + "version": "3.13.9", + "resolved": "https://registry.npmjs.org/@tanstack/vue-virtual/-/vue-virtual-3.13.9.tgz", + "integrity": "sha512-HsvHaOo+o52cVcPhomKDZ3CMpTF/B2qg+BhPHIQJwzn4VIqDyt/rRVqtIomG6jE83IFsE2vlr6cmx7h3dHA0SA==", + "dependencies": { + "@tanstack/virtual-core": "3.13.9" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/tannerlinsley" + }, + "peerDependencies": { + "vue": "^2.7.0 || ^3.0.0" + } + }, "node_modules/@trysound/sax": { "version": "0.2.0", "resolved": "https://registry.npmjs.org/@trysound/sax/-/sax-0.2.0.tgz", diff --git a/package.json b/package.json index 73f243e..f58b360 100644 --- a/package.json +++ b/package.json @@ -5,8 +5,9 @@ "dev": "nuxt dev", "generate": "nuxt generate", "preview": "nuxt preview", - "postinstall": "nuxt prepare", - "lint": "eslint --ext .js,.vue,.ts ." + "postinstall": "nuxt prepare", + "lint": "eslint --ext .js,.vue,.ts .", + "lint:fix": "eslint --ext .js,.vue,.ts --fix ." }, "devDependencies": { "autoprefixer": "^10.4.21", @@ -18,6 +19,7 @@ "vue-i18n": "^11.1.5" }, "dependencies": { + "@headlessui/vue": "^1.7.23", "@heroicons/vue": "^2.2.0", "@typescript-eslint/parser": "^8.34.0", "async-mutex": "^0.5.0", diff --git a/pages/dashboard/reported-tasks/[id].vue b/pages/dashboard/reported-tasks/[id].vue index 09dc4af..5c486a5 100644 --- a/pages/dashboard/reported-tasks/[id].vue +++ b/pages/dashboard/reported-tasks/[id].vue @@ -1,129 +1,90 @@