Commit de09226ad3cc5ff1a9675f6a0b4a4f76c6594c41
1 parent
d900938593
Exists in
master
and in
1 other branch
Visual study page using mask as list of lists
Showing 2 changed files with 45 additions and 23 deletions Inline Diff
scripts/StudyController.js
View file @
de09226
angular.module('flashy.StudyController', ['ui.router']). | 1 | 1 | angular.module('flashy.StudyController', ['ui.router']). | |
2 | 2 | |||
controller('StudyController', ['$scope', '$state', | 3 | 3 | controller('StudyController', ['$scope', '$stateParams', '$state', '$http', | |
function($scope, $state) { | 4 | 4 | function($scope, $stateParams, $state, $http) { | |
console.log('Flashy study controller content in this file. also hell0'); | 5 | 5 | console.log('Flashy study controller content in this file. also hell0'); | |
6 | sectionId = $stateParams.sectionId; | |||
6 | 7 | |||
// Flashcard content | 7 | 8 | // Flashcard content | |
$scope.htmlContent = 'sample text here longwordddddddddddddddddddddddddddd hello there from js review ctrl alwkejflakewjflk awjkefjkwefjlkea jfkewjaweajkakwef jk fjeawkafj kaewjf jawekfj akwejfk '; | 8 | 9 | $scope.htmlContent = 'sample text here longwordddddddddddddddddddddddddddd hello there from js review ctrl alwkejflakewjflk awjkefjkwefjlkea jfkewjaweajkakwef jk fjeawkafj kaewjf jawekfj akwejfk '; | |
$scope.samples = [ | 9 | 10 | //single card | |
11 | $scope.samples = | |||
{ | 10 | 12 | { | |
'name': 'lol', | 11 | 13 | 'name': 'lol', | |
'desc': 'sample text here 111111' | 12 | 14 | 'text': 'sample text here 111111 woo hoo I think it works', | |
}, | 13 | 15 | 'mask': [[0,6],[16,23]] | |
{ | 14 | 16 | }; | |
'name': 'lol 2', | 15 | 17 | ||
'desc': 'sample text here 22222222222222' | 16 | 18 | // get text to display as array | |
}, | 17 | 19 | $scope.displayText = []; | |
{ | 18 | 20 | // get answers to blanks as array | |
'name': 'lol3', | 19 | 21 | $scope.blankText = []; | |
'desc': 'sample text here 33333333333333' | 20 | 22 | var start = 0; // where to start next string break | |
} | 21 | 23 | for (var i = 0; i < $scope.samples.mask.length; i++) { | |
]; | 22 | 24 | $scope.displayText.push($scope.samples.text.substring(start, $scope.samples.mask[i][0])); | |
25 | $scope.blankText.push($scope.samples.text.substring($scope.samples.mask[i][0], $scope.samples.mask[i][1])); | |||
26 | start = $scope.samples.mask[i][1]; | |||
27 | } | |||
28 | if (start != $scope.samples.mask.length-1) | |||
29 | $scope.displayText.push($scope.samples.text.substring(start)); | |||
30 | ||||
31 | // user entered responses as array | |||
32 | $scope.blank = []; | |||
33 | $scope.checkAnswer = function() { | |||
34 | console.log('check!'); | |||
35 | for (var i = 0; i < $scope.blank.length; i++) | |||
36 | console.log($scope.blank[i]); | |||
37 | console.log('actual: ' + $scope.blankText); | |||
38 | $scope.blank = ''; | |||
39 | }; | |||
} | 23 | 40 | } | |
]); | 24 | 41 | ]); | |
25 | 42 | |||
templates/study.html
View file @
de09226
Hello<br> | 1 | 1 | <div class="row"> | |
1. Get card from server.<br> | 2 | 2 | <div class="col s6 offset-s3"> | |
2. Show card<br> | 3 | 3 | <div class="card"> | |
3. Inputs<br> | 4 | 4 | <div class="card-content"> | |
4. Compare answers<br> | 5 | 5 | <span ng-repeat="display in displayText">{{display}}<input ng-model="blank[displayText.indexOf(display)]" ng-show="displayText.indexOf(display) < blankText.length" class="" type="text"/></span> | |
5. User decides for correct/incorrect<br> | 6 | 6 | </div> | |
<div ng-repeat="card in samples"> | 7 | 7 | <div class="card-action"> | |
<flashcard flashcard-content="card.desc"></flashcard> | 8 | 8 | <button class="btn waves-effect waves-light" type="submit" ng-click="checkAnswer()" style="position: relative">Check | |
</div> | 9 | 9 | <i class="mdi-content-send right"></i> | |
10 | </button> | |||
11 | </div> | |||
12 | </div> | |||
13 | </div> | |||
14 | </div> | |||
10 | 15 | |||