feat(exam-correct): display backend error messages
This commit is contained in:
parent
8e41820c9d
commit
6fc0262d2d
@ -23,6 +23,7 @@ const EXAM_CORRECT_USER_INPUT_CANDIDATES_ID = 'exam-correct__user-candidates';
|
|||||||
const EXAM_CORRECT_INPUT_BODY_ID = 'exam-correct__new';
|
const EXAM_CORRECT_INPUT_BODY_ID = 'exam-correct__new';
|
||||||
const EXAM_CORRECT_USER_ATTR = 'exam-correct--user-id';
|
const EXAM_CORRECT_USER_ATTR = 'exam-correct--user-id';
|
||||||
const EXAM_CORRECT_USER_DNAME_ATTR = 'exam-correct--user-dname';
|
const EXAM_CORRECT_USER_DNAME_ATTR = 'exam-correct--user-dname';
|
||||||
|
const EXAM_CORRECT_STATUS_CELL_CLASS = 'exam-correct--status-cell';
|
||||||
|
|
||||||
const STATUS = {
|
const STATUS = {
|
||||||
NONE: null,
|
NONE: null,
|
||||||
@ -279,6 +280,7 @@ export class ExamCorrect {
|
|||||||
users: null,
|
users: null,
|
||||||
results: null,
|
results: null,
|
||||||
status: STATUS.FAILURE,
|
status: STATUS.FAILURE,
|
||||||
|
message: null,
|
||||||
date: null,
|
date: null,
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -314,11 +316,13 @@ export class ExamCorrect {
|
|||||||
newEntry.users = response.users;
|
newEntry.users = response.users;
|
||||||
newEntry.results = results;
|
newEntry.results = results;
|
||||||
}
|
}
|
||||||
|
newEntry.message = response.message || null;
|
||||||
break;
|
break;
|
||||||
case 'failure':
|
case 'failure':
|
||||||
status = STATUS.FAILURE;
|
status = STATUS.FAILURE;
|
||||||
newEntry.users = [user];
|
newEntry.users = [user];
|
||||||
newEntry.results = results;
|
newEntry.results = results;
|
||||||
|
newEntry.message = response.message || null;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
// TODO show tooltip with 'invalid response'
|
// TODO show tooltip with 'invalid response'
|
||||||
@ -330,6 +334,10 @@ export class ExamCorrect {
|
|||||||
});
|
});
|
||||||
newEntry.status = status || STATUS.FAILURE;
|
newEntry.status = status || STATUS.FAILURE;
|
||||||
newEntry.date = response.time || moment().utc().format();
|
newEntry.date = response.time || moment().utc().format();
|
||||||
|
if (newEntry.message) {
|
||||||
|
const messageElem = document.createTextNode(newEntry.message);
|
||||||
|
row.querySelector(`.${EXAM_CORRECT_STATUS_CELL_CLASS}`).appendChild(messageElem);
|
||||||
|
}
|
||||||
savedEntries.push(newEntry);
|
savedEntries.push(newEntry);
|
||||||
this._storageManager.save('entries', savedEntries);
|
this._storageManager.save('entries', savedEntries);
|
||||||
return;
|
return;
|
||||||
@ -468,9 +476,10 @@ export class ExamCorrect {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const statusCell = document.createElement('TD');
|
const statusCell = document.createElement('TD');
|
||||||
const statusDiv = document.createElement('DIV');
|
statusCell.classList.add(EXAM_CORRECT_STATUS_CELL_CLASS);
|
||||||
setStatus(statusDiv, rowInfo.status);
|
const statusSymbol = document.createElement('I');
|
||||||
statusCell.appendChild(statusDiv);
|
setStatus(statusSymbol, rowInfo.status);
|
||||||
|
statusCell.appendChild(statusSymbol);
|
||||||
cells.set(this._cIndices.get('status'), statusCell);
|
cells.set(this._cIndices.get('status'), statusCell);
|
||||||
|
|
||||||
for (let i = 0; i <= this._lastColumnIndex; i++) {
|
for (let i = 0; i <= this._lastColumnIndex; i++) {
|
||||||
|
|||||||
@ -34,6 +34,17 @@ table[uw-exam-correct]
|
|||||||
width: max-content
|
width: max-content
|
||||||
min-width: max-content
|
min-width: max-content
|
||||||
|
|
||||||
|
td.exam-correct--status-cell
|
||||||
|
font-size: .9rem
|
||||||
|
font-weight: 600
|
||||||
|
color: var(--color-fontsec)
|
||||||
|
font-style: italic
|
||||||
|
|
||||||
|
.fas
|
||||||
|
font-size: 1rem
|
||||||
|
text-align: center
|
||||||
|
padding-right: .25rem
|
||||||
|
|
||||||
|
|
||||||
[uw-exam-correct] input:invalid:not(.no-value)
|
[uw-exam-correct] input:invalid:not(.no-value)
|
||||||
border: 2px solid var(--color-error)
|
border: 2px solid var(--color-error)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user