@@ -9,6 +9,7 @@ export default class BlockFeedback extends HParsonsFeedback {
99 this . messageDiv = document . createElement ( "div" ) ;
1010 this . hparsons . outerDiv . appendChild ( this . messageDiv ) ;
1111 }
12+
1213 customizeUI ( ) {
1314 this . hparsons . runButton . textContent = "Check Me" ;
1415 }
@@ -18,12 +19,9 @@ export default class BlockFeedback extends HParsonsFeedback {
1819 this . solved = false ;
1920 // TODO: not sure what is the best way to do this
2021 this . grader = new BlockBasedGrader ( ) ;
21- let solutionBlocks = [ ] ;
22- for ( let i = 0 ; i < this . hparsons . blockAnswer . length ; ++ i ) {
23- solutionBlocks . push ( this . hparsons . originalBlocks [ this . hparsons . blockAnswer [ i ] ] ) ;
24- }
25- this . solution = solutionBlocks ;
26- this . grader . solution = solutionBlocks ;
22+ const solutionIndices = this . hparsons . blockAnswer . map ( Number ) ;
23+ this . solution = solutionIndices ;
24+ this . grader . solution = solutionIndices ;
2725 this . answerArea = this . hparsons . hparsonsInput . querySelector ( '.drop-area' ) ;
2826 }
2927
@@ -38,7 +36,7 @@ export default class BlockFeedback extends HParsonsFeedback {
3836 let act = {
3937 scheme : "block" ,
4038 correct : this . grader . graderState == 'correct' ? "T" : "F" ,
41- answer : this . hparsons . hparsonsInput . getParsonsTextArray ( ) ,
39+ answer : this . hparsons . hparsonsInput . getBlockIndices ( ) ,
4240 percent : this . grader . percent
4341 }
4442 let logData = {
@@ -57,7 +55,7 @@ export default class BlockFeedback extends HParsonsFeedback {
5755 if ( ! this . solved ) {
5856 this . checkCount ++ ;
5957 this . clearFeedback ( ) ;
60- this . grader . answer = this . hparsons . hparsonsInput . getParsonsTextArray ( ) ;
58+ this . grader . answer = this . hparsons . hparsonsInput . getBlockIndices ( ) ;
6159 this . grade = this . grader . grade ( ) ;
6260 if ( this . grade == "correct" ) {
6361 this . hparsons . runButton . disabled = true ;
@@ -100,7 +98,7 @@ export default class BlockFeedback extends HParsonsFeedback {
10098 var notInSolution = [ ] ;
10199 for ( let i = 0 ; i < answerBlocks . length ; i ++ ) {
102100 var block = answerBlocks [ i ] ;
103- var index = this . solution . indexOf ( block . textContent ) ;
101+ var index = this . solution . indexOf ( Number ( block . dataset . index ) ) ;
104102 if ( index == - 1 ) {
105103 notInSolution . push ( block ) ;
106104 } else {
0 commit comments