Add new style for linter and allow 0 points

This commit is contained in:
Sebastian Serth
2020-10-15 16:22:37 +02:00
parent be3ec82bd4
commit 799e37f9ae
6 changed files with 37 additions and 10 deletions

View File

@ -90,7 +90,9 @@ var CodeOceanEditor = {
},
getCardClass: function (result) {
if (result.stderr && !result.score) {
if (result.file_role === 'teacher_defined_linter') {
return 'card bg-info text-white'
} else if (result.stderr && !result.score) {
return 'card bg-danger text-white';
} else if (result.score < 1) {
return 'card bg-warning text-white';
@ -428,8 +430,13 @@ var CodeOceanEditor = {
card.find('.card-title .number').text(index + 1);
card.find('.row .col-sm-9').eq(0).find('.number').eq(0).text(result.passed);
card.find('.row .col-sm-9').eq(0).find('.number').eq(1).text(result.count);
card.find('.row .col-sm-9').eq(1).find('.number').eq(0).text(parseFloat((result.score * result.weight).toFixed(2)));
card.find('.row .col-sm-9').eq(1).find('.number').eq(1).text(result.weight);
if (result.weight !== 0) {
card.find('.row .col-sm-9').eq(1).find('.number').eq(0).text(parseFloat((result.score * result.weight).toFixed(2)));
card.find('.row .col-sm-9').eq(1).find('.number').eq(1).text(result.weight);
} else {
// Hide score row if no score could be achieved
card.find('.attribute-row.row').eq(1).addClass('d-none');
}
card.find('.row .col-sm-9').eq(2).html(result.message);
// Add error message from code to card

View File

@ -48,7 +48,12 @@ CodeOceanEditorEvaluation = {
printScoringResult: function (result, index) {
$('#results').show();
var card = $('#dummies').children().first().clone();
let card;
if (result.file_role === 'teacher_defined_linter') {
card = $('#linter-dummies').children().first().clone();
} else {
card = $('#test-dummies').children().first().clone();
}
if (card.isPresent()) {
// the card won't be present if @embed_options[:hide_test_results] == true
this.populateCard(card, result, index);
@ -58,7 +63,7 @@ CodeOceanEditorEvaluation = {
printScoringResults: function (response) {
$('#results ul').first().html('');
$('.test-count .number').html(response.length);
$('.test-count .number').html(response.filter(function(x) { return x.file_role === 'teacher_defined_test'; }).length);
this.clearOutput();
_.each(response, function (result, index) {