Skip to content

Commit d21974a

Browse files
author
Jon Myrick
authored
Merge pull request CodewarsClone#26 from CodewarsClone/training
Training
2 parents 51c6ab6 + 107b79c commit d21974a

8 files changed

Lines changed: 77 additions & 12 deletions

File tree

src/assets/scss/styles.scss

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,14 @@ main {
9898
font-weight: 400;
9999
}
100100

101+
.font12-reg-black {
102+
color: #131414;
103+
font-family: $font;
104+
font-size: 12px;
105+
line-height: 12px;
106+
font-weight: 400;
107+
}
108+
101109
.side-menu {
102110
background-color: $sidebar-color;
103111
height: 100vh;
@@ -171,4 +179,4 @@ padding: 75px 75px 10px 75px;
171179

172180
a {
173181
text-decoration: none;
174-
}
182+
}

src/components/mainService.js

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,21 @@ angular.module('app').service('mainService', function($http, $q, $sce) {
22

33
// $sce.trustAsResourceUrl('/s');
44

5-
this.getTest = function(solution, examples) {
5+
this.testExamples = function(solution, examples) {
66
return $http({
77
method: 'POST',
8-
url: '/solution',
8+
url: `http://192.168.0.186:3030/test/examples`,
9+
data: {
10+
script: solution,
11+
examples: examples
12+
}
13+
});
14+
};
15+
16+
this.testSuite = function(solution, kataid) {
17+
return $http({
18+
method: 'POST',
19+
url: `/test/suite/${kataid}`,
920
data: {
1021
script: solution
1122
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
2+
<div class="instructions-head">
3+
<button class="instructions-selector font13-reg-gray">Instructions</button>
4+
<button class="instructions-selector font13-reg-gray">Output</button>
5+
</div>
6+
<hr>
7+
<h2 class="font20-reg">Output</h2>
8+
<div>
9+
<p>This is the goddamn output.</p>
10+
<div ng-repeat="test in output">
11+
<p>{{test.test}}</p>
12+
<p>{{test.result}}</p>
13+
</div>
14+
</div>
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
angular.module('app').directive('showOutput', function() {
2+
return {
3+
templateUrl: './output.html',
4+
}
5+
});

src/components/training/training.html

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ <h3 class="font16-reg" id="kata-name">
4040

4141
<div class="kata">
4242

43-
<div class="instructions">
43+
<!-- <div class="instructions">
4444
<div class="instructions-head">
4545
<button class="instructions-selector font13-reg-gray">Instructions</button>
4646
<button class="instructions-selector font13-reg-gray">Output</button>
@@ -49,23 +49,31 @@ <h3 class="font16-reg" id="kata-name">
4949
<h2 class="font20-reg">Name of Kata</h2>
5050
<div>
5151
<p>Here's where the instructions go. We have to think about how to present code samples.</p>
52+
<div ng-repeat="test in output">
53+
<p>{{test.test}}</p>
54+
<p>{{test.result}}</p>
55+
</div>
5256
</div>
57+
</div> -->
58+
59+
<div class="instructions" showOutput>
5360
</div>
5461

5562
<div class="kata-right">
5663

5764
<div class="solution-div">
5865
<p>Solution:</p>
5966
<form>
60-
Function: <textarea name="solution" cols="40" rows="5" id="solution-input" ng-model="solutionInput"></textarea>
67+
Function: <textarea name="solution" cols="40" rows="5" id="solution-input" ng-init="solutionInput = 'var a = 1;'"ng-model="solutionInput"></textarea>
6168
</form>
6269
</div>
6370

6471
<div class="example-tests-div">
6572
<p>Example Tests:</p>
6673
<form>
67-
<textarea name="examples" cols="40" rows="5" id="example-tests-input" ng-model="examplesInput"></textarea>
68-
<button ng-click="sendSolution(solutionInput, examplesInput)" class="run-examples-button font12-reg-blue">RUN EXAMPLES</button>
74+
<textarea name="examples" cols="40" rows="5" ng-init="examplesInput = 'Test.assertEquals(a, 1);'" id="example-tests-input" ng-model="examplesInput"></textarea>
75+
<button ng-click="testExamples(solutionInput, examplesInput)" class="test-examples-button font12-reg-blue">RUN EXAMPLES</button>
76+
<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>
6977
</form>
7078
</div>
7179

src/components/training/training.scss

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,14 +96,22 @@ hr {
9696
width: 40vw;
9797
}
9898

99-
.run-examples-button {
99+
.test-examples-button {
100100
border: 1px solid #91b2e7;
101101
border-radius: 4%;
102102
width: 113px;
103103
height: 30px;
104104
background-color: #3C3C3C;
105105
}
106106

107+
.test-suite-button {
108+
border: 1px solid #91b2e7;
109+
border-radius: 4%;
110+
width: 113px;
111+
height: 30px;
112+
background-color: #91b2e7;
113+
}
114+
107115
.training-body {
108116
background-color: red;
109117
}

src/components/training/trainingCtrl.js

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,22 @@ angular.module('app').controller('trainingCtrl', function($scope, $state, mainSe
44

55
$scope.languages = ['JavaScript', 'Python'];
66
$scope.versions = ['Node v0.10.33', 'Node v6.6.0'];
7+
$scope.output = [];
78

8-
$scope.sendSolution = function(solutions, examples) {
9+
10+
//Examples should be an array of objects. Returned results will be an array with the different tests and their results.
11+
$scope.testExamples = function(solutions, examples) {
12+
solutions = solutions.replace(/\n/g, " ");
13+
let examplesArr = [];
14+
examples = examples.split(/\n/);
15+
examples.forEach(example => examplesArr.push({test: example}));
16+
mainService.testExamples(solutions, examplesArr).then((response) => $scope.output.push(response.data[0]));
17+
}
18+
19+
20+
$scope.testSuite = function(solutions) {
921
solutions = solutions.replace(/\n/g, " ");
10-
examples = examples.replace(/\n/g, " ");
11-
console.log(solutions, examples);
12-
// mainService.getTest(solutionsInput, examples).then((response) => console.log(response));
22+
// mainService.testSuite(solutions, kataid).then((response) => console.log(response));
1323
}
1424

1525

src/index.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
</body>
2424
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.5.6/angular.min.js"></script>
2525
<script src="https://cdnjs.cloudflare.com/ajax/libs/angular-ui-router/0.2.15/angular-ui-router.js"></script>
26+
<script src="https://use.fontawesome.com/b3416c175c.js"></script>
2627
<script type='text/javascript' src='./bundle.js'></script>
2728

2829
</html>

0 commit comments

Comments
 (0)