Forum Replies Created
-
AuthorPosts
-
mawilson
ParticipantI ended up figuring something out; here’s the code I used in case it’s of use to anyone else.
PennController.ResetPrefix(null) Sequence( 'example', SendResults() ) Template('example.csv', item => { var sentence = item.sentence.split(' ') var s_array = [] for (var word of sentence) { word = word.replace(' ', ' ') s_array.push(word) } sentence = s_array return [ 'example', 'DashedSentence', {s: sentence, display: 'in place'} ] })
The basic idea is to modify the item prior to running each trial. I split the sentence on spaces (which won’t split the literal
). Replace the
s with actual spaces, and then pass that array to the controller instead of the sentence stored in the csv.mawilson
ParticipantAh, that’d be it—I’ve changed institutions and hadn’t updated the email address. Thank you!
mawilson
ParticipantAh, I see. Thanks for the info!
I don’t think I’m on the mailing list; would it be possible for me to sign up for it so I can get these announcements directly? I can’t seem to find anything on the main site (but I could well be missing something).
-
This reply was modified 2 years, 5 months ago by
mawilson.
mawilson
ParticipantThank you!
mawilson
ParticipantOh, forgot to add: I’m using whatever version of PennController is currently on the PCIbex Farm (which I think is 1.9).
September 14, 2022 at 5:32 pm in reply to: Running into JS error with MouseTracker when trials have different names #8408mawilson
ParticipantOkay, so after some testing I’ve been able to pare this issue down to what I think is the bare minimum. Using end() in a trial with a MouseTracker before the MouseTracker is initialized causes the script to freeze with the error above in the JavaScript console. Here’s a much more minimal example that shows the problem (link same as before, https://farm.pcibex.net/r/BtxkDp/):
PennController.ResetPrefix(null) // Shorten command names (keep this line here) Sequence('trial') newTrial('trial', newText('').log(), // this is just so there's a result to send, otherwise it spins forever end(), newMouseTracker('mouse') // comment out this line, or put it before end(), and it works )
-
This reply was modified 2 years, 7 months ago by
mawilson. Reason: code formatting
mawilson
ParticipantI’ve realized how to deal with my case; it’s actually pretty easy since JavaScript lets you use addition to concatenate variables of different types.
newVar('grandaveragepercent') .set(getVar('grandaverage')) .set(v => Math.round(v * 100) + '%.')
Then just display the text as before, minus the
.after(newText('%.'))
.(I’d still be curious how this would work if I had two text variables I wanted to concatenate, since IIRC the way variables work in PCIbex wouldn’t just let you do
getVar('mytextvariable1') + getVar('mytextvariable2')
.)mawilson
ParticipantThank you for the help—this is working great now!
mawilson
ParticipantPerfect—thank you so much!
mawilson
ParticipantNevermind; I figured out how to do this. I’ll post it in case anyone else comes across a similar issue.
Template("practice.csv", variable => { var word = variable['word_' + Math.floor(Math.random() * 12)]; return newTrial("trial_prac", // ... whatever else you want here newText("word", word) // ... whatever else you want here ).log("word", word) })
July 20, 2022 at 2:02 pm in reply to: Placing elements of unknown width in sequence in a canvas #8287mawilson
ParticipantThank you! It’s working great now!
July 20, 2022 at 12:17 pm in reply to: Side-by-side buttons in a selector that is removed after selection #8283mawilson
ParticipantThank you for the help!
October 1, 2020 at 11:56 am in reply to: Can counterOverride be used instead of URL parameter? #6183mawilson
ParticipantThanks! It does appear to be working. I just wasn’t sure if it would since the groups are set a bit differently than in base Ibex.
September 22, 2020 at 1:48 pm in reply to: Enabling a button after text is entered without pressing Enter #6155mawilson
ParticipantThis is probably similar enough to fit in this thread, but is there a way to do this for a checkbox (i.e., only enable the button when the checkbox is selected). This one is more crucial since it’s for an HTML consent form, and I want to make absolutely sure people can’t get past the form unless the box saying they consent is checked.
September 21, 2020 at 4:41 pm in reply to: Enabling a button after text is entered without pressing Enter #6150mawilson
ParticipantNo worries! Thank you for all the help!
-
This reply was modified 2 years, 5 months ago by
-
AuthorPosts