Home > database > incomplete > mysql_get_responses.m

mysql_get_responses

PURPOSE ^

SYNOPSIS ^

function responses = mysql_get_responses(subject_id,response_table)

DESCRIPTION ^

 Join the form, question, and data format records to all of the responses from a given subject in a response table
 This creates a master response matrix with all the data entered by the subject and corresponding questions and question types 
 Function was originally written to see how many joins were necessary to obtain all possible data for the responses
 In a real situation, only a part of this query will likely be needed.

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function responses = mysql_get_responses(subject_id,response_table)
0002 %
0003 % Join the form, question, and data format records to all of the responses from a given subject in a response table
0004 % This creates a master response matrix with all the data entered by the subject and corresponding questions and question types
0005 % Function was originally written to see how many joins were necessary to obtain all possible data for the responses
0006 % In a real situation, only a part of this query will likely be needed.
0007 
0008 % 01/04/07 PJ - flagged incomplete because length of responses has to be
0009 % dynamic to accommodate changing numbers of fields in response table
0010 
0011 
0012 query_responses =  ['select * from  ' response_table ' ' ...
0013       'left join `form` on (form.form_id = ' response_table '.form_id) ' ...
0014       'left join form_x_question on (form_x_question.form_id = form.form_id and ' ...
0015       'form_x_question.question_iteration = ' response_table '.question_iteration and ' ...
0016       'form_x_question.form_question_num = ' response_table '.form_question_num) ' ...
0017       'left join question on (question.question_id = form_x_question.question_id) ' ...
0018       'left join question_x_data_format on (question_x_data_format.question_id = question.question_id and ' ...
0019       'question_x_data_format.subquestion = ' response_table '.subquestion) ' ...
0020       'left join data_format on (data_format.data_format_id = question_x_data_format.answer_format_id) ' ...
0021       'where ' response_table '.subject_id = ''' subject_id ''' ' ...
0022       'order by ' response_table '.form_order, form_x_question.form_question_num']
0023                   
0024 [responses{1:41}] = mysql(query_responses)
0025                  
0026 return

Generated on Wed 20-Sep-2023 04:00:50 by m2html © 2003