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_USER_ATTR = 'exam-correct--user-id';
|
||||
const EXAM_CORRECT_USER_DNAME_ATTR = 'exam-correct--user-dname';
|
||||
const EXAM_CORRECT_STATUS_CELL_CLASS = 'exam-correct--status-cell';
|
||||
|
||||
const STATUS = {
|
||||
NONE: null,
|
||||
@ -279,6 +280,7 @@ export class ExamCorrect {
|
||||
users: null,
|
||||
results: null,
|
||||
status: STATUS.FAILURE,
|
||||
message: null,
|
||||
date: null,
|
||||
};
|
||||
|
||||
@ -314,11 +316,13 @@ export class ExamCorrect {
|
||||
newEntry.users = response.users;
|
||||
newEntry.results = results;
|
||||
}
|
||||
newEntry.message = response.message || null;
|
||||
break;
|
||||
case 'failure':
|
||||
status = STATUS.FAILURE;
|
||||
newEntry.users = [user];
|
||||
newEntry.results = results;
|
||||
newEntry.message = response.message || null;
|
||||
break;
|
||||
default:
|
||||
// TODO show tooltip with 'invalid response'
|
||||
@ -330,6 +334,10 @@ export class ExamCorrect {
|
||||
});
|
||||
newEntry.status = status || STATUS.FAILURE;
|
||||
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);
|
||||
this._storageManager.save('entries', savedEntries);
|
||||
return;
|
||||
@ -468,9 +476,10 @@ export class ExamCorrect {
|
||||
}
|
||||
|
||||
const statusCell = document.createElement('TD');
|
||||
const statusDiv = document.createElement('DIV');
|
||||
setStatus(statusDiv, rowInfo.status);
|
||||
statusCell.appendChild(statusDiv);
|
||||
statusCell.classList.add(EXAM_CORRECT_STATUS_CELL_CLASS);
|
||||
const statusSymbol = document.createElement('I');
|
||||
setStatus(statusSymbol, rowInfo.status);
|
||||
statusCell.appendChild(statusSymbol);
|
||||
cells.set(this._cIndices.get('status'), statusCell);
|
||||
|
||||
for (let i = 0; i <= this._lastColumnIndex; i++) {
|
||||
|
||||
@ -34,6 +34,17 @@ table[uw-exam-correct]
|
||||
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)
|
||||
border: 2px solid var(--color-error)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user