/********************************************************************************************************* "Ensemble" is the proprietary property of The Regents of the University of California ("The Regents.") Copyright (c) 2005-10 The Regents of the University of California, Davis campus. All Rights Reserved. Redistribution and use in source and binary forms, with or without modification, are permitted by nonprofit, research institutions for research use only, provided the conditions in the included license agreement are met. Refer to the file "ensemble_license.txt" for the license agreement, located in the top level directory of this distribution. **********************************************************************************************************/ // // This interface allows one to associate an audio file with a given question (question_id passed in as GET variable). // Normally linked from the question editor (question_list.php) // // Author(s): // 3/17/2010 - Stefan Tomic, First Version require_once('../include/researcher_includes.php'); ?>
");
//allow for either $_GET or $_POST methods
//the link from question_list.php passes question_id and subquestion as $_GET
//while file submission happens via $_POST
$question_id = (isset($_GET['question_id']))? $_GET['question_id'] : $_POST['question_id'];
$subquestion = (isset($_GET['subquestion']))? $_GET['subquestion'] : $_POST['subquestion'];
if(isset($_POST['edit_question_text'])) {
if($subquestion == 1)
$sql_update_question_text = sprintf("update question set question_text = '%s' where question_id=%d",$_POST['question_text'],$question_id);
else
$sql_update_question_text = sprintf("update question_x_data_format set heading = '%s' where question_id=%d and subquestion=%d",$_POST['question_text'],$question_id,$subquestion);
mysql_update($sql_update_question_text);
}
if(isset($_POST['submit_audio'])) {
$tmp_filename = $_FILES['audio_file']['tmp_name'];
$orig_name = $_FILES['audio_file']['name'];
$dotloc = strrpos($orig_name,".");
if(!$dotloc)
printf("Please submit a file with a valid filename extension.");
$extension = substr($orig_name,$dotloc+1);
$dest_fname = sprintf("questionID_%d_subquestion_%d.%s",$question_id,$subquestion,$extension);
$dest_fullpath = $question_audio_path . "/" . $dest_fname;
if(!is_uploaded_file($tmp_filename))
die("Error with file upload.");
$move_succeeded = move_uploaded_file($tmp_filename,$dest_fullpath);
if(!$move_succeeded)
die("Error moving file to destination");
chmod($dest_fullpath,0755);
$sql_add_audio_path = sprintf("update question_x_data_format set audio_path = \"%s\" where question_id=%d and subquestion=%d",
$dest_fname,$question_id,$subquestion);
mysql_update($sql_add_audio_path);
}
$sql_get_question_info = sprintf("select question_text, heading, heading_format, audio_path, locked from question left join question_x_data_format using (question_id) where question.question_id = %d and question_x_data_format.subquestion = %d",
$question_id,$subquestion);
$row_question_info = mysql_select($sql_get_question_info);
print "Question ID: "; print $question_id; print ", Subquestion " . $subquestion .""; print "Question Text:"; print ""; if ($subquestion == 1) print "\"" . $row_question_info['question_text'] ."\""; else print "\"" . $row_question_info['heading'] . "\""; if($row_question_info['locked'] != 'T') { printf(" \n\n"); } else print "(question text locked)"; print " "; printf(""); print " Audio Assigned:"; if(!empty($row_question_info['audio_path'])) { printf(" Yes "); printf("Click button to review: "); $quest_audio_url= $question_audio_url_dir . "/" . $row_question_info['audio_path']; $flashOptions['audio_player'] = "play_audio_button.swf"; $flashOptions['urls'][0] = $quest_audio_url; $flashOptions['width'] = 75; $flashOptions['height'] = 75; play_audio_stimuli_flash($flashOptions); } else { printf(" No"); } print " |
"; print ""; printf(" |