Skip to content

Commit 96b3239

Browse files
author
Philip Guo
committed
bammy
1 parent 7027c8e commit 96b3239

4 files changed

Lines changed: 46 additions & 22 deletions

File tree

edu-python-questions.js

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,8 @@ function enterVisualizeMode() {
102102
function 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

134137
function 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
230239
function 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
}

edu-python.css

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ span {
9191

9292
#pyInputPane {
9393
text-align: center;
94-
margin-bottom: 35px;
94+
margin-bottom: 20px;
9595
}
9696

9797
td#stack_td,
@@ -574,17 +574,11 @@ table#gradeMatrix thead {
574574

575575
table#gradeMatrix td.testInputCell,
576576
table#gradeMatrix td.testOutputCell {
577-
padding-left: 10px;
578-
padding-right: 10px;
577+
padding-right: 25px;
579578
padding-bottom: 8px;
580579
vertical-align: middle;
581580
}
582581

583-
#gradeSummary {
584-
margin-top: 12px;
585-
font-size: 12pt;
586-
}
587-
588582
td.testInputVarnameCell,
589583
td.testOutputVarnameCell {
590584
padding-right: 8px;
@@ -595,3 +589,21 @@ td.testOutputValCell {
595589
padding-right: 5px;
596590
}
597591

592+
pre#submittedCodePRE {
593+
font-size: 10pt;
594+
font-family: Andale mono, monospace;
595+
background-color: #dddddd;
596+
padding: 5px;
597+
}
598+
599+
div#submittedSolutionDisplay {
600+
width: 650px; /* to line up with questionsHeaderPane */
601+
text-align: left;
602+
font-size: 12pt;
603+
margin-bottom: 20px;
604+
}
605+
606+
#gradeSummary {
607+
margin-top: 12px;
608+
}
609+

edu-python.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ var lightGray = "#cccccc";
4343
var darkBlue = "#3D58A2";
4444
var lightBlue = "#899CD1";
4545
var pinkish = "#F15149";
46+
var darkRed = "#9d1e18";
4647

4748

4849
// ugh globals!

question.html

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -139,13 +139,13 @@
139139

140140
<div id="pyGradingPane">
141141

142-
<center>
143142

144-
Your submitted solution:<br/>
145-
<textarea id="submittedCodeRO" cols="60" rows="12" wrap="off" readonly="readonly">
146-
</textarea>
143+
<center>
147144

148-
<div id="gradeSummary"></div>
145+
<div id="submittedSolutionDisplay">
146+
<pre id="submittedCodePRE"></pre>
147+
<div id="gradeSummary"></div>
148+
</div>
149149

150150
<table id="gradeMatrix">
151151
<thead>
@@ -155,7 +155,7 @@
155155
<td>Status</td>
156156
</tr>
157157
</thead>
158-
<tbody class="gradeMatrixTbody">
158+
<tbody id="gradeMatrixTbody">
159159
</tbody>
160160
</table>
161161

0 commit comments

Comments
 (0)