Skip to content

Commit 8a0991a

Browse files
committed
fixed conflict
2 parents 11218ec + 7b3f91e commit 8a0991a

5 files changed

Lines changed: 40 additions & 14 deletions

File tree

src/components/mainService.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ this.user = {}
5757
this.getKataById = (kataid) => {
5858
return $http({
5959
method: 'GET',
60-
url: `/api/kata/` + kataid
60+
url: `http://192.168.0.186:3030/api/kata/` + kataid
6161
});
6262
};
6363

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11

22
<h2 class="font20-reg">Instructions</h2>
33
<div>
4-
<p>These are the instructions.</p><p>Moreinfor</p>
4+
<p class="font14-reg">{{instructions}}</p>
55
</div>

src/components/training/output.html

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@ <h2 class="font20-reg">Output</h2>
33
<div>
44
<p>This is the goddamn output.</p>
55
<div ng-repeat="test in output">
6-
<p>{{test.test}}</p>
7-
<p>{{test.result}}</p>
6+
<p class="font14-reg">{{test.test}}</p>
7+
<p class="font14-reg">{{test.result}}</p>
8+
<p class="font14-reg">{{time}}</p>
89
</div>
910
</div>

src/components/training/training.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ <h2 class="font20-reg">Name of Kata</h2>
8282
<textarea name="examples" id="example-input" ng-init="examplesInput = 'Test.assertEquals(a, 1);'" id="example-tests-input" ng-model="examplesInput"></textarea>
8383
</form>
8484
<button ng-click="testExamples()" class="test-examples-button font12-reg-blue">RUN EXAMPLES</button>
85-
<button ng-click="testSuite(solutionInput)" class="test-suite-button font12-reg-black" style=""><i class="fa fa-caret-right fa-lg" style="margin-right: 2px" aria-hidden="true"></i>ATTEMPT</button>
85+
<button ng-click="testSuite()" class="test-suite-button font12-reg-black" style=""><i class="fa fa-caret-right fa-lg" style="margin-right: 2px" aria-hidden="true"></i>ATTEMPT</button>
8686
</div>
8787
</div>
8888
</div>

src/components/training/trainingCtrl.js

Lines changed: 34 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
angular.module('app').controller('trainingCtrl', function($scope, $state, mainService) {
66

7+
/** Create text areas **/
78
var textarea1 = document.getElementById('solution-input');
89
var solutionsCode = CodeMirror.fromTextArea(textarea1, {
910
lineNumbers: true,
@@ -30,28 +31,52 @@ angular.module('app').controller('trainingCtrl', function($scope, $state, mainSe
3031
$scope.showInstructions = function() {
3132
$scope.showOutputShow = true;
3233
$scope.showInstructionsShow = false;
33-
}//comment
34+
}
35+
36+
// GET KATA INFORMATION
37+
$scope.getKataById = (kataid) => {
38+
mainService.getKataById(kataid).then((response) => {
39+
console.log(response.data);
40+
$scope.name = response.data.name;
41+
$scope.instructions = response.data.description;
42+
$scope.kyu = response.data.kyu;
43+
$scope.starter = response.data.starter_code;
44+
$scope.examples = response.data.examples.map((example) => {return example.test});
45+
$scope.kataid = response.data.id;
46+
}).then(() =>{
47+
solutionsCode.setValue($scope.starter);
48+
examplesCode.setValue($scope.examples.join(/\n/));
49+
});
50+
}
51+
52+
$scope.getKataById(2);
53+
54+
3455

3556
//Examples should be an array of objects. Returned results will be an array with the different tests and their results.
3657
$scope.testExamples = function() {
37-
let solutions = solutionsCode.getValue();
38-
let examples = examplesCode.getValue();
58+
var solutions = solutionsCode.getValue();
59+
var examples = examplesCode.getValue();
3960
$scope.showOutput();
4061
solutions = solutions.replace(/\n/g, " ");
4162
solutions = solutions.replace(/\s+/g, " ");
42-
let examplesArr = [];
63+
var examplesArr = [];
4364
console.log("solutions: ", solutions, " examples: ", examples);
4465
examples = examples.split(/\n/);
4566
console.log(examples);
46-
// examples.forEach(example => examplesArr.push({test: example}));
47-
// mainService.testExamples(solutions, examplesArr).then((response) => $scope.output.push(response.data[0]));
67+
examples.forEach(example => examplesArr.push({test: example}));
68+
var t0 = performance.now()
69+
mainService.testExamples(solutions, examplesArr).then((response) => $scope.output.push(response.data[0]));
70+
var t1 = performance.now();
71+
$scope.time = "Time: " + Math.round((t1 - t0)*1000) + " ms";
4872
}
4973

50-
51-
$scope.testSuite = function(solutions) {
74+
$scope.testSuite = function() {
75+
var solutions = solutionsCode.getValue();
5276
$scope.showOutput();
5377
solutions = solutions.replace(/\n/g, " ");
54-
// mainService.testSuite(solutions, kataid).then((response) => console.log(response));
78+
solutions = solutions.replace(/\s+/g, " ");
79+
// mainService.testSuite(solutions, $scope.kataid).then((response) => console.log(response));
5580
}
5681

5782
// this function needs to call the kata by id when the user selects train on the home page -getKataById

0 commit comments

Comments
 (0)