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 {
|
||||
|
||||
_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() {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user