Skip to content

Commit f63b089

Browse files
author
Philip Guo
committed
tweaks
1 parent 53cf945 commit f63b089

4 files changed

Lines changed: 10 additions & 6 deletions

File tree

edu-python-questions.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -150,8 +150,8 @@ $(document).ready(function() {
150150

151151
// concatenate solution code and test code:
152152
function concatSolnTestCode(solnCode, testCode) {
153-
var filler = (solnCode[solnCode.length - 1] != '\n') ? '\n' : '';
154-
return solnCode + filler + "\n# Everything below here is test code\n" + testCode;
153+
// use rtrim to get rid of trailing whitespace and newlines
154+
return solnCode.rtrim() + "\n\n# Everything below here is test code\n" + testCode;
155155
}
156156

157157

@@ -252,7 +252,9 @@ function finishQuestionsInit(questionsDat) {
252252
var numChangedLines = 0;
253253

254254
// split on newlines to do a line-level diff
255-
var diffResults = diff($("#actualCodeInput").val().split(/\n/), questionsDat.skeleton.split(/\n/));
255+
// (rtrim both strings to discount the effect of trailing
256+
// whitespace and newlines)
257+
var diffResults = diff($("#actualCodeInput").val().rtrim().split(/\n/), questionsDat.skeleton.rtrim().split(/\n/));
256258
//console.log(diffResults);
257259
$.each(diffResults, function(i, e) {
258260
if (e.file1 && e.file2) {

edu-python.css

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,7 @@ table#pyCodeOutput .cod {
175175
div#editCodeLinkDiv {
176176
text-align: center;
177177
margin-top: 8px;
178+
margin-bottom: 4px;
178179
}
179180

180181
#editCodeLinkOnError {
@@ -205,7 +206,7 @@ button.medBtn {
205206

206207
#vcrControls {
207208
margin-top: 10px;
208-
margin-bottom: 20px;
209+
margin-bottom: 15px;
209210
}
210211

211212
#vcrControls button {

questions/buggy-mergesort.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ Debug: Mergesort
33

44
Question:
55

6-
Add at most TWO LINES of code to make the given mergesort function work
6+
Add at most TWO lines of code to make the given mergesort function work
77
properly.
88

99
Hint:

questions/inplace-reverse.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@ Debug: In-place reverse
44
Question:
55

66
The given function reverses a list in-place, but it doesn't work for all
7-
test inputs. Change only ONE line to make this function pass all tests.
7+
test inputs. Change only ONE line of code to make this function pass
8+
all tests.
89

910
MaxLineDelta: 1
1011

0 commit comments

Comments
 (0)