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.9 -r1.10 --- openacs-4/packages/curriculum-central/catalog/curriculum-central.en_US.ISO-8859-1.xml 11 Dec 2005 23:37:21 -0000 1.9 +++ openacs-4/packages/curriculum-central/catalog/curriculum-central.en_US.ISO-8859-1.xml 15 Dec 2005 06:27:40 -0000 1.10 @@ -3,6 +3,7 @@ UoS Search + Activity Log Coordinate resolution code to log title Fixed @@ -55,8 +56,8 @@ Edited Reassign Reassigned - Complete - Completed + Submit + Submitted Reopen Reopened Close 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.3 -r1.4 --- openacs-4/packages/curriculum-central/sql/postgresql/uos-create.sql 11 Dec 2005 07:47:40 -0000 1.3 +++ openacs-4/packages/curriculum-central/sql/postgresql/uos-create.sql 15 Dec 2005 06:27:41 -0000 1.4 @@ -67,11 +67,9 @@ references cr_revisions(revision_id) on delete cascade, uos_code varchar(256) - constraint cc_uos_rev_uos_code_nn not null - constraint cc_uos_rev_uos_code_un unique, + constraint cc_uos_rev_uos_code_nn not null, uos_name varchar(256) - constraint cc_uos_rev_uos_name_nn not null - constraint cc_uos_rev_uos_name_un unique, + constraint cc_uos_rev_uos_name_nn not null, credit_value integer, semester varchar(32), online_course_content varchar(256), @@ -87,8 +85,8 @@ prerequisites varchar(256), objectives text, outcomes text, - syllabus text, - syllabus_format varchar(256) + activity_log text, + activity_log_format varchar(256) ); -- Create the UoS revision content type. @@ -103,7 +101,7 @@ ); -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'); +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,activity_log,activity_log_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 @@ -120,8 +118,8 @@ varchar, -- prerequisites text, -- objectives text, -- outcomes - text, -- syllabus - varchar, -- syllabus_format + text, -- activity_log + varchar, -- activity_log_format integer, -- creation_user varchar, -- creation_ip integer, -- context_id @@ -146,8 +144,8 @@ p_prerequisites alias for $12; p_objectives alias for $13; p_outcomes alias for $14; - p_syllabus alias for $15; - p_syllabus_format alias for $16; + p_activity_log alias for $15; + p_activity_log_format alias for $16; p_creation_user alias for $17; p_creation_ip alias for $18; p_context_id alias for $19; @@ -208,8 +206,8 @@ p_prerequisites, -- prerequisites p_objectives, -- objectives p_outcomes, -- outcomes - p_syllabus, -- syllabus - p_syllabus_format, -- syllabus_format + p_activity_log, -- activity_log + p_activity_log_format, -- activity_log_format now(), -- creation_date p_creation_user, -- creation_user p_creation_ip -- creation_ip @@ -289,8 +287,8 @@ varchar, -- prerequisites text, -- objectives text, -- outcomes - text, -- syllabus - varchar, -- syllabus_format + text, -- activity_log + varchar, -- activity_log_format timestamptz, -- creation_date integer, -- creation_user varchar -- creation_ip @@ -312,8 +310,8 @@ 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_activity_log alias for $16; + p_activity_log_format alias for $17; p_creation_date alias for $18; p_creation_user alias for $19; p_creation_ip alias for $20; @@ -340,29 +338,29 @@ (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) + prerequisites, objectives, outcomes, activity_log, activity_log_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); + p_outcomes, p_activity_log, p_activity_log_format); -- make the revision live - PERFORM content_item__set_live_revision(v_revision_id); + -- 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 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; + -- update acs_objects + -- set title = cc_uos__name(p_uos_id) + -- where object_id = p_uos_id; return v_revision_id; end; 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.2 -r1.3 --- openacs-4/packages/curriculum-central/tcl/curriculum-central-procs.tcl 4 Dec 2005 07:32:38 -0000 1.2 +++ openacs-4/packages/curriculum-central/tcl/curriculum-central-procs.tcl 15 Dec 2005 06:27:41 -0000 1.3 @@ -110,8 +110,45 @@ return $departments_list } +##### +# +# Procs for page variables and filters for UoS edit form. +# +##### +ad_proc -public curriculum_central::get_page_variables { + {extra_spec ""} +} { + Adds the UoS listing filter variables for use in the page contract. + Usage: ad_page_contract { doc } [curriculum_central::get_page_variables { foo:integer {bar ""} }] + + @param extra_spec Filter vars to be added to the page variables, along + with the filter vars obtained from the current workflow instance. + + @return Returns a list of filter variables for a page contract. +} { + foreach action_id [workflow::get_actions -workflow_id [curriculum_central::uos::get_instance_workflow_id]] { + lappend filter_vars "f_action_$action_id:optional" + } + + return [concat $filter_vars $extra_spec] +} + + +ad_proc curriculum_central::get_export_variables { + {extra_vars ""} +} { + Gets a list of variables to export for the UoS list. +} { + foreach action_id [workflow::get_actions -workflow_id [curriculum_central::uos::get_instance_workflow_id]] { + lappend export_vars "f_action_$action_id" + } + + return [concat $export_vars $extra_vars] +} + + ##### # # Resolution 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.1 -r1.2 --- openacs-4/packages/curriculum-central/tcl/uos-procs-postgresql.xql 11 Dec 2005 07:47:40 -0000 1.1 +++ openacs-4/packages/curriculum-central/tcl/uos-procs-postgresql.xql 15 Dec 2005 06:27:41 -0000 1.2 @@ -3,9 +3,13 @@ postgresql7.4 - + - SELECT staff_id FROM cc_staff + SELECT * + FROM cc_uos u, cc_uos_revisions r, cr_items i + WHERE u.uos_id = :uos_id + AND i.item_id = u.uos_id + AND r.uos_revision_id = i.latest_revision @@ -15,4 +19,37 @@ + + + SELECT DISTINCT coordinator_id FROM cc_stream + WHERE package_id = :package_id + + + + + + SELECT cc_uos_revision__new ( + null, + :uos_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, + :activity_log, + :activity_log_format, + now(), + :creation_user, + :creation_ip + ); + + 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.3 -r1.4 --- openacs-4/packages/curriculum-central/tcl/uos-procs.tcl 11 Dec 2005 07:47:40 -0000 1.3 +++ openacs-4/packages/curriculum-central/tcl/uos-procs.tcl 15 Dec 2005 06:27:41 -0000 1.4 @@ -64,10 +64,9 @@ states { open { pretty_name "#curriculum-central.open#" - hide_fields { resolution fixed_in_version } } - completed { - pretty_name "#curriculum-central.completed#" + submitted { + pretty_name "#curriculum-central.submitted#" } closed { pretty_name "#curriculum-central.closed#" @@ -103,50 +102,46 @@ privileges { write } always_enabled_p t edit_fields { - component_id - summary - found_in_version - role_resolver - fix_for_version - resolution - fixed_in_version + contact_hours + assessments + online_course_content + objectives + outcomes } } reassign { pretty_name "#curriculum-central.reassign#" pretty_past_tense "#curriculum-central.reassigned#" allowed_roles { stream_coordinator - unit_coordinator } privileges { write } - enabled_states { completed } + enabled_states { submitted } assigned_states { open } - edit_fields { role_resolver } + edit_fields { unit_coordinator_id } } - complete { - pretty_name "#curriculum-central.complete#" - pretty_past_tense "#curriculum-central.completed#" + submit { + pretty_name "#curriculum-central.submit#" + pretty_past_tense "#curriculum-central.submitted#" assigned_role unit_coordinator - enabled_states { completed } + enabled_states { submitted } assigned_states { open } - new_state completed + new_state submitted privileges { write } - edit_fields { resolution fixed_in_version } } close { pretty_name "#curriculum-central.close#" pretty_past_tense "#curriculum-central.closed#" assigned_role stream_coordinator - assigned_states { completed } + assigned_states { submitted } new_state closed privileges { write } } reopen { pretty_name "#curriculum-central.reopen#" pretty_past_tense "#curriculum-central.reopened#" allowed_roles { stream_coordinator unit_coordinator } - enabled_states { completed closed } + enabled_states { submitted closed } new_state open privileges { write } } @@ -221,77 +216,260 @@ # ##### +ad_proc -public curriculum_central::uos::get { + {-uos_id:required} + {-array:required} + {-enabled_action_id {}} +} { + Get the fields for a Unit of Study. + + @param uos_id The ID of the Unit of Study for which we return + fields for. + @param array A predefined array for returning fields in. + @param enabled_action_id ID ofthe enabled workflow action. +} { + # Select the info into the upvar'ed Tcl array + upvar $array row + + db_1row select_latest_uos_data {} -column_array row + + # Get the case ID, so we can get state information + set case_id [workflow::case::get_id \ + -object_id $uos_id \ + -workflow_short_name [curriculum_central::uos::workflow_short_name]] + + # Get state information + workflow::case::fsm::get -case_id $case_id -array case \ + -enabled_action_id $enabled_action_id + + set row(pretty_state) $case(pretty_state) + set row(state_short_name) $case(state_short_name) + set row(hide_fields) $case(state_hide_fields) + set row(entry_id) $case(entry_id) +} + + ad_proc -public curriculum_central::uos::new { -uos_id:required -package_id:required -uos_code:required -uos_name:required -credit_value:required -semester:required - -online_course_content -unit_coordinator_id:required - -contact_hours:required - -assessments:required -core_uos_for -recommended_uos_for -prerequisites:required - -objectives:required - -outcomes:required - -syllabus:required - -syllabus_format:required + -activity_log:required + -activity_log_format:required {-user_id ""} } { Create a new Unit of Study, then send out notifications, starts workflow, etc. + This proc creates a new Unit of Study revision. The live revision is + set at the end of the workflow, when the stream coordinator approves + the Unit of Study. + + Calls curriculum_central::uos::insert. + + @see curriculum_central::uos::insert. @return uos_id The same uos_id passed in, for convenience. } { db_transaction { if { $user_id eq ""} { set user_id [ad_conn user_id] } - set uos_id [package_instantiate_object \ - -var_list [list [list uos_id $uos_id] \ - [list package_id $package_id] \ - [list user_id $user_id] \ - [list uos_code $uos_code] \ - [list uos_name $uos_name] \ - [list credit_value $credit_value] \ - [list semester $semester] \ - [list online_course_content $online_course_content] \ - [list unit_coordinator_id $unit_coordinator_id] \ - [list contact_hours $contact_hours] \ - [list assessments $assessments] \ - [list core_uos_for $core_uos_for] \ - [list recommended_uos_for $recommended_uos_for] \ - [list prerequisites $prerequisites] \ - [list objectives $objectives] \ - [list outcomes $outcomes] \ - [list syllabus $syllabus] \ - [list syllabus_format $syllabus_format] \ - [list object_type "cc_uos"]] \ - -package_name "cc_uos" \ - "cc_uos"] + set uos_id [curriculum_central::uos::insert \ + -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 \ + -unit_coordinator_id $unit_coordinator_id \ + -core_uos_for $core_uos_for \ + -recommended_uos_for $recommended_uos_for \ + -prerequisites $prerequisites \ + -activity_log $activity_log \ + -activity_log_format $activity_log_format ] array set assign_array [list unit_coordinator $unit_coordinator_id] + set workflow_id [workflow::get_id \ + -object_id $package_id \ + -short_name [workflow_short_name]] + # Create a new workflow case for the given UoS. set case_id [workflow::case::new \ - -workflow_id [workflow::get_id \ - -object_id $package_id \ - -short_name [workflow_short_name]] \ + -workflow_id $workflow_id \ -object_id $uos_id \ - -comment $syllabus \ - -comment_mime_type $syllabus_format \ + -comment $activity_log \ + -comment_mime_type $activity_log_format \ -user_id $user_id \ -assignment [array get assign_array]] + + # Get the role_id for the stream coordinator role. + set role_id [workflow::role::get_id -workflow_id $workflow_id \ + -short_name stream_coordinator] + + # Get a list of stream coordinator IDs. + # All stream coordinators are assigned the role of stream coordinator + # for all Units of Study. + set stream_coordinator_ids [db_list get_stream_coordinator_ids {}] + + # Assign the stream coordinators + workflow::case::role::assignee_insert -case_id $case_id \ + -role_id $role_id -party_ids $stream_coordinator_ids -replace + return $uos_id } } +ad_proc -public curriculum_central::uos::insert { + -uos_id:required + -package_id:required + -uos_code:required + -uos_name:required + -credit_value:required + -semester:required + -unit_coordinator_id:required + -core_uos_for + -recommended_uos_for + -prerequisites:required + -activity_log:required + -activity_log_format:required + {-user_id ""} +} { + Inserts a new Unit of Study into the content repository. You should + use curriculum_central::uos::new to make use of workflow side-effects. + + @see curriculum_central::uos::new + @return uos_id The same uos_id passed in, for convenience. +} { + set uos_id [package_instantiate_object \ + -var_list [list [list uos_id $uos_id] \ + [list package_id $package_id] \ + [list user_id $user_id] \ + [list uos_code $uos_code] \ + [list uos_name $uos_name] \ + [list credit_value $credit_value] \ + [list semester $semester] \ + [list unit_coordinator_id $unit_coordinator_id] \ + [list core_uos_for $core_uos_for] \ + [list recommended_uos_for $recommended_uos_for] \ + [list prerequisites $prerequisites] \ + [list activity_log $activity_log] \ + [list activity_log_format $activity_log_format] \ + [list object_type "cc_uos"]] \ + -package_name "cc_uos" \ + "cc_uos"] +} + + +ad_proc -public curriculum_central::uos::edit { + -uos_id:required + -enabled_action_id:required + -activity_log:required + -activity_log_format:required + -array:required + {-user_id ""} + {-creation_ip ""} + {-entry_id {}} +} { + Edit a Unit of Study, then send out notifications as workflow + side-effects. + + @return uos_id The same uos_id passed in, for convenience. +} { + # TODO: Implement this proc. + upvar $array row + + array set assignments [list] + + set role_prefix "role_" + foreach name [array names row "${role_prefix}*"] { + set assignments([string range $name \ + [string length $role_prefix] end]) $row($name) + unset row($name) + } + + db_transaction { + # Update the UoS info. + curriculum_central::uos::update -uos_id $uos_id \ + -user_id $user_id \ + -creation_ip $creation_ip \ + -array row + + set case_id [workflow::case::get_id \ + -workflow_short_name [workflow_short_name] \ + -object_id $uos_id] + + # Assignments + workflow::case::role::assign \ + -replace \ + -case_id $case_id \ + -array assignments + + workflow::case::action::execute \ + -enabled_action_id $enabled_action_id \ + -comment $activity_log \ + -comment_mime_type $activity_log_format \ + -user_id $user_id \ + -entry_id $entry_id + + } + + return $uos_id +} + + +ad_proc -public curriculum_central::uos::update { + -uos_id:required + {-user_id ""} + {-creation_ip ""} + -array:required +} { + Update a Unit of Study in the DB. This proc is called by + curriculum_central::uos::edit. Use the edit proc to change + workflow. This update proc creates a new revision of the + given Unit of Study. + + @param uos_id The ID of the Unit of Study to update. + @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. + @param array An array of updated Unit of Study fields. + @see curriculum_central::uos::edit + @return uos_id The same uos_id passed in, for convenience. +} { + upvar $array row + + if { ![exists_and_not_null user_id] } { + set user_id [ad_conn user_id] + } + + curriculum_central::uos::get -uos_id $uos_id -array new_row + + foreach column [array names row] { + set new_row($column) $row($column) + } + set new_row(creation_user) $user_id + set new_row(creation_ip) $creation_ip + + foreach name [array names new_row] { + set $name $new_row($name) + } + + set revision_id [db_exec_plsql update_uos {}] + + return $uos_id +} + + ##### # # Format log title 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.6 -r1.7 --- openacs-4/packages/curriculum-central/www/index.adp 11 Dec 2005 23:02:19 -0000 1.6 +++ openacs-4/packages/curriculum-central/www/index.adp 15 Dec 2005 06:27:41 -0000 1.7 @@ -5,7 +5,7 @@ [admin] #curriculum-central.view_curriculum_for# Index: openacs-4/packages/curriculum-central/www/coordinate/index.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/curriculum-central/www/coordinate/index.adp,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/curriculum-central/www/coordinate/index.adp 15 Dec 2005 06:27:41 -0000 1.1 @@ -0,0 +1,10 @@ + +@page_title;noquote@ +@context;noquote@ + + + +

Status of created Units of Study


+NOTE: Show listing of UoS status with respect to workflow. Index: openacs-4/packages/curriculum-central/www/coordinate/index.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/curriculum-central/www/coordinate/index.tcl,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/curriculum-central/www/coordinate/index.tcl 15 Dec 2005 06:27:41 -0000 1.1 @@ -0,0 +1,14 @@ +ad_page_contract { + Index page for coordinating a curriculum. + + @author Nick Carroll (nick.c@rroll.net) + @creation-date 2005-11-15 + @cvs-id $Id: index.tcl,v 1.1 2005/12/15 06:27:41 ncarroll Exp $ +} + +auth::require_login + +set page_title [_ curriculum-central.coordinate] +set context [list $page_title] + +ad_return_template Index: openacs-4/packages/curriculum-central/www/coordinate/uos-add.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/curriculum-central/www/coordinate/uos-add.tcl,v diff -u -r1.2 -r1.3 --- openacs-4/packages/curriculum-central/www/coordinate/uos-add.tcl 11 Dec 2005 23:37:21 -0000 1.2 +++ openacs-4/packages/curriculum-central/www/coordinate/uos-add.tcl 15 Dec 2005 06:27:41 -0000 1.3 @@ -53,23 +53,11 @@ {label "#curriculum-central.semester_offering#"} {html {size 50}} } - {online_course_content:text,optional - {label "#curriculum-central.online_course_content#"} - {html {size 50}} - } {unit_coordinator_id:integer(select) {label "#curriculum-central.unit_coordinator#"} {options [curriculum_central::staff_get_options] } {help_text "[_ curriculum-central.help_select_unit_coordinator]"} } - {contact_hours:text - {label "#curriculum-central.contact_hours#"} - {html {size 50}} - } - {assessments:text - {label "#curriculum-central.assessments#"} - {html {size 50}} - } {core_uos_for:text,optional {label "#curriculum-central.core_uos_for#"} {html {size 50}} @@ -82,23 +70,16 @@ {label "#curriculum-central.prerequisites#"} {html {size 50}} } - {objectives:text - {label "#curriculum-central.aims_and_objectives#"} - {html {size 50}} + {activity_log:richtext(richtext) + {label "#curriculum-central.activity_log#"} + {html {cols 50 rows 13}} } - {outcomes:text - {label "#curriculum-central.learning_outcomes#"} - {html {size 50}} - } - {syllabus:richtext(richtext) - {label "#curriculum-central.syllabus#"} - {html {cols 60 rows 13}} - } {return_url:text(hidden) {value $return_url} } } -new_data { - # TODO: Implement this proc. + + # Instantiate a new Unit of Study. curriculum_central::uos::new \ -uos_id $uos_id \ -package_id $package_id \ @@ -107,17 +88,12 @@ -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] + -activity_log [template::util::richtext::get_property contents $activity_log] \ + -activity_log_format [template::util::richtext::get_property format $activity_log] } -after_submit { ad_returnredirect $return_url Index: openacs-4/packages/curriculum-central/www/coordinate/uos-edit.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/curriculum-central/www/coordinate/uos-edit.adp,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/curriculum-central/www/coordinate/uos-edit.adp 15 Dec 2005 06:27:41 -0000 1.1 @@ -0,0 +1,5 @@ + +@page_title;noquote@ +@context;noquote@ + + \ No newline at end of file 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 --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/curriculum-central/www/coordinate/uos-edit.tcl 15 Dec 2005 06:27:41 -0000 1.1 @@ -0,0 +1,219 @@ +ad_page_contract { + Add/Edit a UoS. + + Only a stream coordinator, unit coordinator and lecturer can access + this page, if they are involved in a particular Unit of Study. + + This page implements the UI for the UoS workflow. + + @author Nick Carroll (nick.c@rroll.net) + @creation-date 2005-11-15 + @cvs-id $Id: uos-edit.tcl,v 1.1 2005/12/15 06:27:41 ncarroll Exp $ + +} [curriculum_central::get_page_variables { + uos_id:integer,notnull +}] + +auth::require_login + +set return_url [export_vars -base [ad_conn url] [curriculum_central::get_export_variables {uos_id} ]] + +set page_title "Edit UoS" +set context [list [list . "Coordinate"] "Edit UoS"] + +set case_id [workflow::case::get_id \ + -object_id $uos_id \ + -workflow_short_name \ + [curriculum_central::uos::workflow_short_name]] + +set workflow_id [curriculum_central::uos::get_instance_workflow_id] + +# Action +set enabled_action_id [form get_action uos] + +# Registration required for all actions +set action_id "" + +if { ![empty_string_p $enabled_action_id] } { + auth::require_login + workflow::case::enabled_action_get -enabled_action_id $enabled_action_id -array enabled_action + set action_id $enabled_action(action_id) +} + +# Buttons +set actions [list] +if { $enabled_action_id eq "" } { + foreach available_enabled_action_id [workflow::case::get_available_enabled_action_ids -case_id $case_id] { + workflow::case::enabled_action_get -enabled_action_id $available_enabled_action_id -array enabled_action + workflow::action::get -action_id $enabled_action(action_id) -array available_action + lappend actions [list " [lang::util::localize $available_action(pretty_name)] " $available_enabled_action_id] + } +} + +# Retrieve infor for Unit of Study. +curriculum_central::uos::get \ + -uos_id $uos_id \ + -array uos \ + -enabled_action_id $enabled_action_id + +# Create the form +# Create widgets for displaying UoS information that should already +# have been entered by the Stream Coordinator when the UoS was +# initially created. +ad_form -name uos -cancel_url $return_url -mode display -has_edit 1 -actions $actions -form { + {uos_code:text(inform) + {label "[_ curriculum-central.uos_code]"} + {value $uos(uos_code)} + {mode display} + } + {uos_name:text(inform) + {label "[_ curriculum-central.uos_name]"} + {value $uos(uos_name)} + {mode display} + } +} + +# Only display workflow assignee widget for unit coordinators. +workflow::case::role::add_assignee_widgets \ + -case_id $case_id \ + -form_name uos \ + -role_ids [workflow::role::get_id -workflow_id $workflow_id \ + -short_name unit_coordinator] + +ad_form -extend -name uos -form { + {credit_value:integer(inform) + {label "[_ curriculum-central.credit_value]"} + {value $uos(credit_value)} + {mode display} + } + {semester:integer(inform) + {label "[_ curriculum-central.semester_offering]"} + {value $uos(semester)} + {mode display} + } + {core_uos_for:text(inform) + {label "[_ curriculum-central.core_uos_for]"} + {value $uos(core_uos_for)} + {mode display} + } + {recommended_uos_for:text(inform) + {label "[_ curriculum-central.recommended_uos_for]"} + {value $uos(recommended_uos_for)} + {mode display} + } + {prerequisites:text(inform) + {label "[_ curriculum-central.prerequisites]"} + {value $uos(prerequisites)} + {mode display} + } +} + +# Add widgets for fields that the Unit Coordinator must enter data into. +ad_form -extend -name uos -form { + {contact_hours:text + {label "[_ curriculum-central.contact_hours]"} + {html {size 50}} + {mode display} + } + {assessments:text + {label "[_ curriculum-central.assessments]"} + {html {size 50}} + {mode display} + } + {online_course_content:text,optional + {label "[_ curriculum-central.online_course_content]"} + {html {size 50}} + {mode display} + } + {objectives:text + {label "[_ curriculum-central.aims_and_objectives]"} + {html {size 50}} + {mode display} + } + {outcomes:text + {label "[_ curriculum-central.learning_outcomes]"} + {html {size 50}} + {mode display} + } + {activity_log:richtext(richtext) + {label "#curriculum-central.activity_log#"} + {html {cols 50 rows 13}} + } + {return_url:text(hidden) + {value $return_url} + } + {uos_id:key} + {entry_id:integer(hidden),optional} +} + + +# Export filters +set filters [list] +foreach name [curriculum_central::get_export_variables] { + if { [info exists $name] } { + lappend filters [list "${name}:text(hidden),optional" [list value [set $name]]] + } +} +ad_form -extend -name uos -form $filters + +# Set editable fields +if { $enabled_action_id ne "" } { + foreach field [workflow::action::get_element -action_id $action_id -element edit_fields] { + element set_properties uos $field -mode edit + } +} + + +# on_submit block +ad_form -extend -name uos -on_submit { + array set row [list] + + if { ![empty_string_p $enabled_action_id] } { + foreach field [workflow::action::get_element \ + -action_id $action_id -element edit_fields] { + set row($field) [element get_value uos $field] + } + } + + set activity_log [element get_value uos activity_log] + + curriculum_central::uos::edit \ + -uos_id $uos(uos_id) \ + -enabled_action_id $enabled_action_id \ + -activity_log \ + [template::util::richtext::get_property contents $activity_log] \ + -activity_log_format \ + [template::util::richtext::get_property format $activity_log] \ + -array row \ + -entry_id [element get_value uos entry_id] + + ad_returnredirect $return_url + ad_script_abort + +} -edit_request { + # Dummy block. Required for uos_id:key, otherwise ad_form complains. +} + +# Not-valid block (request or submit error) +# Block that executes whenever the form is displayed, whether initially +# or because of a validation error. +if { ![form is_valid uos] } { + # Get the UoS data + curriculum_central::uos::get \ + -uos_id $uos_id \ + -array uos \ + -enabled_action_id $enabled_action_id + + # Hide elements that should be hidden depending on the bug status + foreach element $uos(hide_fields) { + element set_properties uos $element -widget hidden + } + + # Get values for the role assignment widgets + workflow::case::role::set_assignee_values -case_id $case_id -form_name uos + + # Set values for description field + element set_properties uos activity_log \ + -before_html [workflow::case::get_activity_html -case_id $case_id \ + -action_id $action_id] +} \ No newline at end of file