Index: openacs-4/packages/lab-report/sql/postgresql/lab-report-create.sql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/lab-report/sql/postgresql/lab-report-create.sql,v
diff -u -r1.4 -r1.5
--- openacs-4/packages/lab-report/sql/postgresql/lab-report-create.sql	24 May 2006 12:30:40 -0000	1.4
+++ openacs-4/packages/lab-report/sql/postgresql/lab-report-create.sql	21 Aug 2006 23:25:15 -0000	1.5
@@ -49,6 +49,20 @@
     null
 );
 
+
+select  acs_object_type__create_type (
+    'lr_section_feedback',
+    '#lab-report.section_feedback#',
+    '#lab-report.section_feedback#',
+    'acs_object',
+    'lr_section_feedback',
+    'feedback_id',
+    null,
+    'f',
+    null,
+    null
+);
+
 --
 -- Create tables
 --
@@ -112,7 +126,34 @@
 	content			text
 );
 
+create table lr_section_feedback (
+	feedback_id		integer
+				constraint lr_section_feedback_pk
+				primary key,
+	feedback_criteria_id	integer
+				constraint lr_section_feedback_criteria_id_fk
+				references lrc_feedback_criteria (feedback_criteria_id)
+				on delete cascade,
+	report_id		integer
+				constraint lr_section_feedback_report_id_fk
+				references lr_report (report_id)
+				on delete cascade,
+	section_id		integer
+				constraint lr_section_feedback_section_id_fk
+				references lrc_section (section_id)
+				on delete cascade,
+	instructor_id		integer
+				constraint lrc_lab_instructor_id_fk
+				references users(user_id),
+	rating			varchar (5120),
+	comment			text,
+	package_id		integer
+				constraint lr_section_feedback_package_id_fk
+				references apm_packages (package_id)
+				on delete cascade
+);
 
+
 --
 -- Create functions
 --
@@ -241,5 +282,97 @@
 end;' language 'plpgsql';
 
 
+select define_function_args('lr_section_feedback__new','feedback_id,feedback_criteria_id,report_id,section_id,instructor_id,rating,comment,package_id,creation_date;now,creation_user,creation_ip,context_id');
+
+create function lr_section_feedback__new (
+	integer,
+	integer,
+	integer,
+	integer,
+	integer,
+	varchar,
+	text,
+	integer,
+	timestamptz,
+	integer,
+	varchar,
+	integer
+) returns integer as '
+declare
+	p_feedback_id		alias for $1;        	-- default null
+	p_feedback_criteria_id  alias for $2;
+    	p_report_id		alias for $3;
+    	p_section_id	        alias for $4;
+	p_instructor_id		alias for $5;
+	p_rating		alias for $6;
+	p_comment		alias for $7;
+	p_package_id		alias for $8;
+    	p_creation_date         alias for $9;        	-- default now()
+    	p_creation_user         alias for $10;        	-- default null
+    	p_creation_ip           alias for $11;		-- default null
+    	p_context_id            alias for $12;		-- default null
+
+    	v_feedback_id		lr_section_feedback.feedback_id%TYPE;
+	v_inst_group_id		integer;
+begin
+
+    	v_feedback_id := acs_object__new (
+        	p_feedback_id,
+        	''lr_section_feedback'',
+        	p_creation_date,
+        	p_creation_user,
+        	p_creation_ip,
+        	p_context_id
+    	);
+
+    	INSERT INTO lr_section_feedback (
+       		feedback_id,
+		feedback_criteria_id,
+		report_id,
+		section_id,
+		instructor_id,
+		rating,
+		comment,
+		package_id
+    	) VALUES (
+       		v_feedback_id,
+		p_feedback_criteria_id,
+		p_report_id,
+		p_section_id,
+		p_instructor_id,
+		p_rating,
+		p_comment,
+		p_package_id
+    	);
+
+
+    	SELECT group_id into v_inst_group_id
+      	FROM lrc_groups
+        WHERE magic_name = ''instructors'';
+
+	-- Grant permission to lab instructors on this object.
+    	PERFORM acs_permission__grant_permission(
+          	v_feedback_id,
+          	v_inst_group_id,
+	        ''lab_report_central_read''
+    	);
+
+    	PERFORM acs_permission__grant_permission(
+          	v_feedback_id,
+          	v_inst_group_id,
+	        ''lab_report_central_write''
+    	);
+
+    	PERFORM acs_permission__grant_permission(
+          	v_feedback_id,
+          	v_inst_group_id,
+	        ''lab_report_central_admin''
+    	);
+
+    	return v_feedback_id;
+
+end;' language 'plpgsql';
+
+
 -- Register service contract implementations.
 \i lab-report-sc-create.sql
\ No newline at end of file
