Index: openacs-4/contrib/packages/survey/sql/oracle/survey-create.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/survey/sql/oracle/Attic/survey-create.sql,v diff -u -r1.1 -r1.1.2.1 --- openacs-4/contrib/packages/survey/sql/oracle/survey-create.sql 19 Sep 2003 16:48:03 -0000 1.1 +++ openacs-4/contrib/packages/survey/sql/oracle/survey-create.sql 13 Jan 2004 20:19:31 -0000 1.1.2.1 @@ -291,8 +291,16 @@ references survey_predefined_questions ); +create table survey_block_sections ( + block_section_id integer primary key + section_id integer + constraint survey_b_q_section_id_fk + references survey_sections, + answer_description varchar(400) +); + create table survey_block_questions ( - block_section_id integer, + block_section_id references survey_block_sections, section_id integer constraint survey_b_q_section_id_fk references survey_sections, Index: openacs-4/contrib/packages/survey/sql/postgresql/survey-create.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/survey/sql/postgresql/Attic/survey-create.sql,v diff -u -r1.1 -r1.1.2.1 --- openacs-4/contrib/packages/survey/sql/postgresql/survey-create.sql 19 Sep 2003 16:48:03 -0000 1.1 +++ openacs-4/contrib/packages/survey/sql/postgresql/survey-create.sql 13 Jan 2004 20:19:31 -0000 1.1.2.1 @@ -311,11 +311,16 @@ create index survey_q_sort_order on survey_questions(sort_order); create index survey_q_active_p on survey_questions(active_p); +create table survey_block_sections ( + block_section_id integer primary key + section_id integer + constraint survey_b_q_section_id_fk + references survey_sections, + answer_description varchar(400) +); + create table survey_block_questions ( - block_section_id integer, - section_id integer - constraint survey_b_q_section_id_fk - references survey_sections, + block_section_id references survey_block_sections, choice_id integer constraint survey_b_q_choice_id_nn not null, Index: openacs-4/contrib/packages/survey/tcl/survey-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/survey/tcl/Attic/survey-procs.tcl,v diff -u -r1.1.2.1 -r1.1.2.2 --- openacs-4/contrib/packages/survey/tcl/survey-procs.tcl 26 Nov 2003 16:05:37 -0000 1.1.2.1 +++ openacs-4/contrib/packages/survey/tcl/survey-procs.tcl 13 Jan 2004 20:19:31 -0000 1.1.2.2 @@ -120,6 +120,7 @@ # for this, the "options"-parameter has to be built, which is somewhat complicated set explanation "" set options [list] + lappend options [db_list_of_lists answer_descriptions ""] set all_choices [list] set old_block 0 db_foreach block_choices "" { Index: openacs-4/contrib/packages/survey/tcl/survey-procs.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/survey/tcl/Attic/survey-procs.xql,v diff -u -r1.1 -r1.1.2.1 --- openacs-4/contrib/packages/survey/tcl/survey-procs.xql 19 Sep 2003 16:48:03 -0000 1.1 +++ openacs-4/contrib/packages/survey/tcl/survey-procs.xql 13 Jan 2004 20:19:31 -0000 1.1.2.1 @@ -54,10 +54,16 @@ + + + select max(answer_description), count(*) from survey_block_Sections bs, survey_block_questions bq where section_id=:section_id and bs.block_section_id=bq.block_section_id group by bs.block_section_id, bq.block_section_id order by bs.block_section_id + + + - select label,block_section_id from survey_block_questions where section_id=:section_id order by block_section_id, - sort_order + select label,bs.block_section_id from survey_block_questions bq, survey_block_Sections bs where section_id=:section_id and bs.block_section_id=bq.block_section_id order by block_section_id, + sort_order @@ -447,8 +453,6 @@ - - select question_text,abstract_data_type, presentation_type, Index: openacs-4/contrib/packages/survey/www/admin/section-edit-2.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/survey/www/admin/Attic/section-edit-2.tcl,v diff -u -r1.1 -r1.1.2.1 --- openacs-4/contrib/packages/survey/www/admin/section-edit-2.tcl 19 Sep 2003 16:48:04 -0000 1.1 +++ openacs-4/contrib/packages/survey/www/admin/section-edit-2.tcl 13 Jan 2004 20:19:31 -0000 1.1.2.1 @@ -6,7 +6,8 @@ @author cmceniry@arsdigita.com @author nstrug@arsdigita.com - @date Jun 16, 2000 + @author openacs@sussdorff.de + @date Jan 13, 2004 @cvs-id $Id$ } { @@ -18,6 +19,7 @@ branch_p:boolean,notnull {block_section_p:boolean "f"} page_break_p:boolean,notnull + {answer_descriptions:trim ""} } -validate { first_section_not_branch -requires {branch_p:notnull} { if {$branch_p=="t" && $after==0} { @@ -55,24 +57,38 @@ ad_script_abort } # Make this a block section + # Create a row in survey_block_sections for each set of choices # - create a row in survey_block_questions for each of the choices of the questions # - mark section as block-section db_foreach example_questions "" { set block_id [db_nextval survey_block_section_id_seq] set choice_id [db_nextval survey_block_choice_id_seq] + db_dml make_block_section "" db_dml make_block_choices "" } - db_dml make_block_section "" + db_dml mark_block_section "" } else { if {$old_block_section_p=="t" && $block_section_p=="f"} { # undo block section - db_dml make_noblock_section "" + db_dml mark_noblock_section "" db_dml remove_block_questions "" + db_dml remove_block_sections "" } } + # Answer descriptions for block sections + if {$block_section_p=="t"} { + set answer_descriptions [split $answer_descriptions "\n"] + set count 0 + foreach block_section_id [db_list block_sections ""] { + set answer_description [lindex $answer_descriptions $count] + incr count + db_dml add_answer_description "" + } + } + # after is the section which is to be newly above the section # refers_to is the section our condition refers to # if after is before refers_to we're before our condition and that case should be avoided Index: openacs-4/contrib/packages/survey/www/admin/section-edit-2.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/survey/www/admin/Attic/section-edit-2.xql,v diff -u -r1.1 -r1.1.2.1 --- openacs-4/contrib/packages/survey/www/admin/section-edit-2.xql 19 Sep 2003 16:48:04 -0000 1.1 +++ openacs-4/contrib/packages/survey/www/admin/section-edit-2.xql 13 Jan 2004 20:19:31 -0000 1.1.2.1 @@ -40,36 +40,61 @@ + + + insert into + survey_block_sections(block_section_id,section_id,answer_description) + values (:block_id,:section_id,'') + + insert into - survey_block_questions(block_section_id,section_id,choice_id,label,sort_order) + survey_block_questions(block_section_id,choice_id,label,sort_order) select - :block_id,:section_id,:choice_id,label,sort_order + :block_id,:choice_id,label,sort_order from survey_question_choices where question_id=:question_id - + update survey_sections set block_section_p='t' where section_id=:section_id - + update survey_sections set block_section_p='f' where section_id=:section_id - delete from survey_block_questions where section_id=:section_id + delete from survey_block_questions where block_section_id in (select block_section_id from survey_block_sections where section_id=:section_id) + + + delete from survey_block_sections where section_id=:section_id + + + + + select block_section_id from survey_block_sections where section_id=:section_id order by block_section_id + + + + + + update survey_block_sections set answer_description=:answer_description where block_section_id=:block_section_id + + + + update survey_branches set after=(select section_id from Index: openacs-4/contrib/packages/survey/www/admin/section-edit.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/survey/www/admin/Attic/section-edit.tcl,v diff -u -r1.1 -r1.1.2.1 --- openacs-4/contrib/packages/survey/www/admin/section-edit.tcl 19 Sep 2003 16:48:04 -0000 1.1 +++ openacs-4/contrib/packages/survey/www/admin/section-edit.tcl 13 Jan 2004 20:19:31 -0000 1.1.2.1 @@ -6,6 +6,7 @@ @author cmceniry@arsdigita.com @author nstrug@arsdigita.com + @author openacs@sussdorff.de @date Jun 16, 2000 @cvs-id $Id$ } { @@ -37,9 +38,11 @@ {page_break_p:text(radio) {label "New Page after this section"} {options {{Yes t} {No f}}} {value $page_break_p}} } -if {[survey_block_section_candidate_p $section_id]} { +if {$block_section_p=="t" || [survey_block_section_candidate_p $section_id]} { + set answer_descriptions [join [db_list answer_descriptions ""] "\n"] ad_form -extend -name modify_section -form { {block_section_p:text(radio) {label "Measurement Section"} {options {{Yes t} {No f}}} {value $block_section_p}} + {answer_descriptions:text(textarea),optional {label "Answer descriptions (one per line)"} {value $answer_descriptions}} } } else { ad_form -extend -name modify_section -form { Index: openacs-4/contrib/packages/survey/www/admin/section-edit.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/survey/www/admin/Attic/section-edit.xql,v diff -u -r1.1 -r1.1.2.1 --- openacs-4/contrib/packages/survey/www/admin/section-edit.xql 19 Sep 2003 16:48:04 -0000 1.1 +++ openacs-4/contrib/packages/survey/www/admin/section-edit.xql 13 Jan 2004 20:19:31 -0000 1.1.2.1 @@ -18,4 +18,11 @@ + + + select answer_description from survey_block_sections where section_id=:section_id + order by block_section_id + + +