Reply To: html layout/event times/selector vs. scale/ compatibility

PennController for IBEX Forums Support html layout/event times/selector vs. scale/ compatibility Reply To: html layout/event times/selector vs. scale/ compatibility

#8226
Jeremy
Keymaster

Hi,

The more often you update the values of the Var elements, the less likely it is that participants see a message due to an outdated, empty Var element, so that reasoning would suggest to lower the value of 10. However, it’s quite unlikely that a participant would type any text and validate their answer in less than 10ms

It could be that execution is slowed down and the Timer is not actually run every 10ms but much less frequently. You could try using the javascript function window.requestAnimationFrame instead, which is optimized to execute loops:

Template("ansa_template.csv", row =>
  newTrial("ansa", 
    ...[...new Array(20)].map( (v,i) => newVar("ansa_"+Number(i+1),"").global() )
    ,
    newFunction( ()=>{
      const currentPennController = document.querySelector(".PennController-PennController");
      const checkBlanks = () => {
        document.querySelectorAll("textarea[name^='blank']")
          .forEach( (v,i) => getVar("ansa_"+Number(i+1)).set(v.value)._runPromises() );
        if (currentPennController == document.querySelector(".PennController-PennController"))
          window.requestAnimationFrame( checkBlanks );
      };
      checkBlanks();
    }).call()

Did you also double-check your tests on the Var element, and whether what the participant typed in the boxes is indeed supposed to satisfy those tests when they see the messages?

Jeremy