Skip to content

Commit

Permalink
forgot to add fillin simulator
Browse files Browse the repository at this point in the history
  • Loading branch information
jniznan committed Sep 15, 2014
1 parent 271fca7 commit d133550
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 0 deletions.
26 changes: 26 additions & 0 deletions static/simulators/fillin/controller.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
app.directive("fillin", function(){
return {
restrict: "E",
scope: {
data: "=data",
interface: "=interface"
},
templateUrl: static_url + "simulators/fillin/simulator.html",
controller: function($scope){
$scope.fill = '_';
$scope.answer = '';
$("#simulator-input").focus();

$scope.check_answer = function(){
$scope.answer = $scope.answer.replace(/\s*-\s*/g,'-').trim();
var correct = $scope.answer == $scope.data.answer;
$scope.interface.finish(correct);
};

$scope.change = function(){
$scope.interface.log($scope.answer);
$scope.fill = ($scope.answer == '') ? '__' : $scope.answer;
};
}
}
});
11 changes: 11 additions & 0 deletions static/simulators/fillin/simulator.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<h2>{{ data.pre }}<span style="color: blue">{{ fill }}</span>{{ data.post }}</h2>
<div class="row collapse">
<form ng-submit="check_answer()">
<div class="small-5 small-centered columns">
<input id="simulator-input" class="small-8 columns active" type="text" ng-change="change()" ng-model="answer" autocomplete="off" placeholder="Zadej svoji odpověď"/>
</div>
<div class="small-1 small-centered columns">
<input class="button postfix" type="submit" value="OK" />
</div>
</form>
</div>

0 comments on commit d133550

Please sign in to comment.