Index: openacs-4/packages/survey/www/admin/process-response.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/survey/www/admin/process-response.tcl,v diff -u -r1.4 -r1.5 --- openacs-4/packages/survey/www/admin/process-response.tcl 1 Mar 2005 00:01:44 -0000 1.4 +++ openacs-4/packages/survey/www/admin/process-response.tcl 6 Nov 2013 07:33:54 -0000 1.5 @@ -25,7 +25,7 @@ } -validate { section_exists -requires { section_id } { - if ![db_0or1row section_exists {}] { + if {![db_0or1row section_exists {}]} { ad_complain "Section $section_id does not exist" } } @@ -59,23 +59,23 @@ # but first value for 'choice' abstract_data_type - see ad_page_contract # doc and code for more info. # - if { [exists_and_not_null response_to_question($question_id)] } { - if {$abstract_data_type != "choice"} { + if { ([info exists response_to_question($question_id)] && $response_to_question($question_id) ne "") } { + if {$abstract_data_type ne "choice"} { set response_to_question($question_id) [join $response_to_question($question_id)] } else { - if { [empty_string_p [lindex $response_to_question($question_id) 0 ] ] } { + if { [lindex $response_to_question($question_id) 0 ] eq "" } { set response_to_question($question_id) "" } } } - if { $abstract_data_type == "date" } { + if { $abstract_data_type eq "date" } { if [catch { set response_to_question($question_id) [validate_ad_dateentrywidget "" response_to_question.$question_id [ns_getform]]} errmsg] { ad_complain "$errmsg: Please make sure your dates are valid." } } - if { [exists_and_not_null response_to_question($question_id)] } { + if { ([info exists response_to_question($question_id)] && $response_to_question($question_id) ne "") } { set response_value [string trim $response_to_question($question_id)] } elseif {$required_p == "t"} { @@ -85,7 +85,7 @@ # it is not required to enter a file. Instead, the # file from the prior response will be used. - if { $abstract_data_type != "blob" || [empty_string_p $initial_response_id]} { + if { $abstract_data_type ne "blob" || $initial_response_id eq ""} { lappend questions_with_missing_responses $question_text continue } @@ -95,14 +95,14 @@ set response_value "" } - if {![empty_string_p $response_value]} { - if { $abstract_data_type == "number" } { + if {$response_value ne ""} { + if { $abstract_data_type eq "number" } { if { ![regexp {^(-?[0-9]+\.)?[0-9]+$} $response_value] } { ad_complain "The response to \"$question_text\" must be a number. Your answer was \"$response_value\"." continue } - } elseif { $abstract_data_type == "integer" } { + } elseif { $abstract_data_type eq "integer" } { if { ![regexp {^[0-9]+$} $response_value] } { ad_complain "The response to \"$question_text\" must be an integer. Your answer was \"$response_value\"." @@ -111,11 +111,11 @@ } } - if { $abstract_data_type == "blob" } { + if { $abstract_data_type eq "blob" } { set tmp_filename $response_to_question($question_id.tmpfile) set n_bytes [file size $tmp_filename] if { $n_bytes == 0 && $required_p == "t" && - [empty_string_p $initial_response_id]} { + $initial_response_id eq ""} { ad_complain "Your file is zero-length. Either you attempted to upload a zero length file, a file which does not exist, or something went wrong during the transfer." } @@ -139,7 +139,7 @@ survey_name:onerow } -ad_require_permission $survey_id survey_take_survey +permission::require_permission -object_id $survey_id -privilege survey_take_survey set user_id [ad_conn user_id] @@ -202,19 +202,19 @@ switch -- $abstract_data_type { "choice" { - if { $presentation_type == "checkbox" } { + if { $presentation_type eq "checkbox" } { # Deal with multiple responses. set checked_responses $response_to_question($question_id) foreach response_value $checked_responses { - if { [empty_string_p $response_value] } { + if { $response_value eq "" } { set response_value [db_null] } 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)" } } else { - if { [empty_string_p $response_value] || [empty_string_p [lindex $response_value 0]] } { + if { $response_value eq "" || [lindex $response_value 0] eq "" } { set response_value [db_null] } @@ -227,7 +227,7 @@ values (:response_id, :question_id, :response_value)" } "boolean" { - if { [empty_string_p $response_value] } { + if { $response_value eq "" } { set response_value [db_null] } @@ -236,14 +236,14 @@ } "integer" - "number" { - if { [empty_string_p $response_value] } { + if { $response_value eq "" } { set response_value [db_null] } 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)" } "text" { - if { [empty_string_p $response_value] } { + if { $response_value eq "" } { set response_value [db_null] } @@ -254,7 +254,7 @@ returning clob_answer into :1" -clobs [list $response_value] } "date" { - if { [empty_string_p $response_value] } { + if { $response_value eq "" } { set response_value [db_null] } @@ -263,7 +263,7 @@ } "blob" { - if { ![empty_string_p $response_value] } { + 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) @@ -274,7 +274,7 @@ 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] { + if {![regexp {([^/\\]+)$} $response_value match client_filename]} { # couldn't find a match set client_filename $response_value } @@ -293,7 +293,7 @@ } else { # There was no response. - if {![empty_string_p $initial_response_id]} { + if {$initial_response_id ne ""} { # There was a prior response # Get the revision_id for this question from the # prior question. @@ -313,7 +313,7 @@ } -if {[info exists return_url] && ![empty_string_p $return_url]} { +if {[info exists return_url] && $return_url ne ""} { ad_returnredirect "$return_url" ad_script_abort } else {