Skip to content

Commit

Permalink
BUGFIX: Disabling of audio button on boundary/prominence pages works
Browse files Browse the repository at this point in the history
This feature used to work (I used it in a study) but I recently
discovered that it didn't work.
  • Loading branch information
timmahrt committed Nov 5, 2016
1 parent 03a2058 commit fa69410
Showing 1 changed file with 17 additions and 11 deletions.
28 changes: 17 additions & 11 deletions lmeds/pages/boundary_pages.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def _doBreaksOrProminence(testType, wordIDNum, audioNum, name, textNameStr,
instrMsg = ("%s<br /><br />\n\n" % textNameStr)
htmlTxt += html.makeWrap(instrMsg)

if presentAudioFlag.lower() == 'true':
if presentAudioFlag is True:
htmlTxt += audio.generateAudioButton(name, audioNum, False)
htmlTxt += "<br /><br />\n\n"
else:
Expand Down Expand Up @@ -406,6 +406,7 @@ def __init__(self, name, transcriptName, minPlays, maxPlays,
bindPlayKeyID = html.keyboardletterToChar(bindPlayKeyID)
if bindSubmitID is not None:
bindSubmitID = html.keyboardletterToChar(bindSubmitID)
presentAudio = presentAudio.lower() == "true"

minNumSelected = int(minNumSelected)
maxNumSelected = int(maxNumSelected)
Expand Down Expand Up @@ -444,17 +445,19 @@ def __init__(self, name, transcriptName, minPlays, maxPlays,
self.textDict.update(loader.batchGetText(txtKeyList))

# Variables that all pages need to define
if presentAudio == "true":
if presentAudio is True:
self.numAudioButtons = 1
else:
self.numAudioButtons = 0

if self.doProminence:
if self.doProminence is True:
taskStr = "prominence"
else:
taskStr = "boundary"

self.processSubmitList = ["verifyAudioPlayed()"]
self.processSubmitList = []
if self.presentAudio is True:
self.processSubmitList.append("verifyAudioPlayed()")

if minNumSelected != -1 or maxNumSelected != -1:
verifyNumSelected = 'verifySelectedWithinRange(%d, %d, "%s")'
Expand All @@ -469,10 +472,12 @@ def checkResponseCorrect(self, responseList, correctResponse):
def checkArgs(self):

# Make sure all audio files exist
audioFNList = [self.name + ext for ext in self.webSurvey.audioExtList]
if any([not os.path.exists(join(self.wavDir, fn))
for fn in audioFNList]):
raise utils.FilesDoNotExist(self.wavDir, audioFNList, True)
if self.presentAudio is True:
audioFNList = [self.name + ext
for ext in self.webSurvey.audioExtList]
if any([not os.path.exists(join(self.wavDir, fn))
for fn in audioFNList]):
raise utils.FilesDoNotExist(self.wavDir, audioFNList, True)

# Make sure all text files exist
if not os.path.exists(join(self.txtDir, self.transcriptName + ".txt")):
Expand Down Expand Up @@ -532,7 +537,7 @@ def getHTML(self):
self.boundaryToken,
self.syllableDemarcator)[0]

if self.presentAudio:
if self.presentAudio is True:
embedTxt = audio.getPlaybackJS(True, 1, self.maxPlays,
self.minPlays)
embed = audio.generateEmbed(self.wavDir,
Expand Down Expand Up @@ -625,6 +630,7 @@ def __init__(self, name, transcriptName, minPlays, maxPlays,
bindPlayKeyID = html.keyboardletterToChar(bindPlayKeyID)
if bindSubmitID is not None:
bindSubmitID = html.keyboardletterToChar(bindSubmitID)
presentAudio = presentAudio.lower() == "true"

minNumSelected = int(minNumSelected)
maxNumSelected = int(maxNumSelected)
Expand Down Expand Up @@ -663,7 +669,7 @@ def __init__(self, name, transcriptName, minPlays, maxPlays,
self.textDict.update(loader.batchGetText(txtKeyList))

# Variables that all pages need to define
if presentAudio == "true":
if presentAudio is True:
# Only show one at a time, plays the same audio
self.numAudioButtons = 2
else:
Expand Down Expand Up @@ -755,7 +761,7 @@ def getHTML(self):
htmlTxt += "</div>"

# Add the javascript and style sheets here
if self.presentAudio:
if self.presentAudio is True:
embedTxt = audio.getPlaybackJS(True, 2, self.maxPlays,
self.minPlays)
embed = audio.generateEmbed(self.wavDir,
Expand Down

0 comments on commit fa69410

Please sign in to comment.