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.27 -r1.28 --- openacs-4/packages/curriculum-central/catalog/curriculum-central.en_US.ISO-8859-1.xml 9 Jan 2006 05:52:06 -0000 1.27 +++ openacs-4/packages/curriculum-central/catalog/curriculum-central.en_US.ISO-8859-1.xml 11 Jan 2006 00:49:17 -0000 1.28 @@ -2,6 +2,22 @@ <message_catalog package_key="curriculum-central" package_version="0.1d" locale="en_US" charset="ISO-8859-1"> <msg key="uos">UoS</msg> + <msg key="course_content">Course Content</msg> + <msg key="help_enter_name_of_schedule_week">Enter a name for a scheduled week. For example, enter either Week 1, Week 2, Study Vacation, or Exam Period.</msg> + <msg key="uos_schedule">UoS Schedule</msg> + <msg key="uos_schedules">UoS Schedules</msg> + <msg key="add_schedule_week">Add Schedule Week</msg> + <msg key="add_week_to_list">Add week to list</msg> + <msg key="schedule_week">Schedule Week</msg> + <msg key="no_schedule_weeks_created">No schedule weeks created.</msg> + <msg key="schedule">Schedule</msg> + <msg key="add_a_schedule_week">Add a Schedule Week</msg> + <msg key="view_schedule_template">View Schedule Template</msg> + <msg key="edit_schedule">Edit Schedule</msg> + <msg key="edited_schedule">Edited Schedule</msg> + <msg key="assessment">Assessment</msg> + <msg key="following_are_grade_descriptors">The following are grade descriptors for this Unit of Study.</msg> + <msg key="help_enter_details_of_what_a_student_must_achieve_to_earn_this_grade">Enter details of what a student must acheive to earn this grade.</msg> <msg key="view_grade_descriptors">View Grade Descriptors</msg> <msg key="add_a_grade_descriptor">Add a Grade Descriptor</msg> <msg key="help_enter_name_of_grade_type">Enter a name for the grade type. Eg High Distinction or Pass.</msg> @@ -55,9 +71,8 @@ <msg key="edit_assess_method">Edit Assessment Method</msg> <msg key="add_assess_method">Add Assessment Method</msg> <msg key="assess_methods">Assessment Methods</msg> - <msg key="assessment_and_schedule">Asessment and Schedule</msg> - <msg key="edit_assess_sched">Edit Assessment and Schedule</msg> - <msg key="edited_assess_sched">Edited Assessment and Schedule</msg> + <msg key="edit_assessment">Edit Assessment</msg> + <msg key="edited_assessment">Edited Assessment</msg> <msg key="uos_assessment">Uos Assessment</msg> <msg key="uos_assessments">Uos Assessments</msg> <msg key="uos_assessment_revision">Uos Assessment Revision</msg> @@ -122,7 +137,7 @@ <msg key="edit_tl_method">Edit T&L Method</msg> <msg key="edit_tl">Edit T&L</msg> <msg key="edited_tl">Edited T&L</msg> - <msg key="tl_arrangements_and_requirements">Teaching & Learning Arrangements and Requirements</msg> + <msg key="tl_arrangements_and_requirements">Teaching & Learning (T&L) Arrangements and Requirements</msg> <msg key="teaching_and_learning_approach">Teaching and Learning Approach</msg> <msg key="uos_teaching_and_learning">UoS Teaching and Learning</msg> <msg key="uos_teaching_and_learning_revision">UoS Teaching and Learning Revision</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.11 -r1.12 --- openacs-4/packages/curriculum-central/sql/postgresql/uos-create.sql 9 Jan 2006 05:46:49 -0000 1.11 +++ openacs-4/packages/curriculum-central/sql/postgresql/uos-create.sql 11 Jan 2006 00:49:17 -0000 1.12 @@ -326,3 +326,6 @@ -- UoS Grade Descriptors \i uos-grades-create.sql + +-- UoS Schedule +\i uos-schedule-create.sql Index: openacs-4/packages/curriculum-central/sql/postgresql/uos-schedule-create.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/curriculum-central/sql/postgresql/uos-schedule-create.sql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/curriculum-central/sql/postgresql/uos-schedule-create.sql 11 Jan 2006 00:49:17 -0000 1.1 @@ -0,0 +1,571 @@ +-- +-- packages/curriculum-central/sql/postgresql/uos-schedule-create.sql +-- +-- @author Nick Carroll (nick.c@rroll.net) +-- @creation-date 2006-01-06 +-- @cvs-id $Id: uos-schedule-create.sql,v 1.1 2006/01/11 00:49:17 ncarroll Exp $ +-- +-- + + +-- Create Schedule Week object +create function inline_0 () +returns integer as ' +begin + PERFORM acs_object_type__create_type ( + ''cc_uos_schedule_week'', -- object_type + ''#curriculum-central.schedule_week#'', -- pretty_name + ''#curriculum-central.schedule_weeks#'', -- pretty_plural + ''acs_object'', -- supertype + ''cc_uos_schedule_week'', -- table_name + ''week_id'', -- id_column + null, -- package_name + ''f'', -- abstract_p + null, -- type_extension_table + ''cc_uos_schedule_week__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 schedule. +create table cc_uos_schedule_week ( + week_id integer + constraint cc_uos_schedule_week_week_id_fk + references acs_objects(object_id) + constraint cc_uos_schedule_week_week_id_pk + primary key, + name varchar(256), -- Eg. Week 1, StuVac, Exams. + package_id integer +); + + +create function inline_0 () +returns integer as' +begin + PERFORM acs_object_type__create_type ( + ''cc_uos_schedule_set'', -- object_type + ''#curriculum-central.uos_schedule_set#'', -- pretty_name + ''#curriculum-central.uos_schedule_sets#'', -- pretty_plural + ''acs_object'', -- supertype + ''cc_uos_schedule_set'', -- table_name + ''schedule_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 schedule set as a child type of Uos. +select content_type__register_child_type ( + 'cc_uos', -- parent_type + 'cc_uos_schedule_set', -- child_type + 'generic', -- relation_tag + 0, -- min_n + null -- max_n +); + + +-- content_item subtype +create table cc_uos_schedule_set ( + schedule_set_id integer + constraint cc_uos_schedule_set_fk + references cr_items(item_id) + on delete cascade + constraint cc_uos_schedule_set_pk + primary key, + parent_uos_id integer, + live_revision_id integer, + latest_revision_id integer +); + + +-- Create the UoS Schedule set content_revision +-- A revision may point to many Schedules in the mapping +-- table below. +create table cc_uos_schedule_set_revs ( + schedule_set_revision_id integer + constraint cc_uos_schedule_set_rev_pk + primary key + constraint cc_uos_schedule_set_rev_fk + references cr_revisions(revision_id) + on delete cascade +); + +-- Create the UoS revision content type. +select content_type__create_type ( + 'cc_uos_schedule_set_rev', + 'content_revision', + '#curriculum-central.uos_schedule_set_revision#', + '#curriculum-central.uos_schedule_set_revisions#', + 'cc_uos_schedule_set_revs', + 'schedule_set_revision_id', + 'content_revision.revision_name' +); + +-- Register uos_schedule_set_revision as a child type of uos_revision. +select content_type__register_child_type ( + 'cc_uos_revision', -- parent_type + 'cc_uos_schedule_set_rev', -- child_type + 'generic', -- relation_tag + 0, -- min_n + null -- max_n +); + + +-- Create Schedule object +create function inline_0 () +returns integer as ' +begin + PERFORM acs_object_type__create_type ( + ''cc_uos_schedule'', -- object_type + ''#curriculum-central.schedule#'', -- pretty_name + ''#curriculum-central.schedules#'', -- pretty_plural + ''acs_object'', -- supertype + ''cc_uos_schedule'', -- table_name + ''schedule_id'', -- id_column + null, -- package_name + ''f'', -- abstract_p + null, -- type_extension_table + ''cc_uos_schedule__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 schedule. +create table cc_uos_schedule ( + schedule_id integer + constraint cc_uos_schedule_id_fk + references acs_objects(object_id) + constraint cc_uos_schedule_id_pk + primary key, + week_id integer + constraint cc_uos_schedule_week_fk + references cc_uos_schedule_week(week_id), + course_content text, + assessment_ids varchar(1024) +); + +-- Create Mapping table between revision and texbook. +-- A revision can refer to many schedules, since a +-- Unit of Study may require students to study many schedules. +create table cc_uos_schedule_map ( + revision_id integer + constraint cc_uos_schedule_map_rev_id_fk + references cc_uos_schedule_set_revs(schedule_set_revision_id), + schedule_id integer + constraint cc_uos_schedule_map_schedule_id_fk + references cc_uos_schedule(schedule_id) +); + + +-- +-- +-- Create the functions for the schedule content item and revisions. +-- +-- + +select define_function_args('cc_uos_schedule_set__new', 'schedule_set_id,parent_uos_id,creation_user,creation_ip,context_id,item_subtype;cc_uos_schedule_set,content_type;cc_uos_schedule_set_rev,object_type,package_id'); + +create function cc_uos_schedule_set__new( + integer, -- schedule_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_schedule_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_schedule_set_id cc_uos_schedule_set.schedule_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 schedule set per Unit of Study, + -- so append uos_id + -- to "uos_schedule_set_for_". + v_name := ''uos_schedule_set_for_'' || p_parent_uos_id; + + -- create the content item + v_schedule_set_id := content_item__new ( + v_name, -- name + v_folder_Id, -- parent_id + p_schedule_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_schedule_set_rev__new ( + null, -- schedule_set_revision_id + v_schedule_set_id, -- schedule_set_id + now(), -- creation_date + p_creation_user, -- creation_user + p_creation_ip -- creation_ip + ); + + -- create the item type row + INSERT INTO cc_uos_schedule_set ( + schedule_set_id, parent_uos_id, latest_revision_id + ) VALUES ( + v_schedule_set_id, p_parent_uos_id, v_revision_id + ); + + + -- associate the UoS schedule 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_schedule_set_id, + ''cc_uos_schedule_set'' + ); + + return v_schedule_set_id; + +end; +' language plpgsql; + + +select define_function_args('cc_uos_schedule_set__delete', 'schedule_set_id'); + +create function cc_uos_schedule_set__delete (integer) +returns integer as ' +declare + p_schedule_set_id alias for $1; +begin + + perform content_item__delete(p_schedule_set_id); + + return 0; + +end; +' language 'plpgsql'; + + +create or replace function cc_uos_schedule_set_rev__new ( + integer, -- schedule_set_revision_id + integer, -- schedule_set_id + timestamptz, -- creation_date + integer, -- creation_user + varchar -- creation_ip +) returns int +as ' +declare + p_schedule_set_revision_id alias for $1; + p_schedule_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_schedules#'', -- title + null, -- description + current_timestamp, -- publish_date + null, -- mime_type + null, -- nls_language + null, -- new_data + p_schedule_set_id, -- item_id + p_schedule_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_schedule_set_revs (schedule_set_revision_id) + VALUES (v_revision_id); + + -- Update the latest revision id in cc_uos_schedule_set + UPDATE cc_uos_schedule_set SET latest_revision_id = v_revision_id + WHERE schedule_set_id = p_schedule_set_id; + + return v_revision_id; +end; +' language 'plpgsql'; + + +-- +-- +-- Create the functions for the cc_uos_schedule object. +-- +-- + +select define_function_args('cc_uos_schedule__new','schedule_id,week_id,course_content,assessment_ids,creation_date;now,creation_user,creation_ip,package_id,context_id'); + +create function cc_uos_schedule__new ( + integer, -- schedule_id + integer, -- week_id + text, -- course_content + varchar, -- assessment_ids + timestamptz, -- creation_date + integer, -- creation_user + varchar, -- creation_ip + integer, -- package_id + integer -- context_id +) returns integer as ' +declare + p_schedule_id alias for $1; -- default null + p_week_id alias for $2; + p_course_content alias for $3; + p_assessment_ids 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_schedule_id cc_uos_schedule.schedule_id%TYPE; +begin + v_schedule_id := acs_object__new ( + p_schedule_id, + ''cc_uos_schedule'', + p_creation_date, + p_creation_user, + p_creation_ip, + p_context_id, + NULL, + p_package_id + ); + + INSERT INTO cc_uos_schedule ( + schedule_id, week_id, course_content, assessment_ids + ) + VALUES ( + v_schedule_id, p_week_id, p_course_content, p_assessment_ids + ); + + return v_schedule_id; + +end;' language 'plpgsql'; + + +select define_function_args('cc_uos_schedule__del','schedule_id'); + +create function cc_uos_schedule__del (integer) +returns integer as ' +declare + p_schedule_id alias for $1; +begin + DELETE FROM acs_permissions WHERE object_id = p_schedule_id; + + DELETE FROM cc_uos_schedule WHERE schedule_id = p_schedule_id; + + RAISE NOTICE ''Deleting schedule...''; + PERFORM acs_object__delete(p_schedule_id); + + return 0; + +end;' language 'plpgsql'; + + +select define_function_args('cc_uos_schedule__name','schedule_id'); + +create function cc_uos_schedule__name (integer) +returns varchar as ' +declare + p_schedule_id alias for $1; + + v_name varchar; +begin + SELECT cc_uos_schedule_week__name(week_id) INTO v_name + FROM cc_uos_schedule + WHERE schedule_id = p_schedule_id; + + return v_name; +end; +' language 'plpgsql'; + + +-- +-- Maps a schedule to a schedule revision set. +-- +create function cc_uos_schedule__map ( + integer, -- revision_id + integer -- schedule_id +) returns integer as ' +declare + p_revision_id alias for $1; + p_schedule_id alias for $2; +begin + + RAISE NOTICE ''Mapping schedule to a revision set...''; + + INSERT INTO cc_uos_schedule_map (revision_id, schedule_id) + VALUES (p_revision_id, p_schedule_id); + + return 0; +end; +' language 'plpgsql'; + + +-- +-- Unmaps a schedule from a revision set. +-- +create function cc_uos_schedule__unmap ( + integer, -- revision_id + integer -- schedule_id +) returns integer as ' +declare + p_revision_id alias for $1; + p_schedule_id alias for $2; +begin + + RAISE NOTICE ''Deleting mapping between schedule and revision set...''; + + DELETE FROM cc_uos_schedule_map + WHERE revision_id = p_revision_id + AND schedule_id = p_schedule_id; + + return 0; +end; +' language 'plpgsql'; + + +-- +-- +-- Create the functions for the cc_uos_schedule_week object. +-- +-- + +select define_function_args('cc_uos_schedule_week__new','type_id,name,creation_date;now,creation_user,creation_ip,package_id,context_id'); + +create function cc_uos_schedule_week__new ( + integer, -- week_id + varchar, -- name + timestamptz, -- creation_date + integer, -- creation_user + varchar, -- creation_ip + integer, -- package_id + integer -- context_id +) returns integer as ' +declare + p_week_id alias for $1; -- default null + p_name alias for $2; + p_creation_date alias for $3; -- default now() + p_creation_user alias for $4; -- default null + p_creation_ip alias for $5; -- default null + p_package_id alias for $6; + p_context_id alias for $7; -- default null + + v_week_id cc_uos_schedule_week.week_id%TYPE; +begin + v_week_id := acs_object__new ( + p_week_id, + ''cc_uos_schedule_week'', + p_creation_date, + p_creation_user, + p_creation_ip, + p_context_id, + NULL, + p_package_id + ); + + INSERT INTO cc_uos_schedule_week ( + week_id, name, package_id + ) + VALUES ( + v_week_id, p_name, p_package_id + ); + + return v_week_id; + +end;' language 'plpgsql'; + + +select define_function_args('cc_uos_schedule_week__del','week_id'); + +create function cc_uos_schedule_week__del (integer) +returns integer as ' +declare + p_week_id alias for $1; +begin + DELETE FROM acs_permissions WHERE object_id = p_week_id; + + DELETE FROM cc_uos_schedule_week WHERE week_id = p_week_id; + + RAISE NOTICE ''Deleting schedule...''; + PERFORM acs_object__delete(p_week_id); + + return 0; + +end;' language 'plpgsql'; + + +select define_function_args('cc_uos_schedule_week__name','week_id'); + +create function cc_uos_schedule_week__name (integer) +returns varchar as ' +declare + p_week_id alias for $1; + + v_week_name cc_uos_schedule_week.name%TYPE; +begin + SELECT name INTO v_week_name + FROM cc_uos_schedule_week + WHERE week_id = p_week_id; + + return v_week_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 -r1.10 -r1.11 --- openacs-4/packages/curriculum-central/tcl/curriculum-central-procs.tcl 9 Jan 2006 05:46:49 -0000 1.10 +++ openacs-4/packages/curriculum-central/tcl/curriculum-central-procs.tcl 11 Jan 2006 00:49:17 -0000 1.11 @@ -70,6 +70,11 @@ -content_type "cc_uos_grade_set_rev" \ -include_subtypes "t" + content::folder::register_content_type \ + -folder_id $folder_id \ + -content_type "cc_uos_schedule_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.16 -r1.17 --- openacs-4/packages/curriculum-central/tcl/uos-procs-postgresql.xql 10 Jan 2006 00:52:08 -0000 1.16 +++ openacs-4/packages/curriculum-central/tcl/uos-procs-postgresql.xql 11 Jan 2006 00:49:17 -0000 1.17 @@ -98,6 +98,17 @@ </querytext> </fullquery> + <fullquery name="curriculum_central::uos::add_schedule_widgets.latest_schedule_set"> + <querytext> + SELECT s.schedule_set_id, s.latest_revision_id + FROM cc_uos u, cc_uos_revisions r, cr_items i, cc_uos_schedule_set s + WHERE u.uos_id = :uos_id + AND i.item_id = u.uos_id + AND r.uos_revision_id = i.latest_revision + AND s.parent_uos_id = :uos_id + </querytext> + </fullquery> + <fullquery name="curriculum_central::uos::get_assessment.latest_assess_method_ids"> <querytext> SELECT method_id FROM cc_uos_assess_method_map @@ -132,6 +143,19 @@ </querytext> </fullquery> + <fullquery name="curriculum_central::uos::add_schedule_widgets.latest_schedule"> + <querytext> + SELECT w.week_id, rev.course_content, rev.assessment_ids + FROM cc_uos_schedule_week w LEFT OUTER JOIN + (SELECT s.week_id, s.course_content, s.assessment_ids + FROM cc_uos_schedule_map map, cc_uos_schedule s + WHERE map.revision_id = :latest_revision_id + AND map.schedule_id = s.schedule_id) AS rev + ON (w.week_id = rev.week_id) + ORDER BY w.week_id ASC + </querytext> + </fullquery> + <fullquery name="curriculum_central::uos::get_graduate_attributes.latest_gradattr_ids"> <querytext> SELECT gradattr_id FROM cc_uos_gradattr_map @@ -456,6 +480,16 @@ </querytext> </fullquery> + <fullquery name="curriculum_central::uos::go_live::do_side_effect.get_latest_schedule_revision"> + <querytext> + SELECT i.latest_revision AS latest_schedule_revision + FROM cr_items i, cr_child_rels c + WHERE c.relation_tag = 'cc_uos_schedule_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_ga_revision"> <querytext> SELECT i.latest_revision AS latest_ga_revision @@ -511,6 +545,14 @@ </querytext> </fullquery> + <fullquery name="curriculum_central::uos::go_live::do_side_effect.set_live_schedule_revision"> + <querytext> + UPDATE cc_uos_schedule_set + SET live_revision_id = :latest_schedule_revision + WHERE parent_uos_id = :object_id + </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 @@ -573,4 +615,43 @@ ORDER BY upper_bound DESC </querytext> </fullquery> + + <fullquery name="curriculum_central::uos::update_schedule.update_schedule_set"> + <querytext> + SELECT cc_uos_schedule_set_rev__new ( + null, + :schedule_set_id, + now(), + :user_id, + :creation_ip + ); + </querytext> + </fullquery> + + <fullquery name="curriculum_central::uos::update_schedule.map_schedule_revision"> + <querytext> + SELECT cc_uos_schedule__map ( + :revision_id, + :schedule_id + ); + </querytext> + </fullquery> + + <fullquery name="curriculum_central::uos::get_schedule_pretty_name.pretty_name"> + <querytext> + SELECT name + FROM cc_uos_schedule_week WHERE week_id = :week_id + AND package_id = :package_id + </querytext> + </fullquery> + + <fullquery name="curriculum_central::uos::get_schedule_fields.fields"> + <querytext> + SELECT week_id, :content_prefix || week_id AS content_field, + :assessment_prefix || week_id AS assessment_field + FROM cc_uos_schedule_week WHERE package_id = :package_id + ORDER BY week_id DESC + </querytext> + </fullquery> + </queryset> 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.22 -r1.23 --- openacs-4/packages/curriculum-central/tcl/uos-procs.tcl 10 Jan 2006 00:52:08 -0000 1.22 +++ openacs-4/packages/curriculum-central/tcl/uos-procs.tcl 11 Jan 2006 00:49:17 -0000 1.23 @@ -32,7 +32,6 @@ } -# TODO: Complete workflow ad_proc -private curriculum_central::uos::workflow_create {} { Create the 'uos' workflow for curriculum-central } { @@ -141,9 +140,9 @@ } assigned_states { open } } - edit_assess { - pretty_name "#curriculum-central.edit_assess_sched#" - pretty_past_tense "#curriculum-central.edited_assess_sched#" + edit_assessment { + pretty_name "#curriculum-central.edit_assessment#" + pretty_past_tense "#curriculum-central.edited_assessment#" allowed_roles { stream_coordinator unit_coordinator @@ -155,6 +154,17 @@ } assigned_states { open } } + edit_schedule { + pretty_name "#curriculum-central.edit_schedule#" + pretty_past_tense "#curriculum-central.edited_schedule#" + allowed_roles { + stream_coordinator + unit_coordinator + lecturer + } + privileges { write } + assigned_states { open } + } submit { pretty_name "#curriculum-central.submit#" pretty_past_tense "#curriculum-central.submitted#" @@ -443,6 +453,13 @@ [list object_type "cc_uos_grade_set"]] \ "cc_uos_grade_set"] + # Initiate cc_uos_schedule_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_schedule_set"]] \ + "cc_uos_schedule_set"] + return $uos_id } @@ -862,8 +879,6 @@ 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] \ @@ -880,6 +895,64 @@ } +ad_proc -public curriculum_central::uos::update_schedule { + -schedule_set_id:required + -schedule_fields:required + {-user_id ""} + {-creation_ip ""} +} { + Updates the weekly schedule component for a Unit of Study. + This update proc creates a new schedule revision. + + @param schedule_set_id The ID for a set of schedule weeks. + @param schedule_fields List of schedule fields to be mapped + to the textbook set. The list is structured to contain the week_id + as the first item, the value for the course content field as the + second item, and a list of assessment IDs as the third item. + @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_schedule_set {}] + + # Foreach schedule field, map to the newly created revision_id + # retrieved above. + foreach field $schedule_fields { + set week_id [lindex $field 0] + set course_content [lindex $field 1] + set assessment_ids [lindex $field 2] + + set schedule_id [package_instantiate_object \ + -var_list [list [list package_id $package_id] \ + [list week_id $week_id] \ + [list course_content $course_content] \ + [list assessment_ids $assessment_ids] \ + [list object_type "cc_uos_schedule"]] \ + "cc_uos_schedule"] + + # Use the above schedule_id to map to the revision_id + db_exec_plsql map_schedule_revision {} + } + } + + return $revision_id +} + + ad_proc -public curriculum_central::uos::get_details { {-uos_id:required} {-array:required} @@ -1360,6 +1433,8 @@ # Also set the latest revision to the live revision in cc_uos. db_dml set_live_revision {} + # NC: This needs to be done better. Works for the timebeing. + # Do the same for cc_uos_detail db_1row get_latest_detail_revision {} content::item::set_live_revision -revision_id $latest_detail_revision @@ -1390,10 +1465,15 @@ content::item::set_live_revision -revision_id $latest_assess_revision db_dml set_live_assess_revision {} - # Do the same for cc_uos_assess + # Do the same for cc_uos_grade db_1row get_latest_grade_revision {} content::item::set_live_revision -revision_id $latest_grade_revision db_dml set_live_grade_revision {} + + # Do the same for cc_uos_schedule + db_1row get_latest_schedule_revision {} + content::item::set_live_revision -revision_id $latest_schedule_revision + db_dml set_live_schedule_revision {} } @@ -1498,6 +1578,10 @@ {grade_set_id:integer(hidden),optional {value $grade_set_id} } + {grade_inform:text(inform) + {label "[_ curriculum-central.grade_descriptors]"} + {value "[_ curriculum-central.following_are_grade_descriptors]"} + } } foreach grade_descriptors [db_list_of_lists latest_grade_descriptors {}] { @@ -1510,7 +1594,125 @@ {html {cols 50 rows 4}} {mode display} {value $description} + {help_text "[_ curriculum-central.help_enter_details_of_what_a_student_must_achieve_to_earn_this_grade]"} } } } } + + +ad_proc -public curriculum_central::uos::get_schedule_pretty_name { + {-week_id:required} + {-package_id ""} +} { + Returns a pretty name for the schedule week that matches the given + week_id. + + @param week_id The ID for a schedule week. + @param package_id Instance ID of a package. + + @return Returns a pretty name for the schedule week that matches the + given week_id. Returns an empty string if there is no name for the + given week_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_schedule_fields { + {-package_id ""} +} { + Gets a list of schedule 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 schedule week ID, the second item is the field ID for course content, + which is just the schedule week ID appended to the schedule_week_content_ + prefix. Similarly, the third item is the field ID for assessment IDs, + which is the schedule week ID appended to the schedule_week_assessment_ + prefix. +} { + if { $package_id eq ""} { + set package_id [ad_conn package_id] + } + + set content_prefix "schedule_week_content_" + set assessment_prefix "schedule_week_assessment_" + + return [db_list_of_lists fields {}] +} + + +ad_proc -public curriculum_central::uos::add_schedule_widgets { + {-uos_id:required} + {-form_name:required} + {-section_name ""} + {-package_id ""} + {-content_prefix "schedule_week_content_"} + {-assessment_prefix "schedule_week_assessment_"} +} { + @param uos_id The ID of the Unit of Study for which we create + schedule widgets for. + @param form_name The name of the form to add widgets to. + @param section_name If provided, a section will be added to the form + with the given name. Otherwise no section header will be added. + @param package_id A package instance ID. Otherwise the current + package instance ID is used. + @param content_prefix Prefix used to generate the form field for + the course content for a scheduled week. + @param assessment_prefix Prefix used to generate the form field for + the assessment for a scheduled week. +} { + if { $package_id eq "" } { + set package_id [ad_conn package_id] + } + + # If the section name is provided, then add a section to the form + # using the given section name. + if { $section_name ne "" } { + template::form::section $form_name $section_name + } + + array set row [list] + + if { ![db_0or1row latest_schedule_set {} -column_array row] } { + set row(schedule_set_id) "" + set row(latest_revision_id) "" + } + + set schedule_set_id $row(schedule_set_id) + set latest_revision_id $row(latest_revision_id) + + ad_form -extend -name $form_name -form { + {schedule_set_id:integer(hidden),optional + {value $schedule_set_id} + } + } + + foreach week [db_list_of_lists latest_schedule {}] { + set week_id [lindex $week 0] + set course_content [lindex $week 1] + set assessment_ids [lindex $week 2] + + ad_form -extend -name $form_name -form { + {${content_prefix}${week_id}:text(textarea) + {label "[curriculum_central::uos::get_schedule_pretty_name -week_id $week_id] [_ curriculum-central.course_content]"} + {html {cols 50 rows 4}} + {mode display} + {value $course_content} + } + {${assessment_prefix}${week_id}:text(multiselect),multiple,optional + {label "[curriculum_central::uos::get_schedule_pretty_name -week_id $week_id] [_ curriculum-central.assessment]"} + {options [curriculum_central::uos::assess_method_get_options]} + {html {size 5}} + {mode display} + {values $assessment_ids} + } + } + } +} Index: openacs-4/packages/curriculum-central/www/admin/index.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/curriculum-central/www/admin/index.adp,v diff -u -r1.4 -r1.5 --- openacs-4/packages/curriculum-central/www/admin/index.adp 9 Jan 2006 05:52:06 -0000 1.4 +++ openacs-4/packages/curriculum-central/www/admin/index.adp 11 Jan 2006 00:49:17 -0000 1.5 @@ -32,5 +32,11 @@ <li><a href="grade-ae">#curriculum-central.add_a_grade_descriptor#</a></li> </ul> </li> +<li><span>#curriculum-central.schedule#</span> + <ul> + <li><a href="schedule">#curriculum-central.view_schedule_template#</a></li> + <li><a href="schedule-week-ae">#curriculum-central.add_a_schedule_week#</a></li> + </ul> +</li> </ul> </div> Index: openacs-4/packages/curriculum-central/www/admin/schedule-postgresql.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/curriculum-central/www/admin/schedule-postgresql.xql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/curriculum-central/www/admin/schedule-postgresql.xql 11 Jan 2006 00:49:17 -0000 1.1 @@ -0,0 +1,15 @@ +<?xml version="1.0"?> + +<queryset> + <rdbms><type>postgresql</type><version>7.4</version></rdbms> + + <fullquery name="get_schedule"> + <querytext> + SELECT s.week_id, s.name + FROM cc_uos_schedule_week s + WHERE s.package_id = :package_id + [template::list::orderby_clause -orderby -name "schedule"] + </querytext> + </fullquery> + +</queryset> Index: openacs-4/packages/curriculum-central/www/admin/schedule-week-ae-postgresql.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/curriculum-central/www/admin/schedule-week-ae-postgresql.xql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/curriculum-central/www/admin/schedule-week-ae-postgresql.xql 11 Jan 2006 00:49:17 -0000 1.1 @@ -0,0 +1,23 @@ +<?xml version="1.0"?> + +<queryset> + <rdbms><type>postgresql</type><version>7.4</version></rdbms> + + <fullquery name="week_update"> + <querytext> + UPDATE cc_uos_schedule_week + SET name = :name + WHERE week_id = :week_id + </querytext> + </fullquery> + + <fullquery name="object_update"> + <querytext> + UPDATE acs_objects + SET modifying_user = :modifying_user, + modifying_ip = :modifying_ip + WHERE object_id = :type_id + </querytext> + </fullquery> + +</queryset> Index: openacs-4/packages/curriculum-central/www/admin/schedule-week-ae.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/curriculum-central/www/admin/schedule-week-ae.adp,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/curriculum-central/www/admin/schedule-week-ae.adp 11 Jan 2006 00:49:17 -0000 1.1 @@ -0,0 +1,6 @@ +<master> +<property name="title">@page_title;noquote@</property> +<property name="context">@context;noquote@</property> +<property name="focus">week.name</property> + +<formtemplate id="week"></formtemplate> Index: openacs-4/packages/curriculum-central/www/admin/schedule-week-ae.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/curriculum-central/www/admin/schedule-week-ae.tcl,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/curriculum-central/www/admin/schedule-week-ae.tcl 11 Jan 2006 00:49:17 -0000 1.1 @@ -0,0 +1,49 @@ +ad_page_contract { + Add/Edit a schedule week. + + @author Nick Carroll (nick.c@rroll.net) + @creation-date 2006-01-08 + @cvs-id $Id: schedule-week-ae.tcl,v 1.1 2006/01/11 00:49:17 ncarroll Exp $ +} { + week_id:integer,optional + {return_url "schedule"} +} + +if { [info exists week_id] } { + set page_title [_ curriculum-central.edit_schedule_week] +} else { + set page_title [_ curriculum-central.add_schedule_week] +} + +set context [list $page_title] +set package_id [ad_conn package_id] + +ad_form -name week -cancel_url $return_url -form { + {week_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_schedule_week]"} + } +} -select_query { + SELECT name FROM cc_uos_schedule_week + WHERE week_id = :week_id +} -new_data { + package_instantiate_object \ + -var_list [list [list package_id $package_id] \ + [list object_type cc_uos_schedule_week] \ + [list week_id $week_id] \ + [list name $name]] \ + -form_id week cc_uos_schedule_week + +} -edit_data { + set modifying_user [ad_conn user_id] + set modifying_ip [ad_conn peeraddr] + + db_dml week_update {} + db_dml object_update {} +} -after_submit { + ad_returnredirect $return_url + ad_script_abort +} Index: openacs-4/packages/curriculum-central/www/admin/schedule.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/curriculum-central/www/admin/schedule.adp,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/curriculum-central/www/admin/schedule.adp 11 Jan 2006 00:49:17 -0000 1.1 @@ -0,0 +1,5 @@ +<master> +<property name="title">@page_title;noquote@</property> +<property name="context">@context;noquote@</property> + +<listtemplate name="schedule"></listtemplate> Index: openacs-4/packages/curriculum-central/www/admin/schedule.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/curriculum-central/www/admin/schedule.tcl,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/curriculum-central/www/admin/schedule.tcl 11 Jan 2006 00:49:17 -0000 1.1 @@ -0,0 +1,41 @@ +ad_page_contract { + Page for creating schedule weeks. + + @author Nick Carroll (nick.c@rroll.net) + @creation-date 2006-01-08 + @cvs-id $Id: schedule.tcl,v 1.1 2006/01/11 00:49:17 ncarroll Exp $ +} { + {orderby "week_id,asc"} +} + +set page_title "[_ curriculum-central.uos_schedule]" +set context [list $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 schedule-week-ae { week_id }]} + link_html {title "#curriculum-central.edit_schedule_week#"} + } + name { + label "#curriculum-central.schedule_week#" + } +} + +template::list::create \ + -name schedule \ + -actions [list "#curriculum-central.add_schedule_week#" [export_vars -base schedule-week-ae {}] "#curriculum-central.add_week_to_list#"] \ + -multirow schedule \ + -no_data "#curriculum-central.no_schedule_weeks_created#" \ + -elements $elements \ + -orderby { + week_id {orderby {week_id}} + } + +db_multirow schedule get_schedule {} + +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 -r1.13 -r1.14 --- openacs-4/packages/curriculum-central/www/coordinate/uos-edit.tcl 9 Jan 2006 05:46:50 -0000 1.13 +++ openacs-4/packages/curriculum-central/www/coordinate/uos-edit.tcl 11 Jan 2006 00:49:18 -0000 1.14 @@ -277,8 +277,8 @@ } -# Add assessment and schedule section. -template::form::section uos [_ curriculum-central.assessment_and_schedule] +# Add assessment and section. +template::form::section uos [_ curriculum-central.assessment] # Retrieve assessment info for Unit of Study. curriculum_central::uos::get_assessment \ @@ -312,6 +312,13 @@ -form_name uos +# Add the schedule section and widgets. +curriculum_central::uos::add_schedule_widgets \ + -uos_id $uos_id \ + -form_name uos \ + -section_name [_ curriculum-central.schedule] + + # Add history section template::form::section uos [_ curriculum-central.history] @@ -354,9 +361,9 @@ -action_id $enabled_action_info(action_id) \ -array action_info - # If the current action is edit_assess, then set the + # If the current action is edit_assessment, then set the # grade descriptor fields as editable. - if { $action_info(short_name) eq "edit_assess"} { + if { $action_info(short_name) eq "edit_assessment"} { 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. @@ -366,35 +373,34 @@ element set_properties uos $gd_field_name -mode edit } } + + # If the current action is edit_schedule, then set the + # schedule fields as editable. + if { $action_info(short_name) eq "edit_schedule"} { + foreach schedule_field [curriculum_central::uos::get_schedule_fields] { + # Get the field name from the list of lists. + # week_id is the first item, content field ID is the second item, + # and assessment field ID is the third item. + # We are only interested in the second item. + set schedule_content_field [lindex $schedule_field 1] + element set_properties uos $schedule_content_field -mode edit + + set schedule_assessment_field [lindex $schedule_field 2] + element set_properties uos $schedule_assessment_field -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] @@ -441,15 +447,58 @@ -student_feedback $student_feedback \ -assumed_concepts $assumed_concepts - } elseif { $action_info(short_name) eq "edit_assess" } { + } elseif { $action_info(short_name) eq "edit_assessment" } { curriculum_central::uos::update_assess \ -assess_id $assess_id \ -assess_method_ids $assess_method_ids + + # For Grade Descriptor fields + set grade_descriptors [list] + + if { $enabled_action_id ne "" } { + # Get the grade descriptors, and the information + # added for each one. + 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]] + } + } + curriculum_central::uos::update_grade_descriptors \ -grade_set_id $grade_set_id \ -grade_descriptors $grade_descriptors + + } elseif { $action_info(short_name) eq "edit_schedule" } { + + # For schedule fields + set schedule_fields [list] + + if { $enabled_action_id ne "" } { + # Get the schedule fields, and the information + # added for each one. + foreach schedule_field \ + [curriculum_central::uos::get_schedule_fields] { + set week_id [lindex $schedule_field 0] + set content_field [lindex $schedule_field 1] + set assessment_field [lindex $schedule_field 2] + + # Append week_id, content field and assessment field data. + lappend schedule_fields \ + [list $week_id [element get_value uos $content_field] \ + [element get_value uos $assessment_field]] + } + } + + curriculum_central::uos::update_schedule \ + -schedule_set_id $schedule_set_id \ + -schedule_fields $schedule_fields } # Do a general edit update.