From b6790163c0a987c5880d8cc9a9774ced610e5a9d Mon Sep 17 00:00:00 2001 From: Sarah Vaupel Date: Tue, 4 Feb 2020 09:48:37 +0100 Subject: [PATCH] refactor(exam-correct): minor refactor; no persistent entries for now --- .../src/utils/exam-correct/exam-correct.js | 23 +++++++++++-------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/frontend/src/utils/exam-correct/exam-correct.js b/frontend/src/utils/exam-correct/exam-correct.js index d231dc79d..75ab62a8e 100644 --- a/frontend/src/utils/exam-correct/exam-correct.js +++ b/frontend/src/utils/exam-correct/exam-correct.js @@ -38,10 +38,8 @@ const STATUS = { }) export class ExamCorrect { - _storageManager; - _dateFormat; - _element; + _app; _sendBtn; _userInput; @@ -49,9 +47,12 @@ export class ExamCorrect { _userInputCandidates; _partInputs; + _dateFormat; _cIndices; _lastColumnIndex; + _storageManager; + constructor(element, app) { if (!element) { throw new Error('Exam Correct utility cannot be setup without an element!'); @@ -64,7 +65,9 @@ export class ExamCorrect { this._element = element; this._app = app; - this._storageManager = new StorageManager('EXAM_CORRECT', '0.0.0', { location: LOCATION.SESSION, encryption: { all: { tag: 'exam-correct', exam: this._element.getAttribute('uw-exam-correct') } } }); + // TODO work in progress + // this._storageManager = new StorageManager('EXAM_CORRECT', '0.0.0', { location: LOCATION.SESSION, encryption: { all: { tag: 'exam-correct', exam: this._element.getAttribute('uw-exam-correct') } } }); + this._storageManager = new StorageManager('EXAM_CORRECT', '0.0.0', { location: LOCATION.WINDOW }); this._sendBtn = document.getElementById(EXAM_CORRECT_SEND_BTN_ID); this._userInput = document.getElementById(EXAM_CORRECT_USER_INPUT_ID); @@ -72,9 +75,6 @@ export class ExamCorrect { this._userInputCandidates = document.getElementById(EXAM_CORRECT_USER_INPUT_CANDIDATES_ID); this._partInputs = [...this._element.querySelectorAll(`input[${EXAM_CORRECT_PART_INPUT_ATTR}]`)]; - // TODO get date format by post request - this._dateFormat = 'YYYY-MM-DD HH:mm:ss'; - if (this._sendBtn) this._sendBtn.addEventListener('click', this._sendCorrectionHandler.bind(this)); else console.error('ExamCorrect utility could not detect send button!'); @@ -91,6 +91,9 @@ export class ExamCorrect { throw new Error('ExamCorrect utility could not detect user input candidate list!'); } + // TODO get date format by post request + this._dateFormat = 'YYYY-MM-DD HH:mm:ss'; + this._cIndices = new Map( [...this._element.querySelectorAll('[uw-exam-correct-header]')] .map((header) => [header.getAttribute('uw-exam-correct-header'), header.cellIndex]) @@ -98,12 +101,12 @@ export class ExamCorrect { this._lastColumnIndex = this._element.querySelector('thead > tr').querySelectorAll('th').length - 1; - // show previously submitted results - const previousEntries = this._storageManager.load('entries'); + // TODO show previously submitted results + /* const previousEntries = this._storageManager.load('entries'); if (previousEntries && previousEntries.length > 0) { // TODO sort previous results by current sorting order first previousEntries.forEach((entry) => this._addRow(entry)); - } + } */ } destroy() {