Index: openacs-4/packages/assessment/sql/oracle/assessment-collected-data-create.sql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/assessment/sql/oracle/assessment-collected-data-create.sql,v
diff -u -r1.6 -r1.7
--- openacs-4/packages/assessment/sql/oracle/assessment-collected-data-create.sql	15 May 2007 20:14:16 -0000	1.6
+++ openacs-4/packages/assessment/sql/oracle/assessment-collected-data-create.sql	2 Sep 2008 01:08:46 -0000	1.7
@@ -138,14 +138,29 @@
 	file_id integer
 		constraint as_item_data_file_id_fk
 		references cr_revisions(revision_id)
-                on delete cascade
+                on delete cascade,
+        as_cr_item_id integer,
+        choice_value varchar2(4000)
 	-- to do: figure out how attachment answers should be supported; the Attachment package is still in need of considerable help. Can we rely on it here?
 );
 
 create index as_item_data_pk2 on as_item_data (session_id, section_id, as_item_id);
 create index as_item_data_pk3 on as_item_data (as_item_id, section_id, session_id);
 create index as_item_data_subj_idx on as_item_data (subject_id);
 create index as_item_data_as_item_id_idx on as_item_data (as_item_id);
+
+create or replace trigger as_item_data_ins_trg
+before insert on as_item_data
+for each row
+declare v_item_id integer;
+begin
+select item_id into v_item_id
+from cr_revisions where revision_id = :new.as_item_id;
+:new.as_item_cr_item_id := v_item_id;
+end as_item_data_ins_trg;
+/
+show errors;
+
 create table as_session_results (
        result_id   integer
                    constraint as_sess_res_res_id_pk
@@ -179,6 +194,22 @@
 
 create unique index as_idata_choices_pk2 on as_item_data_choices (choice_id, item_data_id);
 
+create or replace trigger as_item_data_choices_ins_trg
+after insert on as_item_data_choices
+for each row
+declare v_choice_value varchar(4000) default '';
+begin
+
+select title into v_choice_value
+from as_item_choicesx
+where choice_id = :new.choice_id;
+
+update as_item_data set choice_value = coalesce(choice_value,'') || ' ' || coalesce(v_choice_value,'') where item_data_id = :new.item_data_id;
+
+end as_item_data_choices_ins_trg;
+/
+show errors;
+
 -- here the order of the displayed sections is stored per session
 create table as_session_sections (
 	session_id	integer
