diff --git a/data.json b/ccna3.json similarity index 100% rename from data.json rename to ccna3.json diff --git a/data-old.json b/data-test.json similarity index 84% rename from data-old.json rename to data-test.json index 7bb3388..b8adc32 100644 --- a/data-old.json +++ b/data-test.json @@ -1,8 +1,9 @@ { "title": "CCNA 2 Final Exam", - "questions": [{ + "questions": [ + { "id": "quest1", - "type": 0, + "type": 1, "title": "The buffers for packet processing and the running configuration file are temporarily stored in which type of router memory?", "images": [], "options": { @@ -11,11 +12,13 @@ "q1-3": "RAM", "q1-4": "ROM" }, - "correct": "q1-3" + "correct": [ + "q1-3" + ] }, { "id": "quest2", - "type": 0, + "type": 1, "title": "Refer to the exhibit. A company has an internal network of 192.168.10.0/24 for their employee workstations and a DMZ network of 192.168.3.0/24 to host servers. The company uses NAT when inside hosts connect to outside network. A network administrator issues the show ip nat translations command to check the NAT configurations. Which one of source IPv4 addresses is translated by R1 with PAT", "images": [ "i258133v1n1_258133.png" @@ -27,7 +30,10 @@ "q2-4": "192.168.10.35", "q2-5": "172.16.20.5" }, - "correct": "q2-4" + "correct": [ + "q2-4", + "q2-2" + ] } ] } \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index 72666c8..8453f0a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -916,9 +916,9 @@ "integrity": "sha512-fDSoKtuC6UNuxbBOJzL1zf3wU0R56kWjLT/OOgmeGAejvRF9UE9yVetLvmOezoVCGElPZH7iKwK0kDvKfExi4w==" }, "@hibas123/utils": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/@hibas123/utils/-/utils-2.1.1.tgz", - "integrity": "sha512-A5yQfPsG+B5Vg6TsfJPqRi0tbjfobsTEoiTSFS+r+FFGStTL+B29zN5XI7D1RafL+dveKhblqSZ1Pi1YtEMAVw==" + "version": "2.2.3", + "resolved": "https://registry.npmjs.org/@hibas123/utils/-/utils-2.2.3.tgz", + "integrity": "sha512-yAywWMDbt5fmid9E7IRXeCazdbwfC339LhRFIryXab0FqlQzUrm8ggdJaSzWXYC7m3ijdekSezlBno/vOL/L2Q==" }, "@iarna/toml": { "version": "2.2.3", @@ -1045,9 +1045,9 @@ "dev": true }, "@types/node": { - "version": "12.12.12", - "resolved": "https://registry.npmjs.org/@types/node/-/node-12.12.12.tgz", - "integrity": "sha512-MGuvYJrPU0HUwqF7LqvIj50RZUX23Z+m583KBygKYUZLlZ88n6w28XRNJRJgsHukLEnLz6w6SvxZoLgbr5wLqQ==", + "version": "12.12.14", + "resolved": "https://registry.npmjs.org/@types/node/-/node-12.12.14.tgz", + "integrity": "sha512-u/SJDyXwuihpwjXy7hOOghagLEV1KdAST6syfnOk6QZAMzZuWZqXy5aYYZbh8Jdpd4escVFP0MvftHNDb9pruA==", "dev": true }, "@types/q": { @@ -1190,9 +1190,9 @@ } }, "arg": { - "version": "4.1.1", - "resolved": "https://registry.npmjs.org/arg/-/arg-4.1.1.tgz", - "integrity": "sha512-SlmP3fEA88MBv0PypnXZ8ZfJhwmDeIE3SP71j37AiXQBXYosPV0x6uISAaHYSlSVhmHOVkomen0tbGk6Anlebw==" + "version": "4.1.2", + "resolved": "https://registry.npmjs.org/arg/-/arg-4.1.2.tgz", + "integrity": "sha512-+ytCkGcBtHZ3V2r2Z06AncYO8jz46UEamcspGoU8lHcEbpn6J77QK0vdWvChsclg/tM5XIJC5tnjmPp7Eq6Obg==" }, "argparse": { "version": "1.0.10", @@ -7736,9 +7736,9 @@ "dev": true }, "svelte": { - "version": "3.15.0", - "resolved": "https://registry.npmjs.org/svelte/-/svelte-3.15.0.tgz", - "integrity": "sha512-OL9FIdUAmVTXR38cB/2vQQ9xWvW/7IuOASjWMfwRAB5NXywLW4Xqhblouan4odjI0S/JFGsytkgp7jelWpFgSA==" + "version": "3.16.0", + "resolved": "https://registry.npmjs.org/svelte/-/svelte-3.16.0.tgz", + "integrity": "sha512-k7nCQTd9/rGOi25iv/sBeJe2W89hK2lcaUsmUQqikH0Tye7Gh/tvvF9LuNTSF+dQY/isNX+g8K9fJf+5jMLfxw==" }, "svelte-dev-helper": { "version": "1.1.9", @@ -7746,6 +7746,11 @@ "integrity": "sha1-fRh9tcbNu9ZNdaMvkbiZi94yc8M=", "dev": true }, + "svelte-key": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/svelte-key/-/svelte-key-1.0.0.tgz", + "integrity": "sha512-+aM/gdxrkMrCSRWthqj0YIAUpsrwfPKn4VOAHjbn4HZVfZ36ai1P6EWq2Suf5m5WO/2Pa7xUYviVdK80zsoz7A==" + }, "svelte-preprocess-filter": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/svelte-preprocess-filter/-/svelte-preprocess-filter-1.0.0.tgz", @@ -7975,9 +7980,9 @@ } }, "ts-node": { - "version": "8.5.2", - "resolved": "https://registry.npmjs.org/ts-node/-/ts-node-8.5.2.tgz", - "integrity": "sha512-W1DK/a6BGoV/D4x/SXXm6TSQx6q3blECUzd5TN+j56YEMX3yPVMpHsICLedUw3DvGF3aTQ8hfdR9AKMaHjIi+A==", + "version": "8.5.4", + "resolved": "https://registry.npmjs.org/ts-node/-/ts-node-8.5.4.tgz", + "integrity": "sha512-izbVCRV68EasEPQ8MSIGBNK9dc/4sYJJKYA+IarMQct1RtEot6Xp0bXuClsbUSnKpg50ho+aOAx8en5c+y4OFw==", "requires": { "arg": "^4.1.0", "diff": "^4.0.1", @@ -8023,9 +8028,9 @@ "dev": true }, "typescript": { - "version": "3.7.2", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-3.7.2.tgz", - "integrity": "sha512-ml7V7JfiN2Xwvcer+XAf2csGO1bPBdRbFCkYBczNZggrBZ9c7G3riSUeJmqEU5uOtXNPMhE3n+R4FA/3YOAWOQ==", + "version": "3.7.3", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-3.7.3.tgz", + "integrity": "sha512-Mcr/Qk7hXqFBXMN7p7Lusj1ktCBydylfQM/FZCk5glCNQJrCUKPkMHdo9R0MTFWsC/4kPFvDS0fDPvukfCkFsw==", "dev": true }, "uncss": { diff --git a/package.json b/package.json index f9d8257..a89f5de 100644 --- a/package.json +++ b/package.json @@ -10,22 +10,23 @@ "license": "ISC", "dependencies": { "@hibas123/theme": "^1.2.14", - "@hibas123/utils": "^2.1.1", + "@hibas123/utils": "^2.2.3", "feather-icons": "^4.24.1", "navigo": "^7.1.2", - "svelte": "^3.15.0", - "ts-node": "^8.5.2", + "svelte": "^3.16.0", + "svelte-key": "^1.0.0", + "ts-node": "^8.5.4", "uuid": "^3.3.3" }, "devDependencies": { "@types/navigo": "^7.0.1", - "@types/node": "^12.12.12", + "@types/node": "^12.12.14", "@types/uuid": "^3.4.6", "node-sass": "^4.13.0", "parcel-bundler": "^1.12.4", "parcel-plugin-svelte": "^4.0.5", "svelte-preprocess-sass": "^0.2.0", - "typescript": "^3.7.2" + "typescript": "^3.7.3" }, "browserslist": [ "last 2 Chrome versions" diff --git a/src/stores.ts b/src/stores.ts index 7143cba..a48da3b 100644 --- a/src/stores.ts +++ b/src/stores.ts @@ -1,6 +1,21 @@ import { writable, readable } from "svelte/store"; -import Data from "../data.json"; -import { Question } from "./data"; +import { Question, Exam } from "./data"; + +import CCNA2 from "../ccna2.json"; +import CCNA3 from "../ccna3.json"; +import TestData from "../data-test.json"; + +const tests = new Map(); +tests.set("ccna3", CCNA3); +tests.set("ccna2", CCNA2); +tests.set("test", TestData) + +let test = new URL(window.location.href).searchParams.get("exam"); + +const dataVersion = tests.has(test) ? test : "ccna3"; +const Data = tests.get(dataVersion); + +console.log("Running exam:", dataVersion); const runsShould = 3; diff --git a/src/views/Question.svelte b/src/views/Question.svelte index 5c061f8..77cc1a6 100644 --- a/src/views/Question.svelte +++ b/src/views/Question.svelte @@ -8,6 +8,7 @@ import SelectMultiple from "./questions/SelectMultiple.svelte"; import AssignValues from "./questions/AssignValues.svelte"; import TextInput from "./questions/TextInput.svelte"; + import Identity from 'svelte-key' const questions = new Map(); questions.set(QuestionTypes.SelectOne, SelectOne); @@ -24,14 +25,14 @@ let idx = 0; function next() { - idx++; + showResult = false; if (isCorrect) { isCorrect = false; $activeQuestion.correct() } else { $activeQuestion.wrong(); } - showResult = false; + idx++; } @@ -46,7 +47,9 @@ {/each}
- + + +
{#if !showResult} diff --git a/src/views/questions/SelectMultiple.svelte b/src/views/questions/SelectMultiple.svelte index 993ecfd..29c0da0 100644 --- a/src/views/questions/SelectMultiple.svelte +++ b/src/views/questions/SelectMultiple.svelte @@ -5,26 +5,16 @@ export let showResult = false; export let isCorrect = false; - $: options = randomize(Object.keys(question.options).map(e => ({ key: e, value: question.options[e] }))); let selected = []; + $: isCorrect = selected.length === question.correct.length && selected.every(val => question.correct.find(v => v === val)); $: console.log("Selected:", selected, "showResult:", showResult, "isCorrect", isCorrect); - - - function toggle(id) { - if (selected.indexOf(id) < 0) { - selected = [...selected, id]; - } else { - selected = selected.filter(e => e !== id); - } - } -

Select {question.correct.length}

-{#each options as option} +{#each options as option (option.key)}
= 0} @@ -32,9 +22,10 @@