diff --git a/classquiz/db/models.py b/classquiz/db/models.py index 5b08633..8809d2e 100644 --- a/classquiz/db/models.py +++ b/classquiz/db/models.py @@ -112,23 +112,43 @@ class QuizQuestionType(str, Enum): ABCD = "ABCD" RANGE = "RANGE" VOTING = "VOTING" + SLIDE = "SLIDE" + + +class SlideElementTypes(str, Enum): + TEXT = "TEXT" + HEADLINE = "HEADLINE" + IMAGE = "IMAGE" + + +class SlideElement(BaseModel): + type: SlideElementTypes + x: float + y: float + height: float + width: float + data: str + id: int class QuizQuestion(BaseModel): question: str time: str # in Secs type: None | QuizQuestionType = QuizQuestionType.ABCD - answers: list[ABCDQuizAnswer] | RangeQuizAnswer | list[VotingQuizAnswer] + answers: list[ABCDQuizAnswer] | RangeQuizAnswer | list[VotingQuizAnswer] | list[SlideElement] image: str | None = None @validator("answers") def answers_not_none_if_abcd_type(cls, v, values): + print(values) if values["type"] == QuizQuestionType.ABCD and type(v[0]) != ABCDQuizAnswer: raise ValueError("Answers can't be none if type is ABCD") if values["type"] == QuizQuestionType.RANGE and type(v) != RangeQuizAnswer: raise ValueError("Answer must be from type RangeQuizAnswer if type is RANGE") if values["type"] == QuizQuestionType.VOTING and type(v[0]) != VotingQuizAnswer: raise ValueError("Answer must be from type VotingQuizAnswer if type is VOTING") + if values["type"] == QuizQuestionType.SLIDE and type(v[0]) != SlideElement: + raise ValueError("Answer must be from type SlideElement if type is SLIDE") return v diff --git a/frontend/package.json b/frontend/package.json index a359008..576843a 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -24,6 +24,7 @@ "@felte/reporter-tippy": "^1.1.4", "@felte/validator-yup": "^1.0.10", "@fontsource/marck-script": "^4.5.11", + "@neodrag/svelte": "^1.2.4", "@sentry/browser": "^7.23.0", "@sentry/tracing": "^7.23.0", "@simplewebauthn/browser": "^6.2.2", diff --git a/frontend/pnpm-lock.yaml b/frontend/pnpm-lock.yaml index db415aa..d7e3535 100644 --- a/frontend/pnpm-lock.yaml +++ b/frontend/pnpm-lock.yaml @@ -11,6 +11,7 @@ specifiers: '@felte/reporter-tippy': ^1.1.4 '@felte/validator-yup': ^1.0.10 '@fontsource/marck-script': ^4.5.11 + '@neodrag/svelte': ^1.2.4 '@sentry/browser': ^7.23.0 '@sentry/tracing': ^7.23.0 '@simplewebauthn/browser': ^6.2.2 @@ -91,6 +92,7 @@ devDependencies: '@felte/reporter-tippy': 1.1.4_tippy.js@6.3.7 '@felte/validator-yup': 1.0.10_yup@0.32.11 '@fontsource/marck-script': 4.5.11 + '@neodrag/svelte': 1.2.4 '@sentry/browser': 7.27.0 '@sentry/tracing': 7.27.0 '@simplewebauthn/browser': 6.2.2 @@ -1001,6 +1003,13 @@ packages: engines: { node: '>=6.0.0' } dev: true + /@neodrag/svelte/1.2.4: + resolution: + { + integrity: sha512-oGOxAgjtLbHyCJIWv35cvuHpgip9Kzn0ANrCidZb3rXV29w3AWhS7VtKAQfRinzFbmfK0Jeic7aSYdGmtKFKqw== + } + dev: true + /@nodelib/fs.scandir/2.1.5: resolution: { diff --git a/frontend/src/lib/editor.svelte b/frontend/src/lib/editor.svelte index eda9e46..574a0a8 100644 --- a/frontend/src/lib/editor.svelte +++ b/frontend/src/lib/editor.svelte @@ -39,11 +39,13 @@ } const validateInput = async (data: EditorData) => { + // console.log("input", data) try { await dataSchema.validate(data, { abortEarly: false }); schemaInvalid = false; yupErrorMessage = ''; } catch (err) { + console.log('erro!', err.errors); schemaInvalid = true; yupErrorMessage = err.errors ? err.errors[0] : ''; } diff --git a/frontend/src/lib/editor/card.svelte b/frontend/src/lib/editor/card.svelte index a79b74f..061b0ff 100644 --- a/frontend/src/lib/editor/card.svelte +++ b/frontend/src/lib/editor/card.svelte @@ -12,7 +12,7 @@ import Spinner from '../Spinner.svelte'; import { createTippy } from 'svelte-tippy'; import { getLocalization } from '$lib/i18n'; - import Slide from './slide.svelte'; + // import Slide from './slide.svelte'; const { t } = getLocalization(); @@ -50,6 +50,8 @@ data.questions[selected_question].type = QuizQuestionType.ABCD; } */ + + $: console.log();