Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
18 changed files
with
206 additions
and
154 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
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
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
60 changes: 27 additions & 33 deletions
60
quizzo-app/quizzo-js/app/scripts/controllers/play_controller.js
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 |
---|---|---|
@@ -1,40 +1,34 @@ | ||
'use strict'; | ||
|
||
angular.module('quizzoApp').controller('PlayCtrl', | ||
function ($scope, $location, $timeout, quizManagerService) { | ||
angular.module('quizzoApp').controller('PlayCtrl', function ($scope, $location, $timeout, quizManagerService) { | ||
|
||
var timeout; | ||
|
||
// define our 'end of question time' event | ||
$scope.$on('WaitingForNextQuestion', function () { | ||
// see definition below | ||
$timeout.cancel(timeout); | ||
|
||
$scope.question.destroy(); | ||
// show panel waiting for next question and begin polling | ||
$location.path('/question_pending'); | ||
}); | ||
|
||
$scope.castVote = function () { | ||
var selectedChoice = $scope.choices.item().value; | ||
if (selectedChoice) { | ||
// we send along the current question # to make sure we are recording | ||
// the vote on the right question - if it doesn't match the one in | ||
// server state, throw it away | ||
quizManagerService.vote(selectedChoice, $scope.question.questionNumber); | ||
} | ||
}; | ||
|
||
// our timer loop - check for question timeout or end of game | ||
$scope.onTimeout = function() { | ||
quizManagerService.getStatus(); | ||
timeout = $timeout($scope.onTimeout, 1000); | ||
}; | ||
var timeout; | ||
|
||
// fetch our question | ||
$scope.question = quizManagerService.getCurrentQuestion(); | ||
$scope.selectedChoice = { value : '' }; | ||
|
||
// begin timer | ||
timeout = $timeout($scope.onTimeout, 1000); | ||
$scope.$on('WaitingForAnswer', function () { | ||
console.log('New question arrived.'); | ||
$scope.question = quizManagerService.getCurrentQuestion(); | ||
}); | ||
|
||
// define our 'end of question time' event | ||
$scope.$on('WaitingForNextQuestion', function () { | ||
// show panel waiting for next question and begin polling | ||
$location.path('/question_pending'); | ||
}); | ||
|
||
$scope.castVote = function (value) { | ||
var choice = $scope.selectedChoice; | ||
console.log("selected choice is", choice); | ||
if (choice) { | ||
// we send along the current question # to make sure we are recording | ||
// the vote on the right question - if it doesn't match the one in | ||
// server state, throw it away | ||
quizManagerService.vote(choice, $scope.question.questionNumber); | ||
} | ||
}; | ||
|
||
// fetch our question | ||
$scope.question = quizManagerService.getCurrentQuestion(); | ||
|
||
}); |
15 changes: 3 additions & 12 deletions
15
quizzo-app/quizzo-js/app/scripts/controllers/players_pending_controller.js
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 |
---|---|---|
@@ -1,19 +1,10 @@ | ||
'use strict'; | ||
|
||
angular.module('quizzoApp').controller('PlayersPendingCtrl', function ($scope, $timeout, $location, quizManagerService) { | ||
angular.module('quizzoApp').controller('PlayersPendingCtrl', function ($rootScope, $scope, $location) { | ||
|
||
var timeout; | ||
$rootScope.enablePolling(); | ||
// our exit condition... | ||
$scope.$on('WaitingForAnswer', function() { | ||
$timeout.cancel(timeout); | ||
$scope.$on('WaitingForAnswer', function () { | ||
$location.path('/play'); | ||
}); | ||
|
||
$scope.onTimeout = function() { | ||
quizManagerService.getStatus(); | ||
timeout = $timeout($scope.onTimeout, 1000); | ||
}; | ||
|
||
timeout = $timeout($scope.onTimeout, 1000); | ||
|
||
}); |
13 changes: 2 additions & 11 deletions
13
quizzo-app/quizzo-js/app/scripts/controllers/question_pending_controller.js
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 |
---|---|---|
@@ -1,19 +1,10 @@ | ||
'use strict'; | ||
|
||
angular.module('quizzoApp').controller('QuestionPendingCtrl', function ($scope, $timeout, $location, quizManagerService) { | ||
angular.module('quizzoApp').controller('QuestionPendingCtrl', function ($scope, $location) { | ||
|
||
var timeout; | ||
// our exit condition... | ||
$scope.$on('WaitingForAnswer', function() { | ||
$timeout.cancel(timeout); | ||
$scope.$on('WaitingForAnswer', function () { | ||
$location.path('/play'); | ||
}); | ||
|
||
$scope.onTimeout = function() { | ||
quizManagerService.getStatus(); | ||
timeout = $timeout($scope.onTimeout, 1000); | ||
}; | ||
|
||
timeout = $timeout($scope.onTimeout, 1000); | ||
|
||
}); |
24 changes: 15 additions & 9 deletions
24
quizzo-app/quizzo-js/app/scripts/controllers/register_controller.js
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
28 changes: 28 additions & 0 deletions
28
quizzo-app/quizzo-js/app/scripts/controllers/status_update_controller.js
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,28 @@ | ||
angular.module('quizzoApp').controller('StatusUpdateCtrl', function ($timeout, $rootScope, quizManagerService) { | ||
|
||
var timeout; | ||
|
||
$rootScope.pollEnabled = false; | ||
|
||
$rootScope.onTimeout = function () { | ||
// only call poller if enabled | ||
if ($rootScope.enablePolling === true) { | ||
console.log('polling enabled - checking status'); | ||
quizManagerService.getStatus(); | ||
} | ||
|
||
console.log('timing out for 1 second...'); | ||
timeout = $timeout($rootScope.onTimeout, 1000); | ||
}; | ||
|
||
$rootScope.enablePolling = function () { | ||
$rootScope.pollEnabled = true; | ||
}; | ||
|
||
$rootScope.disablePolling = function () { | ||
$rootScope.pollEnabled = true; | ||
}; | ||
|
||
// begin timing process | ||
timeout = $timeout($rootScope.onTimeout, 1000); | ||
}); |
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
Oops, something went wrong.