suddenly: conditional never 'success'

PennController for IBEX Forums Bug Report suddenly: conditional never 'success'

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #8244
    daniela
    Participant

    Hello,

    This issue just started an hour or so ago and now happens even in previous experiments that I haven’t changed at all: when running a conditional to compare a pressed key’s value (F or J) to the expected value (F or J) based on which button corresponds to ‘yes’ (variable.match), I always get the feedback that my selection was incorrect. So either the ‘yes_key’ isn’t logging, the response key isn’t logging, or the expected value isn’t logging, and so there is never a ‘success’ in my conditional. This might be related to my PCIbex version (1.8) or that I’m using the older version of PCIbex Farm hosted on my department’s server–although it was working fine until the afternoon. When I run the exact same experiment (via git repo) on the new PCIbex Farm I don’t get this problem.

    Some example code:

    (1) At the beginning of the experiment (first PC element), I define the ‘yes_key’ and ‘no_key’ as ‘F’ or ‘J’, and set them globally.

    // set 'yes' and 'no' keys
                   newVar("yes_key")
                   .settings.global()
                   .set( "F" ) // for F-version
                   // .set( "J" ) // for J-version
                   ,
                   // set 'no' key; this is necessary for the conditional in the practice round (for feedback)
                   newVar("no_key")
                   .settings.global()
                   .set( "J" ) // for F-version
                   // .set( "F" ) // for J-version
    

    (2) In a practice round PC element, I check whether the given trial constitute a match or mismatch (via variable.match), then later one wait for a key response for ‘rating’. I then compare ‘rating’ to the ‘yes_key’ and to the expected response (‘match’), to print the relevant feedback for CORRECT or INCORRECT responses.

    ...
    // set trial's correct response; must remain here
                                              newVar("match")
                                              .set(variable.match)
                                              ,
    ...
    // wait for key response
    newKey("rating", "FJ")
                                          .callback( getTimer("time_out1").stop() )
                                          .log("all")  
    ,
    ...
    // create variable for rating response
                                          newVar("rating")
                                          .set(getKey("rating") )
                                          ,
    // test response and give feedback
                                          getVar("rating")
                                          .test.is( // check if the rating...
                                          getVar("yes_key")) // ...is the same as the 'yes' key
                                          .and(getVar("match") // and if the correct answer...
                                          .test.is("yes")) // is 'yes'
                                          .or( // conversely,
                                          getVar("rating") // check if the rating...
                                          .test.is(
                                          getVar("no_key")) // ...equals 'no'
                                          .and(getVar("match") // and if the correct answer...
                                          .test.is("no"))) // is 'no'
                                          .success // if either of those is true, the answer was correct
                                          (      
                                          
                                          newText ("match_text", variable.prac_correct)  // print the CORRECT feedback response for this trial
                                          .settings.css("font-size", "20px")
                                          .settings.css("font-family","times new roman")
                                          .print("20vw","40vh")
                                          ,
                                          newText("spacebar", "Press the spacebar to continue.")
                                          .settings.css("font-size", "15px")
                                          .settings.italic()
                                          .settings.css("font-family","times new roman")
                                          .settings.center()
                                          .settings.color("red")
                                          .print("20vw","50vh")
                                          ,
                                          newKey("feedback1", " ")
                                          .wait()
                                          
                                          )
                                          .failure // otherwise, the answer was wrong
                                          (
                                          newText ("mismatch_text", variable.prac_incorrect)  // print INCORRECT feedback
                                          .settings.css("font-size", "20px")
                                          .settings.css("font-family","times new roman")
                                          .settings.color("red")
                                          .print("20vw","40vh")
                                          ,
                                          newText("spacebar", "Press the spacebar to continue.")
                                          .settings.css("font-size", "15px")
                                          .settings.italic()
                                          .settings.css("font-family","times new roman")
                                          .settings.center()
                                          .settings.color("red")
                                          .print("20vw","50vh")
                                          ,
                                          newKey("feedback2", " ")
                                          .wait()
                                          
                                          ) )
    

    I hope the code I’ve copied is sufficient, the script is quite long and so I didn’t want to copy irrelevant code.

    Best
    Daniela

    #8255
    Jeremy
    Keymaster

    Hello Daniela,

    My apologies for the late reply. As far as I can tell, you don’t need to use any Var element in your code. You could do something like this instead:

    // Top of your script
    const YES_KEY = 'F', NO_KEY = 'J';
    
    // inside your trial
    newKey("rating", "FJ")
      .callback( getTimer("time_out1").stop() )
      .log("all")  
    ,
    getTimer("time_out1").wait() // I added this here as it seems to make sense given the callback above
    ,
    getKey("rating")
      .test.pressed( variable.match=='yes' ? YES_KEY : NO_KEY )
      .success(
        newText ("match_text", variable.prac_correct)  // print the CORRECT feedback response for this trial
          .css({"font-size":"20px","font-family":"times new roman"})
          .print("20vw","40vh")
      )
      .failure(
        newText ("mismatch_text", variable.prac_incorrect)  // print INCORRECT feedback
          .css({"font-size":"20px","font-family":"times new roman"})
          .color("red")
          .print("20vw","40vh")
      )
    ,
    newText("spacebar", "Press the spacebar to continue.")
      .css({"font-size":"15px","font-family":"times new roman"})
      .italic()
      .center()
      .color("red")
      .print("20vw","50vh")
    ,
    newKey("feedback", " ").wait()

    Remember that you can always share your project’s demonstration link as a way to share your code and make troubleshooting easier

    Jeremy

Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.