44
55angular . module ( 'app' ) . controller ( 'trainingCtrl' , function ( $scope , $state , mainService ) {
66
7- var textarea = document . getElementById ( 'solution-input' ) ;
8- var myCodeMirror = CodeMirror . fromTextArea ( textarea , {
9- lineNumbers : true ,
7+ var textarea1 = document . getElementById ( 'solution-input' ) ;
8+ var solutionsCode = CodeMirror . fromTextArea ( textarea1 , {
9+ lineNumbers : true ,
1010 theme : 'seti' ,
1111 } ) ;
1212
13- var textarea = document . getElementById ( 'example-input' ) ;
14- var myCodeMirror = CodeMirror . fromTextArea ( textarea , {
15- lineNumbers : true ,
13+ var textarea2 = document . getElementById ( 'example-input' ) ;
14+ var examplesCode = CodeMirror . fromTextArea ( textarea2 , {
15+ lineNumbers : true ,
1616 theme : 'seti' ,
1717 } ) ;
1818
@@ -30,18 +30,21 @@ var textarea = document.getElementById('solution-input');
3030 $scope . showInstructions = function ( ) {
3131 $scope . showOutputShow = true ;
3232 $scope . showInstructionsShow = false ;
33- }
33+ } //comment
3434
3535 //Examples should be an array of objects. Returned results will be an array with the different tests and their results.
36- $scope . testExamples = function ( solutions , examples ) {
36+ $scope . testExamples = function ( ) {
37+ let solutions = solutionsCode . getValue ( ) ;
38+ let examples = examplesCode . getValue ( ) ;
3739 $scope . showOutput ( ) ;
3840 solutions = solutions . replace ( / \n / g, " " ) ;
41+ solutions = solutions . replace ( / \s + / g, " " ) ;
3942 let examplesArr = [ ] ;
40- console . log ( examples ) ;
43+ console . log ( "solutions: " , solutions , " examples: " , examples ) ;
4144 examples = examples . split ( / \n / ) ;
4245 console . log ( examples ) ;
43- examples . forEach ( example => examplesArr . push ( { test : example } ) ) ;
44- mainService . testExamples ( solutions , examplesArr ) . then ( ( response ) => $scope . output . push ( response . data [ 0 ] ) ) ;
46+ // examples.forEach(example => examplesArr.push({test: example}));
47+ // mainService.testExamples(solutions, examplesArr).then((response) => $scope.output.push(response.data[0]));
4548 }
4649
4750
0 commit comments