refactor(exam-correct): minor refactor; no persistent entries for now
This commit is contained in:
parent
fc9bd55202
commit
b6790163c0
@ -38,10 +38,8 @@ const STATUS = {
|
|||||||
})
|
})
|
||||||
export class ExamCorrect {
|
export class ExamCorrect {
|
||||||
|
|
||||||
_storageManager;
|
|
||||||
_dateFormat;
|
|
||||||
|
|
||||||
_element;
|
_element;
|
||||||
|
_app;
|
||||||
|
|
||||||
_sendBtn;
|
_sendBtn;
|
||||||
_userInput;
|
_userInput;
|
||||||
@ -49,9 +47,12 @@ export class ExamCorrect {
|
|||||||
_userInputCandidates;
|
_userInputCandidates;
|
||||||
_partInputs;
|
_partInputs;
|
||||||
|
|
||||||
|
_dateFormat;
|
||||||
_cIndices;
|
_cIndices;
|
||||||
_lastColumnIndex;
|
_lastColumnIndex;
|
||||||
|
|
||||||
|
_storageManager;
|
||||||
|
|
||||||
constructor(element, app) {
|
constructor(element, app) {
|
||||||
if (!element) {
|
if (!element) {
|
||||||
throw new Error('Exam Correct utility cannot be setup without an element!');
|
throw new Error('Exam Correct utility cannot be setup without an element!');
|
||||||
@ -64,7 +65,9 @@ export class ExamCorrect {
|
|||||||
this._element = element;
|
this._element = element;
|
||||||
this._app = app;
|
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._sendBtn = document.getElementById(EXAM_CORRECT_SEND_BTN_ID);
|
||||||
this._userInput = document.getElementById(EXAM_CORRECT_USER_INPUT_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._userInputCandidates = document.getElementById(EXAM_CORRECT_USER_INPUT_CANDIDATES_ID);
|
||||||
this._partInputs = [...this._element.querySelectorAll(`input[${EXAM_CORRECT_PART_INPUT_ATTR}]`)];
|
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)
|
if (this._sendBtn)
|
||||||
this._sendBtn.addEventListener('click', this._sendCorrectionHandler.bind(this));
|
this._sendBtn.addEventListener('click', this._sendCorrectionHandler.bind(this));
|
||||||
else console.error('ExamCorrect utility could not detect send button!');
|
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!');
|
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._cIndices = new Map(
|
||||||
[...this._element.querySelectorAll('[uw-exam-correct-header]')]
|
[...this._element.querySelectorAll('[uw-exam-correct-header]')]
|
||||||
.map((header) => [header.getAttribute('uw-exam-correct-header'), header.cellIndex])
|
.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;
|
this._lastColumnIndex = this._element.querySelector('thead > tr').querySelectorAll('th').length - 1;
|
||||||
|
|
||||||
// show previously submitted results
|
// TODO show previously submitted results
|
||||||
const previousEntries = this._storageManager.load('entries');
|
/* const previousEntries = this._storageManager.load('entries');
|
||||||
if (previousEntries && previousEntries.length > 0) {
|
if (previousEntries && previousEntries.length > 0) {
|
||||||
// TODO sort previous results by current sorting order first
|
// TODO sort previous results by current sorting order first
|
||||||
previousEntries.forEach((entry) => this._addRow(entry));
|
previousEntries.forEach((entry) => this._addRow(entry));
|
||||||
}
|
} */
|
||||||
}
|
}
|
||||||
|
|
||||||
destroy() {
|
destroy() {
|
||||||
|
|||||||
Reference in New Issue
Block a user