Index: openacs-4/packages/curriculum/sql/oracle/curriculum-create.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/curriculum/sql/oracle/curriculum-create.sql,v diff -u -r1.1 -r1.2 --- openacs-4/packages/curriculum/sql/oracle/curriculum-create.sql 26 May 2003 17:40:02 -0000 1.1 +++ openacs-4/packages/curriculum/sql/oracle/curriculum-create.sql 3 Jun 2003 10:48:45 -0000 1.2 @@ -10,36 +10,79 @@ @ curriculum-curriculum-package-create.sql --- Keep track of which elements a particular user has seen. create table cu_user_element_map ( - user_id integer - constraint cu_user_element_map_user_id_nn - not null - constraint cu_user_element_map_user_id_fk - references users - on delete cascade, - element_id integer - constraint cu_user_element_map_elem_id_nn - not null - constraint cu_user_element_map_elem_id_fk - references cu_elements - on delete cascade, - curriculum_id integer - constraint cu_user_element_map_curr_id_nn - not null - constraint cu_user_element_map_curr_id_fk - references cu_curriculums - on delete cascade, - package_id integer - constraint cu_user_element_map_pack_id_nn - not null - constraint cu_user_element_map_pack_id_fk - references apm_packages - on delete cascade, - completion_date date - default sysdate - constraint cu_user_element_map_comp_da_nn - not null, + user_id integer + constraint cu_user_element_map_user_id_nn + not null + constraint cu_user_element_map_user_id_fk + references users + on delete cascade, + element_id integer + constraint cu_user_element_map_elem_id_nn + not null + constraint cu_user_element_map_elem_id_fk + references cu_elements + on delete cascade, + curriculum_id integer + constraint cu_user_element_map_curr_id_nn + not null + constraint cu_user_element_map_curr_id_fk + references cu_curriculums + on delete cascade, + package_id integer + constraint cu_user_element_map_pack_id_nn + not null + constraint cu_user_element_map_pack_id_fk + references apm_packages + on delete cascade, + completion_date date + default sysdate + constraint cu_user_element_map_comp_da_nn + not null, constraint cu_user_element_map_pk primary key (user_id, element_id) ); + +comment on table cu_user_element_map is ' +Keep track of which elements a particular user has seen so that we can check the element in the curriculum bar and mark it visited. +'; + +comment on column cu_user_element_map.curriculum_id is ' +We use this column mainly to be able to clear/uncheck a single curriculum bar in a package instance. +'; + +comment on column cu_user_element_map.package_id is ' +We use this column mainly to be able to clear/uncheck all the curriculum bars in a package instance. +'; + + +create table cu_user_curriculum_map ( + user_id integer + constraint cu_user_curr_map_user_id_nn + not null + constraint cu_user_curr_map_user_id_fk + references users + on delete cascade, + curriculum_id integer + constraint cu_user_curr_map_curr_id_nn + not null + constraint cu_user_curr_map_curr_id_fk + references cu_curriculums + on delete cascade, + package_id integer + constraint cu_user_curr_map_pack_id_nn + not null + constraint cu_user_curr_map_pack_id_fk + references apm_packages + on delete cascade, + constraint cu_user_curriculum_map_pk + primary key (user_id, curriculum_id) +); + +comment on table cu_user_curriculum_map is ' +Tracks the curriculums the user does NOT want in his/her personal curriculum bar (if activated). When the user is newly registered (and no rows exist for the user in the map), all published curriculums will be dispayed. +'; + +comment on column cu_user_curriculum_map.package_id is ' +We use this column mainly to be able to add all the curriculums in a package instance to the user''s personalized bar (delete from cu_user_curriculum_map where user_id = :user_id and package_id = :package_id). +'; Index: openacs-4/packages/curriculum/sql/oracle/curriculum-curriculum-package-create.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/curriculum/sql/oracle/curriculum-curriculum-package-create.sql,v diff -u -r1.1 -r1.2 --- openacs-4/packages/curriculum/sql/oracle/curriculum-curriculum-package-create.sql 26 May 2003 17:40:02 -0000 1.1 +++ openacs-4/packages/curriculum/sql/oracle/curriculum-curriculum-package-create.sql 3 Jun 2003 10:48:45 -0000 1.2 @@ -110,14 +110,17 @@ from cu_elements where curriculum_id = cu_curriculum.del.curriculum_id; begin - delete from acs_permissions - where object_id = cu_curriculum.del.curriculum_id; - -- Delete all elements in the curriculum. for v_element_val in c_element_cur loop cu_element.del(v_element_val.element_id); end loop; + delete from acs_permissions + where object_id = cu_curriculum.del.curriculum_id; + + delete from cu_curriculums + where curriculum_id = cu_curriculum.del.curriculum_id; + acs_object.delete(cu_curriculum.del.curriculum_id); end del; Index: openacs-4/packages/curriculum/sql/oracle/curriculum-drop.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/curriculum/sql/oracle/curriculum-drop.sql,v diff -u -r1.1 -r1.2 --- openacs-4/packages/curriculum/sql/oracle/curriculum-drop.sql 26 May 2003 17:40:02 -0000 1.1 +++ openacs-4/packages/curriculum/sql/oracle/curriculum-drop.sql 3 Jun 2003 10:48:45 -0000 1.2 @@ -4,7 +4,8 @@ -- @creation-date 2003-05-23 -- @cvs-id $Id$ --- Drop the mapping table. +-- Drop the mapping tables. +drop table cu_user_curriculum_map; drop table cu_user_element_map; -- Drop the cu_element object. Index: openacs-4/packages/curriculum/sql/oracle/curriculum-element-create.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/curriculum/sql/oracle/curriculum-element-create.sql,v diff -u -r1.1 -r1.2 --- openacs-4/packages/curriculum/sql/oracle/curriculum-element-create.sql 26 May 2003 17:40:02 -0000 1.1 +++ openacs-4/packages/curriculum/sql/oracle/curriculum-element-create.sql 3 Jun 2003 10:48:45 -0000 1.2 @@ -14,7 +14,9 @@ curriculum_id integer constraint cu_elements_curriculum_id_fk references cu_curriculums (curriculum_id) - on delete cascade, + on delete cascade + constraint cu_elements_curriculum_id_nn + not null, name varchar(200) constraint cu_elements_name_nn not null, Index: openacs-4/packages/curriculum/sql/postgresql/curriculum-create.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/curriculum/sql/postgresql/curriculum-create.sql,v diff -u -r1.1 -r1.2 --- openacs-4/packages/curriculum/sql/postgresql/curriculum-create.sql 26 May 2003 17:42:18 -0000 1.1 +++ openacs-4/packages/curriculum/sql/postgresql/curriculum-create.sql 3 Jun 2003 10:45:44 -0000 1.2 @@ -10,36 +10,79 @@ \i curriculum-curriculum-package-create.sql --- Keep track of which elements a particular user has seen. create table cu_user_element_map ( - user_id integer - constraint cu_user_element_map_user_id_nn - not null - constraint cu_user_element_map_user_id_fk - references users - on delete cascade, - element_id integer - constraint cu_user_element_map_element_id_nn - not null - constraint cu_user_element_map_elemen_id_fk - references cu_elements - on delete cascade, - curriculum_id integer - constraint cu_user_element_map_curriculum_id_nn - not null - constraint cu_user_element_map_curriculum_id_fk - references cu_curriculums - on delete cascade, - package_id integer - constraint cu_user_element_map_package_id_nn - not null - constraint cu_user_element_map_package_id_fk - references apm_packages - on delete cascade, - completion_date timestamptz - default current_timestamp - constraint cu_user_element_map_completion_date_nn - not null, + user_id integer + constraint cu_user_element_map_user_id_nn + not null + constraint cu_user_element_map_user_id_fk + references users + on delete cascade, + element_id integer + constraint cu_user_element_map_element_id_nn + not null + constraint cu_user_element_map_elemen_id_fk + references cu_elements + on delete cascade, + curriculum_id integer + constraint cu_user_element_map_curriculum_id_nn + not null + constraint cu_user_element_map_curriculum_id_fk + references cu_curriculums + on delete cascade, + package_id integer + constraint cu_user_element_map_package_id_nn + not null + constraint cu_user_element_map_package_id_fk + references apm_packages + on delete cascade, + completion_date timestamptz + default current_timestamp + constraint cu_user_element_map_completion_date_nn + not null, constraint cu_user_element_map_pk primary key (user_id, element_id) ); + +comment on table cu_user_element_map is ' +Keep track of which elements a particular user has seen so that we can check the element in the curriculum bar and mark it visited. +'; + +comment on column cu_user_element_map.curriculum_id is ' +We use this column mainly to be able to clear/uncheck a single curriculum bar in a package instance. +'; + +comment on column cu_user_element_map.package_id is ' +We use this column mainly to be able to clear/uncheck all the curriculum bars in a package instance. +'; + + +create table cu_user_curriculum_map ( + user_id integer + constraint cu_user_curriculum_map_user_id_nn + not null + constraint cu_user_curriculum_map_user_id_fk + references users + on delete cascade, + curriculum_id integer + constraint cu_user_curriculum_map_curriculum_id_nn + not null + constraint cu_user_curriculum_map_curriculum_id_fk + references cu_curriculums + on delete cascade, + package_id integer + constraint cu_user_curriculum_map_package_id_nn + not null + constraint cu_user_curriculum_map_package_id_fk + references apm_packages + on delete cascade, + constraint cu_user_curriculum_map_pk + primary key (user_id, curriculum_id) +); + +comment on table cu_user_curriculum_map is ' +Tracks the curriculums the user does NOT want in his/her personal curriculum bar (if activated). When the user is newly registered (and no rows exist for the user in the map), all published curriculums will be dispayed. +'; + +comment on column cu_user_curriculum_map.package_id is ' +We use this column mainly to be able to add all the curriculums in a package instance to the user''s personalized bar (delete from cu_user_curriculum_map where user_id = :user_id and package_id = :package_id). +'; Index: openacs-4/packages/curriculum/sql/postgresql/curriculum-curriculum-package-create.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/curriculum/sql/postgresql/curriculum-curriculum-package-create.sql,v diff -u -r1.1 -r1.2 --- openacs-4/packages/curriculum/sql/postgresql/curriculum-curriculum-package-create.sql 26 May 2003 17:42:18 -0000 1.1 +++ openacs-4/packages/curriculum/sql/postgresql/curriculum-curriculum-package-create.sql 3 Jun 2003 10:45:44 -0000 1.2 @@ -76,9 +76,6 @@ v_cur RECORD; v_return integer := 0; begin - delete from acs_permissions - where object_id = p_curriculum_id; - for v_cur in select element_id from cu_elements where curriculum_id = p_curriculum_id @@ -87,6 +84,9 @@ perform cu_element__del(v_cur.element_id); end loop; + delete from acs_permissions + where object_id = p_curriculum_id; + raise NOTICE ''Deleting curriculum - %'',p_curriculum_id; perform acs_object__delete(p_curriculum_id); Index: openacs-4/packages/curriculum/sql/postgresql/curriculum-drop.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/curriculum/sql/postgresql/curriculum-drop.sql,v diff -u -r1.1 -r1.2 --- openacs-4/packages/curriculum/sql/postgresql/curriculum-drop.sql 26 May 2003 17:42:18 -0000 1.1 +++ openacs-4/packages/curriculum/sql/postgresql/curriculum-drop.sql 3 Jun 2003 10:45:44 -0000 1.2 @@ -4,7 +4,8 @@ -- @creation-date 2003-05-23 -- @cvs-id $Id$ --- Drop the mapping table. +-- Drop the mapping tables. +drop table cu_user_curriculum_map; drop table cu_user_element_map; -- Drop the cu_element object. Index: openacs-4/packages/curriculum/sql/postgresql/curriculum-element-create.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/curriculum/sql/postgresql/curriculum-element-create.sql,v diff -u -r1.1 -r1.2 --- openacs-4/packages/curriculum/sql/postgresql/curriculum-element-create.sql 26 May 2003 17:42:18 -0000 1.1 +++ openacs-4/packages/curriculum/sql/postgresql/curriculum-element-create.sql 3 Jun 2003 10:45:44 -0000 1.2 @@ -15,7 +15,9 @@ curriculum_id integer constraint cu_elements_curriculum_id_fk references cu_curriculums (curriculum_id) - on delete cascade, + on delete cascade + constraint cu_elements_curriculum_id_nn + not null, name varchar(200) constraint cu_elements_name_nn not null,