Skip to content

Instantly share code, notes, and snippets.

@kishiyamat
Last active October 12, 2023 20:31
Show Gist options
  • Save kishiyamat/df3cbb3c2d2dc58b626112bdc1a3913a to your computer and use it in GitHub Desktop.
Save kishiyamat/df3cbb3c2d2dc58b626112bdc1a3913a to your computer and use it in GitHub Desktop.
PennController.ResetPrefix(null); // Shorten command names (keep this line here))
// DebugOff() // Uncomment this line only when you are 100% done designing your experiment
// NOTE: Empty project からではなく Self-Paced Reading を選択してから作業する
// これは PennController.js が機能しないため。もしEmptyから作成したい場合、以下をDLしてULする。
// https://github.com/PennController/penncontroller/blob/master/releases/2.0/PennController.js
// First show instructions, then experiment trials, send results and show end screen
Sequence("instructions", "experiment", SendResults(), "end")
// This is run at the beginning of each trial
// Declare a global Var element "ID" in which we will store the participant's ID
Header(newVar("ID").global())
.log("id", getVar("ID")) // Add the ID to all trials' results lines
// Instructions
newTrial("instructions",
// Automatically print all Text elements, centered (これは大事)
defaultText.center().print(),
// 表示させる内容
newText("Welcome!"+"<br>"+
"In this task, you will have to read few sentences."+"<br>"+
"Are you ready?"+"<br>"+
"Please type in your ID below and then click on the Start button "+
"to start the experiment."),
// Save ID -> Validate -> Store
newTextInput("inputID", "").center().print(),
// Only validate a click on Start when inputID has been filled
newButton("Start").center().print().wait(getTextInput("inputID").testNot.text("")),
// Store the text from inputID into the Var element in global scope
getVar("ID").set(getTextInput("inputID"))
)
// First experiment trial
newTrial("experiment",
newController(
"DashedSentence",
{s: "You have just begun reading the sentence you have just finished reading."})
.print().log().wait().remove(),
// Make sure to log the participant's progress
newButton("Next sentence please!").print().wait()
)
// Second, more concise experiment trial
newTrial("experiment",
newController(
"DashedSentence",
{s : "Time flies like an arrow, but fruit flies like a banana."})
.print().log().wait().remove(),
newButton("I'm done")
.print().wait()
)
// Final screen
newTrial("end",
newText("Thank you for your participation!").center().print(),
// This link a placeholder: replace it with a URL provided by your participant-pooling platform
// newText("<p><a href='https://www.pcibex.net/' target='_blank'>" +
// "Click here to validate your submission</a></p>").center().print(),
// Trick: stay on this trial forever (until tab is closed)
newButton().wait()
)
.setOption("countsForProgressBar",false)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment