survsimp_answer_summary_display

one of the documented procedures in this installation of the ACS
Usage:
survsimp_answer_summary_display   db   response_id   { html_p "1" }   { category_id_list "" }
What it does:
Returns a string with the questions and answers. If html_p =t, the format will be html. Otherwise, it will be text. If a list of category_ids is provided, the questions will be limited to that set of categories.
Defined in: /web/philip/tcl/survey-simple-defs.tcl

Source code:



    set return_string ""

    if [empty_string_p $category_id_list] {
    set selection [ns_db select $db "select * 
from survsimp_questions, survsimp_question_responses
where  survsimp_question_responses.response_id = $response_id
and survsimp_questions.question_id = survsimp_question_responses.question_id
and survsimp_questions.active_p = 't'
order by sort_key"]
    } else {
    set selection [ns_db select $db "select survsimp_questions.*, 
survsimp_question_responses.*
from survsimp_questions, survsimp_question_responses, site_wide_category_map
where survsimp_question_responses.response_id = $response_id
and survsimp_questions.question_id = survsimp_question_responses.question_id
and survsimp_questions.active_p = 't'
and site_wide_category_map.on_which_table='survsimp_questions'
and site_wide_category_map.on_what_id = survsimp_questions.question_id
and site_wide_category_map.category_id in ([join $category_id_list " , "])
order by sort_key"]
    }

    set db2 [ns_db gethandle subquery]
    set question_id_previous ""

    while {[ns_db getrow $db $selection]} {
	set_variables_after_query
	if {$question_id == $question_id_previous} {
	    continue
	}

	if $html_p {
	    append return_string "<b>$question_text</b> 
	    <blockquote>"
	} else {
	    append return_string "$question_text:  "
	}
	append return_string "$clob_answer $number_answer $varchar_answer $date_answer"

	if {$choice_id != 0 && ![empty_string_p $choice_id] && $question_id != $question_id_previous} {
	    set label_list [database_to_tcl_list $db2 "select label
	from survsimp_question_choices, survsimp_question_responses
where survsimp_question_responses.question_id = $question_id
and survsimp_question_responses.response_id = $response_id
and survsimp_question_choices.choice_id = survsimp_question_responses.choice_id"]
            append return_string "[join $label_list ", "]"
        }

	if ![empty_string_p $boolean_answer] {
	    append return_string "[ad_decode $boolean_answer "t" "True" "False"]"
	 
	}

	if $html_p {
	    append return_string "</blockquote>
	    <P>"
	} else {
	    append return_string "\n\n"
	}

	set question_id_previous $question_id
    }
    ns_db releasehandle $db2
    return "$return_string"


philg@mit.edu