Commit de09226ad3cc5ff1a9675f6a0b4a4f76c6594c41

Authored by Melody
1 parent d900938593

Visual study page using mask as list of lists

Showing 2 changed files with 45 additions and 23 deletions Side-by-side Diff

scripts/StudyController.js View file @ de09226
1 1 angular.module('flashy.StudyController', ['ui.router']).
2 2  
3   -controller('StudyController', ['$scope', '$state',
4   - function($scope, $state) {
  3 +controller('StudyController', ['$scope', '$stateParams', '$state', '$http',
  4 + function($scope, $stateParams, $state, $http) {
5 5 console.log('Flashy study controller content in this file. also hell0');
  6 + sectionId = $stateParams.sectionId;
6 7  
7 8 // Flashcard content
8 9 $scope.htmlContent = 'sample text here longwordddddddddddddddddddddddddddd hello there from js review ctrl alwkejflakewjflk awjkefjkwefjlkea jfkewjaweajkakwef jk fjeawkafj kaewjf jawekfj akwejfk ';
9   - $scope.samples = [
  10 + //single card
  11 + $scope.samples =
10 12 {
11 13 'name': 'lol',
12   - 'desc': 'sample text here 111111'
13   - },
14   - {
15   - 'name': 'lol 2',
16   - 'desc': 'sample text here 22222222222222'
17   - },
18   - {
19   - 'name': 'lol3',
20   - 'desc': 'sample text here 33333333333333'
21   - }
22   - ];
  14 + 'text': 'sample text here 111111 woo hoo I think it works',
  15 + 'mask': [[0,6],[16,23]]
  16 + };
  17 +
  18 + // get text to display as array
  19 + $scope.displayText = [];
  20 + // get answers to blanks as array
  21 + $scope.blankText = [];
  22 + var start = 0; // where to start next string break
  23 + for (var i = 0; i < $scope.samples.mask.length; i++) {
  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 ]);
templates/study.html View file @ de09226
1   -Hello<br>
2   -1. Get card from server.<br>
3   -2. Show card<br>
4   -3. Inputs<br>
5   -4. Compare answers<br>
6   -5. User decides for correct/incorrect<br>
7   -<div ng-repeat="card in samples">
8   - <flashcard flashcard-content="card.desc"></flashcard>
9   -</div>
  1 + <div class="row">
  2 + <div class="col s6 offset-s3">
  3 + <div class="card">
  4 + <div class="card-content">
  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>
  6 + </div>
  7 + <div class="card-action">
  8 + <button class="btn waves-effect waves-light" type="submit" ng-click="checkAnswer()" style="position: relative">Check
  9 + <i class="mdi-content-send right"></i>
  10 + </button>
  11 + </div>
  12 + </div>
  13 + </div>
  14 + </div>