Beautify error messages in JavaScript when scoring submissions

This commit is contained in:
Sebastian Serth
2020-03-05 11:04:03 +01:00
parent ca1dd0e7dd
commit f50e26095a

View File

@ -436,14 +436,21 @@ configureEditors: function () {
if (result.error_messages) {
const targetNode = card.find('.row .col-sm-9').eq(3);
let errorMessagesToShow = [];
result.error_messages.forEach(function (item) {
if (item) {
errorMessagesToShow.push(item)
}
})
// one or more errors?
if (result.error_messages.length > 1) {
if (errorMessagesToShow.length > 1) {
// delete all current elements
targetNode.text('');
// create a new list and appand each element
const ul = document.createElement("ul");
ul.setAttribute('class', 'error_messages_list');
result.error_messages.forEach(function (item) {
errorMessagesToShow.forEach(function (item) {
var li = document.createElement("li");
var text = document.createTextNode(item);
li.appendChild(text);
@ -451,7 +458,7 @@ configureEditors: function () {
})
targetNode.append(ul);
} else {
targetNode.text(result.error_messages.join(''));
targetNode.text(errorMessagesToShow.join(''));
}
}
//card.find('.row .col-sm-9').eq(4).find('a').attr('href', '#output-' + index);