Index: openacs-4/packages/curriculum-central/catalog/curriculum-central.en_US.ISO-8859-1.xml
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/curriculum-central/catalog/curriculum-central.en_US.ISO-8859-1.xml,v
diff -u -r1.21 -r1.22
--- openacs-4/packages/curriculum-central/catalog/curriculum-central.en_US.ISO-8859-1.xml	4 Jan 2006 00:24:15 -0000	1.21
+++ openacs-4/packages/curriculum-central/catalog/curriculum-central.en_US.ISO-8859-1.xml	4 Jan 2006 23:32:33 -0000	1.22
@@ -2,6 +2,25 @@
 <message_catalog package_key="curriculum-central" package_version="0.1d" locale="en_US" charset="ISO-8859-1">
 
   <msg key="uos">UoS</msg>
+  <msg key="no_graduate_attributes_created">No graduate attributes have been created</msg>
+  <msg key="add_graduate_attribute_to_list">Add graduate attributes to the list.</msg>
+  <msg key="help_graduate_attributes">Select one or more graduate attributes from the list that are associated with this Unit of Study.  To select more than one item from the list, hold down the Shirt key whilst selecting an item.  If an item doesn't appear in the list, then click &lt;a href=&quot;gradattr-ae?return_url=%return_url%&quot;&gt;here&lt;/a&gt; to add it (Note: clicking on the link will redirect you to another page).</msg>
+  <msg key="very_low">Very Low</msg>
+  <msg key="low">Low</msg>
+  <msg key="moderate">Moderate</msg>
+  <msg key="high">High</msg>
+  <msg key="very_high">Very High</msg>
+  <msg key="level">Level</msg>
+  <msg key="help_enter_graduate_attribute_name">Enter a name for the graduate attribute.</msg>
+  <msg key="help_enter_graduate_attribute_identifier">Enter an identifier for the graduate attribute.  Use the Unit of Study code if you want this graduate attribute to be associated with a specific Unit of Study, eg ELEC1001.</msg>
+  <msg key="help_enter_graduate_attribute_description">Enter a description for the graduate attribute.  What are the qualities associated with this type of graduate attribute?</msg>
+  <msg key="help_enter_graduate_attribute_level">To what level of contribution does the Unit of Study have towards the associated Unit of Study?</msg>
+  <msg key="add_graduate_attribute">Add Graduate Attribute</msg>
+  <msg key="edit_graduate_attribute">Edit Graduate Attribute</msg>
+  <msg key="graduate_attribute">Graduate Attribute</msg>
+  <msg key="graduate_attributes">Graduate Attributes</msg>
+  <msg key="graduate_attribute_revision">Graduate Attribute Revision</msg>
+  <msg key="graduate_attribute_revisions">Graduate Attribute Revisions</msg>
   <msg key="assumed_concepts">Assumed Concepts</msg>
   <msg key="help_assumed_concepts">Concepts that are assumed students already know or are familiar with.</msg>
   <msg key="formal_contact_hrs">Formal Contact Hours</msg>
Index: openacs-4/packages/curriculum-central/sql/postgresql/uos-create.sql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/curriculum-central/sql/postgresql/uos-create.sql,v
diff -u -r1.7 -r1.8
--- openacs-4/packages/curriculum-central/sql/postgresql/uos-create.sql	3 Jan 2006 12:53:52 -0000	1.7
+++ openacs-4/packages/curriculum-central/sql/postgresql/uos-create.sql	4 Jan 2006 23:32:35 -0000	1.8
@@ -314,3 +314,6 @@
 
 -- UoS Workload
 \i uos-workload-create.sql
+
+-- UoS Graduate Attributes
+\i uos-gradattr-create.sql
Index: openacs-4/packages/curriculum-central/sql/postgresql/uos-gradattr-create.sql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/curriculum-central/sql/postgresql/uos-gradattr-create.sql,v
diff -u
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/curriculum-central/sql/postgresql/uos-gradattr-create.sql	4 Jan 2006 23:32:35 -0000	1.1
@@ -0,0 +1,453 @@
+--
+-- packages/curriculum-central/sql/postgresql/uos-gradattr-create.sql
+--
+-- @author Nick Carroll (nick.c@rroll.net)
+-- @creation-date 2005-12-28
+-- @cvs-id $Id: uos-gradattr-create.sql,v 1.1 2006/01/04 23:32:35 ncarroll Exp $
+--
+--
+
+
+create function inline_0 ()
+returns integer as'
+begin 
+    PERFORM acs_object_type__create_type (
+	''cc_uos_gradattr_set'',			-- object_type
+	''#curriculum-central.uos_graduate_attribtue_set#'',   -- pretty_name
+	''#curriculum-central.uos_graduate_attribute_sets#'',  -- pretty_plural
+	''acs_object'',					-- supertype
+	''cc_uos_gradattr_set'',			-- table_name
+	''gradattr_set_id'',				-- id_column
+	null,						-- package_name
+	''f'',						-- abstract_p
+	null,						-- type_extension_table
+	null						-- name_method
+    );
+
+    return 0;
+end;' language 'plpgsql';
+
+select inline_0 ();
+drop function inline_0 ();
+
+
+-- Register UoS graduate attributes as a child type of Uos.
+select content_type__register_child_type (
+    'cc_uos',                	-- parent_type 
+    'cc_uos_gradattr_set',      -- child_type
+    'generic',               	-- relation_tag
+    0,                       	-- min_n
+    null                     	-- max_n
+);
+
+
+-- content_item subtype
+create table cc_uos_gradattr_set (
+	gradattr_set_id		integer
+                        	constraint cc_uos_gradattr_set_fk
+                        	references cr_items(item_id)
+				on delete cascade
+				constraint cc_uos_gradattr_set_pk
+				primary key,
+	parent_uos_id		integer,
+	live_revision_id	integer,
+	latest_revision_id	integer
+);
+
+
+-- Create the UoS Graduate Attributes content_revision
+-- A revision may point to many Graduate Attributes in the mapping
+-- table below.
+create table cc_uos_gradattr_set_revs (
+	ga_set_revision_id	integer
+				constraint cc_uos_gradattr_set_rev_pk
+				primary key
+				constraint cc_uos_gradattr_set_rev_fk
+				references cr_revisions(revision_id)
+				on delete cascade
+);
+
+-- Create the UoS revision content type.
+select content_type__create_type (
+    'cc_uos_gradattr_set_rev',
+    'content_revision',
+    '#curriculum-central.uos_graduate_attribute_set_revision#',
+    '#curriculum-central.uos_graduate_attribute_set_revisions#',
+    'cc_uos_gradattr_set_revs',
+    'ga_set_revision_id',
+    'content_revision.revision_name'
+);
+
+-- Register uos_gradattr_set_revision as a child type of uos_revision.
+select content_type__register_child_type (
+    'cc_uos_revision',			-- parent_type 
+    'cc_uos_gradattr_set_rev',		-- child_type
+    'generic',               		-- relation_tag
+    0,                       		-- min_n
+    null                     		-- max_n
+);
+
+
+-- Create Graduate Attribute object
+create function inline_0 ()
+returns integer as '
+begin
+    PERFORM acs_object_type__create_type (
+    ''cc_uos_gradattr'', 				-- object_type
+    ''#curriculum-central.graduate_attribute#'',   	-- pretty_name
+    ''#curriculum-central.graduate_attributes#'',  	-- pretty_plural
+    ''acs_object'',                			-- supertype
+    ''cc_uos_gradattr'',	    			-- table_name
+    ''gradattr_id'',               			-- id_column
+    null,                          			-- package_name
+    ''f'',                         			-- abstract_p
+    null,                          			-- type_extension_table
+    ''cc_uos_gradattr__name''		      		-- name_method
+    );
+
+    return 0;
+end;' language 'plpgsql';
+
+select inline_0 ();
+drop function inline_0 ();
+
+-- Create the table that will be used to store information about a graduate
+-- attribute.
+create table cc_uos_gradattr (
+	gradattr_id		integer
+				constraint cc_uos_gradattr_id_fk
+				references acs_objects(object_id)
+				constraint cc_uos_gradattr_id_pk
+				primary key,
+	name			varchar(256), -- eg. Communication, Research.
+	identifier		varchar(256), -- for form multiselect.
+	description		text,         -- GA description.
+	level			integer	      -- 1, 2, 3, 4 or 5.
+);
+
+-- Create Mapping table between revision and graduate attribute type.
+-- A revision can refer to many graduate attribute types, since a
+-- Unit of Study can impart many types of graduate attributes to students.
+create table cc_uos_gradattr_map (
+	revision_id		integer
+				constraint cc_uos_gradattr_map_rev_id_fk
+				references cc_uos_gradattr_set_revs(ga_set_revision_id),
+	gradattr_id		integer
+				constraint cc_uos_gradattr_map_gradattr_id_fk
+				references cc_uos_gradattr(gradattr_id)
+);
+
+
+--
+--
+-- Create the functions for the graduate attribute content item and revisions.
+--
+--
+
+select define_function_args('cc_uos_gradattr_set__new', 'gradattr_set_id,parent_uos_id,creation_user,creation_ip,context_id,item_subtype;cc_uos_gradattr_set,content_type;cc_uos_gradattr_set_rev,object_type,package_id');
+
+create function cc_uos_gradattr_set__new(
+	integer,	-- gradattr_set_id
+	integer,	-- parent_uos_id
+	integer,	-- creation_user
+	varchar,	-- creation_ip
+	integer,	-- context_id
+	varchar,	-- item_subtype
+	varchar,	-- content_type
+	varchar,	-- object_type
+	integer		-- package_id
+) returns integer as'
+declare
+
+	p_gradattr_set_id		alias for $1;
+	p_parent_uos_id			alias for $2;
+	p_creation_user			alias for $3;
+	p_creation_ip			alias for $4;
+	p_context_id			alias for $5;
+	p_item_subtype			alias for $6;
+	p_content_type			alias for $7;
+	p_object_type			alias for $8;
+	p_package_id			alias for $9;
+
+	v_gradattr_set_id		cc_uos_gradattr_set.gradattr_set_id%TYPE;
+	v_folder_id			integer;
+	v_revision_id			integer;
+	v_name				varchar;
+	v_rel_id			integer;
+begin
+	-- get the content folder for this instance
+	select folder_id into v_folder_id
+	    from cc_curriculum
+	    where curriculum_id = p_package_id;
+
+	-- Create a unique name
+	-- Can only have one graduate attribute set per Unit of Study,
+	-- so append uos_id
+	-- to "uos_gradattr_set_for_".
+	v_name := ''uos_gradattr_set_for_'' || p_parent_uos_id;
+
+	-- create the content item
+	v_gradattr_set_id := content_item__new (
+		v_name,			-- name
+		v_folder_Id,		-- parent_id
+		p_gradattr_set_id,	-- item_id
+		null,			-- locale
+		now(),			-- creation_date
+		p_creation_user,	-- creation_user
+		v_folder_id,		-- context_id
+		p_creation_ip,		-- creation_ip
+		p_item_subtype,		-- item_subtype
+		p_content_type,		-- content_type
+		null,			-- title
+		null,			-- description
+		null,			-- mime_type
+		null,			-- nls_language
+		null,			-- data
+		p_package_id
+	);
+
+	-- create the initial revision
+	v_revision_id := cc_uos_gradattr_set_rev__new (
+		null,				-- gradattr_set_revision_id
+		v_gradattr_set_id,		-- gradattr_set_id
+		now(),				-- creation_date
+		p_creation_user,		-- creation_user
+		p_creation_ip			-- creation_ip
+	);
+
+	-- create the item type row
+	INSERT INTO cc_uos_gradattr_set (
+		gradattr_set_id, parent_uos_id, latest_revision_id
+	) VALUES (
+		v_gradattr_set_id, p_parent_uos_id, v_revision_id
+	);
+
+
+	-- associate the UoS graduate attribute set with the parent UoS
+	v_rel_id := acs_object__new(
+		NULL,
+      		''cr_item_child_rel'',
+      		current_timestamp,
+      		p_creation_user,
+      		p_creation_ip,
+      		p_package_id
+	);
+
+  	INSERT INTO cr_child_rels (
+      		rel_id, parent_id, child_id, relation_tag
+      	) VALUES (
+      		v_rel_id,
+		p_parent_uos_id,
+		v_gradattr_set_id,
+		''cc_uos_gradattr_set''
+  	);	
+
+	return v_gradattr_set_id;
+
+end;
+' language plpgsql;
+
+
+select define_function_args('cc_uos_gradattr_set__delete', 'gradattr_set_id');
+
+create function cc_uos_gradattr_set__delete (integer)
+returns integer as '
+declare
+	p_gradattr_set_id		alias for $1;
+begin
+
+	perform content_item__delete(p_gradattr_set_id);
+
+	return 0;
+
+end;
+' language 'plpgsql';
+
+
+create or replace function cc_uos_gradattr_set_rev__new (
+	integer,			-- gradattr_set_revision_id
+	integer,			-- gradattr_set_id
+	timestamptz,			-- creation_date
+	integer,			-- creation_user
+	varchar				-- creation_ip
+) returns int
+as '
+declare
+	p_gradattr_set_revision_id		alias for $1;
+	p_gradattr_set_id			alias for $2;
+	p_creation_date				alias for $3;
+	p_creation_user				alias for $4;
+	p_creation_ip				alias for $5;
+
+	v_revision_id				integer;
+	v_title					varchar;
+begin
+
+	-- create the initial revision
+	v_revision_id := content_revision__new (
+		''#curriculum-central.uos_graduate_attributes#'',  -- title
+		null,					-- description
+		current_timestamp,			-- publish_date
+		null,					-- mime_type
+		null,					-- nls_language
+		null,					-- new_data
+		p_gradattr_set_id,			-- item_id
+		p_gradattr_set_revision_id,		-- revision_id
+		p_creation_date,			-- creation_date
+		p_creation_user,			-- creation_user
+		p_creation_ip				-- creation_ip
+	);
+
+	-- insert into the uos-specific revision table
+	INSERT INTO cc_uos_gradattr_set_revs (ga_set_revision_id)
+	VALUES (v_revision_id);
+
+	-- Update the latest revision id in cc_uos_gradattr_set
+	UPDATE cc_uos_gradattr_set SET latest_revision_id = v_revision_id
+	WHERE gradattr_set_id = p_gradattr_set_id;
+
+	return v_revision_id;
+end;
+' language 'plpgsql';
+
+
+--
+--
+-- Create the functions for the cc_uos_gradattr object.
+--
+--
+
+select define_function_args('cc_uos_gradattr__new','gradattr_id,name,identifier,description,level,creation_date;now,creation_user,creation_ip,package_id,context_id');
+
+create function cc_uos_gradattr__new (
+	integer,			-- gradattr_id
+	varchar,			-- name
+	varchar,			-- identifier
+	text,				-- description
+	integer,			-- level
+	timestamptz,			-- creation_date
+	integer,			-- creation_user
+	varchar,			-- creation_ip
+	integer,			-- package_id
+	integer				-- context_id
+) returns integer as '
+declare
+    	p_gradattr_id			alias for $1;        -- default null
+    	p_name				alias for $2;
+    	p_identifier			alias for $3;
+	p_description			alias for $4;
+	p_level				alias for $5;
+    	p_creation_date             	alias for $6;        -- default now()
+    	p_creation_user             	alias for $7;        -- default null
+    	p_creation_ip              	alias for $8;        -- default null
+	p_package_id			alias for $9;
+    	p_context_id                	alias for $10;       -- default null
+
+	v_gradattr_id			cc_uos_gradattr.gradattr_id%TYPE;
+	v_title				varchar;
+begin
+	v_title := p_name || '' ('' || p_identifier || '')'';
+
+	v_gradattr_id := acs_object__new (
+        	p_gradattr_id,
+        	''cc_uos_gradattr'',
+        	p_creation_date,
+        	p_creation_user,
+        	p_creation_ip,
+        	p_context_id,
+		v_title,
+		p_package_id
+    	);
+
+	INSERT INTO cc_uos_gradattr (
+		gradattr_id, name, identifier, description, level
+	)
+	VALUES (
+		v_gradattr_id, p_name, p_identifier, p_description, p_level
+	);
+
+    return v_gradattr_id;
+
+end;' language 'plpgsql';
+
+
+select define_function_args('cc_uos_gradattr__del','gradattr_id');
+
+create function cc_uos_gradattr__del (integer)
+returns integer as '
+declare
+    	p_gradattr_id                alias for $1;
+begin
+    	DELETE FROM acs_permissions WHERE object_id = p_gradattr_id;
+
+    	DELETE FROM cc_uos_gradattr WHERE gradattr_id = p_gradattr_id;
+
+	RAISE NOTICE ''Deleting graduate attribute...'';
+    	PERFORM acs_object__delete(p_gradattr_id);
+
+	return 0;
+
+end;' language 'plpgsql';
+
+
+select define_function_args('cc_uos_gradattr__name','gradattr_id');
+
+create function cc_uos_gradattr__name (integer)
+returns varchar as '
+declare
+    	p_gradattr_id      alias for $1;
+
+	v_gradattr_name    cc_uos_gradattr.name%TYPE;
+begin
+	SELECT name INTO v_gradattr_name
+       	FROM cc_uos_gradattr
+        WHERE gradattr_id = p_gradattr_id;
+
+    	return v_gradattr_name;
+end;
+' language 'plpgsql';
+
+
+--
+-- Maps a graduate attribute to a graduate attribute revision set.
+--
+create function cc_uos_gradattr__map (
+	integer,			-- revision_id
+	integer				-- gradattr_id
+) returns integer as '
+declare
+	p_revision_id		alias for $1;
+	p_gradattr_id		alias for $2;
+begin
+
+	RAISE NOTICE ''Mapping graduate attribute to a revision set...'';
+
+	INSERT INTO cc_uos_gradattr_map (revision_id, gradattr_id)
+	VALUES (p_revision_id, p_gradattr_id);
+
+	return 0;
+end;
+' language 'plpgsql';
+
+
+--
+-- Unmaps a graduate attribute from a revision set.
+--
+create function cc_uos_gradattr__unmap (
+	integer,			-- revision_id
+	integer				-- gradattr_id
+) returns integer as '
+declare
+	p_revision_id		alias for $1;
+	p_gradattr_id		alias for $2;
+begin
+
+	RAISE NOTICE ''Deleting mapping between graduate attribute and revision set...'';
+
+	DELETE FROM cc_uos_gradattr_map
+	WHERE revision_id = p_revision_id
+	AND gradattr_id = p_gradattr_id;
+
+	return 0;
+end;
+' language 'plpgsql';
Index: openacs-4/packages/curriculum-central/sql/postgresql/uos-tl-create.sql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/curriculum-central/sql/postgresql/uos-tl-create.sql,v
diff -u -r1.1 -r1.2
--- openacs-4/packages/curriculum-central/sql/postgresql/uos-tl-create.sql	3 Jan 2006 03:23:27 -0000	1.1
+++ openacs-4/packages/curriculum-central/sql/postgresql/uos-tl-create.sql	4 Jan 2006 23:32:35 -0000	1.2
@@ -94,7 +94,7 @@
     PERFORM acs_object_type__create_type (
     ''cc_uos_tl_method'',          -- object_type
     ''#curriculum-central.teaching_and_learning_method#'',   -- pretty_name
-    ''#curriculum-central.teaching_and_learning_method#s'',  -- pretty_plural
+    ''#curriculum-central.teaching_and_learning_methods#'',  -- pretty_plural
     ''acs_object'',                -- supertype
     ''cc_uos_tl_method'',          -- table_name
     ''method_id'',                 -- id_column
Index: openacs-4/packages/curriculum-central/tcl/curriculum-central-procs.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/curriculum-central/tcl/curriculum-central-procs.tcl,v
diff -u -r1.6 -r1.7
--- openacs-4/packages/curriculum-central/tcl/curriculum-central-procs.tcl	3 Jan 2006 12:53:52 -0000	1.6
+++ openacs-4/packages/curriculum-central/tcl/curriculum-central-procs.tcl	4 Jan 2006 23:32:35 -0000	1.7
@@ -50,6 +50,11 @@
 		-content_type "cc_uos_workload_revision" \
 		-include_subtypes "t"
 
+	    content::folder::register_content_type \
+		-folder_id $folder_id \
+		-content_type "cc_uos_gradattr_set_rev" \
+		-include_subtypes "t"
+
 	    set keyword_id [content::keyword::new -heading "$instance_name"]
 
 	    # Inserts into cc_curriculum
Index: openacs-4/packages/curriculum-central/tcl/uos-procs-postgresql.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/curriculum-central/tcl/uos-procs-postgresql.xql,v
diff -u -r1.10 -r1.11
--- openacs-4/packages/curriculum-central/tcl/uos-procs-postgresql.xql	3 Jan 2006 13:26:48 -0000	1.10
+++ openacs-4/packages/curriculum-central/tcl/uos-procs-postgresql.xql	4 Jan 2006 23:32:35 -0000	1.11
@@ -39,6 +39,17 @@
      </querytext>
    </fullquery>
 
+   <fullquery name="curriculum_central::uos::get_graduate_attributes.latest_ga">
+     <querytext>
+       SELECT g.gradattr_set_id, g.latest_revision_id
+           FROM cc_uos u, cc_uos_revisions r, cr_items i, cc_uos_gradattr_set g
+	   WHERE u.uos_id = :uos_id
+	   AND i.item_id = u.uos_id
+	   AND r.uos_revision_id = i.latest_revision
+	   AND g.parent_uos_id = :uos_id
+     </querytext>
+   </fullquery>
+
    <fullquery name="curriculum_central::uos::get_workload.latest_workload">
      <querytext>
        SELECT w.workload_id, wr.formal_contact_hrs, wr.informal_study_hrs,
@@ -61,6 +72,13 @@
      </querytext>
    </fullquery>
 
+   <fullquery name="curriculum_central::uos::get_graduate_attributes.latest_gradattr_ids">
+     <querytext>
+       SELECT gradattr_id FROM cc_uos_gradattr_map
+           WHERE revision_id = :latest_revision_id
+     </querytext>
+   </fullquery>
+
    <fullquery name="curriculum_central::uos::num_pending.get_users_pending_uos">
      <querytext>
        SELECT count(*)
@@ -167,6 +185,18 @@
      </querytext>
    </fullquery>
 
+   <fullquery name="curriculum_central::uos::update_graduate_attributes.update_ga">
+     <querytext>
+       SELECT cc_uos_gradattr_set_rev__new (
+           null,
+	   :gradattr_set_id,
+	   now(),
+	   :user_id,
+	   :creation_ip
+       );
+     </querytext>
+   </fullquery>
+
    <fullquery name="curriculum_central::uos::update_workload.update_workload">
      <querytext>
        SELECT cc_uos_workload_revision__new (
@@ -194,6 +224,15 @@
      </querytext>
    </fullquery>
 
+   <fullquery name="curriculum_central::uos::update_graduate_attributes.map_ga_to_revision">
+     <querytext>
+       SELECT cc_uos_gradattr__map (
+           :revision_id,
+	   :gradattr_id
+       );
+     </querytext>
+   </fullquery>
+
    <fullquery name="curriculum_central::uos::tl_method_get_options.tl_methods">
      <querytext>
        SELECT m.name || ' (' || m.identifier || ')' AS method_name,
@@ -204,6 +243,16 @@
      </querytext>
    </fullquery>
 
+   <fullquery name="curriculum_central::uos::graduate_attributes_get_options.select_ga">
+     <querytext>
+       SELECT g.name || ' (' || g.identifier || ')' AS ga_name,
+           g.gradattr_id
+       FROM cc_uos_gradattr g, acs_objects o
+       WHERE o.object_id = g.gradattr_id
+       AND o.package_id = :package_id
+     </querytext>
+   </fullquery>
+
    <fullquery name="curriculum_central::uos::go_live::do_side_effect.get_latest_revision">
      <querytext>
        SELECT latest_revision FROM cr_items WHERE item_id = :object_id
@@ -230,6 +279,16 @@
      </querytext>
    </fullquery>
 
+   <fullquery name="curriculum_central::uos::go_live::do_side_effect.get_latest_ga_revision">
+     <querytext>
+       SELECT i.latest_revision AS latest_ga_revision
+           FROM cr_items i, cr_child_rels c
+           WHERE c.relation_tag = 'cc_uos_gradattr_set'
+	   AND c.parent_id = :object_id
+	   AND i.item_id = c.child_id
+     </querytext>
+   </fullquery>
+
    <fullquery name="curriculum_central::uos::go_live::do_side_effect.get_latest_workload_revision">
      <querytext>
        SELECT i.latest_revision AS latest_workload_revision
@@ -261,6 +320,13 @@
      </querytext>
    </fullquery>
 
+   <fullquery name="curriculum_central::uos::go_live::do_side_effect.set_live_ga_revision">
+     <querytext>
+       UPDATE cc_uos_gradattr_set SET live_revision_id = :latest_ga_revision
+           WHERE parent_uos_id = :object_id
+     </querytext>
+   </fullquery>
+
    <fullquery name="curriculum_central::uos::go_live::do_side_effect.set_live_workload_revision">
      <querytext>
        UPDATE cc_uos_workload SET live_revision_id = :latest_workload_revision
Index: openacs-4/packages/curriculum-central/tcl/uos-procs.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/curriculum-central/tcl/uos-procs.tcl,v
diff -u -r1.14 -r1.15
--- openacs-4/packages/curriculum-central/tcl/uos-procs.tcl	3 Jan 2006 13:26:48 -0000	1.14
+++ openacs-4/packages/curriculum-central/tcl/uos-procs.tcl	4 Jan 2006 23:32:35 -0000	1.15
@@ -137,6 +137,7 @@
                     privileges { write }
 		    edit_fields {
 			tl_approach_ids
+			gradattr_ids
 			formal_contact_hrs
 			informal_study_hrs
 			student_commitment
@@ -399,8 +400,15 @@
 		        [list object_type "cc_uos_tl"]] \
 		       "cc_uos_tl"]
 
+    # Initiate cc_uos_gradattr_set
+    set ga_id [package_instantiate_object \
+        -var_list [list [list parent_uos_id $uos_id] \
+	  	        [list package_id $package_id] \
+		        [list object_type "cc_uos_gradattr_set"]] \
+		       "cc_uos_gradattr_set"]
+
     # Initiate cc_uos_workload
-    set tl_id [package_instantiate_object \
+    set workload_id [package_instantiate_object \
         -var_list [list [list parent_uos_id $uos_id] \
 	  	        [list package_id $package_id] \
 		        [list object_type "cc_uos_workload"]] \
@@ -588,6 +596,8 @@
     This update proc creates a new teaching and learning revision..
 
     @param tl_id The ID of the teaching and learning object to update.
+    @param tl_approach_ids List of IDs that need to be mapped to the set
+    of teaching learning approaches (tl_id).
     @param user_id The ID of the user that updated the Unit of Study.
     @param creation_ip The IP of the user that made the update.
 
@@ -609,7 +619,6 @@
 	# Foreach tl_approach_id map to the newly created revision_id
 	# retrieved above.
 	foreach tl_approach_id $tl_approach_ids {
-	    ns_log Warning "Map revision_id <$revision_id> to tl_approach_id <$tl_approach_id>"
 	    db_exec_plsql map_tl_to_revision {}
 	}
     }
@@ -618,6 +627,47 @@
 }
 
 
+ad_proc -public curriculum_central::uos::update_graduate_attributes {
+    -gradattr_set_id:required
+    -gradattr_ids:required
+    {-user_id ""}
+    {-creation_ip ""}
+} {
+    Updates the graduate attributes component for a Unit of Study.
+    This update proc creates a new graduate attributes revision.
+
+    @param gradattr_set_id The ID for a set of graduate attributes.
+    @param gradattr_ids List of selected graduate attributes that need
+    to be mapped to the graduate attributes set.
+    @param user_id The ID of the user that updated the Unit of Study.
+    @param creation_ip The IP of the user that made the update.
+
+    @return revision_id Returns the ID of the newly created revision for
+    convenience, otherwise the empty string if unsuccessful.
+} {
+    if { $user_id eq "" } {
+        set user_id [ad_conn user_id]
+    }
+    if { $creation_ip eq "" } {
+	set creation_ip [ad_conn peeraddr]
+    }
+
+    # Set the default value for revision_id.
+    set revision_id ""
+    db_transaction {
+	set revision_id [db_exec_plsql update_ga {}]
+
+	# Foreach gradattr_id map to the newly created revision_id
+	# retrieved above.
+	foreach gradattr_id $gradattr_ids {
+	    db_exec_plsql map_ga_to_revision {}
+	}
+    }
+
+    return $revision_id
+}
+
+
 ad_proc -public curriculum_central::uos::update_workload {
     -workload_id:required
     {-formal_contact_hrs ""}
@@ -724,6 +774,37 @@
 }
 
 
+ad_proc -public curriculum_central::uos::get_graduate_attributes {
+    {-uos_id:required}
+    {-array:required}
+} {
+    Get the graduate attributes for a Unit of Study.
+
+    @param uos_id The ID of the Unit of Study for which we return
+    graduate attributes for.
+    @param array A predefined array for returning fields in.  Values include
+    gradattr_set_id, gradattr_ids, latest_revision_id.
+
+    @return Array containing graduate attributes infor for a UoS.
+} {
+    # Select the info into the upvar'ed Tcl array
+    upvar $array row
+
+    if { ![db_0or1row latest_ga {} -column_array row] } {
+	# Set default values
+	set row(gradattr_set_id) ""
+	set row(latest_revision_id) ""
+    }
+    
+    if { $row(latest_revision_id) ne "" } {
+	set latest_revision_id $row(latest_revision_id)
+	set row(gradattr_ids) [db_list latest_gradattr_ids {}]
+    } else {
+	set row(gradattr_ids) ""
+    }
+}
+
+
 ad_proc -public curriculum_central::uos::get_workload {
     {-uos_id:required}
     {-array:required}
@@ -772,6 +853,23 @@
 }
 
 
+ad_proc curriculum_central::uos::graduate_attributes_get_options {
+    {-package_id ""}
+} {
+    Returns a two-column list of registered graduate attributes.
+
+    @return Returns a two-column list of registered graduate attributes.
+} {
+    if { $package_id eq ""} {
+	set package_id [ad_conn package_id]
+    }
+
+    set ga_list [db_list_of_lists select_ga {}]
+
+    return $ga_list
+}
+
+
 #####
 #
 # UoS Pending
@@ -969,6 +1067,11 @@
     content::item::set_live_revision -revision_id $latest_tl_revision
     db_dml set_live_tl_revision {}
 
+    # Do the same for cc_uos_gradattr_set
+    db_1row get_latest_ga_revision {}
+    content::item::set_live_revision -revision_id $latest_ga_revision
+    db_dml set_live_ga_revision {}
+
     # Do the same for cc_uos_workload
     db_1row get_latest_workload_revision {}
     content::item::set_live_revision -revision_id $latest_workload_revision
Index: openacs-4/packages/curriculum-central/www/coordinate/gradattr-ae-postgresql.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/curriculum-central/www/coordinate/gradattr-ae-postgresql.xql,v
diff -u
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/curriculum-central/www/coordinate/gradattr-ae-postgresql.xql	4 Jan 2006 23:32:36 -0000	1.1
@@ -0,0 +1,27 @@
+<?xml version="1.0"?>
+
+<queryset>
+   <rdbms><type>postgresql</type><version>7.4</version></rdbms>
+
+   <fullquery name="gradattr_update">
+     <querytext>
+       UPDATE cc_uos_gradattr
+           SET name = :name,
+	   identifier = :identifier,
+	   description = :description,
+	   level = :level
+	   WHERE gradattr_id = :gradattr_id
+     </querytext>
+   </fullquery>
+
+   <fullquery name="object_update">
+     <querytext>
+       UPDATE acs_objects
+           SET modifying_user = :modifying_user,
+	   modifying_ip = :modifying_ip,
+	   package_id = :package_id
+	   WHERE object_id = :gradattr_id
+     </querytext>
+   </fullquery>
+
+</queryset>
Index: openacs-4/packages/curriculum-central/www/coordinate/gradattr-ae.adp
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/curriculum-central/www/coordinate/gradattr-ae.adp,v
diff -u
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/curriculum-central/www/coordinate/gradattr-ae.adp	4 Jan 2006 23:32:36 -0000	1.1
@@ -0,0 +1,6 @@
+<master>
+<property name="title">@page_title;noquote@</property>
+<property name="context">@context;noquote@</property>
+<property name="focus">gradattr.name</property>
+
+<formtemplate id="gradattr"></formtemplate>
Index: openacs-4/packages/curriculum-central/www/coordinate/gradattr-ae.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/curriculum-central/www/coordinate/gradattr-ae.tcl,v
diff -u
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/curriculum-central/www/coordinate/gradattr-ae.tcl	4 Jan 2006 23:32:36 -0000	1.1
@@ -0,0 +1,74 @@
+ad_page_contract {
+    Add/Edit a graduate attribute
+
+    @author Nick Carroll (nick.c@rroll.net)
+    @creation-date 2006-01-04
+    @cvs-id $Id: gradattr-ae.tcl,v 1.1 2006/01/04 23:32:36 ncarroll Exp $
+} {
+    gradattr_id:integer,optional
+    {return_url "gradattrs"}
+}
+
+auth::require_login
+
+if { [info exists gradattr_id] } {
+    set page_title [_ curriculum-central.edit_graduate_attribute]
+} else {
+    set page_title [_ curriculum-central.add_graduate_attribute]
+}
+
+set context [list $page_title]
+set package_id [ad_conn package_id]
+
+ad_form -name gradattr -cancel_url $return_url -form {
+    {gradattr_id:key(acs_object_id_seq)}
+    {return_url:text(hidden) {value $return_url}}
+    {name:text
+	{html {size 25}}
+	{label "[_ curriculum-central.name]" }
+	{help_text "[_ curriculum-central.help_enter_graduate_attribute_name]"}
+    }
+    {identifier:text
+	{html {size 25}}
+	{label "[_ curriculum-central.identifier]" }
+	{help_text "[_ curriculum-central.help_enter_graduate_attribute_identifier]"}
+    }
+    {description:text(textarea)
+	{html {cols 40 rows 10}}
+	{label "[_ curriculum-central.description]" }
+	{help_text "[_ curriculum-central.help_enter_graduate_attribute_description]"}
+    }
+    {level:integer(radio)
+	{label "[_ curriculum-central.level]" }
+	{help_text "[_ curriculum-central.help_enter_graduate_attribute_level]"}
+	{options 
+	    {{"[_ curriculum-central.very_low]" 1}
+	     {"[_ curriculum-central.low]" 2}
+	     {"[_ curriculum-central.moderate]" 3}
+	     {"[_ curriculum-central.high]" 4}
+	     {"[_ curriculum-central.very_high]" 5}}
+	}
+    }
+} -select_query {
+       SELECT name, identifier, description, level
+	   FROM cc_uos_gradattr WHERE gradattr_id = :gradattr_id
+} -new_data {
+    package_instantiate_object \
+	-var_list [list [list package_id $package_id] \
+		        [list object_type cc_uos_gradattr] \
+		        [list name $name] \
+		        [list identifier $identifier] \
+		        [list description $description] \
+		        [list level $level]] \
+	-form_id gradattr cc_uos_gradattr
+
+} -edit_data {
+    set modifying_user [ad_conn user_id]
+    set modifying_ip [ad_conn peeraddr]
+
+    db_dml gradattr_update {}
+    db_dml object_update {}
+} -after_submit {
+    ad_returnredirect $return_url
+    ad_script_abort
+}
Index: openacs-4/packages/curriculum-central/www/coordinate/gradattrs-postgresql.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/curriculum-central/www/coordinate/gradattrs-postgresql.xql,v
diff -u
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/curriculum-central/www/coordinate/gradattrs-postgresql.xql	4 Jan 2006 23:32:36 -0000	1.1
@@ -0,0 +1,16 @@
+<?xml version="1.0"?>
+
+<queryset>
+   <rdbms><type>postgresql</type><version>7.4</version></rdbms>
+
+   <fullquery name="get_gradattrs">
+     <querytext>
+       SELECT g.gradattr_id, g.name, g.identifier, g.description, g.level
+       FROM cc_uos_gradattr g, acs_objects o
+	   WHERE package_id = :package_id
+	   AND g.gradattr_id = o.object_id
+	   [template::list::orderby_clause -orderby -name "gradattrs"]
+     </querytext>
+   </fullquery>
+
+</queryset>
Index: openacs-4/packages/curriculum-central/www/coordinate/gradattrs.adp
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/curriculum-central/www/coordinate/gradattrs.adp,v
diff -u
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/curriculum-central/www/coordinate/gradattrs.adp	4 Jan 2006 23:32:36 -0000	1.1
@@ -0,0 +1,5 @@
+<master>
+<property name="title">@page_title;noquote@</property>
+<property name="context">@context;noquote@</property>
+
+<listtemplate name="gradattrs"></listtemplate>
Index: openacs-4/packages/curriculum-central/www/coordinate/gradattrs.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/curriculum-central/www/coordinate/gradattrs.tcl,v
diff -u
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/curriculum-central/www/coordinate/gradattrs.tcl	4 Jan 2006 23:32:36 -0000	1.1
@@ -0,0 +1,71 @@
+ad_page_contract {
+    Page for listing graduate attributes.
+
+    @author Nick Carroll (nick.c@rroll.net)
+    @creation-date 2006-1-4
+    @cvs-id $Id: gradattrs.tcl,v 1.1 2006/01/04 23:32:36 ncarroll Exp $
+} {
+    {orderby "name,asc"}
+}
+
+set page_title "[_ curriculum-central.graduate_attributes]"
+set context [list [list . [_ curriculum-central.coordinate]] $page_title]
+set package_id [ad_conn package_id]
+
+set elements {
+    edit {
+	sub_class narrow
+	display_template {
+	    <img src="/shared/images/Edit16.gif" height="16" width="16" border="0">
+	}
+	link_url_eval {[export_vars -base gradattr-ae { gradattr_id }]}
+	link_html {title "#curriculum-central.edit_graduate_attribute#"}
+    }
+    name {
+	label "#curriculum-central.name#"
+    }
+    identifier {
+	label "#curriculum-central.identifier#"
+    }
+    description {
+	label "#curriculum-central.description#"
+    }
+    level {
+	display_template {
+	    <switch @gradattrs.level@>
+	        <case value="1">
+	            #curriculum-central.very_low#
+	        </case>
+	        <case value="2">
+	            #curriculum-central.low#
+	        </case>
+	        <case value="3">
+	            #curriculum-central.moderate#
+	        </case>
+	        <case value="4">
+	            #curriculum-central.high#
+	        </case>
+	        <case value="5">
+	            #curriculum-central.very_high#
+	        </case>
+	    </switch>
+	}
+	label "#curriculum-central.level#"
+    }
+}
+
+template::list::create \
+    -name gradattrs \
+    -actions [list "#curriculum-central.add_graduate_attribute#" [export_vars -base gradattr-ae {}] "#curriculum-central.add_graduate_attribute_to_list#"] \
+    -multirow gradattrs \
+    -no_data "#curriculum-central.no_graduate_attributes_created#" \
+    -elements $elements \
+    -orderby {
+	name {orderby {lower(name)}}
+	identifier {orderby {lower(identifier)}}
+	level {orderby level}
+    }
+
+db_multirow gradattrs get_gradattrs {}
+
+ad_return_template
Index: openacs-4/packages/curriculum-central/www/coordinate/tl-method-ae.adp
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/curriculum-central/www/coordinate/tl-method-ae.adp,v
diff -u -r1.1 -r1.2
--- openacs-4/packages/curriculum-central/www/coordinate/tl-method-ae.adp	3 Jan 2006 03:23:28 -0000	1.1
+++ openacs-4/packages/curriculum-central/www/coordinate/tl-method-ae.adp	4 Jan 2006 23:32:36 -0000	1.2
@@ -1,6 +1,6 @@
 <master>
 <property name="title">@page_title;noquote@</property>
 <property name="context">@context;noquote@</property>
-<property name="focus">tl_method.pretty_name</property>
+<property name="focus">tl_method.name</property>
 
 <formtemplate id="tl_method"></formtemplate>
\ No newline at end of file
Index: openacs-4/packages/curriculum-central/www/coordinate/tl-methods.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/curriculum-central/www/coordinate/tl-methods.tcl,v
diff -u -r1.1 -r1.2
--- openacs-4/packages/curriculum-central/www/coordinate/tl-methods.tcl	3 Jan 2006 03:23:28 -0000	1.1
+++ openacs-4/packages/curriculum-central/www/coordinate/tl-methods.tcl	4 Jan 2006 23:32:36 -0000	1.2
@@ -1,5 +1,5 @@
 ad_page_contract {
-    Page for listing Teaching and Learning Approachess.
+    Page for listing Teaching and Learning Approaches.
 
     @author Nick Carroll (nick.c@rroll.net)
     @creation-date 2005-11-15
@@ -30,12 +30,6 @@
     description {
 	label "#curriculum-central.description#"
     }
-    delete {
-	sub_class narrow
-	display_template {
-	    <img src="/shared/images/Delete16.gif" height="16" width="16" border="0">
-	}
-    }
 }
 
 template::list::create \
Index: openacs-4/packages/curriculum-central/www/coordinate/uos-edit.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/curriculum-central/www/coordinate/uos-edit.tcl,v
diff -u -r1.8 -r1.9
--- openacs-4/packages/curriculum-central/www/coordinate/uos-edit.tcl	4 Jan 2006 00:24:16 -0000	1.8
+++ openacs-4/packages/curriculum-central/www/coordinate/uos-edit.tcl	4 Jan 2006 23:32:36 -0000	1.9
@@ -177,7 +177,29 @@
     }
 }
 
-# Retrieve workflow info for Unit of Study.
+
+# Retrieve graduate attribute info for Unit of Study.
+curriculum_central::uos::get_graduate_attributes \
+    -uos_id $uos_id \
+    -array uos_gradattr
+
+# Add widgets for Graduate Attributes
+ad_form -extend -name uos -form {
+    {gradattr_set_id:integer(hidden),optional
+	{value $uos_gradattr(gradattr_set_id)}
+    }
+    {gradattr_ids:text(multiselect),multiple,optional
+	{label "[_ curriculum-central.graduate_attributes]"}
+	{options [curriculum_central::uos::graduate_attributes_get_options]}
+	{html {size 5}}
+	{values $uos_gradattr(gradattr_ids)}
+	{mode display}
+        {help_text "[_ curriculum-central.help_graduate_attributes]"}
+    }
+}
+
+
+# Retrieve workload info for Unit of Study.
 curriculum_central::uos::get_workload \
     -uos_id $uos_id \
     -array uos_workload
@@ -308,6 +330,10 @@
 	    -tl_id $tl_id \
 	    -tl_approach_ids $tl_approach_ids
 
+	curriculum_central::uos::update_graduate_attributes \
+	    -gradattr_set_id $gradattr_set_id \
+	    -gradattr_ids $gradattr_ids
+
 	curriculum_central::uos::update_workload \
 	    -workload_id $workload_id \
 	    -formal_contact_hrs $formal_contact_hrs \