Exemple #1
0
    def clipFinished(self):

        time = globals.currentTime()
        if time - self.clipStartTime < self.clipDuration + self.lineInterval:
            return False

        return True
Exemple #2
0
    def processResponse(self, button):

        if self.started and not self.responded and self.phase == 2:
            #self.player.pause()
            #self.player.next()
            correct = 0

            let = ['A', 'B', 'C']

            if button >= 0 and button < 4:

                print 'Answer '+let[button]+' was selected. Correct answer was '+let[self.correctAnswer]
                if button ==  self.correctAnswer:
                    correct = 1
            else:
                print 'No answer was selected. Correct answer was '+let[self.correctAnswer]

            if correct:
                correctSound = pyglet.resource.media('correct.wav')
                correctSound.play()
                globals.bonusCounter += globals.TABLET_QUIZ_BONUS
                #self.correctSound.play()
            else:
                incorrectSound = pyglet.resource.media('incorrect.wav')
                incorrectSound.play()
                #self.incorrectSound.play()

            self.phase = 3
            self.responded = True
            self.tabletDisplayText = ''

            self.db.addData(['pp', globals.participant, 'cond', self.fullCondition, 'correct', correct,
                            'answer', button, 'conversation', self.conversation, 'question', self.clip,
                            'condtime', r3(globals.conditionTime()), 'time', r3(globals.currentTime())], True)
Exemple #3
0
    def clipFinished(self):

        time = globals.currentTime()
        if time - self.clipStartTime < self.clipDuration + self.lineInterval:
            return False

        return True
Exemple #4
0
    def updateTabletText(self, dt):
        time = globals.currentTime()
        if time - self.lastLineTime >= self.lineInterval and self.phase < 2: # time to show the next line on screen
            #print 'Show new line. maxLineIdx from '+str(self.maxLineIdx)+' to '+str(self.maxLineIdx+1)
            #self.minLineIdx += 1
            self.maxLineIdx += 1
            self.lastLineTime = time

            if self.maxLineIdx < len(self.clipLines):
                #print 'Still new lines left to show'
                totalLen = 0 # determine total displayed text length in lines (approx)
                for i in range(self.minLineIdx+1, self.maxLineIdx+1):
                    totalLen += self.clipLines[i].lineLen(self.tabletLineWidth)

                #print 'Total length: '+str(totalLen)

                # displayed text will be too long, strip oldest lines until it fits
                if totalLen > self.maxDisplayLength:
                    #print 'Got to remove some lines from the display'
                    difference = totalLen - self.maxDisplayLength
                    while difference > 0:
                        ll = self.clipLines[self.minLineIdx+1].lineLen(self.tabletLineWidth)
                        difference -= ll
                        self.minLineIdx += 1

                # update displayed text
                self.tabletDisplayText = '<font face="Helvetica,Arial" size=+1>'
                for i in range(self.minLineIdx+1, self.maxLineIdx+1):
                    self.tabletDisplayText += self.clipLines[i].output()+'<br><br>'

                self.tabletDisplayText += '</font>'

                correctSound = pyglet.resource.media('message.wav')
                correctSound.play()
Exemple #5
0
    def startNextClip(self):
        if self.started:
            self.responseCountdown = 0.0
            self.isi = 0.0
            self.responded = False
            self.playedLetter = False
            self.phase = 1
            self.minLineIdx = -1
            self.maxLineIdx = -1
            self.lastLineTime = 0
            self.clipLines = []

            if self.clip + 1 >= self.lastClip:
                #self.pickConversation()
                self.clip = -1
                self.stopTask()
            else:

                self.clip += 1
                #self.clip = 0

                #print 'play clip: ' + str(self.clip+1) + ' of '+ str(self.lastClip)
                with open('tablet/' + str(self.curShow) + '/' +
                          str(self.curShow) + 'frag' + str(self.clip + 1) +
                          '.txt') as f:
                    lines = f.readlines()

                    duration = lines[0]
                    duration = duration.split(':')
                    self.clipDuration = (float(duration[0]) * 60 +
                                         float(duration[1]))
                    #print 'Duration of clip: '+str(self.clipDuration)

                    i = 1
                    while len(lines[i]) > 2:
                        l = lines[i].split(' - ')
                        #print str(len(lines[i]))
                        #print lines[i]
                        #print l[0]
                        #print l[1]
                        self.clipLines.append(ClipLine(l[0], l[1]))
                        i += 1

                    self.lineInterval = self.clipDuration / len(self.clipLines)
                    #print 'Line interval: '+str(self.clipDuration)

                    #print 'Question: '+lines[i+1]
                    self.clipQuestion = Question(lines[i + 1], lines[i + 2],
                                                 lines[i + 3], lines[i + 4])

                self.clipStartTime = globals.currentTime()
Exemple #6
0
    def startNextClip(self):
        if self.started:
            self.responseCountdown = 0.0
            self.isi = 0.0
            self.responded = False
            self.playedLetter = False
            self.phase = 1
            self.minLineIdx = -1
            self.maxLineIdx = -1
            self.lastLineTime = 0
            self.clipLines = []

            if self.clip+1 >= self.lastClip:
                #self.pickConversation()
                self.clip = -1
                self.stopTask()
            else:

                self.clip += 1
                #self.clip = 0

                #print 'play clip: ' + str(self.clip+1) + ' of '+ str(self.lastClip)
                with open('tablet/'+str(self.curShow)+'/'+str(self.curShow)+'frag'+str(self.clip+1)+'.txt') as f:
                    lines = f.readlines()

                    duration = lines[0]
                    duration = duration.split(':')
                    self.clipDuration = (float(duration[0])*60 + float(duration[1]))
                    #print 'Duration of clip: '+str(self.clipDuration)

                    i = 1
                    while len(lines[i]) > 2:
                        l = lines[i].split(' - ')
                        #print str(len(lines[i]))
                        #print lines[i]
                        #print l[0]
                        #print l[1]
                        self.clipLines.append(ClipLine(l[0], l[1]))
                        i += 1

                    self.lineInterval = self.clipDuration / len(self.clipLines)
                    #print 'Line interval: '+str(self.clipDuration)

                    #print 'Question: '+lines[i+1]
                    self.clipQuestion = Question(lines[i+1], lines[i+2], lines[i+3], lines[i+4])

                self.clipStartTime = globals.currentTime()
Exemple #7
0
    def processResponse(self, button):

        if self.started and not self.responded and self.phase == 2:
            #self.player.pause()
            #self.player.next()
            correct = 0

            let = ['A', 'B', 'C']

            if button >= 0 and button < 4:
                if self.audioIsPlaying():
                    if self.llPlayer is not None:
                        self.llPlayer.terminate()
                        self.llPlayer = None

                print 'Answer ' + let[
                    button] + ' was selected. Correct answer was ' + let[
                        self.correctAnswer]
                if button == self.correctAnswer:
                    correct = 1
            else:
                print 'No answer was selected. Correct answer was ' + let[
                    self.correctAnswer]

            if correct:
                correctSound = pyglet.resource.media('correct.wav')
                correctSound.play()
                globals.bonusCounter += globals.RADIO_QUIZ_BONUS
                #self.correctSound.play()
            else:
                incorrectSound = pyglet.resource.media('incorrect.wav')
                incorrectSound.play()
                #self.incorrectSound.play()

            self.phase = 3
            self.responded = True

            self.db.addData([
                'pp', globals.participant, 'cond', self.fullCondition,
                'correct', correct, 'answer', button, 'conversation',
                self.conversation, 'question', self.clip, 'condtime',
                r3(globals.conditionTime()), 'time',
                r3(globals.currentTime())
            ], True)
Exemple #8
0
    def updateTabletText(self, dt):
        time = globals.currentTime()
        if time - self.lastLineTime >= self.lineInterval and self.phase < 2:  # time to show the next line on screen
            #print 'Show new line. maxLineIdx from '+str(self.maxLineIdx)+' to '+str(self.maxLineIdx+1)
            #self.minLineIdx += 1
            self.maxLineIdx += 1
            self.lastLineTime = time

            if self.maxLineIdx < len(self.clipLines):
                #print 'Still new lines left to show'
                totalLen = 0  # determine total displayed text length in lines (approx)
                for i in range(self.minLineIdx + 1, self.maxLineIdx + 1):
                    totalLen += self.clipLines[i].lineLen(self.tabletLineWidth)

                #print 'Total length: '+str(totalLen)

                # displayed text will be too long, strip oldest lines until it fits
                if totalLen > self.maxDisplayLength:
                    #print 'Got to remove some lines from the display'
                    difference = totalLen - self.maxDisplayLength
                    while difference > 0:
                        ll = self.clipLines[self.minLineIdx + 1].lineLen(
                            self.tabletLineWidth)
                        difference -= ll
                        self.minLineIdx += 1

                # update displayed text
                self.tabletDisplayText = '<font face="Helvetica,Arial" size=+1>'
                for i in range(self.minLineIdx + 1, self.maxLineIdx + 1):
                    self.tabletDisplayText += self.clipLines[i].output(
                    ) + '<br><br>'

                self.tabletDisplayText += '</font>'

                correctSound = pyglet.resource.media('message.wav')
                correctSound.play()