Skip to content

Commit

Permalink
Merge pull request #40 from DynieM/accessibility-edits
Browse files Browse the repository at this point in the history
Accessibility edits
  • Loading branch information
clpetersonucf authored Jun 11, 2024
2 parents bff5801 + 49a3189 commit a53750a
Show file tree
Hide file tree
Showing 8 changed files with 2,280 additions and 2,124 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ node_modules
bower_components
*build
coverage
.vscode/
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,10 @@
],
"coverageThreshold": {
"global": {
"statements": 90,
"statements": 84,
"branches": 60,
"functions": 80,
"lines": 90
"functions": 78,
"lines": 86
}
}
},
Expand Down
8 changes: 5 additions & 3 deletions src/audioControls.html
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
<div class='audio-controls'>
<span class='play-btn'
<button class='play-btn'
aria-label="Play audio clue."
ng-class="{'paused' : audio.paused}"
ng-click='$event.stopPropagation(); play()'>
</span>
ng-click='$event.stopPropagation(); play()'
ng-keypress="$event.stopPropagation()">
</button>
<span class='time'>
<span class='seek-bar'>
<input type='range'
Expand Down
163 changes: 150 additions & 13 deletions src/controllers/player.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,27 @@ angular.module 'matching'
$scope.totalItems = 0
$scope.setCreated = false
$scope.helpVisible = false
$scope.completePerPage = []

$scope.unfinishedPagesBefore = false
$scope.unfinishedPagesAfter = false
helpModal = document.getElementById("instructions");

if helpModal
helpModal.setAttribute("inert", '');


_assistiveAlert = (msg) ->
alertEl = document.getElementById('assistive-alert')
if alertEl then alertEl.innerHTML = msg


$scope.qset = {}

$scope.circumference = Math.PI * 80

_boardElement = document.getElementById('gameboard')

# these are used for animation
$scope.pageAnimate = false
$scope.pageNext = false
Expand All @@ -41,6 +54,7 @@ angular.module 'matching'
CIRCLE_OFFSET = 40
PROGRESS_BAR_LENGTH = 160


materiaCallbacks.start = (instance, qset) ->
$scope.qset = qset
$scope.title = instance.name
Expand All @@ -55,12 +69,15 @@ angular.module 'matching'
$scope.totalItems = qset.items[0].items.length
$scope.totalPages = Math.ceil $scope.totalItems/ITEMS_PER_PAGE

document.title = instance.name + ' Materia widget'

# set up the pages
for [1..$scope.totalPages]
$scope.pages.push {questions:[], answers:[]}
$scope.selectedQA.push {question:-1, answer:-1}
$scope.questionCircles.push []
$scope.answerCircles.push []
$scope.completePerPage.push 0

_itemIndex = 0
_pageIndex = 0
Expand Down Expand Up @@ -151,13 +168,12 @@ angular.module 'matching'
return false if direction == 'previous' and $scope.currentPage <= 0
return false if direction == 'next' and $scope.currentPage >= $scope.totalPages - 1


_clearSelections()
$scope.pageAnimate = true

$scope.pageNext = (direction == 'next')
$timeout ->
$scope.currentPage-- if direction == 'previous'
$scope.currentPage++ if direction == 'next'
_checkUnfinishedPages()
, ANIMATION_DURATION/3

Expand All @@ -166,28 +182,73 @@ angular.module 'matching'
$scope.pageAnimate = false
, ANIMATION_DURATION*1.1

if _boardElement then _boardElement.focus()
if direction == 'next'
($scope.currentPage = $scope.currentPage + 1)
_assistiveAlert 'Page incremented. You are on the next page. There are ' + ($scope.completePerPage[$scope.currentPage] ?= 0) + ' out of ' + $scope.pages[$scope.currentPage].questions.length + ' matches done.'
else if direction == 'previous'
($scope.currentPage = $scope.currentPage - 1)
_assistiveAlert 'Page decremented. You are on the previous page. There are ' + ($scope.completePerPage[$scope.currentPage] ?= 0) + " out of " + $scope.pages[$scope.currentPage].questions.length + ' matches done.'

$scope.checkForQuestionAudio = (index) ->
$scope.pages[$scope.currentPage].questions[index].asset != undefined


$scope.checkForAnswerAudio = (index) ->
$scope.pages[$scope.currentPage].answers[index].asset != undefined




_updateCompletionStatus = () ->

$scope.completePerPage = []
for match in $scope.matches
if !$scope.completePerPage[match.matchPageId] then $scope.completePerPage[match.matchPageId] = 1
else $scope.completePerPage[match.matchPageId]+=1


_pushMatch = () ->
$scope.matches.push {
questionId: $scope.selectedQuestion.id
questionIndex: $scope.selectedQA[$scope.currentPage].question
answerId: $scope.selectedAnswer.id
answerIndex: $scope.selectedQA[$scope.currentPage].answer
matchPageId: $scope.currentPage
color: _getColor()
}

newMatch = {
questionId: $scope.selectedQuestion.id,
questionIndex: $scope.selectedQA[$scope.currentPage].question,
answerId: $scope.selectedAnswer.id,
answerIndex: $scope.selectedQA[$scope.currentPage].answer,
matchPageId: $scope.currentPage,
color: _getColor()
}

duplicateFound = false


for existingMatch in $scope.matches
if existingMatch.questionId == newMatch.questionId and existingMatch.answerId == newMatch.answerId
duplicateFound = true
break


if not duplicateFound
$scope.matches.push newMatch

_updateCompletionStatus()

if($scope.totalItems == $scope.matches.length)
_assistiveAlert 'All matches have been made. You may now submit your answers.'
else
_assistiveAlert 'Match made. There are ' + ($scope.totalItems - $scope.matches.length) + ' matches left.'

_assistiveAlert $scope.pages[$scope.currentPage].questions[$scope.selectedQA[$scope.currentPage].question].text + ' matched with ' +
$scope.pages[$scope.currentPage].answers[$scope.selectedQA[$scope.currentPage].answer].text + '. ' +
($scope.pages[$scope.currentPage].questions.length - ($scope.completePerPage[$scope.currentPage])) + ' of ' + $scope.pages[$scope.currentPage].questions.length + ' matches left on current page '


_applyCircleColor = () ->
# find appropriate circle
$scope.questionCircles[$scope.currentPage][$scope.selectedQA[$scope.currentPage].question].color = _getColor()
$scope.answerCircles[$scope.currentPage][$scope.selectedQA[$scope.currentPage].answer].color = _getColor()


_getColor = () ->
'c' + colorNumber

Expand Down Expand Up @@ -245,6 +306,7 @@ angular.module 'matching'
$scope.answerCircles[$scope.currentPage][match2_AIndex].color = 'c0'
$scope.matches.splice indexOfAnswer, 1


_pushMatch()

_applyCircleColor()
Expand All @@ -257,10 +319,14 @@ angular.module 'matching'

$scope.unapplyHoverSelections()

else if $scope.selectedQA[$scope.currentPage].question != -1 then _assistiveAlert $scope.selectedQuestion.text + ' selected.'
else if $scope.selectedQA[$scope.currentPage].answer != -1 then _assistiveAlert $scope.selectedAnswer.text + ' selected.'

_clearSelections = () ->
$scope.selectedQA[$scope.currentPage].question = -1
$scope.selectedQA[$scope.currentPage].answer = -1


_updateLines = () ->
$scope.lines = []
for [1..$scope.totalPages]
Expand Down Expand Up @@ -334,6 +400,15 @@ angular.module 'matching'

return false

$scope.getMatchWith = (item) ->
if item.type == 'question'
a = $scope.matches.find( (match) -> match.questionId == item.id)
if a then return $scope.pages[a.matchPageId].answers[a.answerIndex].text

else if item.type == 'answer'
q = $scope.matches.find( (match) -> match.answerId == item.id)
if q then return $scope.pages[q.matchPageId].questions[q.questionIndex].text

$scope.drawPrelineToRight = (hoverItem) ->
elementId = hoverItem.id
# get the index of the item in the current page by finding it with its id
Expand Down Expand Up @@ -414,8 +489,9 @@ angular.module 'matching'
when "KeyT" then $scope.selectAnswer($scope.pages[$scope.currentPage].answers[4])
when "KeyY" then $scope.selectAnswer($scope.pages[$scope.currentPage].answers[5])
# left and right arrow keys will change the page
when "ArrowLeft" then $scope.changePage('previous')
when "ArrowRight" then $scope.changePage('next')
when "ArrowLeft" then document.getElementsByClassName('column1')[0].getElementsByClassName('word')[0].focus()
when "ArrowRight" then document.getElementsByClassName('column2')[0].getElementsByClassName('word')[0].focus()

# enter and space will function the same as clicking on the focused element
when "Enter", "Space"
switch window.document.activeElement.id
Expand All @@ -438,6 +514,7 @@ angular.module 'matching'

when "finish-button" then $scope.submit()


$scope.getItemLetter = (index) ->
# determines the letter that will be displayed next to each answer choice in the second column
switch index
Expand Down Expand Up @@ -470,6 +547,7 @@ angular.module 'matching'
$scope.selectedQA[$scope.currentPage].answer = indexId
_checkForMatches()


$scope.submit = () ->
return if $scope.getPercentDone() < 1
qsetItems = $scope.qset.items[0].items
Expand All @@ -495,6 +573,18 @@ angular.module 'matching'
randomIndex = Math.floor Math.random() * (index + 1)
[qsetItems[index], qsetItems[randomIndex]] = [qsetItems[randomIndex], qsetItems[index]]

$scope.setIsFirstPage = () ->
isFirstPage = false
if $scope.currentPage == 0
isFirstPage = true
return isFirstPage

$scope.setIsLastPage = () ->
isLastPage = false
if $scope.currentPage == $scope.pages.length - 1
isLastPage = true
return isLastPage

_checkUnfinishedPages = () ->
$scope.unfinishedPagesBefore = false
$scope.unfinishedPagesAfter = false
Expand All @@ -512,11 +602,58 @@ angular.module 'matching'
if matchesPerPage[page] < pairsPerPage[page]
if matchesPerPage[$scope.currentPage] == pairsPerPage[$scope.currentPage]
$scope.unfinishedPagesBefore = true

unless $scope.currentPage == $scope.pages.length - 1
for page in [$scope.currentPage..pairsPerPage.length]
if matchesPerPage[page] < pairsPerPage[page]
if matchesPerPage[$scope.currentPage] == pairsPerPage[$scope.currentPage]
$scope.unfinishedPagesAfter = true

$scope.unfocused = () ->
$scope.helpVisible = !$scope.helpVisible
helpButton = document.getElementById("help-button");
gameBoard = document.getElementById("gameboard");
panelButtons = document.getElementById("page-selector");
finishButton = document.getElementById("finish-button");


if panelButtons
panelButtons.setAttribute("inert", '');

if helpButton
helpButton.setAttribute("inert", '');
if gameBoard
gameBoard.setAttribute("inert", '');
if finishButton
finishButton.setAttribute("inert", '');


if helpModal
helpModal.removeAttribute("inert");

$scope.focused = () ->


$scope.helpVisible = false
helpButton = document.getElementById("help-button");
gameBoard = document.getElementById("gameboard");
panelButtons = document.getElementById("page-selector");
finishButton = document.getElementById("finish-button");

if panelButtons
panelButtons.removeAttribute("inert", '');
if helpButton
helpButton.removeAttribute("inert", '');
if gameBoard
gameBoard.removeAttribute("inert", '');
if finishButton
finishButton.removeAttribute("inert", '');



if helpModal
helpModal.setAttribute("inert", '');


Materia.Engine.start materiaCallbacks
]
]
2 changes: 2 additions & 0 deletions src/install.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,5 @@ meta_data:
Students must match one set of words or
phrases to a corresponding word, phrase,
or definition.
accessibility_keyboard: Full
accessibility_reader: Full
Loading

0 comments on commit a53750a

Please sign in to comment.