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.6 -r1.7 --- openacs-4/packages/curriculum-central/catalog/curriculum-central.en_US.ISO-8859-1.xml 4 Dec 2005 13:08:26 -0000 1.6 +++ openacs-4/packages/curriculum-central/catalog/curriculum-central.en_US.ISO-8859-1.xml 11 Dec 2005 07:47:40 -0000 1.7 @@ -117,10 +117,12 @@ Select the Dean. Note: The Dean must have an account on the system. Enter a name for this faculty. Example: Faculty of Engineering. Select a staff member from the list of users. + Select the Unit Coordinator from the list of staff. Enter the staff member's title. For example: Mr, Mrs, Ms, Dr, Associate Professor, Professor, etc. Enter the staff member's position. For example: Honorary Associate Professor, Research Fellow, Adjunct Lecturer, etc. Select the department that the staff member belongs to. Staff Title Staff Position + Add Unit of Study 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.2 -r1.3 --- openacs-4/packages/curriculum-central/sql/postgresql/uos-create.sql 4 Dec 2005 07:30:45 -0000 1.2 +++ openacs-4/packages/curriculum-central/sql/postgresql/uos-create.sql 11 Dec 2005 07:47:40 -0000 1.3 @@ -103,8 +103,7 @@ ); --- TODO: variable assignment -select define_function_args('cc_uos__new', 'uos_id,owner_id,object_type,name,code,department,faculty,creation_user,creation_ip,context_id'); +select define_function_args('cc_uos__new', 'uos_id,uos_code,uos_name,unit_coordinator_id,credit_value,semester,online_course_content,contact_hours,assessments,core_uos_for,recommended_uos_for,prerequisites,objectives,outcomes,syllabus,syllabus_format,creation_user,creation_ip,context_id,item_subtype;cc_uos,content_type;cc_uos_revision,object_type,package_id'); create function cc_uos__new( integer, -- uos_id @@ -127,7 +126,9 @@ varchar, -- creation_ip integer, -- context_id varchar, -- item_subtype - varchar -- content_type + varchar, -- content_type + varchar, -- object_type + integer -- package_id ) returns integer as' declare @@ -152,27 +153,68 @@ p_context_id alias for $19; p_item_subtype alias for $20; p_content_type alias for $21; + p_object_type alias for $22; + p_package_id alias for $23; - v_uos_id cc_uos.uos_id%TYPE; + v_uos_id cc_uos.uos_id%TYPE; + v_folder_id integer; + v_revision_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; - v_uos_id := acs_object__new ( - p_uos_id, - p_object_type, - now(), - p_creation_user, - p_creation_ip, - p_context_id + -- create the content item + v_uos_id := content_item__new ( + p_uos_name, -- name + v_folder_Id, -- parent_id + p_uos_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 ); - insert into cc_uos values(v_uos_id, p_owner_id, p_name, p_code, p_department, p_faculty); - - PERFORM acs_permission__grant_permission( - v_uos_id, - p_unit_coordinator_id, - ''admin'' - ); + -- create the item type row + insert into cc_uos (uos_id, package_id, parent_id, + uos_code, uos_name, unit_coordinator_id) + VALUES (v_uos_id, p_package_id, v_folder_id, p_uos_code, + p_uos_name, p_unit_coordinator_id); + -- create the initial revision + v_revision_id := cc_uos_revision__new ( + null, -- uos_revision_id + v_uos_id, -- uos_id + p_uos_code, -- uos_code + p_uos_name, -- uos_name + p_credit_value, -- credit_value + p_semester, -- semester + p_online_course_content, -- online_course_content + p_unit_coordinator_id, -- unit_coordinator_id + p_contact_hours, -- contact_hours + p_assessments, -- assessments + p_core_uos_for, -- core_uos_for + p_recommended_uos_for, -- recommended_uos_for + p_prerequisites, -- prerequisites + p_objectives, -- objectives + p_outcomes, -- outcomes + p_syllabus, -- syllabus + p_syllabus_format, -- syllabus_format + now(), -- creation_date + p_creation_user, -- creation_user + p_creation_ip -- creation_ip + ); + return v_uos_id; end; @@ -184,21 +226,34 @@ create function cc_uos__delete (integer) returns integer as ' declare - p_uos_id alias for $1; + p_uos_id alias for $1; + + v_case_id integer; + rec record; begin - delete from acs_permissions - where object_id = p_uos_id; + -- Every UoS is associated with a workflow case + select case_id into v_case_id + from workflow_cases + where object_id = p_uos_id; - delete from cc_uos - where uos_id = p_uos_id; + perform workflow_case_pkg__delete(v_case_id); - raise NOTICE ''Deleting UoS...''; - PERFORM acs_object__delete(p_uos_id); + -- Every UoS may have notifications attached to it + -- and there is one column in the notifications datamodel that + -- doesn''t cascade + for rec in select notification_id from notifications + where response_id = p_uos_id loop + PERFORM notification__delete (rec.notification_id); + + end loop; + + perform content_item__delete(p_uos_id); + return 0; -end;' -language plpgsql; +end; +' language 'plpgsql'; select define_function_args('cc_uos__name', 'uos_id'); @@ -213,6 +268,102 @@ from cc_uos where uos_id = p_uos_id; - return v_uos; + return v_uos_name; end; -' language plpgsql; +' language 'plpgsql'; + + +create or replace function cc_uos_revision__new ( + integer, -- uos_revision_id + integer, -- uos_id + varchar, -- uos_code + varchar, -- uos_name + integer, -- credit_value + varchar, -- semester + varchar, -- online_course_content + integer, -- unit_coordinator_id + varchar, -- contact_hours + varchar, -- assessments + varchar, -- core_uos_for + varchar, -- recommended_uos_for + varchar, -- prerequisites + text, -- objectives + text, -- outcomes + text, -- syllabus + varchar, -- syllabus_format + timestamptz, -- creation_date + integer, -- creation_user + varchar -- creation_ip +) returns int +as ' +declare + p_uos_revision_id alias for $1; + p_uos_id alias for $2; + p_uos_code alias for $3; + p_uos_name alias for $4; + p_credit_value alias for $5; + p_semester alias for $6; + p_online_course_content alias for $7; + p_unit_coordinator_id alias for $8; + p_contact_hours alias for $9; + p_assessments alias for $10; + p_core_uos_for alias for $11; + p_recommended_uos_for alias for $12; + p_prerequisites alias for $13; + p_objectives alias for $14; + p_outcomes alias for $15; + p_syllabus alias for $16; + p_syllabus_format alias for $17; + p_creation_date alias for $18; + p_creation_user alias for $19; + p_creation_ip alias for $20; + + v_revision_id integer; +begin + -- create the initial revision + v_revision_id := content_revision__new ( + p_uos_name, -- title + null, -- description + current_timestamp, -- publish_date + null, -- mime_type + null, -- nls_language + null, -- new_data + p_uos_id, -- item_id + p_uos_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_revisions + (uos_revision_id, uos_code, uos_name, credit_value, + semester, online_course_content, unit_coordinator_id, + contact_hours, assessments, core_uos_for, recommended_uos_for, + prerequisites, objectives, outcomes, syllabus, syllabus_format) + values + (v_revision_id, p_uos_code, p_uos_name, p_credit_value, + p_semester, p_online_course_content, p_unit_coordinator_id, + p_contact_hours, p_assessments, p_core_uos_for, + p_recommended_uos_for, p_prerequisites, p_objectives, + p_outcomes, p_syllabus, p_syllabus_format); + + -- make the revision live + PERFORM content_item__set_live_revision(v_revision_id); + + -- update the cache + update cc_uos + set live_revision_id = v_revision_id, + uos_code = p_uos_code, + uos_name = p_uos_name, + unit_coordinator_id = p_unit_coordinator_id + where uos_id = p_uos_id; + + -- update the title in acs_objects + update acs_objects + set title = cc_uos__name(p_uos_id) + where object_id = p_uos_id; + + return v_revision_id; +end; +' language 'plpgsql'; Index: openacs-4/packages/curriculum-central/tcl/install-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/curriculum-central/tcl/install-procs.tcl,v diff -u -r1.1 -r1.2 --- openacs-4/packages/curriculum-central/tcl/install-procs.tcl 20 Nov 2005 23:51:10 -0000 1.1 +++ openacs-4/packages/curriculum-central/tcl/install-procs.tcl 11 Dec 2005 07:47:40 -0000 1.2 @@ -71,6 +71,8 @@ ad_proc -private curriculum_central::install::register_implementations {} { db_transaction { + curriculum_central::install::register_unit_coordinator_impl + curriculum_central::install::register_stream_coordinator_impl curriculum_central::install::register_format_log_title_impl curriculum_central::install::register_uos_notification_info_impl } @@ -85,6 +87,15 @@ -impl_name "FormatLogTitle" acs_sc::impl::delete \ + -contract_name [workflow::service_contract::role_default_assignees] \ + -impl_name "UnitCoordinator" + + acs_sc::impl::delete \ + -contract_name [workflow::service_contract::role_default_assignees] \ + -impl_name "StreamCoordinator" + + + acs_sc::impl::delete \ -contract_name [workflow::service_contract::notification_info] \ -impl_name "UoSNotificationInfo" } @@ -129,6 +140,42 @@ } +ad_proc -private curriculum_central::install::register_unit_coordinator_impl {} { + + set spec { + name "UnitCoordinator" + aliases { + GetObjectType curriculum_central::uos::object_type + GetPrettyName curriculum_central::uos::get_unit_coordinator::pretty_name + GetAssignees curriculum_central::uos::get_unit_coordinator::get_assignees + } + } + + lappend spec contract_name [workflow::service_contract::role_default_assignees] + lappend spec owner [curriculum_central::package_key] + + acs_sc::impl::new_from_spec -spec $spec +} + + +ad_proc -private curriculum_central::install::register_stream_coordinator_impl {} { + + set spec { + name "StreamCoordinator" + aliases { + GetObjectType curriculum_central::uos::object_type + GetPrettyName curriculum_central::uos::get_stream_coordinator::pretty_name + GetAssignees curriculum_central::uos::get_stream_coordinator::get_assignees + } + } + + lappend spec contract_name [workflow::service_contract::role_default_assignees] + lappend spec owner [curriculum_central::package_key] + + acs_sc::impl::new_from_spec -spec $spec +} + + ad_proc -private curriculum_central::install::roles_create {} { Creates the Stream Coordinator, Unit Coordinator and Lecturer roles. } { 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 --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/curriculum-central/tcl/uos-procs-postgresql.xql 11 Dec 2005 07:47:40 -0000 1.1 @@ -0,0 +1,18 @@ + + + + postgresql7.4 + + + + SELECT staff_id FROM cc_staff + + + + + + SELECT staff_id FROM cc_staff + + + + 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.2 -r1.3 --- openacs-4/packages/curriculum-central/tcl/uos-procs.tcl 4 Dec 2005 07:32:38 -0000 1.2 +++ openacs-4/packages/curriculum-central/tcl/uos-procs.tcl 11 Dec 2005 07:47:40 -0000 1.3 @@ -11,8 +11,10 @@ } namespace eval curriculum_central::uos {} - namespace eval curriculum_central::uos::format_log_title {} +namespace eval curriculum_central::uos::get_unit_coordinator {} +namespace eval curriculum_central::uos::get_stream_coordinator {} +namespace eval curriculum_central::uos::notification_info {} ad_proc -public curriculum_central::uos::workflow_short_name {} { Get the short name of the workflow for Units of Study. @@ -267,7 +269,8 @@ [list objectives $objectives] \ [list outcomes $outcomes] \ [list syllabus $syllabus] \ - [list syllabus_format $syllabus_format]] \ + [list syllabus_format $syllabus_format] \ + [list object_type "cc_uos"]] \ -package_name "cc_uos" \ "cc_uos"] @@ -318,6 +321,43 @@ ##### # +# Get Unit Coordinator +# +##### + +ad_proc -private curriculum_central::uos::get_unit_coordinator::pretty_name {} { + return "[_ curriculum-central.unit_coordinator]" +} + +ad_proc -private curriculum_central::uos::get_unit_coordinator::get_assignees { + case_id + object_id + role_id +} { + return [db_list select_unit_coordinators {} -default {}] +} + +##### +# +# Get Stream Coordinator +# +##### + +ad_proc -private curriculum_central::uos::get_stream_coordinator::pretty_name {} { + return "[_ curriculum-central.stream_coordinator]" +} + +ad_proc -private curriculum_central::uos::get_stream_coordinator::get_assignees { + case_id + object_id + role_id +} { + return [db_list select_stream_coordinators {} -default {}] +} + + +##### +# # Notification Info # ##### Index: openacs-4/packages/curriculum-central/www/dept-streams-postgresql.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/curriculum-central/www/dept-streams-postgresql.xql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/curriculum-central/www/dept-streams-postgresql.xql 11 Dec 2005 07:47:41 -0000 1.1 @@ -0,0 +1,20 @@ + + + + postgresql7.4 + + + + SELECT stream_id, stream_name FROM cc_stream WHERE + department_id = :department_id + + + + + + SELECT f.faculty_id, f.faculty_name FROM cc_faculty f, cc_department d + WHERE d.department_id = :department_id + AND f.faculty_id = d.faculty_id + + + Index: openacs-4/packages/curriculum-central/www/dept-streams.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/curriculum-central/www/dept-streams.adp,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/curriculum-central/www/dept-streams.adp 11 Dec 2005 07:47:41 -0000 1.1 @@ -0,0 +1,10 @@ + +@page_title;noquote@ +@context;noquote@ + +View Units of Study for: + Index: openacs-4/packages/curriculum-central/www/dept-streams.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/curriculum-central/www/dept-streams.tcl,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/curriculum-central/www/dept-streams.tcl 11 Dec 2005 07:47:41 -0000 1.1 @@ -0,0 +1,34 @@ +ad_page_contract { + + + @author Nick Carroll (nick.c@rroll.net) + @creation-date 2005-11-15 + @cvs-id $Id: dept-streams.tcl,v 1.1 2005/12/11 07:47:41 ncarroll Exp $ +} { + department_id:integer + department_name +} + +# Retrieve info about the faculty that the department belongs to for +# contextual navigation. +db_1row context_faculty {} + +set page_title $department_name +set context [list [list [export_vars -url -base faculty-depts \ + {faculty_name faculty_id}] $faculty_name] \ + $page_title] +set package_id [ad_conn package_id] + +# Check for streams. If no streams, then display no-streams template. +if { ![curriculum_central::stream::streams_exist_p] } { + ad_return_template "no-streams" + return +} + +# Get list of streams. +db_multirow -extend {stream_uos_url} streams streams {} { + set stream_uos_url [export_vars -url -base stream-uos \ + {stream_id stream_name}] +} + +ad_return_template Index: openacs-4/packages/curriculum-central/www/faculty-depts-postgresql.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/curriculum-central/www/faculty-depts-postgresql.xql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/curriculum-central/www/faculty-depts-postgresql.xql 11 Dec 2005 07:47:41 -0000 1.1 @@ -0,0 +1,13 @@ + + + + postgresql7.4 + + + + SELECT department_id, department_name FROM cc_department WHERE + faculty_id = :faculty_id + + + + Index: openacs-4/packages/curriculum-central/www/faculty-depts.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/curriculum-central/www/faculty-depts.adp,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/curriculum-central/www/faculty-depts.adp 11 Dec 2005 07:47:41 -0000 1.1 @@ -0,0 +1,10 @@ + +@page_title;noquote@ +@context;noquote@ + +View degree streams for: + Index: openacs-4/packages/curriculum-central/www/faculty-depts.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/curriculum-central/www/faculty-depts.tcl,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/curriculum-central/www/faculty-depts.tcl 11 Dec 2005 07:47:41 -0000 1.1 @@ -0,0 +1,28 @@ +ad_page_contract { + + + @author Nick Carroll (nick.c@rroll.net) + @creation-date 2005-11-15 + @cvs-id $Id: faculty-depts.tcl,v 1.1 2005/12/11 07:47:41 ncarroll Exp $ +} { + faculty_id + faculty_name +} + +set page_title $faculty_name +set context [list $page_title] +set package_id [ad_conn package_id] + +# Check for streams. If no streams, then display no-streams template. +if { ![curriculum_central::stream::streams_exist_p] } { + ad_return_template "no-streams" + return +} + +# Get list of departments. +db_multirow -extend {dept_streams_url} depts depts {} { + set dept_streams_url [export_vars -url -base dept-streams \ + {department_id department_name}] +} + +ad_return_template Index: openacs-4/packages/curriculum-central/www/index.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/curriculum-central/www/index.adp,v diff -u -r1.3 -r1.4 --- openacs-4/packages/curriculum-central/www/index.adp 11 Dec 2005 05:34:37 -0000 1.3 +++ openacs-4/packages/curriculum-central/www/index.adp 11 Dec 2005 07:47:41 -0000 1.4 @@ -11,6 +11,6 @@ View curriculum for: \ No newline at end of file + Index: openacs-4/packages/curriculum-central/www/index.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/curriculum-central/www/index.tcl,v diff -u -r1.3 -r1.4 --- openacs-4/packages/curriculum-central/www/index.tcl 11 Dec 2005 05:34:37 -0000 1.3 +++ openacs-4/packages/curriculum-central/www/index.tcl 11 Dec 2005 07:47:41 -0000 1.4 @@ -18,6 +18,9 @@ } # Get list of faculties. -db_multirow faculties faculties {} +db_multirow -extend {faculty_dept_url} faculties faculties {} { + set faculty_dept_url [export_vars -url -base faculty-depts \ + {faculty_id faculty_name}] +} ad_return_template Index: openacs-4/packages/curriculum-central/www/uos-add.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/curriculum-central/www/Attic/uos-add.adp,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/curriculum-central/www/uos-add.adp 11 Dec 2005 07:47:41 -0000 1.1 @@ -0,0 +1,6 @@ + +@page_title;noquote@ +@context;noquote@ +uos.uos_code + + Index: openacs-4/packages/curriculum-central/www/uos-add.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/curriculum-central/www/Attic/uos-add.tcl,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/curriculum-central/www/uos-add.tcl 11 Dec 2005 07:47:41 -0000 1.1 @@ -0,0 +1,127 @@ +ad_page_contract { + Add a new UoS. + + This page can only be accessed by a stream coordinator. Stream + coordinators are the only users that can initiate the workflow + for creating Units of Study. The stream coordinator creates the + Unit of Study, and assigns it to a unit coordinator to fill in the + unit outline. + + @author Nick Carroll (nick.c@rroll.net) + @creation-date 2005-11-15 + @cvs-id $Id: uos-add.tcl,v 1.1 2005/12/11 07:47:41 ncarroll Exp $ +} { + {return_url ""} +} + +if { [empty_string_p $return_url] } { + set return_url "." +} + +ad_require_permission [ad_conn package_id] create + +# User needs to be logged in here +auth::require_login + +# Set some common variables +set package_id [ad_conn package_id] +set package_key [ad_conn package_key] +set workflow_id [curriculum_central::uos::get_instance_workflow_id] +set user_id [ad_conn user_id] + +set page_title "[_ curriculum-central.add_unit_of_study]" +set context [list $page_title] + +# Create the form. +# TODO: Fix up form. Can use drop-down boxes for some of the fields. +ad_form -name uos -cancel_url $return_url -form { + {uos_id:key(acs_object_id_seq)} + + {uos_code:text + {label "UoS Code"} + {html {size 50}} + } + {uos_name:text + {label "UoS Name"} + {html {size 50}} + } + {credit_value:integer + {label "Credit Value"} + {html {size 50}} + } + {semester:integer + {label "Semester Offering"} + {html {size 50}} + } + {online_course_content:text,optional + {label "Online Course Content"} + {html {size 50}} + } + {unit_coordinator_id:integer(select) + {label "Unit Coordinator"} + {options [curriculum_central::staff_get_options] } + {help_text "[_ curriculum-central.help_select_unit_coordinator]"} + } + {contact_hours:text + {label "Contact Hours"} + {html {size 50}} + } + {assessments:text + {label "Assessments"} + {html {size 50}} + } + {core_uos_for:text,optional + {label "Core UoS for"} + {html {size 50}} + } + {recommended_uos_for:text,optional + {label "Recommended UoS for"} + {html {size 50}} + } + {prerequisites:text,optional + {label "Prerequisites"} + {html {size 50}} + } + {objectives:text + {label "Aims and Objectives"} + {html {size 50}} + } + {outcomes:text + {label "Learning Outcomes"} + {html {size 50}} + } + {syllabus:richtext(richtext) + {label "Syllabus"} + {html {cols 60 rows 13}} + } + {return_url:text(hidden) + {value $return_url} + } +} -new_data { + # TODO: Implement this proc. + curriculum_central::uos::new \ + -uos_id $uos_id \ + -package_id $package_id \ + -user_id $user_id \ + -uos_code $uos_code \ + -uos_name $uos_name \ + -credit_value $credit_value \ + -semester $semester \ + -online_course_content $online_course_content \ + -unit_coordinator_id $unit_coordinator_id \ + -contact_hours $contact_hours \ + -assessments $assessments \ + -core_uos_for $core_uos_for \ + -recommended_uos_for $recommended_uos_for \ + -prerequisites $prerequisites \ + -objectives $objectives \ + -outcomes $outcomes \ + -syllabus [template::util::richtext::get_property contents $syllabus] \ + -syllabus_format [template::util::richtext::get_property format $syllabus] + +} -after_submit { + ad_returnredirect $return_url + ad_script_abort +} + +ad_return_template