Index: openacs-4/packages/survey/www/process-response.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/survey/www/process-response.tcl,v diff -u -r1.19 -r1.20 --- openacs-4/packages/survey/www/process-response.tcl 12 Feb 2019 18:45:14 -0000 1.19 +++ openacs-4/packages/survey/www/process-response.tcl 3 Sep 2024 15:37:54 -0000 1.20 @@ -53,7 +53,7 @@ # in ad_page_contract. Because :multiple flag will sorround empty # strings and all multiword values with one level of curly braces {} # we need to get rid of them for almost any abstract_data_type - # except 'choice', where this is intended behaviour. Why bother + # except 'choice', where this is intended behavior. Why bother # with :multiple flag at all? Because otherwise we would lost all # but first value for 'choice' abstract_data_type - see ad_page_contract # doc and code for more info. @@ -77,8 +77,8 @@ set ok [ad_page_contract_filter_proc_date "date" date_value] if {$ok} { set response_to_question($question_id) [ns_buildsqldate $date_value(month) \ - $date_value(day) \ - $date_value(year)] + $date_value(day) \ + $date_value(year)] } else { ad_complain "Please make sure your dates are valid." } @@ -108,8 +108,8 @@ ad_complain "[_ survey.lt_The_response_to_ques_i]" continue - } } + } } if { $abstract_data_type eq "blob" } { @@ -143,7 +143,7 @@ set user_id [ad_conn user_id] -get_survey_info -survey_id $survey_id +survey::get_info -survey_id $survey_id set type $survey_info(type) set survey_id $survey_info(survey_id) set survey_name $survey_info(name) @@ -191,83 +191,83 @@ # Deal with multiple responses. set checked_responses $response_to_question($question_id) foreach response_value $checked_responses { - db_dml survey_question_response_checkbox_insert "insert into survey_question_responses (response_id, question_id, choice_id) - values (:response_id, :question_id, :response_value)" + values (:response_id, :question_id, :response_value)" } } else { + if { [lindex $response_value 0] eq "" } { + set response_value "" + } db_dml survey_question_response_choice_insert "insert into survey_question_responses (response_id, question_id, choice_id) - values (:response_id, :question_id, :response_value)" + values (:response_id, :question_id, :response_value)" } } "shorttext" { db_dml survey_question_choice_shorttext_insert "insert into survey_question_responses (response_id, question_id, varchar_answer) - values (:response_id, :question_id, :response_value)" + values (:response_id, :question_id, :response_value)" } "boolean" { db_dml survey_question_response_boolean_insert "insert into survey_question_responses (response_id, question_id, boolean_answer) - values (:response_id, :question_id, :response_value)" + values (:response_id, :question_id, :response_value)" } "integer" - "number" { db_dml survey_question_response_integer_insert "insert into survey_question_responses (response_id, question_id, number_answer) - values (:response_id, :question_id, :response_value)" + values (:response_id, :question_id, :response_value)" } "text" { - db_dml survey_question_response_text_insert " - insert into survey_question_responses - (response_id, question_id, clob_answer) - values (:response_id, :question_id, empty_clob()) - returning clob_answer into :1" -clobs [list $response_value] - } - "date" { +insert into survey_question_responses +(response_id, question_id, clob_answer) +values (:response_id, :question_id, empty_clob()) +returning clob_answer into :1" -clobs [list $response_value] + } + "date" { + db_dml survey_question_response_date_insert "insert into survey_question_responses (response_id, question_id, date_answer) +values (:response_id, :question_id, :response_value)" + } + "blob" { - db_dml survey_question_response_date_insert "insert into survey_question_responses (response_id, question_id, date_answer) - values (:response_id, :question_id, :response_value)" - } - "blob" { - - if { $response_value ne "" } { + if { $response_value ne "" } { # this stuff only makes sense to do if we know the file exists - set tmp_filename $response_to_question($question_id.tmpfile) + set tmp_filename $response_to_question($question_id.tmpfile) - set file_extension [string tolower [file extension $response_value]] - # remove the first . from the file extension - regsub {\.} $file_extension "" file_extension - set guessed_file_type [ns_guesstype $response_value] + set file_extension [string tolower [file extension $response_value]] + # remove the first . from the file extension + regsub {\.} $file_extension "" file_extension + set guessed_file_type [ns_guesstype $response_value] - set n_bytes [file size $tmp_filename] - # strip off the C:\directories... crud and just get the file name - if {![regexp {([^/\\]+)$} $response_value match client_filename]} { + set n_bytes [file size $tmp_filename] + # strip off the C:\directories... crud and just get the filename + if {![regexp {([^/\\]+)$} $response_value match client_filename]} { # couldn't find a match - set client_filename $response_value - } - if { $n_bytes == 0 } { - error "This should have been checked earlier." - } else { - set unique_name "${response_value}_${response_id}" - set mime_type [ns_guesstype $client_filename] - set revision_id [cr_import_content -title $client_filename "" $tmp_filename $n_bytes $mime_type $unique_name ] - # we use cr_import_content now --DaveB - # this abstracts out for use the blob handling for oracle or postgresql - # we are linking the file item_id to the survey_question_response attachment_answer field now + set client_filename $response_value + } + if { $n_bytes == 0 } { + error "This should have been checked earlier." + } else { + set unique_name "${response_value}_${response_id}" + set mime_type [ns_guesstype $client_filename] + set revision_id [cr_import_content -title $client_filename "" $tmp_filename $n_bytes $mime_type $unique_name ] +# we use cr_import_content now --DaveB +# this abstracts out for use the blob handling for oracle or postgresql +# we are linking the file item_id to the survey_question_response attachment_answer field now db_dml survey_question_response_attachment_insert " - insert into survey_question_responses - (response_id, question_id, attachment_answer) - values - (:response_id, :question_id, :revision_id - )" - } +insert into survey_question_responses +(response_id, question_id, attachment_answer) +values +(:response_id, :question_id, :revision_id + )" } } } } } +} - survey_do_notifications -response_id $response_id +survey::do_notifications -response_id $response_id } @@ -279,6 +279,10 @@ ad_return_template } + + + + # Local variables: # mode: tcl # tcl-indent-level: 4