From ef6317fac4eab348e182c48947eea83b3bc0c434 Mon Sep 17 00:00:00 2001 From: Cay Henning Date: Mon, 20 Feb 2023 12:49:42 -0500 Subject: [PATCH] Sends audio ID only if there is an audio asset (copied from matching widget) --- src/controllers/player.coffee | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/controllers/player.coffee b/src/controllers/player.coffee index aededdc..d8a93fc 100644 --- a/src/controllers/player.coffee +++ b/src/controllers/player.coffee @@ -73,7 +73,7 @@ Matching.controller 'matchingPlayerCtrl', ['$scope', '$timeout', '$sce', ($scope _pageIndex++ wrapQuestionUrl = -> - if item.assets[0] != 0 and item.assets[0] != undefined # for qsets published after this commit, this value will be 0, for older qsets it's undefined + if item.assets and item.assets?[0] != 0 and item.assets?[0] != undefined # for qsets published after this commit, this value will be 0, for older qsets it's undefined return $sce.trustAsResourceUrl Materia.Engine.getImageAssetUrl(item.assets[0]) $scope.pages[_pageIndex].questions.push { @@ -106,7 +106,7 @@ Matching.controller 'matchingPlayerCtrl', ['$scope', '$timeout', '$sce', ($scope ### wrapAnswerUrl = -> - if item.assets[1] != 0 and item.assets[1] != undefined # for qsets published after this commit, this value will be 0, for older qsets it's undefined + if item.assets?[1] != 0 and item.assets?[1] != undefined # for qsets published after this commit, this value will be 0, for older qsets it's undefined return $sce.trustAsResourceUrl Materia.Engine.getImageAssetUrl(item.assets[1]) $scope.pages[_pageIndex].answers.push { @@ -475,7 +475,8 @@ Matching.controller 'matchingPlayerCtrl', ['$scope', '$timeout', '$sce', ($scope matchedItemAnswerId = matchedItem[0].answerId # get the answer of that match at that question id and use that as the 2nd argument mappedQsetItemText = qsetItems.filter( (item) -> item.id == matchedItemAnswerId)[0].answers[0].text - mappedQsetAudioString = qsetItems.filter( (item) -> item.id == matchedItemAnswerId)[0].assets[2] + # the audioString should ONLY be provided if there is actually an audio asset present for the answer card - we check that by referencing assets[1]. Otherwise, pass null + mappedQsetAudioString = if qsetItems.filter( (item) -> item.id == matchedItemAnswerId)[0].assets and qsetItems.filter( (item) -> item.id == matchedItemAnswerId)[0].assets[1] != 0 then qsetItems.filter( (item) -> item.id == matchedItemAnswerId)[0].assets[2] else null else mappedQsetItemText = null Materia.Score.submitQuestionForScoring(qsetItems[i].id, mappedQsetItemText, mappedQsetAudioString)