@@ -102,6 +102,8 @@ function enterVisualizeMode() {
102102function enterGradingMode ( ) {
103103 appMode = 'grade' ;
104104
105+ $ ( "#gradeMatrix #gradeMatrixTbody" ) . empty ( ) ; // clear it!!!
106+
105107 $ ( "#pyInputPane" ) . hide ( ) ;
106108 $ ( "#pyOutputPane" ) . hide ( ) ;
107109 $ ( "#pyGradingPane" ) . show ( ) ;
@@ -128,19 +130,26 @@ function genTestResultHandler(idx) {
128130
129131 readyToGradeSubmission ( ) ;
130132 }
133+
131134 return ret ;
132135}
133136
134137function genDebugLinkHandler ( failingTestIndex ) {
135138 function ret ( ) {
136- console . log ( 'DEBUG' , failingTestIndex ) ;
137-
138- // TODO: switch back to visualize mode, populating the "test" input
139+ // Switch back to visualize mode, populating the "test" input
139140 // field with the failing test case, and RE-RUN the back-end to
140141 // visualize execution (with proper IDs)
141142
143+ curTestIndex = failingTestIndex ;
144+ $ ( "#testCodeInput" ) . val ( tests [ curTestIndex ] ) ;
145+
146+ $ ( this ) . html ( "One sec ..." ) ; // this is the current LINK element
147+
148+ $ ( "#executeBtn" ) . trigger ( 'click' ) ; // emulate an execute button press!
149+
142150 return false ; // don't reload the page
143151 }
152+
144153 return ret ;
145154}
146155
@@ -229,12 +238,14 @@ function finishQuestionsInit(questionsDat) {
229238// have been populated by their respective AJAX POST calls
230239function readyToGradeSubmission ( ) {
231240 enterGradingMode ( ) ;
232- $ ( "#submittedCodeRO" ) . val ( $ ( "#actualCodeInput" ) . val ( ) ) ;
241+
242+ $ ( "#submittedCodePRE" ) . html ( htmlspecialchars ( $ ( "#actualCodeInput" ) . val ( ) ) ) ;
243+ //$("#submittedCodeRO").val($("#actualCodeInput").val());
233244
234245 for ( var i = 0 ; i < tests . length ; i ++ ) {
235246 var res = testResults [ i ] ;
236247
237- $ ( "#gradeMatrix tbody. gradeMatrixTbody" ) . append ( '<tr class="gradeMatrixRow"></tr>' ) ;
248+ $ ( "#gradeMatrix tbody# gradeMatrixTbody" ) . append ( '<tr class="gradeMatrixRow"></tr>' ) ;
238249
239250 $ ( "#gradeMatrix tr.gradeMatrixRow:last" ) . append ( '<td class="testInputCell"></td>' ) ;
240251
@@ -258,7 +269,7 @@ function readyToGradeSubmission() {
258269 }
259270
260271 if ( res . status == 'error' ) {
261- $ ( "#gradeMatrix tr.gradeMatrixRow:last" ) . append ( '<td class="testOutputCell">' + res . error_msg + '</td>' ) ;
272+ $ ( "#gradeMatrix tr.gradeMatrixRow:last" ) . append ( '<td class="testOutputCell"><span style="padding: 5px; background-color: ' + errorColor + ';">' + res . error_msg + '</span> </td>' ) ;
262273 }
263274 else {
264275 assert ( res . status == 'ok' ) ;
@@ -302,11 +313,11 @@ function readyToGradeSubmission() {
302313 }
303314
304315 if ( numPassed < tests . length ) {
305- $ ( "#gradeSummary" ) . html ( 'Your solution passed ' + numPassed + '/ ' + tests . length + ' tests. Try to debug the incorrect outputs !' ) ;
316+ $ ( "#gradeSummary" ) . html ( 'Your submitted answer passed ' + numPassed + ' out of ' + tests . length + ' tests. Try to debug the failed tests !' ) ;
306317 }
307318 else {
308319 assert ( numPassed == tests . length ) ;
309- $ ( "#gradeSummary" ) . html ( 'Congrats, your solution passed all ' + tests . length + ' tests!' ) ;
320+ $ ( "#gradeSummary" ) . html ( 'Congrats, your submitted answer passed all ' + tests . length + ' tests!' ) ;
310321 }
311322
312323}
0 commit comments