Commit d5f15020040416dcdaa343fac5369dd9c4197aff

Authored by Andrew Buss

Merge branch 'master' of git.ucsd.edu:110swag/flashy-frontend

Showing 2 changed files Inline Diff

scripts/StudyController.js View file @ d5f1502
angular.module('flashy.StudyController', ['ui.router']). 1 1 angular.module('flashy.StudyController', ['ui.router']).
2 2
controller('StudyController', ['$scope', '$stateParams', '$state', '$http', 'UserService', 3 3 controller('StudyController', ['$scope', '$stateParams', '$state', '$http', 'UserService',
function($scope, $stateParams, $state, $http, UserService) { 4 4 function($scope, $stateParams, $state, $http, UserService) {
console.log('Flashy study controller content in this file. also hell0'); 5 5 console.log('Flashy study controller content in this file. also hell0');
sectionId = $stateParams.sectionId; 6 6 sectionId = $stateParams.sectionId;
7 7 $scope.isParamOpen = true;
8
$(document).ready(function() { 8 9 $(document).ready(function() {
$('.datepicker').pickadate({ 9 10 $('.datepicker').pickadate({
selectMonths: true, // Creates a dropdown to control month 10 11 selectMonths: true, // Creates a dropdown to control month
selectYears: 15 // Creates a dropdown of 15 years to control year 11 12 selectYears: 15 // Creates a dropdown of 15 years to control year
}); 12 13 });
13 14
$('select').material_select(); 14 15 $('select').material_select();
}); 15 16 });
16 17
$scope.UserService = UserService; 17 18 $scope.UserService = UserService;
$scope.isParamOpen = true; 18 19 $scope.isParamOpen = true;
19 20
console.log($scope.UserService.getUserData().sections); 20 21 console.log($scope.UserService.getUserData().sections);
21 22
$scope.toggleSectionToStudy = function(id) { 22 23 $scope.toggleSectionToStudy = function(id) {
console.log('toggle sect', id); 23 24 console.log('toggle sect', id);
$scope.sectionToStudy = id; 24 25 $scope.sectionToStudy = id;
}; 25 26 };
26 27
$scope.openParams = function() { 27 28 $scope.openParams = function() {
$scope.isParamOpen = !$scope.isParamOpen; 28 29 $scope.isParamOpen = !$scope.isParamOpen;
}; 29 30 };
30 31
$scope.fetchQuiz = function(a, b) { 31 32 $scope.fetchQuiz = function(a, b) {
//console.log($scope.startDate, $scope.endDate); 32 33 //console.log($scope.startDate, $scope.endDate);
console.log(a, b); 33 34 console.log(a, b);
}; 34 35 };
35 36
/* 36 37 /*
$scope.fetchQuiz = function() { 37 38 $scope.fetchQuiz = function() {
console.log('fetching quiz...'); 38 39 console.log('fetching quiz...');
var studyRequest = { 39 40 var studyRequest = {
'sections': ($scope.sectionToStudy == null) ? [] : [$scope.sectionToStudy], 40 41 'sections': ($scope.sectionToStudy == null) ? [] : [$scope.sectionToStudy],
'material_date_begin':, 41 42 'material_date_begin':,
'material_date_end': 42 43 'material_date_end':
}; 43 44 };
44 45
// $http.post('/api/study/', studyRequest). 45 46 // $http.post('/api/study/', studyRequest).
//TODO 46 47 //TODO
}; 47 48 };
*/ 48 49 */
49 50
// Flashcard content 50 51 // Flashcard content
$scope.htmlContent = 'sample text here longwordddddddddddddddddddddddddddd hello there from js review ctrl alwkejflakewjflk awjkefjkwefjlkea jfkewjaweajkakwef jk fjeawkafj kaewjf jawekfj akwejfk '; 51 52 $scope.htmlContent = 'sample text here longwordddddddddddddddddddddddddddd hello there from js review ctrl alwkejflakewjflk awjkefjkwefjlkea jfkewjaweajkakwef jk fjeawkafj kaewjf jawekfj akwejfk ';
//single card 52 53 //single card
$scope.samples = 53 54 $scope.samples =
{ 54 55 {
'name': 'lol', 55 56 'name': 'lol',
'text': 'sample text here 111111 woo hoo I think it works', 56 57 'text': 'sample text here 111111 woo hoo I think it works',
'mask': [[0, 6], [16, 23]] 57 58 'mask': [[0, 6], [16, 23]]
}; 58 59 };
59 60
// get text to display as array 60 61 // get text to display as array
$scope.displayText = []; 61 62 $scope.displayText = [];
// get answers to blanks as array 62 63 // get answers to blanks as array
$scope.blankText = []; 63 64 $scope.blankText = [];
var start = 0; // where to start next string break 64 65 var start = 0; // where to start next string break
for (var i = 0; i < $scope.samples.mask.length; i++) { 65 66 for (var i = 0; i < $scope.samples.mask.length; i++) {
$scope.displayText.push($scope.samples.text.substring(start, $scope.samples.mask[i][0])); 66 67 $scope.displayText.push($scope.samples.text.substring(start, $scope.samples.mask[i][0]));
$scope.blankText.push($scope.samples.text.substring($scope.samples.mask[i][0], $scope.samples.mask[i][1])); 67 68 $scope.blankText.push($scope.samples.text.substring($scope.samples.mask[i][0], $scope.samples.mask[i][1]));
start = $scope.samples.mask[i][1]; 68 69 start = $scope.samples.mask[i][1];
} 69 70 }
if (start != $scope.samples.mask.length - 1) 70 71 if (start != $scope.samples.mask.length - 1)
$scope.displayText.push($scope.samples.text.substring(start)); 71 72 $scope.displayText.push($scope.samples.text.substring(start));
templates/study.html View file @ d5f1502
<!-- Parameters for the studying --> 1 1 <!-- Parameters for the studying -->
2 2
<div class="collapsible-header param-header" 3 3 <div class="collapsible-header param-header"
ng-click="openParams()"> 4 4 ng-click="openParams()">
<i class="mdi-image-filter-drama"></i>Choose study settings</div> 5 5 <i class="mdi-image-filter-drama"></i>Choose study settings</div>
6 6
<div class="study-params dropping" ng-init="isParamOpen = true" ng-if="isParamOpen"> 7 7 <div class="study-params dropping" ng-show="isParamOpen">
<div class="row"> 8 8 <div class="row">
<h3>Choose what to study</h3> 9 9 <h3>Choose what to study</h3>
<!-- lots of difficulty with materializecss select and angularjs. If we want to 10 10 <!-- lots of difficulty with materializecss select and angularjs. If we want to
refactor into a select(which prob looks better), maybe refer to this article: 11 11 refactor into a select(which prob looks better), maybe refer to this article:
http://stackoverflow.com/questions/29402495/values-not-showing-up-in-select-button 12 12 http://stackoverflow.com/questions/29402495/values-not-showing-up-in-select-button
--> 13 13 -->
<!-- Also suffered huge casualties trying to do radios...let's just do buttons... 14 14 <!-- Also suffered huge casualties trying to do radios...let's just do buttons...
--> 15 15 -->
<a class="waves-effect waves-light btn toggley" 16 16 <a class="waves-effect waves-light btn toggley"
ng-init="sectionToStudy = null" 17 17 ng-init="sectionToStudy = null"
ng-click="toggleSectionToStudy(null)" 18 18 ng-click="toggleSectionToStudy(null)"
ng-class="{'pink white-text': sectionToStudy == null}"> 19 19 ng-class="{'pink white-text': sectionToStudy == null}">
All classes</a> 20 20 All classes</a>
<div ng-repeat="section in UserService.getUserData().sections"> 21 21 <div ng-repeat="section in UserService.getUserData().sections">
<a class="waves-effect waves-light btn toggley" 22 22 <a class="waves-effect waves-light btn toggley"
ng-click="toggleSectionToStudy(section.id)" 23 23 ng-click="toggleSectionToStudy(section.id)"
ng-class="{'pink white-text': sectionToStudy == section.id}"> 24 24 ng-class="{'pink white-text': sectionToStudy == section.id}">
{{section.short_name}} 25 25 {{section.short_name}}
</a> 26 26 </a>
</div> 27 27 </div>
28 28
<!-- 29 29 <!--
<div class="input-field col s12"> 30 30 <div class="input-field col s12">
<select ng-model="selectedClass" 31 31 <select ng-model="selectedClass"
ng-options="section.short_name for section in UserService.getUserData().sections"> 32 32 ng-options="section.short_name for section in UserService.getUserData().sections">
</select> 33 33 </select>
<label>Materialize Select</label> 34 34 <label>Materialize Select</label>
</div> 35 35 </div>
--> 36 36 -->
</div> 37 37 </div>
38 38
<div class="row"> 39 39 <div class="row">
<div class="card"> 40 40 <div class="card">
<h3>Choose Date</h3> 41 41 <h3>Choose Date</h3>
<input type="date" class="datepicker" ng-model="startDate" placeholder="Start Date"/> 42 42 <input type="date" class="datepicker" ng-model="startDate" placeholder="Start Date"/>
<input type="date" class="datepicker" ng-model"endDate" placeholder="End Date"/> 43 43 <input type="date" class="datepicker" ng-model"endDate" placeholder="End Date"/>
</div> 44 44 </div>
</div> 45 45 </div>
46 46
<div class="row"> 47 47 <div class="row">
<div class="card-action"> 48 48 <div class="card-action">
<button class="btn waves-effect waves-light" ng-click="fetchQuiz()"> 49 49 <button class="btn waves-effect waves-light" ng-click="fetchQuiz()">
Fetch! 50 50 Fetch!
<i class="mdi-content-send right"></i> 51 51 <i class="mdi-content-send right"></i>
</button> 52 52 </button>
</div> 53 53 </div>
</div> 54 54 </div>
</div> 55 55 </div>
56 56
57 57
<!-- Fetched card "quiz" --> 58 58 <!-- Fetched card "quiz" -->
<div class="row"> 59 59 <div class="row">
<div class="card"> 60 60 <div class="card">
<div class="card-content"> 61 61 <div class="card-content">
<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> 62 62 <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>
</div> 63 63 </div>
<div class="card-action"> 64 64 <div class="card-action">