Making multiple examps available

Updating dependencies
Possibly fixing errors on MultipleSelect Questions
This commit is contained in:
Fabian Stamm 2019-12-04 14:13:48 +01:00
parent 18beebda7a
commit a980e25e93
7 changed files with 69 additions and 48 deletions

View File

@ -1,8 +1,9 @@
{ {
"title": "CCNA 2 Final Exam", "title": "CCNA 2 Final Exam",
"questions": [{ "questions": [
{
"id": "quest1", "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?", "title": "The buffers for packet processing and the running configuration file are temporarily stored in which type of router memory?",
"images": [], "images": [],
"options": { "options": {
@ -11,11 +12,13 @@
"q1-3": "RAM", "q1-3": "RAM",
"q1-4": "ROM" "q1-4": "ROM"
}, },
"correct": "q1-3" "correct": [
"q1-3"
]
}, },
{ {
"id": "quest2", "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", "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": [ "images": [
"i258133v1n1_258133.png" "i258133v1n1_258133.png"
@ -27,7 +30,10 @@
"q2-4": "192.168.10.35", "q2-4": "192.168.10.35",
"q2-5": "172.16.20.5" "q2-5": "172.16.20.5"
}, },
"correct": "q2-4" "correct": [
"q2-4",
"q2-2"
]
} }
] ]
} }

41
package-lock.json generated
View File

@ -916,9 +916,9 @@
"integrity": "sha512-fDSoKtuC6UNuxbBOJzL1zf3wU0R56kWjLT/OOgmeGAejvRF9UE9yVetLvmOezoVCGElPZH7iKwK0kDvKfExi4w==" "integrity": "sha512-fDSoKtuC6UNuxbBOJzL1zf3wU0R56kWjLT/OOgmeGAejvRF9UE9yVetLvmOezoVCGElPZH7iKwK0kDvKfExi4w=="
}, },
"@hibas123/utils": { "@hibas123/utils": {
"version": "2.1.1", "version": "2.2.3",
"resolved": "https://registry.npmjs.org/@hibas123/utils/-/utils-2.1.1.tgz", "resolved": "https://registry.npmjs.org/@hibas123/utils/-/utils-2.2.3.tgz",
"integrity": "sha512-A5yQfPsG+B5Vg6TsfJPqRi0tbjfobsTEoiTSFS+r+FFGStTL+B29zN5XI7D1RafL+dveKhblqSZ1Pi1YtEMAVw==" "integrity": "sha512-yAywWMDbt5fmid9E7IRXeCazdbwfC339LhRFIryXab0FqlQzUrm8ggdJaSzWXYC7m3ijdekSezlBno/vOL/L2Q=="
}, },
"@iarna/toml": { "@iarna/toml": {
"version": "2.2.3", "version": "2.2.3",
@ -1045,9 +1045,9 @@
"dev": true "dev": true
}, },
"@types/node": { "@types/node": {
"version": "12.12.12", "version": "12.12.14",
"resolved": "https://registry.npmjs.org/@types/node/-/node-12.12.12.tgz", "resolved": "https://registry.npmjs.org/@types/node/-/node-12.12.14.tgz",
"integrity": "sha512-MGuvYJrPU0HUwqF7LqvIj50RZUX23Z+m583KBygKYUZLlZ88n6w28XRNJRJgsHukLEnLz6w6SvxZoLgbr5wLqQ==", "integrity": "sha512-u/SJDyXwuihpwjXy7hOOghagLEV1KdAST6syfnOk6QZAMzZuWZqXy5aYYZbh8Jdpd4escVFP0MvftHNDb9pruA==",
"dev": true "dev": true
}, },
"@types/q": { "@types/q": {
@ -1190,9 +1190,9 @@
} }
}, },
"arg": { "arg": {
"version": "4.1.1", "version": "4.1.2",
"resolved": "https://registry.npmjs.org/arg/-/arg-4.1.1.tgz", "resolved": "https://registry.npmjs.org/arg/-/arg-4.1.2.tgz",
"integrity": "sha512-SlmP3fEA88MBv0PypnXZ8ZfJhwmDeIE3SP71j37AiXQBXYosPV0x6uISAaHYSlSVhmHOVkomen0tbGk6Anlebw==" "integrity": "sha512-+ytCkGcBtHZ3V2r2Z06AncYO8jz46UEamcspGoU8lHcEbpn6J77QK0vdWvChsclg/tM5XIJC5tnjmPp7Eq6Obg=="
}, },
"argparse": { "argparse": {
"version": "1.0.10", "version": "1.0.10",
@ -7736,9 +7736,9 @@
"dev": true "dev": true
}, },
"svelte": { "svelte": {
"version": "3.15.0", "version": "3.16.0",
"resolved": "https://registry.npmjs.org/svelte/-/svelte-3.15.0.tgz", "resolved": "https://registry.npmjs.org/svelte/-/svelte-3.16.0.tgz",
"integrity": "sha512-OL9FIdUAmVTXR38cB/2vQQ9xWvW/7IuOASjWMfwRAB5NXywLW4Xqhblouan4odjI0S/JFGsytkgp7jelWpFgSA==" "integrity": "sha512-k7nCQTd9/rGOi25iv/sBeJe2W89hK2lcaUsmUQqikH0Tye7Gh/tvvF9LuNTSF+dQY/isNX+g8K9fJf+5jMLfxw=="
}, },
"svelte-dev-helper": { "svelte-dev-helper": {
"version": "1.1.9", "version": "1.1.9",
@ -7746,6 +7746,11 @@
"integrity": "sha1-fRh9tcbNu9ZNdaMvkbiZi94yc8M=", "integrity": "sha1-fRh9tcbNu9ZNdaMvkbiZi94yc8M=",
"dev": true "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": { "svelte-preprocess-filter": {
"version": "1.0.0", "version": "1.0.0",
"resolved": "https://registry.npmjs.org/svelte-preprocess-filter/-/svelte-preprocess-filter-1.0.0.tgz", "resolved": "https://registry.npmjs.org/svelte-preprocess-filter/-/svelte-preprocess-filter-1.0.0.tgz",
@ -7975,9 +7980,9 @@
} }
}, },
"ts-node": { "ts-node": {
"version": "8.5.2", "version": "8.5.4",
"resolved": "https://registry.npmjs.org/ts-node/-/ts-node-8.5.2.tgz", "resolved": "https://registry.npmjs.org/ts-node/-/ts-node-8.5.4.tgz",
"integrity": "sha512-W1DK/a6BGoV/D4x/SXXm6TSQx6q3blECUzd5TN+j56YEMX3yPVMpHsICLedUw3DvGF3aTQ8hfdR9AKMaHjIi+A==", "integrity": "sha512-izbVCRV68EasEPQ8MSIGBNK9dc/4sYJJKYA+IarMQct1RtEot6Xp0bXuClsbUSnKpg50ho+aOAx8en5c+y4OFw==",
"requires": { "requires": {
"arg": "^4.1.0", "arg": "^4.1.0",
"diff": "^4.0.1", "diff": "^4.0.1",
@ -8023,9 +8028,9 @@
"dev": true "dev": true
}, },
"typescript": { "typescript": {
"version": "3.7.2", "version": "3.7.3",
"resolved": "https://registry.npmjs.org/typescript/-/typescript-3.7.2.tgz", "resolved": "https://registry.npmjs.org/typescript/-/typescript-3.7.3.tgz",
"integrity": "sha512-ml7V7JfiN2Xwvcer+XAf2csGO1bPBdRbFCkYBczNZggrBZ9c7G3riSUeJmqEU5uOtXNPMhE3n+R4FA/3YOAWOQ==", "integrity": "sha512-Mcr/Qk7hXqFBXMN7p7Lusj1ktCBydylfQM/FZCk5glCNQJrCUKPkMHdo9R0MTFWsC/4kPFvDS0fDPvukfCkFsw==",
"dev": true "dev": true
}, },
"uncss": { "uncss": {

View File

@ -10,22 +10,23 @@
"license": "ISC", "license": "ISC",
"dependencies": { "dependencies": {
"@hibas123/theme": "^1.2.14", "@hibas123/theme": "^1.2.14",
"@hibas123/utils": "^2.1.1", "@hibas123/utils": "^2.2.3",
"feather-icons": "^4.24.1", "feather-icons": "^4.24.1",
"navigo": "^7.1.2", "navigo": "^7.1.2",
"svelte": "^3.15.0", "svelte": "^3.16.0",
"ts-node": "^8.5.2", "svelte-key": "^1.0.0",
"ts-node": "^8.5.4",
"uuid": "^3.3.3" "uuid": "^3.3.3"
}, },
"devDependencies": { "devDependencies": {
"@types/navigo": "^7.0.1", "@types/navigo": "^7.0.1",
"@types/node": "^12.12.12", "@types/node": "^12.12.14",
"@types/uuid": "^3.4.6", "@types/uuid": "^3.4.6",
"node-sass": "^4.13.0", "node-sass": "^4.13.0",
"parcel-bundler": "^1.12.4", "parcel-bundler": "^1.12.4",
"parcel-plugin-svelte": "^4.0.5", "parcel-plugin-svelte": "^4.0.5",
"svelte-preprocess-sass": "^0.2.0", "svelte-preprocess-sass": "^0.2.0",
"typescript": "^3.7.2" "typescript": "^3.7.3"
}, },
"browserslist": [ "browserslist": [
"last 2 Chrome versions" "last 2 Chrome versions"

View File

@ -1,6 +1,21 @@
import { writable, readable } from "svelte/store"; import { writable, readable } from "svelte/store";
import Data from "../data.json"; import { Question, Exam } from "./data";
import { Question } from "./data";
import CCNA2 from "../ccna2.json";
import CCNA3 from "../ccna3.json";
import TestData from "../data-test.json";
const tests = new Map<string, Exam>();
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; const runsShould = 3;

View File

@ -8,6 +8,7 @@
import SelectMultiple from "./questions/SelectMultiple.svelte"; import SelectMultiple from "./questions/SelectMultiple.svelte";
import AssignValues from "./questions/AssignValues.svelte"; import AssignValues from "./questions/AssignValues.svelte";
import TextInput from "./questions/TextInput.svelte"; import TextInput from "./questions/TextInput.svelte";
import Identity from 'svelte-key'
const questions = new Map(); const questions = new Map();
questions.set(QuestionTypes.SelectOne, SelectOne); questions.set(QuestionTypes.SelectOne, SelectOne);
@ -24,14 +25,14 @@
let idx = 0; let idx = 0;
function next() { function next() {
idx++; showResult = false;
if (isCorrect) { if (isCorrect) {
isCorrect = false; isCorrect = false;
$activeQuestion.correct() $activeQuestion.correct()
} else { } else {
$activeQuestion.wrong(); $activeQuestion.wrong();
} }
showResult = false; idx++;
} }
</script> </script>
@ -46,7 +47,9 @@
</div> </div>
{/each} {/each}
<div class="margin"> <div class="margin">
<Identity key={idx}>
<svelte:component key={idx} this={component} {question} {showResult} bind:isCorrect /> <svelte:component key={idx} this={component} {question} {showResult} bind:isCorrect />
</Identity>
</div> </div>
<div class="margin fl"> <div class="margin fl">
{#if !showResult} {#if !showResult}

View File

@ -5,26 +5,16 @@
export let showResult = false; export let showResult = false;
export let isCorrect = false; export let isCorrect = false;
$: options = randomize(Object.keys(question.options).map(e => ({ key: e, value: question.options[e] }))); $: options = randomize(Object.keys(question.options).map(e => ({ key: e, value: question.options[e] })));
let selected = []; let selected = [];
$: isCorrect = selected.length === question.correct.length && selected.every(val => question.correct.find(v => v === val)); $: isCorrect = selected.length === question.correct.length && selected.every(val => question.correct.find(v => v === val));
$: console.log("Selected:", selected, "showResult:", showResult, "isCorrect", isCorrect); $: 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);
}
}
</script> </script>
<h3>Select {question.correct.length}</h3> <h3>Select {question.correct.length}</h3>
{#each options as option} {#each options as option (option.key)}
<div <div
key={option.key} key={option.key}
class:should={showResult && question.correct.indexOf(option.key) >= 0} class:should={showResult && question.correct.indexOf(option.key) >= 0}
@ -33,8 +23,9 @@
<input <input
type="checkbox" type="checkbox"
id={option.key} id={option.key}
checked={selected.indexOf(option.key) >= 0} bind:group={selected}
on:click={(evt)=>showResult ? evt.preventDefault() : toggle(option.key)} on:click={(evt)=>showResult ? evt.preventDefault() : undefined}
value={option.key}
> >
<span></span> <span></span>
</label> </label>