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

#7976
HPI
Participant

Hi,
thank you for your help with writing several operations after a success. It worked.
The only thing that took me a while, some try-fail rounds, is the setting of a variable as a definite value (different from 0, and when calling it with “getVar”)
I wanted to mark whether each trial was correctly answered so I wanted to assign a 1 when it was correct, and a 0 when the response was not correct and I was writing
success( getVar(“score”).set( v=> 1 ). This wouldn’t work, it worked at the end writing set(1). I thought this syntax was used only in the definition of a variable. But I got it.

And I thought such a counter would appear as a row in the results after the selection of the response, but I managed to log it at the end so it appears attached as a column.

So this is solved. Many thanks!

————————

I have to add after the experiment a small test for language proficiency.
This text is called C-test. There is a text like a piece I show here underneath:

“It was so easy to get lost in an ancient building”

That appears to the participants with parts of the words missing:

“It was so ea__ to get lost in an anc__ buil____”

The participant has to fill the gaps.

This type of text has been already implemented on ibex in my university, but with the old Ibex syntax, and I have all my exp in the new syntax, so I would like to adjust the script in the old Ibex to add it to my script with the new syntax.

There is a function written previously that I don’t know if it exists already in Pcibex, or if I have to add it to my script, in that case, I wanted to double-check with you if it’s ok to declare it in this way.

function blank(a, b) {
  var sentence = b ? b : a;
   var n = b ? a : null;

   var seq = [""];
   var inBlank = false;
  for (var i = 0; i < sentence.length; ++i) {
      var c = sentence.charAt(i)
      if (inBlank) {
           if (c == '_')
               (seq[seq.length])++;
          else {
               seq.push(c);
               inBlank = true;
           }
       }
       else {
           if (c != '_')
               seq[seq.length-1] += c
          else {
               seq.push(1);
               inBlank = true;
           }
       }
   }

Then the text is called like this:

["blank", "Form", blank(""It was so ea__ to get lost in an anc__ buil____"")],

The texts are obviously not composed just by one sentence but by many in sequence.

Questions:

Can I add the function written in this way on top of my script that uses only the new syntax? Should I rewrite the function? I am not sure I have found the documentation on the syntax in the new pcIbex.

Then I guess I have to make a template in which each text corresponds to a variable, so if it has to appear all in one screen to the participants, if I write it first in excel, each full text should stay in a single cell.

Then how should I call in the function “blank” to operate on the texts?

Thank you for your help and for answering my thousands questions!

HPI