diff --git a/package-lock.json b/package-lock.json index 3268bb7..9ea0a7a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -19,7 +19,7 @@ "svelte": "^3.49.0", "svelte-preprocess": "^4.10.7", "tailwindcss": "^3.1.8", - "vite": "^3.0.0" + "vite": "^3.0.9" } }, "node_modules/@nodelib/fs.scandir": { @@ -1842,15 +1842,15 @@ "dev": true }, "node_modules/vite": { - "version": "3.0.3", - "resolved": "https://registry.npmjs.org/vite/-/vite-3.0.3.tgz", - "integrity": "sha512-sDIpIcl3mv1NUaSzZwiXGEy1ZoWwwC2vkxUHY6yiDacR6zf//ZFuBJrozO62gedpE43pmxnLATNR5IYUdAEkMQ==", + "version": "3.0.9", + "resolved": "https://registry.npmjs.org/vite/-/vite-3.0.9.tgz", + "integrity": "sha512-waYABTM+G6DBTCpYAxvevpG50UOlZuynR0ckTK5PawNVt7ebX6X7wNXHaGIO6wYYFXSM7/WcuFuO2QzhBB6aMw==", "dev": true, "dependencies": { "esbuild": "^0.14.47", - "postcss": "^8.4.14", + "postcss": "^8.4.16", "resolve": "^1.22.1", - "rollup": "^2.75.6" + "rollup": ">=2.75.6 <2.77.0 || ~2.77.0" }, "bin": { "vite": "bin/vite.js" @@ -3047,16 +3047,16 @@ "dev": true }, "vite": { - "version": "3.0.3", - "resolved": "https://registry.npmjs.org/vite/-/vite-3.0.3.tgz", - "integrity": "sha512-sDIpIcl3mv1NUaSzZwiXGEy1ZoWwwC2vkxUHY6yiDacR6zf//ZFuBJrozO62gedpE43pmxnLATNR5IYUdAEkMQ==", + "version": "3.0.9", + "resolved": "https://registry.npmjs.org/vite/-/vite-3.0.9.tgz", + "integrity": "sha512-waYABTM+G6DBTCpYAxvevpG50UOlZuynR0ckTK5PawNVt7ebX6X7wNXHaGIO6wYYFXSM7/WcuFuO2QzhBB6aMw==", "dev": true, "requires": { "esbuild": "^0.14.47", "fsevents": "~2.3.2", - "postcss": "^8.4.14", + "postcss": "^8.4.16", "resolve": "^1.22.1", - "rollup": "^2.75.6" + "rollup": ">=2.75.6 <2.77.0 || ~2.77.0" } }, "wrappy": { diff --git a/package.json b/package.json index 668cde5..abc58cc 100644 --- a/package.json +++ b/package.json @@ -17,7 +17,7 @@ "svelte": "^3.49.0", "svelte-preprocess": "^4.10.7", "tailwindcss": "^3.1.8", - "vite": "^3.0.0" + "vite": "^3.0.9" }, "dependencies": { "svelte-routing": "^1.6.0" diff --git a/src/routes/finish.svelte b/src/lib/Components/Forms/Finish.svelte similarity index 100% rename from src/routes/finish.svelte rename to src/lib/Components/Forms/Finish.svelte diff --git a/src/lib/Components/Forms/IntervalForm.svelte b/src/lib/Components/Forms/IntervalForm.svelte index 9999052..24d0769 100644 --- a/src/lib/Components/Forms/IntervalForm.svelte +++ b/src/lib/Components/Forms/IntervalForm.svelte @@ -1,27 +1,21 @@ - (control = myAnswer !== '' ? between(myAnswer, answers.right.min, answers.right.max) : null)}> - {answers.title} - {answers.about} + (control = myAnswer !== '' ? between(myAnswer, params.correct[0], params.correct[1]) : null)}> + {title} + {params.quesion}
diff --git a/src/lib/Components/Forms/MultiChoiceForm.svelte b/src/lib/Components/Forms/MultiChoiceForm.svelte index 035e1ab..85ce64e 100644 --- a/src/lib/Components/Forms/MultiChoiceForm.svelte +++ b/src/lib/Components/Forms/MultiChoiceForm.svelte @@ -1,38 +1,39 @@ - - title - about + + {title} + {params.quesion}
- {#each answers as { label, checked }} + {#each params.options as option, i} - {label} + {option} {/each}
diff --git a/src/lib/Components/Forms/NumberForm.svelte b/src/lib/Components/Forms/NumberForm.svelte index 31fcf8c..de7f208 100644 --- a/src/lib/Components/Forms/NumberForm.svelte +++ b/src/lib/Components/Forms/NumberForm.svelte @@ -1,16 +1,18 @@ - (control = myAnswer !== '' ? myAnswer === answers.right : null)}> - {answers.title} - {answers.about} + (control = myAnswer !== '' ? myAnswer === params.correct : null)}> + {title} + {params.about}
diff --git a/src/lib/Components/Forms/Renderer.svelte b/src/lib/Components/Forms/Renderer.svelte index 6d92ec2..f78af4c 100644 --- a/src/lib/Components/Forms/Renderer.svelte +++ b/src/lib/Components/Forms/Renderer.svelte @@ -5,23 +5,8 @@ import MultiplyForm from './MultiChoiceForm.svelte' import IntervalForm from './IntervalForm.svelte' import QrCode from './QrCode.svelte' - - let control = null // if true => spravne if false spatne - $: console.log(control) - - /* - let questions = [ - { type: 'text', correct: 'jablko', quesion: 'text otazky', description: '', options: null }, - { type: 'multichoice', correct: ['banan', 'cokolada'], quesion: 'text otazky', description: '', options: ['banan', 'cokolada', 'mleko'] }, - { type: 'singlechoice', correct: 'jablko', quesion: 'text otazky', description: '', options: ['banan', 'cokolada', 'mleko'] }, - { type: 'interval', correct: [0, 3], quesion: 'text otazky', description: '', options: null }, - ] - */ - - const answers = { - type: 'singlechoice', - //... answers - } + import { navigate } from 'svelte-routing' + import Finish from './Finish.svelte' const components = { text: TextForm, @@ -30,7 +15,35 @@ multichoice: MultiplyForm, interval: IntervalForm, qrcode: QrCode, + + finish: Finish, + } + + let control = null // if true => spravne if false spatne + $: console.log(control ? 'správně' : !control ? 'špatně' : null) + + const nextQuestion = () => { + if (clientAnswers.pos + 1 === clientAnswers.end) { + page = components.finish + return '' + } + control = null + clientAnswers.pos++ + } + + let questions = [ + { type: 'singlechoice', correct: 'banan', quesion: 'text otazky', description: '', options: ['banan', 'cokolada', 'mleko'] }, + { type: 'interval', correct: [0, 3], quesion: 'text otazky', description: '', options: null }, + { type: 'text', correct: 'jablko', quesion: 'text otazky', description: '', options: null }, + { type: 'multichoice', correct: ['banan', 'cokolada'], quesion: 'text otazky', description: '', options: ['banan', 'cokolada', 'mleko'] }, + ] + let page + $: page = components[questions[clientAnswers.pos].type] + + let clientAnswers = { + pos: 0, + end: questions.length, } - + diff --git a/src/lib/Components/Forms/SingleChoiceForm.svelte b/src/lib/Components/Forms/SingleChoiceForm.svelte index 6b255d0..4172248 100644 --- a/src/lib/Components/Forms/SingleChoiceForm.svelte +++ b/src/lib/Components/Forms/SingleChoiceForm.svelte @@ -1,25 +1,22 @@ - (control = myAnswer !== undefined ? myAnswer === answers.right : null)}> + (control = typeof myAnswer === 'string' ? myAnswer === params.correct : null)}> {title} - {about} + {params.quesion}
- {#each answers.labels as label} + {#each params.options as option} - {label} + {option} {/each}
diff --git a/src/lib/Components/Forms/TextForm.svelte b/src/lib/Components/Forms/TextForm.svelte index 43267fc..b4bd6d3 100644 --- a/src/lib/Components/Forms/TextForm.svelte +++ b/src/lib/Components/Forms/TextForm.svelte @@ -1,20 +1,22 @@ - (control = myAnswer !== '' ? compare(myAnswer, answers.right) : null)}> - {answers.title} - {answers.about} + (control = myAnswer !== '' ? compare(myAnswer, params.correct) : null)}> + {title} + {params.quesion}
diff --git a/src/lib/Components/Quiz/Layout.svelte b/src/lib/Components/Quiz/Layout.svelte index 0e5e5be..22bde0c 100644 --- a/src/lib/Components/Quiz/Layout.svelte +++ b/src/lib/Components/Quiz/Layout.svelte @@ -4,6 +4,9 @@ import Section from '../Section.svelte' import Map from '../game/Map.svelte' import Button from '../Button.svelte' + + export let control, nextQuestion + $: console.log(control) @@ -14,7 +17,7 @@
-
+
Popis úkolu: @@ -22,9 +25,20 @@
- + {#if control !== null} + + {:else} + + {/if}
+
+ {#if control} + správně + {:else if control !== null} + špatně + {/if} +
diff --git a/src/lib/Components/Quiz/answers/CheckBox.svelte b/src/lib/Components/Quiz/answers/CheckBox.svelte index 54255d6..0374dca 100644 --- a/src/lib/Components/Quiz/answers/CheckBox.svelte +++ b/src/lib/Components/Quiz/answers/CheckBox.svelte @@ -1,8 +1,8 @@
@@ -17,7 +17,7 @@
-