var group1question1={ //plugin code goes here };
var group1question2={ //plugin code goes here };
var group1question3={ //plugin code goes here };
var group2question1={ //plugin code goes here };
var group2question2={ //plugin code goes here };
var group2question3={ //plugin code goes here };
var group3question1={ //plugin code goes here };
var group3question2={ //plugin code goes here };
var group3question3={ //plugin code goes here };
var group4question1={ //plugin code goes here };
var group4question2={ //plugin code goes here };
var group4question3={ //plugin code goes here };--
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/d3e927bb-acea-4e0c-a764-ed52963b209c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
/**
* jspsych-survey-text
* a jspsych plugin for free response survey questions
*
* Josh de Leeuw
*
* documentation: docs.jspsych.org
*
*/
var focused_box
jsPsych.plugins['survey-text'] = (function() {
var plugin = {};
plugin.trial = function(display_element, trial) {
trial.preamble = typeof trial.preamble == 'undefined' ? "" : trial.preamble;
if (typeof trial.rows == 'undefined') {
trial.rows = [];
for (var i = 0; i < trial.questions.length; i++) {
trial.rows.push(1);
}
}
if (typeof trial.columns == 'undefined') {
trial.columns = [];
for (var i = 0; i < trial.questions.length; i++) {
trial.columns.push(40);
}
}
// Default value for time limit option
trial.timing_response = trial.timing_response || -1;
// Time handlers
var setTimeoutHandlers = [];
// if any trial variables are functions
// this evaluates the function and replaces
// it with the output of the function
trial = jsPsych.pluginAPI.evaluateFunctionParameters(trial);
// show preamble text
display_element.append($('<div>', {
"id": 'jspsych-survey-text-preamble',
"class": 'jspsych-survey-text-preamble'
}));
$('#jspsych-survey-text-preamble').html(trial.preamble);
// add questions
for (var i = 0; i < trial.questions.length; i++) {
// create div
display_element.append($('<div>', {
"id": 'jspsych-survey-text-' + i,
"class": 'jspsych-survey-text-question'
}));
// add question text
$("#jspsych-survey-text-" + i).append('<p class="jspsych-survey-text">' + trial.questions[i] + '</p>');
// add text box
//$("#jspsych-survey-text-" + i).append('<textarea name="#jspsych-survey-text-response-' + i + '" cols="' + trial.columns[i] + '" rows="' + trial.rows[i] + '"></textarea>'); //original
focused_box = $("#jspsych-survey-text-" + i).append('<textarea name="#jspsych-survey-text-response-' + i + '" cols="' + trial.columns[i] + '" rows="' + trial.rows[i] + '"></textarea>');
}
// add submit button
display_element.append($('<button>', {
'id': 'jspsych-survey-text-next',
'class': 'jspsych-btn jspsych-survey-text'
}));
$("#jspsych-survey-text-next").html('Submit Answers');
$("#jspsych-survey-text-next").click(function() {
// measure response time
var endTime = (new Date()).getTime();
var response_time = endTime - startTime;
// create object to hold responses
var question_data = {};
var obje;
$("div.jspsych-survey-text-question").each(function(index) {
var id = "Q" + index;
var val = $(this).children('textarea').val();
console.log('val is: '+val);
var obje = {};
obje[id] = val;
console.log('obje is: '+val);
$.extend(question_data, obje);
});
var trialdata = {
"rt": response_time,
"responses": JSON.stringify(question_data)
};
display_element.html('');
// next trial
jsPsych.finishTrial(trialdata);
});
var end_trial = function() {
var endTime = (new Date()).getTime();
var response_time = endTime - startTime;
// kill any remaining setTimeout handlers
for (var i = 0; i < setTimeoutHandlers.length; i++) {
clearTimeout(setTimeoutHandlers[i]);
}
// kill keyboard listeners
if (typeof keyboardListener !== 'undefined') {
jsPsych.pluginAPI.cancelKeyboardResponse(keyboardListener);
}
// gather the data to store for the trial
var trial_data = {
"rt": response_time
};
//jsPsych.data.write(trial_data);
// clear the display
display_element.html('');
// move on to the next trial
jsPsych.finishTrial(trial_data);
};
var startTime = (new Date()).getTime();
if (trial.timing_response > 0) {
var t2 = setTimeout(function() {
end_trial();
}, trial.timing_response);
setTimeoutHandlers.push(t2);
}
};
return plugin;
})();To view this discussion on the web visit https://groups.google.com/d/msgid/jspsych/46fccb11-b4b5-49b7-a47b-d9140dfd86cd%40googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jspsych/92b637bd-ad83-4a92-9948-0b7272e2e098%40googlegroups.com.