Add python adapter error messages to score output

This commit is contained in:
Maximilian Grundke
2016-03-09 18:01:30 +01:00
parent 26d2b11d9f
commit 99ee7337ed
5 changed files with 8 additions and 2 deletions

View File

@ -703,7 +703,8 @@ $(function() {
panel.find('.row .col-sm-9').eq(1).find('.number').eq(0).text((result.score * result.weight).toFixed(2));
panel.find('.row .col-sm-9').eq(1).find('.number').eq(1).text(result.weight);
panel.find('.row .col-sm-9').eq(2).text(result.message);
panel.find('.row .col-sm-9').eq(3).find('a').attr('href', '#output-' + index);
panel.find('.row .col-sm-9').eq(3).text(result.error_messages.join(', '));
panel.find('.row .col-sm-9').eq(4).find('a').attr('href', '#output-' + index);
};
var chunkBuffer = [{streamedResponse: true}];

View File

@ -66,6 +66,7 @@
= row(label: '.passed_tests', value: t('shared.out_of', maximum_value: 0, value: 0).html_safe)
= row(label: 'activerecord.attributes.submission.score', value: t('shared.out_of', maximum_value: 0, value: 0).html_safe)
= row(label: '.feedback')
= row(label: '.error_messages')
= row(label: '.output', value: link_to(t('shared.show'), '#'))
#score data-maximum-score=@exercise.maximum_score data-score=@submission.try(:score)
h4

View File

@ -222,6 +222,7 @@ de:
text: 'Ihr Browser unterstützt nicht alle Funktionalitäten, die %{application_name} benötigt. Bitte nutzen Sie einen modernen Browser, um %{application_name} zu besuchen.'
title: Ihr Browser wird nicht unterstützt!
default_feedback: Sehr gut. Alle Tests waren erfolgreich.
error_messages: Fehlermeldungen
feedback: Feedback
file: 'Test-Datei <span class="number">%{number}</span> (<span class="filename">%{filename}</span>)'
hint: Tipp

View File

@ -222,6 +222,7 @@ en:
text: 'Your browser does not support features required for using %{application_name}. Please access %{application_name} using a modern browser.'
title: Your browser is not supported!
default_feedback: Well done. All tests have been passed.
error_messages: Error Messages
feedback: Feedback
file: 'Test File <span class="number">%{number}</span> (<span class="filename">%{filename}</span>)'
hint: Hint

View File

@ -1,6 +1,7 @@
class PyUnitAdapter < TestingFrameworkAdapter
COUNT_REGEXP = /Ran (\d+) test/
FAILURES_REGEXP = /FAILED \(failures=(\d+)\)/
ASSERTION_ERROR_REGEXP = /AssertionError:\s(.*)/
def self.framework_name
'PyUnit'
@ -10,6 +11,7 @@ class PyUnitAdapter < TestingFrameworkAdapter
count = COUNT_REGEXP.match(output[:stderr]).captures.first.to_i
matches = FAILURES_REGEXP.match(output[:stderr])
failed = matches ? matches.captures.try(:first).to_i : 0
{count: count, failed: failed}
error_matches = ASSERTION_ERROR_REGEXP.match(output[:stderr]).captures
{count: count, failed: failed, error_messages: error_matches}
end
end