Skip to content

Commit fe03277

Browse files
author
Philip Guo
committed
don't let people submit code with exceptions
1 parent 4b8e96d commit fe03277

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

edu-python-questions.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,25 @@ function finishQuestionsInit(questionsDat) {
203203
// do this AFTER making #pyOutputPane visible, or else
204204
// jsPlumb connectors won't render properly
205205
processTrace(traceData, true);
206+
207+
// don't let the user submit answer when there's an error
208+
var hasError = false;
209+
for (var i = 0; i < curTrace.length; i++) {
210+
var curEntry = curTrace[i];
211+
if (curEntry.event == 'exception' ||
212+
curEntry.event == 'uncaught_exception') {
213+
hasError = true;
214+
break;
215+
}
216+
}
217+
218+
if (hasError) {
219+
$('#submitBtn').attr('disabled', true);
220+
}
221+
else {
222+
$('#submitBtn').attr('disabled', false);
223+
}
224+
206225
},
207226
"json");
208227
});

0 commit comments

Comments
 (0)