-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added field simulator; questions for multiplication (fixes #11)
- Loading branch information
Showing
3 changed files
with
182 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
app.directive("field", function(){ | ||
return { | ||
restrict: "E", | ||
scope: { | ||
data: "=data", | ||
interface: "=interface" | ||
}, | ||
templateUrl: static_url + "simulators/field/simulator.html", | ||
controller: function($scope){ | ||
$scope.response = ''; | ||
|
||
var container = document.getElementById('count_display'); | ||
var field = $scope.data.field; | ||
for (var i=0; i < field.length; i++) { | ||
var line = field[i]; | ||
var div = document.createElement('div'); | ||
container.appendChild(div); | ||
div.style.height = "33px"; | ||
for (var j=0; j < line.length; j++) { | ||
var span = document.createElement('span'); | ||
div.appendChild(span); | ||
span.style.padding = "1px"; | ||
var img = document.createElement('img'); | ||
span.appendChild(img); | ||
if (line[j] == 1) { | ||
img.src = "/static/img/cube_orange.png"; | ||
} else { | ||
img.src = "/static/img/cube_grey.png"; | ||
} | ||
} | ||
} | ||
|
||
$scope.set_text = function(n){ | ||
$scope.response = n; | ||
$scope.submit(); | ||
}; | ||
|
||
$scope.submit = function() { | ||
var correct = $scope.response == $scope.data.answer; | ||
$scope.interface.finish(correct); | ||
}; | ||
|
||
// TODO - logging | ||
} | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<h2> {{response}} </h2> | ||
<div id="count_display"> | ||
</div> | ||
<div style="height:30px;"></div> | ||
<form ng-submit="submit()"> | ||
<div class="row collapse"> | ||
<div class="small-5 small-centered columns"> | ||
<input class="small-8 columns active" focus type="text" ng-model="response" autocomplete="off" placeholder="Zadej svoji odpověď"/> | ||
</div> | ||
<div class="small-1 small-centered columns"> | ||
<input class="button postfix" type="submit" value="OK" /> | ||
</div> | ||
</div> | ||
</form> |