Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into basim-setup-django
Browse files Browse the repository at this point in the history
  • Loading branch information
bazadactyl committed Jun 1, 2017
2 parents 5882088 + f5ccd3a commit 4f136b7
Showing 1 changed file with 35 additions and 1 deletion.
36 changes: 35 additions & 1 deletion src/static/js/submit.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,46 @@ $('#code-submit-form').submit(function () {
function handleAjaxSuccess(response) {
console.log("AJAX success!");
console.log(response);

if (response.success) {
document.getElementById('result-text').innerHTML += "Success!";
} else {
document.getElementById('result-text').innerHTML += "Failed.";
}
document.getElementById('result-text').innerHTML += response.details;

var nTestCases = response.testCaseDetails.length;
var passes = 0;
for (var i = 0; i < nTestCases; i++) {
passes += response.testCaseDetails[i].passed ? 1 : 0;
}
document.getElementById('result-text').innerHTML
+= ' Passed ' + passes + '/' + nTestCases + ' test cases.<br><br>';

// Print all the test case details.
for (var i = 0; i < nTestCases; i++) {
testCasePanelTitle = 'Test case ' + (i+1) + '/' + nTestCases
+ ' (' + response.testCaseDetails[i].testCaseType + '): ';
if (response.testCaseDetails[i].passed) {
testCasePanelTitle += 'passed!<br>';
} else {
testCasePanelTitle += 'failed.<br>';
}

processInfoString = 'Return code ' + response.testCaseDetails[i].processInfo.returnCode + ', '
+ 'utime: ' + response.testCaseDetails[i].processInfo.utime + ' s, '
+ 'stime: ' + response.testCaseDetails[i].processInfo.stime + ' s, '
+ 'maxrss: ' + response.testCaseDetails[i].processInfo.maxrss + ' kB.<br>';


document.getElementById('result-text').innerHTML
+= '<div class="panel panel-default">'
+ '<div class="panel-heading" style="font-size: medium;">' + testCasePanelTitle + '</div>'
+ '<div class="panel-body" style="font-family: monospace; font-size: medium;">'
+ processInfoString
+ 'Input:<br>' + response.testCaseDetails[i].inputString + '<br><br>'
+ 'Output:<br>' + response.testCaseDetails[i].outputString
+ '</div></div>';
}
}

function handleAjaxError(response) {
Expand Down

0 comments on commit 4f136b7

Please sign in to comment.