@@ -75,20 +75,10 @@ export default class LineBasedGrader {
7575 let isCorrectOrder = this . checkCorrectOrdering ( solutionLines , answerLines )
7676
7777 // Determine whether blocks are indented correctly
78- this . indentLeft = [ ] ;
79- this . indentRight = [ ] ;
80- let loopLimit = Math . min ( solutionLines . length , answerLines . length ) ;
81- for ( i = 0 ; i < loopLimit ; i ++ ) {
82- if ( answerLines [ i ] . viewIndent ( ) < solutionLines [ i ] . indent ) {
83- this . indentRight . push ( answerLines [ i ] ) ;
84- } else if ( answerLines [ i ] . viewIndent ( ) > solutionLines [ i ] . indent ) {
85- this . indentLeft . push ( answerLines [ i ] ) ;
86- }
87- }
88- this . incorrectIndents =
89- this . indentLeft . length + this . indentRight . length ;
78+ let isCorrectIndents = this . checkCorrectIndentation ( solutionLines , answerLines ) ;
79+
9080 if (
91- this . incorrectIndents == 0 &&
81+ isCorrectIndents &&
9282 isCorrectOrder &&
9383 this . correctLength
9484 ) {
@@ -105,6 +95,23 @@ export default class LineBasedGrader {
10595 return state ;
10696 }
10797
98+ checkCorrectIndentation ( solutionLines , answerLines ) {
99+ this . indentLeft = [ ] ;
100+ this . indentRight = [ ] ;
101+ let loopLimit = Math . min ( solutionLines . length , answerLines . length ) ;
102+ for ( let i = 0 ; i < loopLimit ; i ++ ) {
103+ if ( answerLines [ i ] . viewIndent ( ) < answerLines [ i ] . indent ) {
104+ this . indentRight . push ( answerLines [ i ] ) ;
105+ } else if ( answerLines [ i ] . viewIndent ( ) > solutionLines [ i ] . indent ) {
106+ this . indentLeft . push ( answerLines [ i ] ) ;
107+ }
108+ }
109+ this . incorrectIndents =
110+ this . indentLeft . length + this . indentRight . length ;
111+
112+ return this . incorrectIndents == 0 ;
113+ }
114+
108115 checkCorrectOrdering ( solutionLines , answerLines ) {
109116 let isCorrectOrder = true ;
110117 this . correctLines = 0 ;
0 commit comments