0) { array_multisort($query_qod,SORT_ASC,$query_qoo,SORT_ASC,$query_qid,SORT_ASC,$query_qfh,SORT_ASC,$query_stimselect,SORT_ASC,$query_goto,SORT_ASC,$query_repeat,SORT_ASC,$query_newfm,SORT_ASC,$query_bkloop,SORT_ASC); for($num = 1 ; $num <= sizeof($query_qid);$num++) { //if we are swapping order nums (old_form_order !=num), make sure we are not swapping //identical forms. If we try to do this, a duplicate key sql error will show up $duplicate_exists = 0; if($num != $query_qoo[$num-1]) { $sql_check_duplicate = sprintf("select * from experiment_x_form where experiment_id=%d",$_POST['experiment_id']). sprintf(" and form_id=%d and form_order=%d",$query_qid[$num-1],$num); mysql_select_db($database_researcher, $researcher); $check_duplicate = mysql_query($sql_check_duplicate,$researcher) or die(mysql_error()); $duplicate_exists = mysql_num_rows($check_duplicate); } if($duplicate_exists == 0) { //find the key of the form that the goto points to and update goto to point to its new form order. $new_goto_key = array_keys($query_qoo,$query_goto[$num-1]); if($new_goto_key != FALSE) $new_goto = $query_qod[$new_goto_key[0]]; else $new_goto = NULL; $update_query = sprintf("UPDATE experiment_x_form SET form_order=%d, form_handler='%s', form_id=%d,",$num,$query_qfh[$num-1],$query_newfm[$num-1]). sprintf(" `stimulus_matlab`=%s, ",GetSQLValueString($query_stimselect[$num-1], "text")). sprintf(" goto=%s, `repeat`=%s, break_loop_button ='%s' ",GetSQLValueString($new_goto,"int"),GetSQLValueString($query_repeat[$num-1],"int"),$query_bkloop[$num-1]). sprintf(" WHERE form_order=%d AND form_id=%d AND experiment_id=%d",$query_qoo[$num-1],$query_qid[$num-1],$_POST['experiment_id']); mysql_select_db($database_researcher, $researcher); mysql_query($update_query,$researcher) or die(mysql_error()); } } } } /************obtain all experiment info********************/ $query_experiment_info = sprintf("SELECT * FROM experiment WHERE experiment.experiment_id=%s", $_SESSION['editor_experiment_id']); $experiment_info = mysql_query($query_experiment_info, $researcher) or die(mysql_error()); $row_experiment_info = mysql_fetch_assoc($experiment_info); $totalRows_experiment_info = mysql_num_rows($experiment_info); $query_experiment_forms = sprintf("SELECT form.form_id,form.form_name,experiment_x_form.form_order,experiment_x_form.form_handler,"). sprintf("experiment_x_form.`stimulus_matlab`,"). sprintf("experiment_x_form.goto,experiment_x_form.`repeat`, experiment_x_form.break_loop_button"). sprintf(" FROM form,experiment_x_form WHERE form.form_id=experiment_x_form.form_id AND"). sprintf(" experiment_x_form.experiment_id=%s ORDER BY experiment_x_form.form_order", $_SESSION['editor_experiment_id']); $experiment_forms = mysql_query($query_experiment_forms, $researcher) or die(mysql_error()); $row_experiment_forms = mysql_fetch_assoc($experiment_forms); $totalRows_experiment_forms = mysql_num_rows($experiment_forms); $query_all_forms = "SELECT form_id,form_name FROM form order by form_name"; $all_forms = mysql_query($query_all_forms, $researcher) or die(mysql_error()); while($row_all_forms[] = mysql_fetch_assoc($all_forms)) //fetch all form info and put it into a 2D array. Rows= individual forms, Cols = field values of form table $totalRows_all_forms = mysql_num_rows($all_forms); $form_processing_contents = scandir($ENSEMBLE_QEI_QPI_DIR . "/form_processing"); foreach($form_processing_contents as $form_processing_file) { if(preg_match("/^form_.+$/",$form_processing_file)) $form_handler_options[] = $form_processing_file; } $total_form_handler_options = count($form_handler_options); //get all of the current form info for the experiment do { $form_orders[] = $row_experiment_forms['form_order']; $form_names[] = $row_experiment_forms['form_name']; $form_ids[] = $row_experiment_forms['form_id']; $form_handlers[] = $row_experiment_forms['form_handler']; $stimselects[] = $row_experiment_forms['stimulus_matlab']; $gotos[] = $row_experiment_forms['goto']; $repeats[] = $row_experiment_forms['repeat']; $break_loop_buttons[] = $row_experiment_forms['break_loop_button']; } while ($row_experiment_forms = mysql_fetch_assoc($experiment_forms)); // Look for theme support in the attribute table $query_all_themes = "SELECT name FROM attribute WHERE class='theme'"; $all_themes = mysql_query($query_all_themes, $researcher) or die(mysql_error()); $row_all_themes = array(); //fetch all themes and put names in 1D array while($row = mysql_fetch_array($all_themes)) { $row_all_themes[] = $row[0]; } /*************************************************************/ ?>
Experiment Editor |
if ($totalRows_experiment_info != 0) { ?>
\n"; ?> //only allow form additions if experiment isn't locked if($exp_lock['locked'] != 'T') { ?>
} //if($exp_lock['locked'] != 'T') ?> "; printf("