Skip to content

Commit

Permalink
fix no response problem. now saves correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
hanayik committed Oct 10, 2017
1 parent 4168c0f commit ed6704d
Showing 1 changed file with 24 additions and 7 deletions.
31 changes: 24 additions & 7 deletions core.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,8 @@ var savePath
var summaryIsOnScreen = false
isPractice = false
var firstVideoNotFinished = true
var iti = 1500 // milliseconds
var fbTime = 750


function checkForUpdateFromRender() {
Expand Down Expand Up @@ -523,8 +525,6 @@ function updateKeys() {
return
}
// gets called from: document.addEventListener('keydown', updateKeys);
iti = 1500 // milliseconds
fbTime = 750
keys.key = event.key
keys.time = performance.now() // gives ms
keys.rt = 0
Expand All @@ -548,9 +548,8 @@ function updateKeys() {
} else if (isPractice) {
clearScreen()
accuracy = checkAccuracy()
totalAccArray.push(accuracy)
totalAcc = mean(totalAccArray)
console.log('total acc: ', totalAcc)
//totalAccArray.push(accuracy)
//totalAcc = mean(totalAccArray)
console.log("accuracy: ", accuracy)
keys.rt = getRT()
console.log("RT: ", keys.rt)
Expand Down Expand Up @@ -751,7 +750,18 @@ function showNextTrial(level) {
vid2.onended = function() {
clearScreen()
trialTimeoutID = setTimeout(function() {
showNextTrial(level)
keys.rt = 0
keys.key = ''
accuracy = checkAccuracy()
totalAccArray.push(accuracy)
totalAcc = mean(totalAccArray)
console.log('total acc: ', totalAcc)
console.log("accuracy: ", accuracy)
showFeedback(accuracy)
setTimeout(clearScreen, fbTime)
//['subj', 'session', 'assessment', 'level', 'stim1', 'stim2', 'correctResp', 'keyPressed', 'reactionTime', 'accuracy', os.EOL]
appendTrialDataToFile(fileToSave, [subjID, sessID, 'PhonTx', level, trials[trialOrder[t]].stim1.trim(), trials[trialOrder[t]].stim2.trim(), trials[trialOrder[t]].correctResp.trim(), keys.key, keys.rt, accuracy])
setTimeout(function() {showNextTrial(level)}, iti + fbTime)
}, trialTimeoutTime)
}
content.appendChild(vid2)
Expand Down Expand Up @@ -812,7 +822,14 @@ function showNextPracticeTrial(level) {
vid2.onended = function() {
clearScreen()
trialTimeoutID = setTimeout(function() {
showNextPracticeTrial(level)
clearScreen()
keys.rt = 0
keys.key = ''
accuracy = checkAccuracy()
console.log("accuracy: ", accuracy)
showFeedback(accuracy)
setTimeout(clearScreen, fbTime)
setTimeout(function() {showNextPracticeTrial(level)}, iti + fbTime)
}, trialTimeoutTime)
}
content.appendChild(vid2)
Expand Down

0 comments on commit ed6704d

Please sign in to comment.