diff --git a/src/creator.coffee b/src/creator.coffee index 4260b4e..847be2d 100755 --- a/src/creator.coffee +++ b/src/creator.coffee @@ -28,7 +28,7 @@ Hangman.directive('focusMe', ['$timeout', '$parse', ($timeout, $parse) -> ]) Hangman.factory 'Resource', ['$sanitize', ($sanitize) -> - buildQset: (title, items, partial, attempts, random) -> + buildQset: (title, items, partial, attempts, random, enableQuestionBank, questionBankVal) -> qsetItems = [] qset = {} @@ -47,7 +47,7 @@ Hangman.factory 'Resource', ['$sanitize', ($sanitize) -> Materia.CreatorCore.cancelSave 'Word #'+(i+1)+' needs to contain at least one letter or number.' return false - qset.options = {partial: partial, attempts: attempts, random: random} + qset.options = {partial: partial, attempts: attempts, random: random, enableQuestionBank: enableQuestionBank, questionBankVal: questionBankVal} qset.assets = [] qset.rand = false qset.name = title @@ -97,6 +97,10 @@ Hangman.controller 'HangmanCreatorCtrl', ['$timeout', '$scope', '$sanitize', 'Re $scope.partial = false $scope.random = false $scope.attempts = 5 + $scope.questionBankModal = false + $scope.enableQuestionBank = false + $scope.questionBankVal = 1 + $scope.questionBankValTemp = 1 # for use with paginating results $scope.currentPage = 0; @@ -191,7 +195,12 @@ Hangman.controller 'HangmanCreatorCtrl', ['$timeout', '$scope', '$sanitize', 'Re $scope.hideCover() $scope.hideCover = -> - $scope.showTitleDialog = $scope.showIntroDialog = false + $scope.showTitleDialog = $scope.showIntroDialog = $scope.questionBankModal = false + $scope.questionBankValTemp = $scope.questionBankVal + + $scope.validateQuestionBankVal = -> + if ($scope.questionBankValTemp >= 1 && $scope.questionBankValTemp <= $scope.items.length) + $scope.questionBankVal = $scope.questionBankValTemp $scope.initNewWidget = (widget, baseUrl) -> $scope.$apply -> @@ -202,12 +211,16 @@ Hangman.controller 'HangmanCreatorCtrl', ['$timeout', '$scope', '$sanitize', 'Re $scope.attempts = ~~qset.options.attempts or 5 $scope.partial = qset.options.partial $scope.random = qset.options.random + $scope.enableQuestionBank = if qset.options.enableQuestionBank then qset.options.enableQuestionBank else false + $scope.questionBankVal = if qset.options.questionBankVal then qset.options.questionBankVal else 1 + $scope.questionBankValTemp = if qset.options.questionBankVal then qset.options.questionBankVal else 1 + $scope.onQuestionImportComplete qset.items[0].items $scope.$apply() $scope.onSaveClicked = (mode = 'save') -> - qset = Resource.buildQset $sanitize($scope.title), $scope.items, $scope.partial, $scope.attempts, $scope.random + qset = Resource.buildQset $sanitize($scope.title), $scope.items, $scope.partial, $scope.attempts, $scope.random, $scope.enableQuestionBank, $scope.questionBankVal if qset then Materia.CreatorCore.save $sanitize($scope.title), qset $scope.onSaveComplete = (title, widget, qset, version) -> true diff --git a/src/creator.html b/src/creator.html index b6e5885..841c589 100644 --- a/src/creator.html +++ b/src/creator.html @@ -26,6 +26,12 @@

+

Incorrect guesses per phrase

@@ -51,8 +57,16 @@

Randomize Order

- - + + +
+
? +
+

+ If Question Bank is on then the check to randomize order is disabled. This is because the question bank + randomizes the question order already. +

+

Partial scoring

@@ -168,11 +182,10 @@

Phrase

{{currentPage+1}}/{{numberOfPages()}}
-
Click here to add your first question
-
+

Guess the Phrase

@@ -188,5 +201,30 @@

Guess the Phrase

+
+
+ +
+ + No + Yes + +
+
+
+ + +
+ + out of {{items.length}} +
+
+
+

If question bank is enabled, questions will be randomized.

+ +
+ diff --git a/src/creator.scss b/src/creator.scss index ba2d8eb..0479c57 100644 --- a/src/creator.scss +++ b/src/creator.scss @@ -483,6 +483,85 @@ button.add-question { } } +.question-bank-dialog { + + position: fixed; + top: 50%; + left: 50%; + margin: 0; + transform: translate(-50%, -50%); + background-color: #ffffff; + padding: 0; + height: 200px; + width: 300px; + display: flex; + justify-content: center; + align-items: center; + flex-direction: column; + + input { + margin-top: 0; + padding: 0; + width: unset; + background: #ffffff; + font-size: 17px; + text-align: center; + border: none; + vertical-align: unset; + font-family: 'Lato'; + } + .num-input-wrapper { + display: flex; + justify-content: center; + width: 100%; + align-items: center; + margin-bottom: 5px; + + .num-input { + color: black; + outline: 1px solid black; + width: 35px; + margin: 2px 5px 0 0; + } + } + + .enable-qb-question { + margin-top: 15px; + margin-bottom: 10px; + + .enable-qb-options { + display: flex; + justify-content: center; + } + } + .qb-warning { + font-size: 14px; + margin: 0; + text-align: center; + } + + .dialog-close-button { + position: relative; + margin: 15 0 10 0; + font-size: 15px; + width: 100px; + background-color: #70bd34; + color: black; + + &:hover { + background-color: #88df45; + border: 1px solid #88df45; + color: black; + cursor: pointer; + } + + &:disabled { + background-color: #cccccc; + color: #ffffff; + } + } +} + .arrow-box { position: absolute; background: #fbf767; @@ -619,9 +698,45 @@ button.add-question { top: 28px; background: #fff; } + + .qb-button { + position: absolute; + background-color: $green; + color: #fff; + width: unset; + right: 590px; + top: 35px; + + &:hover { + background-color: #7AD038; + cursor: pointer; + } + + &:disabled { + background-color: #ccc; + border: 1px solid #ccc; + color: #fff; + cursor: not-allowed; + } + + &.gray-out:not(:disabled) { + background-color: #5a5a5a; + border: 1px solid #5a5a5a; + color: #fff; + + &:hover { + background-color: #938f8f; + border: 1px solid #938f8f; + cursor: pointer; + } + + } + + } + .attempts { position: absolute; - right: 355px; + right: 395px; cursor: pointer; top:0px; @@ -764,10 +879,17 @@ button.add-question { .random { position: absolute; top: 0px; - right: 185px; + right: 225px; font-family: "Lato"; + label.checktoggle { left: 24px; + + &.disabled-look { + background-color: #676363; + opacity: 0.5; + cursor: not-allowed; + } } } } @@ -788,6 +910,9 @@ button.add-question { transition: all 0.15s ease; + &.randomizer-tip { + right: 190px; + } &:hover { opacity: 1; background: #53a1d1; @@ -851,6 +976,10 @@ button.add-question { } } + &.randomize-tooltip { + right: 180px; + } + } .answer { diff --git a/src/player.coffee b/src/player.coffee index 095b873..ccdf3c5 100755 --- a/src/player.coffee +++ b/src/player.coffee @@ -285,6 +285,9 @@ HangmanEngine.controller 'HangmanEngineCtrl', ['$scope', '$timeout', 'Parse', 'R Hangman.Draw.playAnimation 'torso', 'pander' $scope.anvilStage = 1 + $scope.prepareQuestionBank = (qsetArr, questionBankVal) -> + return _shuffle(qsetArr.items).slice(0, questionBankVal) + $scope.startQuestion = -> $scope.$apply -> @@ -323,10 +326,10 @@ HangmanEngine.controller 'HangmanEngineCtrl', ['$scope', '$timeout', 'Parse', 'R $scope.max = Reset.attempts ~~_qset.options.attempts $scope.keyboard = Reset.keyboard() ), 500 - + _shuffle = (a) -> - for i in [1...a.length] + for i in [0...a.length] j = Math.floor Math.random() * (a.length) [a[i], a[j]] = [a[j], a[i]] a @@ -344,6 +347,11 @@ HangmanEngine.controller 'HangmanEngineCtrl', ['$scope', '$timeout', 'Parse', 'R if _qset.options.random _qset.items[0].items = _shuffle _qset.items[0].items + if(_qset.options.random and _qset.options.enableQuestionBank) + _qset.items[0].items = _qset.items[0].items.slice(0, _qset.options.questionBankVal) + else if(qset.options.enableQuestionBank) + _qset.items[0].items = window.scope.prepareQuestionBank(qset.items[0], qset.options.questionBankVal) + $scope.total = _qset.items[0].items.length $scope.max = Reset.attempts ~~_qset.options.attempts $scope.keyboard = Reset.keyboard()