From e1014955947ab517d2a6b03bf9acac4bc5ed45d8 Mon Sep 17 00:00:00 2001 From: tom Date: Thu, 16 May 2024 16:35:39 -0400 Subject: [PATCH 1/4] this is becoming more complicated than i thought --- src/helpers/ItemFactory.js | 8 ++++++++ src/helpers/TestFactory.js | 20 ++++++++++++++++++++ src/views/Home.vue | 32 ++++++++++++++++++++++++++++++++ 3 files changed, 60 insertions(+) diff --git a/src/helpers/ItemFactory.js b/src/helpers/ItemFactory.js index 6a5e407..af433ec 100644 --- a/src/helpers/ItemFactory.js +++ b/src/helpers/ItemFactory.js @@ -8308,4 +8308,12 @@ export class ItemFactory { return items } + pushItem (xml) { + const identifier = xml.match(/identifier="([^"]+)"/)[1] + const guid = Math.random().toString(16).slice(2); + const submissionMode = "simultaneous" + + items.push({identifier, guid, submissionMode, xml}); + return {identifier}; + } } diff --git a/src/helpers/TestFactory.js b/src/helpers/TestFactory.js index ecf744b..4a676b8 100644 --- a/src/helpers/TestFactory.js +++ b/src/helpers/TestFactory.js @@ -1570,4 +1570,24 @@ export class TestFactory { return this.tests.find(test => test.id === id) } + pushNewTest (title, description, items) { + const id = Math.random().toString(16).slice(2); + + tests.push({ + id, + title, + description, + items: items.map(item => ({ + "identifier": item.identifier, + "sessionControl": item.sessionControl || { + "showFeedback": true, + "validateResponses": false, + "submissionMode": "individual" + } + })), + count: items.length.toString() + }) + + return id; + } } diff --git a/src/views/Home.vue b/src/views/Home.vue index b97c1ff..ff91094 100644 --- a/src/views/Home.vue +++ b/src/views/Home.vue @@ -33,6 +33,14 @@ + @@ -82,6 +90,18 @@ + +
+ +
@@ -135,6 +155,17 @@ export default { } }) + }, + onFileChanged($event) { + const target = $event.target; + if (target && target.files && target.files[0]) { + const file = target.files[0]; + const reader = new FileReader(); + reader.onload = (e) => { + console.log(e.target.result); + }; + reader.readAsText(file); + } } }, @@ -145,6 +176,7 @@ export default { mounted () { } + } From 0fa1198df567b6d5d3a638760e5a2a6aeb0e9366 Mon Sep 17 00:00:00 2001 From: tom Date: Thu, 16 May 2024 17:29:37 -0400 Subject: [PATCH 2/4] grossly making progress --- src/helpers/ItemFactory.js | 10 ++-- src/helpers/TestControllerUtilities.js | 4 +- src/helpers/TestFactory.js | 12 +++-- src/views/Home.vue | 63 ++++++++++++++++++++++---- 4 files changed, 73 insertions(+), 16 deletions(-) diff --git a/src/helpers/ItemFactory.js b/src/helpers/ItemFactory.js index af433ec..1895e19 100644 --- a/src/helpers/ItemFactory.js +++ b/src/helpers/ItemFactory.js @@ -8276,6 +8276,11 @@ identifier="Ch5_Modeling_3" title="Ch5_Modeling_3"> /* eslint-enable */ export class ItemFactory { + static _instance; + + static instance () { + return ItemFactory._instance ??= new ItemFactory(); + } constructor () { this.items = items @@ -8308,12 +8313,11 @@ export class ItemFactory { return items } - pushItem (xml) { - const identifier = xml.match(/identifier="([^"]+)"/)[1] + pushItem (identifier, xml) { const guid = Math.random().toString(16).slice(2); const submissionMode = "simultaneous" - items.push({identifier, guid, submissionMode, xml}); + this.items.push({identifier, guid, submissionMode, xml}); return {identifier}; } } diff --git a/src/helpers/TestControllerUtilities.js b/src/helpers/TestControllerUtilities.js index 36de038..f95eafb 100644 --- a/src/helpers/TestControllerUtilities.js +++ b/src/helpers/TestControllerUtilities.js @@ -25,8 +25,8 @@ export class TestControllerUtilities { navigateItemData = null constructor () { - this.testFactory = new TestFactory() - this.itemFactory = new ItemFactory() + this.testFactory = TestFactory.instance() + this.itemFactory = ItemFactory.instance() return this } diff --git a/src/helpers/TestFactory.js b/src/helpers/TestFactory.js index 4a676b8..71138c5 100644 --- a/src/helpers/TestFactory.js +++ b/src/helpers/TestFactory.js @@ -1556,6 +1556,12 @@ const tests = [ /* eslint-enable */ export class TestFactory { + static _instance; + + static instance () { + return TestFactory._instance ??= new TestFactory(); + } + constructor () { this.tests = tests @@ -1570,10 +1576,10 @@ export class TestFactory { return this.tests.find(test => test.id === id) } - pushNewTest (title, description, items) { + pushTest (title, description, items) { const id = Math.random().toString(16).slice(2); - tests.push({ + this.tests.push({ id, title, description, @@ -1582,7 +1588,7 @@ export class TestFactory { "sessionControl": item.sessionControl || { "showFeedback": true, "validateResponses": false, - "submissionMode": "individual" + "submissionMode": "simultaneous" } })), count: items.length.toString() diff --git a/src/views/Home.vue b/src/views/Home.vue index ff91094..1d6d45d 100644 --- a/src/views/Home.vue +++ b/src/views/Home.vue @@ -96,8 +96,8 @@ Upload an .xml file containing a qti-assessment-item @@ -116,6 +116,7 @@ diff --git a/src/views/TestRunner.vue b/src/views/TestRunner.vue index f8604fc..ccde026 100644 --- a/src/views/TestRunner.vue +++ b/src/views/TestRunner.vue @@ -342,7 +342,7 @@ export default { // Inject report into End Panel this.$refs.endpanel.setUnanswered(report.unanswered) this.$refs.endpanel.setItemSummary(report.summary) - + // Show the End page this.currentPanel = 'end'