Re: [jspsych] randomization + data

281 views
Skip to first unread message

Josh de Leeuw

unread,
Mar 8, 2015, 10:45:46 PM3/8/15
to Mansi Patel, jsp...@googlegroups.com
You could use the "data" parameter of the plugin to add information to the saved data. Since I'm not sure exactly how your experiment is set up, I don't know the best way for you to do this, but here is an example to hopefully get you headed in the right direction:

var questions = [
 {question_id: 1, prompt: 'This is the text of question 1.'},
 {question_id: 2, prompt: 'This is the text of question 2.'},
 {question_id: 3, prompt: 'This is the text of question 3.'}
];

var random_question = jsPsych.randomization.sample(questions, 1); // pick one question at random from the questions array

var trial = {
  type: 'survey-likert',
  questions: [[random_question.prompt]],
  // other parameters for the plugin...
  data: [{question_id: random_question.question_id}]
};

What the above code will do is record a field called 'question_id' with the data file. This would let you know exactly which question was asked.

--Josh

On Sun, Mar 8, 2015 at 7:50 PM, <mansip...@gmail.com> wrote:
Hi,

I am using jsPsych likert scale plugin with psiturk and I was wondering if I could get help with something:

So I'm debugging the experiment and for one I cannot say the datafiles (I previously asked this question in the psiturk google groups and it was suggested that I should cite out parts of the likert scale plugin to see if I can say the data. But that does not seem to work.)

The data is still saving in the database file so it is okay, however, when I randomize the question order, its saving in that random order and I have no way of identifying which questions it is that are appearing.

So I was wondering if there is a direction anyone can lead me in that would allow me to solve either of the problems.

Thanks,
Mansi

--
You received this message because you are subscribed to the Google Groups "jsPsych" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jspsych+u...@googlegroups.com.
To post to this group, send email to jsp...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jspsych/4e45a121-be8b-44ed-9e63-1d28a0f59554%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

mansip...@gmail.com

unread,
Mar 10, 2015, 3:06:49 PM3/10/15
to jsp...@googlegroups.com, mansip...@gmail.com
Hi Josh,

I have been trying this but it does not seem to work. The first question will appear normally but when I click submit the experiment ends.

I was thinking, an alternative could be to change the plugin file. The last bit of the code for saving the data is the following:

var question_data = {};
$("div.jspsych-survey-likert-slider").each(function(index) {
var id = "Q" + index;
var val = $(this).slider("value");
var obje = {};
obje[id] = val;
$.extend(question_data, obje);
});

What I am attempting to do is change "Q" so that it gives me the question instead of the letter Q. (eg. db file output = /Q/:2)
If I change it to "trial.questions[i]" instead I get the db file output to be something like /undefined/:2

Is there something else I can do in this respect that would allow me to see the question?

Thanks!

Josh de Leeuw

unread,
Mar 10, 2015, 3:19:54 PM3/10/15
to Mansi Patel, jsp...@googlegroups.com
Your idea for using trial.question[i] is a good one. My guess is that the problem is that the variable i is undefined (or some unexpected number) in the scope of that function. You could try using trial.questions[index] instead, since index is defined.

--
You received this message because you are subscribed to the Google Groups "jsPsych" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jspsych+u...@googlegroups.com.
To post to this group, send email to jsp...@googlegroups.com.

mansip...@gmail.com

unread,
Mar 10, 2015, 3:35:34 PM3/10/15
to jsp...@googlegroups.com, mansip...@gmail.com
Just to update, that worked! I replaced [i] with [index]. Also, if anyone needs to see the preamble a similar thing can be done with that as well:

var question_data = {};
$("div.jspsych-survey-likert-slider").each(function(index) {
var id = trial.questions[index] + trial.preamble[index];
var val = $(this).slider("value");
var obje = {};
obje[id] = val;
$.extend(question_data, obje);
});

Thanks for all the help!
Reply all
Reply to author
Forward
0 new messages