Index: openacs-4/packages/curriculum-central/curriculum-central.info =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/curriculum-central/curriculum-central.info,v diff -u -N -r1.5 -r1.6 --- openacs-4/packages/curriculum-central/curriculum-central.info 3 Jan 2006 12:53:51 -0000 1.5 +++ openacs-4/packages/curriculum-central/curriculum-central.info 9 Jan 2006 05:46:49 -0000 1.6 @@ -7,14 +7,14 @@ f f - + Nick Carroll An application for managing the subjects comprising a course of study in a School or University. WEG Curriculum Central is an application for managing subjects comprising a course of study in a School or University. The application will allow academic staff to collaborate on course syllabus and rubrics, which can then be conveyed to students using course maps. 0 - + 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 -N -r1.25 -r1.26 --- openacs-4/packages/curriculum-central/catalog/curriculum-central.en_US.ISO-8859-1.xml 6 Jan 2006 12:37:38 -0000 1.25 +++ openacs-4/packages/curriculum-central/catalog/curriculum-central.en_US.ISO-8859-1.xml 9 Jan 2006 05:46:49 -0000 1.26 @@ -2,6 +2,23 @@ UoS + Enter a name for the grade type. Eg High Distinction or Pass. + Enter a lower bound for the grade type. For example, a lower bound for a Fail might be 0, a lower bound for a high distinction might be 85. + Enter an upper bound for the grade type. For example, an upper bound for a high distinction might be 100, whereas an upper bound for a Fail might be 49. + Add grade type to list. + No grade types have been created. + Edit Grade Type + Add Grade Type + Grade Type + Lower Bound + Upper Bound + Grade Types + Grade Descriptor Set + Grade Descriptor Sets + Grade Descriptor Set Revision + Grade Descriptor Set Revisions + Grade Descriptor + Grade Descriptors Manage your list of textbooks Enter the title of the textbook. Enter the author of the textbook. 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 -N -r1.10 -r1.11 --- openacs-4/packages/curriculum-central/sql/postgresql/uos-create.sql 6 Jan 2006 12:37:39 -0000 1.10 +++ openacs-4/packages/curriculum-central/sql/postgresql/uos-create.sql 9 Jan 2006 05:46:49 -0000 1.11 @@ -322,4 +322,7 @@ \i uos-assess-create.sql -- UoS Textbooks -\i uos-textbook-create.sql \ No newline at end of file +\i uos-textbook-create.sql + +-- UoS Grade Descriptors +\i uos-grades-create.sql Index: openacs-4/packages/curriculum-central/sql/postgresql/uos-grades-create.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/curriculum-central/sql/postgresql/uos-grades-create.sql,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/curriculum-central/sql/postgresql/uos-grades-create.sql 9 Jan 2006 05:46:49 -0000 1.1 @@ -0,0 +1,574 @@ +-- +-- packages/curriculum-central/sql/postgresql/uos-grade-create.sql +-- +-- @author Nick Carroll (nick.c@rroll.net) +-- @creation-date 2006-01-06 +-- @cvs-id $Id: uos-grades-create.sql,v 1.1 2006/01/09 05:46:49 ncarroll Exp $ +-- +-- + + +-- Create Grade Type object +create function inline_0 () +returns integer as ' +begin + PERFORM acs_object_type__create_type ( + ''cc_uos_grade_type'', -- object_type + ''#curriculum-central.grade_type#'', -- pretty_name + ''#curriculum-central.grade_types#'', -- pretty_plural + ''acs_object'', -- supertype + ''cc_uos_grade_type'', -- table_name + ''type_id'', -- id_column + null, -- package_name + ''f'', -- abstract_p + null, -- type_extension_table + ''cc_uos_grade_type__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 grade. +create table cc_uos_grade_type ( + type_id integer + constraint cc_uos_grade_type_type_id_fk + references acs_objects(object_id) + constraint cc_uos_grade_type_type_id_pk + primary key, + name varchar(256), + lower_bound integer, + upper_bound integer, + package_id integer +); + + +create function inline_0 () +returns integer as' +begin + PERFORM acs_object_type__create_type ( + ''cc_uos_grade_set'', -- object_type + ''#curriculum-central.uos_grade_set#'', -- pretty_name + ''#curriculum-central.uos_grade_sets#'', -- pretty_plural + ''acs_object'', -- supertype + ''cc_uos_grade_set'', -- table_name + ''grade_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 grade set as a child type of Uos. +select content_type__register_child_type ( + 'cc_uos', -- parent_type + 'cc_uos_grade_set', -- child_type + 'generic', -- relation_tag + 0, -- min_n + null -- max_n +); + + +-- content_item subtype +create table cc_uos_grade_set ( + grade_set_id integer + constraint cc_uos_grade_set_fk + references cr_items(item_id) + on delete cascade + constraint cc_uos_grade_set_pk + primary key, + parent_uos_id integer, + live_revision_id integer, + latest_revision_id integer +); + + +-- Create the UoS Grade set content_revision +-- A revision may point to many Grades in the mapping +-- table below. +create table cc_uos_grade_set_revs ( + grade_set_revision_id integer + constraint cc_uos_grade_set_rev_pk + primary key + constraint cc_uos_grade_set_rev_fk + references cr_revisions(revision_id) + on delete cascade +); + +-- Create the UoS revision content type. +select content_type__create_type ( + 'cc_uos_grade_set_rev', + 'content_revision', + '#curriculum-central.uos_grade_set_revision#', + '#curriculum-central.uos_grade_set_revisions#', + 'cc_uos_grade_set_revs', + 'grade_set_revision_id', + 'content_revision.revision_name' +); + +-- Register uos_grade_set_revision as a child type of uos_revision. +select content_type__register_child_type ( + 'cc_uos_revision', -- parent_type + 'cc_uos_grade_set_rev', -- child_type + 'generic', -- relation_tag + 0, -- min_n + null -- max_n +); + + +-- Create Grade object +create function inline_0 () +returns integer as ' +begin + PERFORM acs_object_type__create_type ( + ''cc_uos_grade'', -- object_type + ''#curriculum-central.grade_descriptor#'', -- pretty_name + ''#curriculum-central.grade_descriptors#'', -- pretty_plural + ''acs_object'', -- supertype + ''cc_uos_grade'', -- table_name + ''grade_id'', -- id_column + null, -- package_name + ''f'', -- abstract_p + null, -- type_extension_table + ''cc_uos_grade__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 grade. +create table cc_uos_grade ( + grade_id integer + constraint cc_uos_grade_id_fk + references acs_objects(object_id) + constraint cc_uos_grade_id_pk + primary key, + grade_type_id integer + constraint cc_uos_grade_type_fk + references cc_uos_grade_type(type_id), + description text -- Grade descriptor entry +); + +-- Create Mapping table between revision and texbook. +-- A revision can refer to many gradess, since a +-- Unit of Study may require students to study many grades. +create table cc_uos_grade_map ( + revision_id integer + constraint cc_uos_grade_map_rev_id_fk + references cc_uos_grade_set_revs(grade_set_revision_id), + grade_id integer + constraint cc_uos_grade_map_grade_id_fk + references cc_uos_grade(grade_id) +); + + +-- +-- +-- Create the functions for the grade content item and revisions. +-- +-- + +select define_function_args('cc_uos_grade_set__new', 'grade_set_id,parent_uos_id,creation_user,creation_ip,context_id,item_subtype;cc_uos_grade_set,content_type;cc_uos_grade_set_rev,object_type,package_id'); + +create function cc_uos_grade_set__new( + integer, -- grade_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_grade_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_grade_set_id cc_uos_grade_set.grade_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 grade set per Unit of Study, + -- so append uos_id + -- to "uos_grade_set_for_". + v_name := ''uos_grade_set_for_'' || p_parent_uos_id; + + -- create the content item + v_grade_set_id := content_item__new ( + v_name, -- name + v_folder_Id, -- parent_id + p_grade_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_grade_set_rev__new ( + null, -- grade_set_revision_id + v_grade_set_id, -- grade_set_id + now(), -- creation_date + p_creation_user, -- creation_user + p_creation_ip -- creation_ip + ); + + -- create the item type row + INSERT INTO cc_uos_grade_set ( + grade_set_id, parent_uos_id, latest_revision_id + ) VALUES ( + v_grade_set_id, p_parent_uos_id, v_revision_id + ); + + + -- associate the UoS grade 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_grade_set_id, + ''cc_uos_grade_set'' + ); + + return v_grade_set_id; + +end; +' language plpgsql; + + +select define_function_args('cc_uos_grade_set__delete', 'grade_set_id'); + +create function cc_uos_grade_set__delete (integer) +returns integer as ' +declare + p_grade_set_id alias for $1; +begin + + perform content_item__delete(p_grade_set_id); + + return 0; + +end; +' language 'plpgsql'; + + +create or replace function cc_uos_grade_set_rev__new ( + integer, -- grade_set_revision_id + integer, -- grade_set_id + timestamptz, -- creation_date + integer, -- creation_user + varchar -- creation_ip +) returns int +as ' +declare + p_grade_set_revision_id alias for $1; + p_grade_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_grades#'', -- title + null, -- description + current_timestamp, -- publish_date + null, -- mime_type + null, -- nls_language + null, -- new_data + p_grade_set_id, -- item_id + p_grade_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_grade_set_revs (grade_set_revision_id) + VALUES (v_revision_id); + + -- Update the latest revision id in cc_uos_grade_set + UPDATE cc_uos_grade_set SET latest_revision_id = v_revision_id + WHERE grade_set_id = p_grade_set_id; + + return v_revision_id; +end; +' language 'plpgsql'; + + +-- +-- +-- Create the functions for the cc_uos_grade object. +-- +-- + +select define_function_args('cc_uos_grade__new','grade_id,grade_type_id,description,creation_date;now,creation_user,creation_ip,package_id,context_id'); + +create function cc_uos_grade__new ( + integer, -- grade_id + integer, -- grade_type_id + text, -- description + timestamptz, -- creation_date + integer, -- creation_user + varchar, -- creation_ip + integer, -- package_id + integer -- context_id +) returns integer as ' +declare + p_grade_id alias for $1; -- default null + p_grade_type_id alias for $2; + p_description alias for $3; + p_creation_date alias for $4; -- default now() + p_creation_user alias for $5; -- default null + p_creation_ip alias for $6; -- default null + p_package_id alias for $7; + p_context_id alias for $8; -- default null + + v_grade_id cc_uos_grade.grade_id%TYPE; +begin + v_grade_id := acs_object__new ( + p_grade_id, + ''cc_uos_grade'', + p_creation_date, + p_creation_user, + p_creation_ip, + p_context_id, + NULL, + p_package_id + ); + + INSERT INTO cc_uos_grade ( + grade_id, grade_type_id, description + ) + VALUES ( + v_grade_id, p_grade_type_id, p_description + ); + + return v_grade_id; + +end;' language 'plpgsql'; + + +select define_function_args('cc_uos_grade__del','grade_id'); + +create function cc_uos_grade__del (integer) +returns integer as ' +declare + p_grade_id alias for $1; +begin + DELETE FROM acs_permissions WHERE object_id = p_grade_id; + + DELETE FROM cc_uos_grade WHERE grade_id = p_grade_id; + + RAISE NOTICE ''Deleting grade...''; + PERFORM acs_object__delete(p_grade_id); + + return 0; + +end;' language 'plpgsql'; + + +select define_function_args('cc_uos_grade__name','grade_id'); + +create function cc_uos_grade__name (integer) +returns varchar as ' +declare + p_grade_id alias for $1; + + v_name varchar; +begin + SELECT cc_uos_grade_type__name(grade_type_id) INTO v_name + FROM cc_uos_grade + WHERE grade_id = p_grade_id; + + return v_name; +end; +' language 'plpgsql'; + + +-- +-- Maps a grade to a grade revision set. +-- +create function cc_uos_grade__map ( + integer, -- revision_id + integer -- grade_id +) returns integer as ' +declare + p_revision_id alias for $1; + p_grade_id alias for $2; +begin + + RAISE NOTICE ''Mapping grade to a revision set...''; + + INSERT INTO cc_uos_grade_map (revision_id, grade_id) + VALUES (p_revision_id, p_grade_id); + + return 0; +end; +' language 'plpgsql'; + + +-- +-- Unmaps a grade from a revision set. +-- +create function cc_uos_grade__unmap ( + integer, -- revision_id + integer -- grade_id +) returns integer as ' +declare + p_revision_id alias for $1; + p_grade_id alias for $2; +begin + + RAISE NOTICE ''Deleting mapping between grade and revision set...''; + + DELETE FROM cc_uos_grade_map + WHERE revision_id = p_revision_id + AND grade_id = p_grade_id; + + return 0; +end; +' language 'plpgsql'; + + +-- +-- +-- Create the functions for the cc_uos_grade_type object. +-- +-- + +select define_function_args('cc_uos_grade_type__new','type_id,name,lower_bound,upper_bound,creation_date;now,creation_user,creation_ip,package_id,context_id'); + +create function cc_uos_grade_type__new ( + integer, -- type_id + varchar, -- name + integer, -- lower_bound + integer, -- upper_bound + timestamptz, -- creation_date + integer, -- creation_user + varchar, -- creation_ip + integer, -- package_id + integer -- context_id +) returns integer as ' +declare + p_type_id alias for $1; -- default null + p_name alias for $2; + p_lower_bound alias for $3; + p_upper_bound alias for $4; + p_creation_date alias for $5; -- default now() + p_creation_user alias for $6; -- default null + p_creation_ip alias for $7; -- default null + p_package_id alias for $8; + p_context_id alias for $9; -- default null + + v_type_id cc_uos_grade_type.type_id%TYPE; +begin + v_type_id := acs_object__new ( + p_type_id, + ''cc_uos_grade_type'', + p_creation_date, + p_creation_user, + p_creation_ip, + p_context_id, + NULL, + p_package_id + ); + + INSERT INTO cc_uos_grade_type ( + type_id, name, lower_bound, upper_bound, package_id + ) + VALUES ( + v_type_id, p_name, p_lower_bound, p_upper_bound, p_package_id + ); + + return v_type_id; + +end;' language 'plpgsql'; + + +select define_function_args('cc_uos_grade_type__del','type_id'); + +create function cc_uos_grade_type__del (integer) +returns integer as ' +declare + p_type_id alias for $1; +begin + DELETE FROM acs_permissions WHERE object_id = p_type_id; + + DELETE FROM cc_uos_grade_type WHERE type_id = p_type_id; + + RAISE NOTICE ''Deleting grade...''; + PERFORM acs_object__delete(p_type_id); + + return 0; + +end;' language 'plpgsql'; + + +select define_function_args('cc_uos_grade_type__name','type_id'); + +create function cc_uos_grade_type__name (integer) +returns varchar as ' +declare + p_type_id alias for $1; + + v_type_name cc_uos_grade_type.name%TYPE; +begin + SELECT name INTO v_type_name + FROM cc_uos_grade_type + WHERE type_id = p_type_id; + + return v_type_name; +end; +' language 'plpgsql'; 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 -N -r1.9 -r1.10 --- openacs-4/packages/curriculum-central/tcl/curriculum-central-procs.tcl 6 Jan 2006 12:37:39 -0000 1.9 +++ openacs-4/packages/curriculum-central/tcl/curriculum-central-procs.tcl 9 Jan 2006 05:46:49 -0000 1.10 @@ -65,6 +65,11 @@ -content_type "cc_uos_textbook_set_rev" \ -include_subtypes "t" + content::folder::register_content_type \ + -folder_id $folder_id \ + -content_type "cc_uos_grade_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 -N -r1.14 -r1.15 --- openacs-4/packages/curriculum-central/tcl/uos-procs-postgresql.xql 6 Jan 2006 12:37:39 -0000 1.14 +++ openacs-4/packages/curriculum-central/tcl/uos-procs-postgresql.xql 9 Jan 2006 05:46:49 -0000 1.15 @@ -87,6 +87,17 @@ + + + SELECT g.grade_set_id, g.latest_revision_id + FROM cc_uos u, cc_uos_revisions r, cr_items i, cc_uos_grade_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 + + + SELECT method_id FROM cc_uos_assess_method_map @@ -108,6 +119,19 @@ + + + SELECT t.type_id, grade_rev.description + FROM cc_uos_grade_type t LEFT OUTER JOIN + (SELECT g.grade_type_id, g.description + FROM cc_uos_grade_map map, cc_uos_grade g + WHERE map.revision_id = :latest_revision_id + AND map.grade_id = g.grade_id) AS grade_rev + ON (t.type_id = grade_rev.grade_type_id) + ORDER BY t.upper_bound DESC + + + SELECT gradattr_id FROM cc_uos_gradattr_map @@ -275,6 +299,27 @@ + + + SELECT cc_uos_grade_set_rev__new ( + null, + :grade_set_id, + now(), + :user_id, + :creation_ip + ); + + + + + + SELECT cc_uos_grade__map ( + :revision_id, + :grade_id + ); + + + SELECT cc_uos_tl_method__map ( @@ -483,7 +528,7 @@ - + SELECT sum(weighting) FROM cc_uos_assess a, @@ -493,6 +538,22 @@ AND map.assess_revision_id = a.latest_revision_id AND map.method_id = meth.method_id - + + + + SELECT name || ' (' || lower_bound || ' to ' || upper_bound || ')' + AS pretty_name + FROM cc_uos_grade_type WHERE type_id = :type_id + AND package_id = :package_id + + + + + + SELECT type_id, :prefix || type_id AS field_id + FROM cc_uos_grade_type WHERE package_id = :package_id + ORDER BY upper_bound DESC + + 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 -N -r1.20 -r1.21 --- openacs-4/packages/curriculum-central/tcl/uos-procs.tcl 6 Jan 2006 12:37:39 -0000 1.20 +++ openacs-4/packages/curriculum-central/tcl/uos-procs.tcl 9 Jan 2006 05:46:49 -0000 1.21 @@ -436,6 +436,13 @@ [list object_type "cc_uos_assess"]] \ "cc_uos_assess"] + # Initiate cc_uos_grade_set + set textbook_set_id [package_instantiate_object \ + -var_list [list [list parent_uos_id $uos_id] \ + [list package_id $package_id] \ + [list object_type "cc_uos_grade_set"]] \ + "cc_uos_grade_set"] + return $uos_id } @@ -817,6 +824,62 @@ } +ad_proc -public curriculum_central::uos::update_grade_descriptors { + -grade_set_id:required + -grade_descriptors:required + {-user_id ""} + {-creation_ip ""} +} { + Updates the grade descriptor component for a Unit of Study. + This update proc creates a new grade descriptor revision. + + @param grade_set_id The ID for a set of grade descriptors. + @param grade_descriptors List of grade descriptors + to be mapped to the textbook 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 package_id [ad_conn package_id] + + # Set the default value for revision_id. + set revision_id "" + db_transaction { + set revision_id [db_exec_plsql update_grade_set {}] + + # Foreach grade_descriptor map to the newly created revision_id + # retrieved above. + foreach grade_descriptor $grade_descriptors { + set grade_type_id [lindex $grade_descriptor 0] + set description [lindex $grade_descriptor 1] + + ns_log Warning "NC: (grade_type_id $grade_type_id) = $description" + + set grade_id [package_instantiate_object \ + -var_list [list [list package_id $package_id] \ + [list grade_type_id $grade_type_id] \ + [list description $description] \ + [list object_type "cc_uos_grade"]] \ + "cc_uos_grade"] + + # Use the above grade_id to map to the revision_id + db_exec_plsql map_grade_descriptor_revision {} + } + } + + return $revision_id +} + + ad_proc -public curriculum_central::uos::get_details { {-uos_id:required} {-array:required} @@ -1354,4 +1417,95 @@ } return $total -} \ No newline at end of file +} + + +ad_proc -public curriculum_central::uos::get_grade_descriptor_pretty_name { + {-type_id:required} + {-package_id ""} +} { + Returns a pretty name for the grade descriptor that matches the given + type_id. + + @param type_id The ID for a grade descriptor type. + @param package_id Instance ID of a package. + + @return Returns a pretty name for the grade descriptor that matches the + given type_id. Pretty name includes the grade bounds. Returns an + empty string if there is no name for the given type_id. +} { + if { $package_id eq ""} { + set package_id [ad_conn package_id] + } + + return [db_string pretty_name {} -default ""] +} + + +ad_proc -public curriculum_central::uos::get_grade_descriptor_fields { + {-package_id ""} +} { + Gets a list of grade descriptor field IDs. + + @param package_id Instance ID of a package. + + @return Returns a list of lists where the first item of a list contains + the grade type ID, and the second item is the field ID, which is just + the grade type ID appended to the grade_descriptor_ prefix. +} { + if { $package_id eq ""} { + set package_id [ad_conn package_id] + } + + set prefix "grade_descriptor_" + + return [db_list_of_lists fields {}] +} + + +ad_proc -public curriculum_central::uos::add_grade_descriptor_widgets { + {-uos_id:required} + {-form_name:required} + {-package_id ""} + {-prefix "grade_descriptor_"} +} { + @param uos_id The ID of the Unit of Study for which we create grade + descriptor widgets for. + @param form_name The name of the form to add widgets to. + @param package_id + @param prefix +} { + if { $package_id eq ""} { + set package_id [ad_conn package_id] + } + + array set row [list] + + if { ![db_0or1row latest_grade_set {} -column_array row] } { + set row(grade_set_id) "" + set row(latest_revision_id) "" + } + + set grade_set_id $row(grade_set_id) + set latest_revision_id $row(latest_revision_id) + + ad_form -extend -name $form_name -form { + {grade_set_id:integer(hidden),optional + {value $grade_set_id} + } + } + + foreach grade_descriptors [db_list_of_lists latest_grade_descriptors {}] { + set type_id [lindex $grade_descriptors 0] + set description [lindex $grade_descriptors 1] + + ad_form -extend -name $form_name -form { + {${prefix}${type_id}:text(textarea) + {label "[curriculum_central::uos::get_grade_descriptor_pretty_name -type_id $type_id]"} + {html {cols 50 rows 4}} + {mode display} + {value $description} + } + } + } +} Index: openacs-4/packages/curriculum-central/www/admin/grade-ae-postgresql.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/curriculum-central/www/admin/grade-ae-postgresql.xql,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/curriculum-central/www/admin/grade-ae-postgresql.xql 9 Jan 2006 05:46:50 -0000 1.1 @@ -0,0 +1,25 @@ + + + + postgresql7.4 + + + + UPDATE cc_uos_grade_type + SET name = :name, + lower_bound = :lower_bound, + upper_bound = :upper_bound + WHERE type_id = :type_id + + + + + + UPDATE acs_objects + SET modifying_user = :modifying_user, + modifying_ip = :modifying_ip + WHERE object_id = :type_id + + + + Index: openacs-4/packages/curriculum-central/www/admin/grade-ae.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/curriculum-central/www/admin/grade-ae.adp,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/curriculum-central/www/admin/grade-ae.adp 9 Jan 2006 05:46:50 -0000 1.1 @@ -0,0 +1,6 @@ + +@page_title;noquote@ +@context;noquote@ +grade.name + + \ No newline at end of file Index: openacs-4/packages/curriculum-central/www/admin/grade-ae.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/curriculum-central/www/admin/grade-ae.tcl,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/curriculum-central/www/admin/grade-ae.tcl 9 Jan 2006 05:46:50 -0000 1.1 @@ -0,0 +1,62 @@ +ad_page_contract { + Add/Edit a grade type. + + @author Nick Carroll (nick.c@rroll.net) + @creation-date 2006-01-08 + @cvs-id $Id: grade-ae.tcl,v 1.1 2006/01/09 05:46:50 ncarroll Exp $ +} { + type_id:integer,optional + {return_url "grades"} +} + +if { [info exists type_id] } { + set page_title [_ curriculum-central.edit_grade_type] +} else { + set page_title [_ curriculum-central.add_grade_type] +} + +set context [list $page_title] +set package_id [ad_conn package_id] + +ad_form -name grade -cancel_url $return_url -form { + {type_id:key(acs_object_id_seq)} + {return_url:text(hidden) {value $return_url}} + {name:text + {html {size 50}} + {label "#curriculum-central.name#" } + {help_text "[_ curriculum-central.help_enter_name_of_grade_type]"} + } + {lower_bound:integer + {html {size 3}} + {label "#curriculum-central.lower_bound#" } + {help_text "[_ curriculum-central.help_enter_lower_bound]"} + } + {upper_bound:integer + {html {size 3}} + {label "#curriculum-central.upper_bound#" } + {help_text "[_ curriculum-central.help_enter_upper_bound]"} + } +} -select_query { + SELECT name, lower_bound, upper_bound + FROM cc_uos_grade_type + WHERE type_id = :type_id +} -new_data { + package_instantiate_object \ + -var_list [list [list package_id $package_id] \ + [list object_type cc_uos_grade_type] \ + [list type_id $type_id] \ + [list name $name] \ + [list lower_bound $lower_bound] \ + [list upper_bound $upper_bound]] \ + -form_id grade cc_uos_grade_type + +} -edit_data { + set modifying_user [ad_conn user_id] + set modifying_ip [ad_conn peeraddr] + + db_dml grade_update {} + db_dml object_update {} +} -after_submit { + ad_returnredirect $return_url + ad_script_abort +} Index: openacs-4/packages/curriculum-central/www/admin/grades-postgresql.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/curriculum-central/www/admin/grades-postgresql.xql,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/curriculum-central/www/admin/grades-postgresql.xql 9 Jan 2006 05:46:50 -0000 1.1 @@ -0,0 +1,15 @@ + + + + postgresql7.4 + + + + SELECT g.type_id, g.name, g.lower_bound, g.upper_bound + FROM cc_uos_grade_type g + WHERE g.package_id = :package_id + [template::list::orderby_clause -orderby -name "grades"] + + + + Index: openacs-4/packages/curriculum-central/www/admin/grades.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/curriculum-central/www/admin/grades.adp,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/curriculum-central/www/admin/grades.adp 9 Jan 2006 05:46:50 -0000 1.1 @@ -0,0 +1,5 @@ + +@page_title;noquote@ +@context;noquote@ + + Index: openacs-4/packages/curriculum-central/www/admin/grades.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/curriculum-central/www/admin/grades.tcl,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/curriculum-central/www/admin/grades.tcl 9 Jan 2006 05:46:50 -0000 1.1 @@ -0,0 +1,47 @@ +ad_page_contract { + Page for creating grade types. + + @author Nick Carroll (nick.c@rroll.net) + @creation-date 2006-01-08 + @cvs-id $Id: grades.tcl,v 1.1 2006/01/09 05:46:50 ncarroll Exp $ +} { + {orderby "upper_bound,desc"} +} + +set page_title "[_ curriculum-central.uos_grade_types]" +set context [list [_ curriculum-central.uos_grade_types]] +set package_id [ad_conn package_id] + +set elements { + edit { + sub_class narrow + display_template { + + } + link_url_eval {[export_vars -base grade-ae { type_id }]} + link_html {title "#curriculum-central.edit_grade_type#"} + } + name { + label "#curriculum-central.grade_type#" + } + lower_bound { + label "#curriculum-central.lower_bound#" + } + upper_bound { + label "#curriculum-central.upper_bound#" + } +} + +template::list::create \ + -name grades \ + -actions [list "#curriculum-central.add_grade_type#" [export_vars -base grade-ae {}] "#curriculum-central.add_grade_type_to_list#"] \ + -multirow grades \ + -no_data "#curriculum-central.no_grade_types_created#" \ + -elements $elements \ + -orderby { + upper_bound {orderby {upper_bound}} + } + +db_multirow grades get_grades {} + +ad_return_template 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 -N -r1.12 -r1.13 --- openacs-4/packages/curriculum-central/www/coordinate/uos-edit.tcl 6 Jan 2006 12:37:39 -0000 1.12 +++ openacs-4/packages/curriculum-central/www/coordinate/uos-edit.tcl 9 Jan 2006 05:46:50 -0000 1.13 @@ -280,7 +280,6 @@ # Add assessment and schedule section. template::form::section uos [_ curriculum-central.assessment_and_schedule] -# TODO: Work on the following assessment section. # Retrieve assessment info for Unit of Study. curriculum_central::uos::get_assessment \ -uos_id $uos_id \ @@ -307,6 +306,12 @@ } +# Add the grade descriptor widgets. +curriculum_central::uos::add_grade_descriptor_widgets \ + -uos_id $uos_id \ + -form_name uos + + # Add history section template::form::section uos [_ curriculum-central.history] @@ -339,18 +344,57 @@ foreach field [workflow::action::get_element -action_id $action_id -element edit_fields] { element set_properties uos $field -mode edit } + + # Retrieve some workflow information + workflow::case::enabled_action_get \ + -enabled_action_id $enabled_action_id \ + -array enabled_action_info + + workflow::action::get \ + -action_id $enabled_action_info(action_id) \ + -array action_info + + # If the current action is edit_assess, then set the + # grade descriptor fields as editable. + if { $action_info(short_name) eq "edit_assess"} { + foreach gd_field [curriculum_central::uos::get_grade_descriptor_fields] { + # Get the field name from the list of lists. + # type_id is the first item, and field_id is the second item. + # We are only interested in the second item. + set gd_field_name [lindex $gd_field 1] + + element set_properties uos $gd_field_name -mode edit + } + } } # on_submit block ad_form -extend -name uos -on_submit { array set row [list] + # For Grade Descriptor fields + set grade_descriptors [list] + if { $enabled_action_id ne "" } { foreach field [workflow::action::get_element \ -action_id $action_id -element edit_fields] { set row($field) [element get_value uos $field] + + ns_log Warning "NC: $field = [element get_value uos $field]" } + + # TODO: Create get_grade_descriptor_fields proc + foreach descriptor_field \ + [curriculum_central::uos::get_grade_descriptor_fields] { + set type_id [lindex $descriptor_field 0] + set field_id [lindex $descriptor_field 1] + + # Append grade_type_id followed by the description. + lappend grade_descriptors [list $type_id [element get_value uos $field_id]] + + ns_log Warning "$type_id - $field_id - [element get_value uos $field_id]" + } } set activity_log [element get_value uos activity_log] @@ -403,6 +447,9 @@ -assess_id $assess_id \ -assess_method_ids $assess_method_ids + curriculum_central::uos::update_grade_descriptors \ + -grade_set_id $grade_set_id \ + -grade_descriptors $grade_descriptors } # Do a general edit update.