START TRANSACTION;
--
INSERT INTO `attribute` (`name`, `class`) VALUES('2afc_example', 'stim_set');
set @attribute_id = (SELECT `attribute_id` FROM `attribute` WHERE `name` = '2afc_example' ORDER BY `attribute_id` DESC LIMIT 1);
--
INSERT INTO `data_format` (`type`, `enum_values`) VALUES('enum', '"same","different"');
set @data_format_id = (SELECT `data_format_id` FROM `data_format` WHERE `type` = 'enum' AND `enum_values` LIKE '"same","different"' ORDER BY `data_format_id` DESC LIMIT 1);
--
INSERT INTO `experiment` (`start_date`, `experiment_title`, `experiment_description`, `response_table`, `irb_id`, `end_date`, `language`, `play_question_audio`, `encrypted_response_table`, `params`, `locked`) VALUES('2012-12-01', '2AFC example', 'Example 2AFC task using trials', 'response_2afc_example', NULL, NULL, 'english', 'F', 'F', 'question_numbering=by_form,progress_report=off', 'F');
set @experiment_id = (SELECT `experiment_id` FROM `experiment` WHERE `experiment_title` = '2AFC example' ORDER BY `experiment_id` DESC LIMIT 1);
--
INSERT INTO `form` (`form_name`, `form_category`, `header`, `footer`, `header_audio_path`, `footer_audio_path`, `version`, `locked`, `condition`, `condition_matlab`, `visit_once`) VALUES('2AFC_example_trial_present_stimuli', 'experiment specific', 'You will hear 2 sounds in succession. After the sounds finish, you will be asked to choose whether the sounds were the same or different.', NULL, NULL, NULL, 1, 'F', NULL, NULL, 'F');
set @form_id = (SELECT `form_id` FROM `form` WHERE `form_name` = '2AFC_example_trial_present_stimuli' ORDER BY `form_id` DESC LIMIT 1);
--
-- forms with names "start_session" and "end_session" are required
set @start_session_form_id = (SELECT `form_id` FROM `form` WHERE `form_name` = 'start_session' ORDER BY `form_id` DESC LIMIT 1);
set @end_session_form_id = (SELECT `form_id` FROM `form` WHERE `form_name` = 'end_session' ORDER BY `form_id` DESC LIMIT 1);
INSERT INTO `experiment_x_form` (`experiment_id`, `form_id`, `form_order`, `form_handler`, `goto`, `repeat`, `condition`, `condition_matlab`, `stimulus_matlab`, `break_loop_button`, `break_loop_button_text`) VALUES(@experiment_id, @start_session_form_id, 1, 'form_start_session.php', NULL, NULL, NULL, NULL, NULL, 'F', NULL);
INSERT INTO `experiment_x_form` (`experiment_id`, `form_id`, `form_order`, `form_handler`, `goto`, `repeat`, `condition`, `condition_matlab`, `stimulus_matlab`, `break_loop_button`, `break_loop_button_text`) VALUES(@experiment_id, @form_id, 2, 'form_2_stim_trial.php', 2, 999, NULL, NULL, 'two_afc_select_basic(''params'',''two_afc_globals'')', 'F', NULL);
INSERT INTO `experiment_x_form` (`experiment_id`, `form_id`, `form_order`, `form_handler`, `goto`, `repeat`, `condition`, `condition_matlab`, `stimulus_matlab`, `break_loop_button`, `break_loop_button_text`) VALUES(@experiment_id, @end_session_form_id, 3, 'form_end_session.php', NULL, NULL, NULL, NULL, NULL, 'F', NULL);
--
-- define the question
INSERT INTO `question` (`question_text`, `question_category`, `heading_format`, `locked`) VALUES('Were those sounds the same or different?', 'experiment specific', 'single_quest', 'T');
-- set @question_id = SELECT LAST_INSERT_ID();
set @question_id = (SELECT `question_id` FROM `question` WHERE `question_text` = 'Were those sounds the same or different?' AND `question_category` = 'experiment specific' AND `heading_format` = 'single_quest' AND `locked` = 'T' ORDER BY `question_id` DESC LIMIT 1);
INSERT INTO `question_x_data_format` (`question_id`, `subquestion`, `answer_format_id`, `heading`, `range`, `default`, `html_field_type`, `audio_path`, `required`) VALUES(@question_id, 1, @data_format_id, NULL, NULL, NULL, 'radiogroup', NULL, 'T');
set @qdf_id = (SELECT `qdf_id` FROM `question_x_data_format` WHERE `question_id` = @question_id AND `subquestion` = 1 AND `answer_format_id` = @data_format_id ORDER BY `qdf_id` DESC LIMIT 1);
--
-- link the question to the form
INSERT INTO `form_x_question` (`form_id`, `question_id`, `question_iteration`, `form_question_num`) VALUES(@form_id, @question_id, 1, 1);
--
-- define the stimuli
INSERT INTO `stimulus` (`name`, `description`, `playlist`, `artist`, `album`, `genre`, `file_format`, `size`, `duration`, `year`, `compression_bit_rate`, `sample_rate`, `sample_size`, `channels`, `width`, `height`, `location`) VALUES('290sin_500ms.wav', '2afc_example', NULL, NULL, NULL, NULL, 'wav', NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0, 0, '/audio/2afc_example/290sin_500ms.wav');
set @stimulus_id_1 = (SELECT `stimulus_id` FROM `stimulus` WHERE `name` = '290sin_500ms.wav' ORDER BY `stimulus_id` DESC LIMIT 1);
INSERT INTO `stimulus` (`name`, `description`, `playlist`, `artist`, `album`, `genre`, `file_format`, `size`, `duration`, `year`, `compression_bit_rate`, `sample_rate`, `sample_size`, `channels`, `width`, `height`, `location`) VALUES('292sin_500ms.wav', '2afc_example', NULL, NULL, NULL, NULL, 'wav', NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0, 0, '/audio/2afc_example/292sin_500ms.wav');
set @stimulus_id_2 = (SELECT `stimulus_id` FROM `stimulus` WHERE `name` = '292sin_500ms.wav' ORDER BY `stimulus_id` DESC LIMIT 1);
INSERT INTO `stimulus` (`name`, `description`, `playlist`, `artist`, `album`, `genre`, `file_format`, `size`, `duration`, `year`, `compression_bit_rate`, `sample_rate`, `sample_size`, `channels`, `width`, `height`, `location`) VALUES('294sin_500ms.wav', '2afc_example', NULL, NULL, NULL, NULL, 'wav', NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0, 0, '/audio/2afc_example/294sin_500ms.wav');
set @stimulus_id_3 = (SELECT `stimulus_id` FROM `stimulus` WHERE `name` = '294sin_500ms.wav' ORDER BY `stimulus_id` DESC LIMIT 1);
INSERT INTO `stimulus` (`name`, `description`, `playlist`, `artist`, `album`, `genre`, `file_format`, `size`, `duration`, `year`, `compression_bit_rate`, `sample_rate`, `sample_size`, `channels`, `width`, `height`, `location`) VALUES('296sin_500ms.wav', '2afc_example', NULL, NULL, NULL, NULL, 'wav', NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0, 0, '/audio/2afc_example/296sin_500ms.wav');
set @stimulus_id_4 = (SELECT `stimulus_id` FROM `stimulus` WHERE `name` = '296sin_500ms.wav' ORDER BY `stimulus_id` DESC LIMIT 1);
INSERT INTO `stimulus` (`name`, `description`, `playlist`, `artist`, `album`, `genre`, `file_format`, `size`, `duration`, `year`, `compression_bit_rate`, `sample_rate`, `sample_size`, `channels`, `width`, `height`, `location`) VALUES('298sin_500ms.wav', '2afc_example', NULL, NULL, NULL, NULL, 'wav', NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0, 0, '/audio/2afc_example/298sin_500ms.wav');
set @stimulus_id_5 = (SELECT `stimulus_id` FROM `stimulus` WHERE `name` = '298sin_500ms.wav' ORDER BY `stimulus_id` DESC LIMIT 1);
INSERT INTO `stimulus` (`name`, `description`, `playlist`, `artist`, `album`, `genre`, `file_format`, `size`, `duration`, `year`, `compression_bit_rate`, `sample_rate`, `sample_size`, `channels`, `width`, `height`, `location`) VALUES('300sin_500ms.wav', '2afc_example', NULL, NULL, NULL, NULL, 'wav', NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0, 0, '/audio/2afc_example/300sin_500ms.wav');
set @stimulus_id_6 = (SELECT `stimulus_id` FROM `stimulus` WHERE `name` = '300sin_500ms.wav' ORDER BY `stimulus_id` DESC LIMIT 1);
-- define the trials
set @response_enum_same = 1;
set @response_enum_different = 2;
INSERT INTO `trial` (`stimulus_id1`, `stimulus_id2`, `question_id`, `data_format_id`, `correct_response_enum`, `correct_response_text`) VALUES(@stimulus_id_1, @stimulus_id_1, @question_id, @data_format_id, @response_enum_same, NULL);
set @trial_id = (SELECT `trial_id` FROM `trial` WHERE `stimulus_id1` = @stimulus_id_1 AND `stimulus_id2` = @stimulus_id_1 AND `question_id` = @question_id ORDER BY `trial_id` DESC LIMIT 1);
INSERT INTO `trial_x_attribute` (`trial_id`, `attribute_id`, `attribute_value_double`, `attribute_value_text`) VALUES(@trial_id, @attribute_id, NULL, NULL);
--
INSERT INTO `trial` (`stimulus_id1`, `stimulus_id2`, `question_id`, `data_format_id`, `correct_response_enum`, `correct_response_text`) VALUES(@stimulus_id_1, @stimulus_id_2, @question_id, @data_format_id, @response_enum_different, NULL);
set @trial_id = (SELECT `trial_id` FROM `trial` WHERE `stimulus_id1` = @stimulus_id_1 AND `stimulus_id2` = @stimulus_id_2 AND `question_id` = @question_id ORDER BY `trial_id` DESC LIMIT 1);
INSERT INTO `trial_x_attribute` (`trial_id`, `attribute_id`, `attribute_value_double`, `attribute_value_text`) VALUES(@trial_id, @attribute_id, NULL, NULL);
--
INSERT INTO `trial` (`stimulus_id1`, `stimulus_id2`, `question_id`, `data_format_id`, `correct_response_enum`, `correct_response_text`) VALUES(@stimulus_id_1, @stimulus_id_3, @question_id, @data_format_id, @response_enum_different, NULL);
set @trial_id = (SELECT `trial_id` FROM `trial` WHERE `stimulus_id1` = @stimulus_id_1 AND `stimulus_id2` = @stimulus_id_3 AND `question_id` = @question_id ORDER BY `trial_id` DESC LIMIT 1);
INSERT INTO `trial_x_attribute` (`trial_id`, `attribute_id`, `attribute_value_double`, `attribute_value_text`) VALUES(@trial_id, @attribute_id, NULL, NULL);
--
INSERT INTO `trial` (`stimulus_id1`, `stimulus_id2`, `question_id`, `data_format_id`, `correct_response_enum`, `correct_response_text`) VALUES(@stimulus_id_1, @stimulus_id_4, @question_id, @data_format_id, @response_enum_different, NULL);
set @trial_id = (SELECT `trial_id` FROM `trial` WHERE `stimulus_id1` = @stimulus_id_1 AND `stimulus_id2` = @stimulus_id_4 AND `question_id` = @question_id ORDER BY `trial_id` DESC LIMIT 1);
INSERT INTO `trial_x_attribute` (`trial_id`, `attribute_id`, `attribute_value_double`, `attribute_value_text`) VALUES(@trial_id, @attribute_id, NULL, NULL);
--
INSERT INTO `trial` (`stimulus_id1`, `stimulus_id2`, `question_id`, `data_format_id`, `correct_response_enum`, `correct_response_text`) VALUES(@stimulus_id_1, @stimulus_id_5, @question_id, @data_format_id, @response_enum_different, NULL);
set @trial_id = (SELECT `trial_id` FROM `trial` WHERE `stimulus_id1` = @stimulus_id_1 AND `stimulus_id2` = @stimulus_id_5 AND `question_id` = @question_id ORDER BY `trial_id` DESC LIMIT 1);
INSERT INTO `trial_x_attribute` (`trial_id`, `attribute_id`, `attribute_value_double`, `attribute_value_text`) VALUES(@trial_id, @attribute_id, NULL, NULL);
--
INSERT INTO `trial` (`stimulus_id1`, `stimulus_id2`, `question_id`, `data_format_id`, `correct_response_enum`, `correct_response_text`) VALUES(@stimulus_id_1, @stimulus_id_6, @question_id, @data_format_id, @response_enum_different, NULL);
set @trial_id = (SELECT `trial_id` FROM `trial` WHERE `stimulus_id1` = @stimulus_id_1 AND `stimulus_id2` = @stimulus_id_6 AND `question_id` = @question_id ORDER BY `trial_id` DESC LIMIT 1);
INSERT INTO `trial_x_attribute` (`trial_id`, `attribute_id`, `attribute_value_double`, `attribute_value_text`) VALUES(@trial_id, @attribute_id, NULL, NULL);
--
INSERT INTO `trial` (`stimulus_id1`, `stimulus_id2`, `question_id`, `data_format_id`, `correct_response_enum`, `correct_response_text`) VALUES(@stimulus_id_2, @stimulus_id_1, @question_id, @data_format_id, @response_enum_different, NULL);
set @trial_id = (SELECT `trial_id` FROM `trial` WHERE `stimulus_id1` = @stimulus_id_2 AND `stimulus_id2` = @stimulus_id_1 AND `question_id` = @question_id ORDER BY `trial_id` DESC LIMIT 1);
INSERT INTO `trial_x_attribute` (`trial_id`, `attribute_id`, `attribute_value_double`, `attribute_value_text`) VALUES(@trial_id, @attribute_id, NULL, NULL);
--
INSERT INTO `trial` (`stimulus_id1`, `stimulus_id2`, `question_id`, `data_format_id`, `correct_response_enum`, `correct_response_text`) VALUES(@stimulus_id_2, @stimulus_id_2, @question_id, @data_format_id, @response_enum_same, NULL);
set @trial_id = (SELECT `trial_id` FROM `trial` WHERE `stimulus_id1` = @stimulus_id_2 AND `stimulus_id2` = @stimulus_id_2 AND `question_id` = @question_id ORDER BY `trial_id` DESC LIMIT 1);
INSERT INTO `trial_x_attribute` (`trial_id`, `attribute_id`, `attribute_value_double`, `attribute_value_text`) VALUES(@trial_id, @attribute_id, NULL, NULL);
--
INSERT INTO `trial` (`stimulus_id1`, `stimulus_id2`, `question_id`, `data_format_id`, `correct_response_enum`, `correct_response_text`) VALUES(@stimulus_id_2, @stimulus_id_3, @question_id, @data_format_id, @response_enum_different, NULL);
set @trial_id = (SELECT `trial_id` FROM `trial` WHERE `stimulus_id1` = @stimulus_id_2 AND `stimulus_id2` = @stimulus_id_3 AND `question_id` = @question_id ORDER BY `trial_id` DESC LIMIT 1);
INSERT INTO `trial_x_attribute` (`trial_id`, `attribute_id`, `attribute_value_double`, `attribute_value_text`) VALUES(@trial_id, @attribute_id, NULL, NULL);
--
INSERT INTO `trial` (`stimulus_id1`, `stimulus_id2`, `question_id`, `data_format_id`, `correct_response_enum`, `correct_response_text`) VALUES(@stimulus_id_2, @stimulus_id_4, @question_id, @data_format_id, @response_enum_different, NULL);
set @trial_id = (SELECT `trial_id` FROM `trial` WHERE `stimulus_id1` = @stimulus_id_2 AND `stimulus_id2` = @stimulus_id_4 AND `question_id` = @question_id ORDER BY `trial_id` DESC LIMIT 1);
INSERT INTO `trial_x_attribute` (`trial_id`, `attribute_id`, `attribute_value_double`, `attribute_value_text`) VALUES(@trial_id, @attribute_id, NULL, NULL);
--
INSERT INTO `trial` (`stimulus_id1`, `stimulus_id2`, `question_id`, `data_format_id`, `correct_response_enum`, `correct_response_text`) VALUES(@stimulus_id_2, @stimulus_id_5, @question_id, @data_format_id, @response_enum_different, NULL);
set @trial_id = (SELECT `trial_id` FROM `trial` WHERE `stimulus_id1` = @stimulus_id_2 AND `stimulus_id2` = @stimulus_id_5 AND `question_id` = @question_id ORDER BY `trial_id` DESC LIMIT 1);
INSERT INTO `trial_x_attribute` (`trial_id`, `attribute_id`, `attribute_value_double`, `attribute_value_text`) VALUES(@trial_id, @attribute_id, NULL, NULL);
--
INSERT INTO `trial` (`stimulus_id1`, `stimulus_id2`, `question_id`, `data_format_id`, `correct_response_enum`, `correct_response_text`) VALUES(@stimulus_id_2, @stimulus_id_6, @question_id, @data_format_id, @response_enum_different, NULL);
set @trial_id = (SELECT `trial_id` FROM `trial` WHERE `stimulus_id1` = @stimulus_id_2 AND `stimulus_id2` = @stimulus_id_6 AND `question_id` = @question_id ORDER BY `trial_id` DESC LIMIT 1);
INSERT INTO `trial_x_attribute` (`trial_id`, `attribute_id`, `attribute_value_double`, `attribute_value_text`) VALUES(@trial_id, @attribute_id, NULL, NULL);
--
COMMIT;
