0001 function qtxt2qdf(host,database)
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019 params = mysql_login(struct('host',host,'database',database,'login_type','researcher'));
0020 conn_id = mysql_make_conn(params);
0021
0022
0023 mysql_str = sprintf('SELECT question_id, question_text FROM question;');
0024 [qid,qt] = mysql(conn_id,mysql_str);
0025
0026 nq = length(qid);
0027 for iq = 1:nq
0028 new_str = strrep(qt{iq},'"','\"');
0029
0030 mysql_str = sprintf(['SELECT heading FROM question_x_data_format WHERE ' ...
0031 'question_id="%d" AND subquestion="1";'], qid(iq));
0032 curr_str = mysql(conn_id,mysql_str);
0033 if ~isempty(curr_str)
0034 curr_str = curr_str{1};
0035 else
0036 curr_str = '';
0037 end
0038
0039 if isempty(curr_str)
0040 mysql_str = sprintf(['UPDATE question_x_data_format SET question_x_data_format.heading="%s" ' ...
0041 'WHERE question_id="%d" AND subquestion="1";'], new_str, qid(iq));
0042 dummy = mysql(conn_id,mysql_str);
0043 else
0044 fprintf('Did not overwrite existing text for question (%d): %s\n', qid(iq), curr_str);
0045 end
0046 end
0047
0048
0049 mysql(conn_id,'close');