Index: openacs-4/contrib/packages/simulation/lib/cases.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/simulation/lib/Attic/cases.tcl,v diff -u -r1.2 -r1.3 --- openacs-4/contrib/packages/simulation/lib/cases.tcl 2 Dec 2003 13:46:53 -0000 1.2 +++ openacs-4/contrib/packages/simulation/lib/cases.tcl 19 Dec 2003 13:03:19 -0000 1.3 @@ -13,8 +13,13 @@ set package_id [ad_conn package_id] set elements { + label { + label "Case" + orderby upper(w.pretty_name) + link_url_eval {[export_vars -base case { case_id }]} + } pretty_name { - label "Cases" + label "Simulation" orderby upper(w.pretty_name) } } @@ -26,13 +31,16 @@ -elements $elements db_multirow cases select_cases " - select wc.case_id, + select distinct wc.case_id, + sc.label, w.pretty_name from workflow_cases wc, + sim_cases sc, workflow_case_role_party_map wcrpm, workflows w where wcrpm.party_id = :party_id and wc.case_id = wcrpm.case_id + and sc.sim_case_id = wc.object_id and w.workflow_id = wc.workflow_id [template::list::orderby_clause -orderby -name "cases"] -" \ No newline at end of file +" Index: openacs-4/contrib/packages/simulation/sql/postgresql/simulation-tables-create.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/simulation/sql/postgresql/Attic/simulation-tables-create.sql,v diff -u -r1.19 -r1.20 --- openacs-4/contrib/packages/simulation/sql/postgresql/simulation-tables-create.sql 19 Dec 2003 10:23:11 -0000 1.19 +++ openacs-4/contrib/packages/simulation/sql/postgresql/simulation-tables-create.sql 19 Dec 2003 13:03:20 -0000 1.20 @@ -105,9 +105,9 @@ references parties on delete cascade, type varchar(20) constraint sim_party_sim_map_type_ck - check (type in ('enrolled', 'invited', 'auto-enroll')), + check (type in ('enrolled', 'invited', 'auto_enroll')), constraint sim_party_sim_map_pk - primary key (simulation_id, party_id) + primary key (simulation_id, party_id, type) ); comment on table sim_party_sim_map is 'Each record is an invitation to a party to participate in a simulation.'; @@ -160,7 +160,7 @@ 'acs_object', -- supertype 'sim_cases', -- table_name 'sim_case_id' , -- id_column - null, -- package_name + 'sim_case', -- package_name 'f', -- abstract_p null, -- type_extension_table 'sim_case__name' -- name_method Index: openacs-4/contrib/packages/simulation/tcl/simulation-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/simulation/tcl/Attic/simulation-procs.tcl,v diff -u -r1.18 -r1.19 --- openacs-4/contrib/packages/simulation/tcl/simulation-procs.tcl 18 Dec 2003 15:22:56 -0000 1.18 +++ openacs-4/contrib/packages/simulation/tcl/simulation-procs.tcl 19 Dec 2003 13:03:20 -0000 1.19 @@ -189,7 +189,7 @@ from sim_party_sim_map where party_id = g.group_id and simulation_id = :workflow_id - and type = 'auto-enroll' + and type = 'auto_enroll' )"] set groups_list [list] db_foreach subsite_group_options " Index: openacs-4/contrib/packages/simulation/tcl/template-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/simulation/tcl/Attic/template-procs.tcl,v diff -u -r1.29 -r1.30 --- openacs-4/contrib/packages/simulation/tcl/template-procs.tcl 19 Dec 2003 11:25:20 -0000 1.29 +++ openacs-4/contrib/packages/simulation/tcl/template-procs.tcl 19 Dec 2003 13:03:20 -0000 1.30 @@ -126,7 +126,7 @@ # Handle auxillary rows array set aux [list] foreach attr { - enrolled invited auto-enroll + enrolled invited auto_enroll } { if { [info exists row($attr)] } { set aux($attr) $row($attr) @@ -173,7 +173,7 @@ } # Update sim_party_sim_map table - foreach map_type { enrolled invited auto-enroll } { + foreach map_type { enrolled invited auto_enroll } { if { [info exists aux($map_type)] } { # Clear out old mappings first db_dml clear_old_mappings { @@ -332,20 +332,20 @@ ad_proc -public simulation::template::get_parties { {-members:boolean} {-workflow_id:required} - {-rel_type "auto-enroll"} + {-rel_type "auto_enroll"} } { Return a list of parties related to the given simulation. @param rel_type The type of relationship of the party to the simulation template. Permissible values are - enrolled, invited, and auto-enroll + enrolled, invited, and auto_enroll @param members Provide this switch if you want all members of the simulation parties rather than the parties themselves. @return A list of party_id:s } { - ad_assert_arg_value_in_list rel_type {enrolled invited auto-enroll} + ad_assert_arg_value_in_list rel_type { enrolled invited auto_enroll } if { $members_p } { return [db_list template_parties { @@ -500,13 +500,20 @@ } { simulation::template::get -workflow_id $workflow_id -array simulation + if { ![string equal $simulation(sim_type) "casting_sim"] } { + error "This simulation is in state $simulation(sim_type), it must be in 'casting_sim'" + } + db_transaction { - # Auto enroll users in auto-enroll groups + # Auto enroll users in auto_enroll groups set simulation_edit(enrolled) [list] - foreach users_list [simulation::template::get_parties -members -rel_type auto-enroll -workflow_id $workflow_id] { + foreach users_list [simulation::template::get_parties -members -rel_type auto_enroll -workflow_id $workflow_id] { set simulation_edit(enrolled) [concat $simulation_edit(enrolled) $users_list] } + # Remove duplicates + set simulation_edit(enrolled) [lsort -unique $simulation_edit(enrolled)] + # Change sim_type to live_sim set simulation_edit(sim_type) live_sim @@ -555,11 +562,15 @@ set workflow_short_name [workflow::get_element -workflow_id $workflow_id -element short_name] + set case_counter 0 + # Create the cases and for each case assign users to roles while { $total_users > 0 } { + incr case_counter set sim_case_id [simulation::case::new \ - -workflow_id $workflow_id] + -workflow_id $workflow_id \ + -label "Case \#$case_counter"] set case_id [workflow::case::get_id \ -object_id $sim_case_id \ -workflow_short_name $workflow_short_name] @@ -599,6 +610,11 @@ set row($role_short_name($role_id)) $assignees } + #foreach { short_name users } { + # Remove duplicates, otherwise the call below bombs + # set role($short_name) [lsort -unique $role($short_name)] + #} + ns_log Notice "pm debug case_id=$case_id role::assign [array get row]" workflow::case::role::assign \ -case_id $case_id \ Index: openacs-4/contrib/packages/simulation/www/siminst/index.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/simulation/www/siminst/Attic/index.tcl,v diff -u -r1.21 -r1.22 --- openacs-4/contrib/packages/simulation/www/siminst/index.tcl 18 Dec 2003 09:58:28 -0000 1.21 +++ openacs-4/contrib/packages/simulation/www/siminst/index.tcl 19 Dec 2003 13:03:21 -0000 1.22 @@ -185,7 +185,7 @@ party_approved_member_map pamm, users u where spsm.simulation_id = w.workflow_id - and spsm.type = 'auto-enroll' + and spsm.type = 'auto_enroll' and spsm.party_id = pamm.party_id and pamm.member_id = u.user_id) as n_users, to_char(ss.case_start, 'YYYY-MM-DD') as case_start Index: openacs-4/contrib/packages/simulation/www/siminst/simulation-casting-2.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/simulation/www/siminst/Attic/simulation-casting-2.tcl,v diff -u -r1.13 -r1.14 --- openacs-4/contrib/packages/simulation/www/siminst/simulation-casting-2.tcl 18 Dec 2003 12:39:55 -0000 1.13 +++ openacs-4/contrib/packages/simulation/www/siminst/simulation-casting-2.tcl 19 Dec 2003 13:03:21 -0000 1.14 @@ -50,7 +50,7 @@ {label "Casting type"} {options {{Automatic auto} {Group group} {Open open}}} } - {enroll_groups:integer(checkbox),multiple,optional + {auto_enroll:integer(checkbox),multiple,optional {label "Enroll all users in these groups"} {options $eligible_groups} {help_text {Use Group Administration to add groups}} @@ -74,7 +74,7 @@ set $elm $sim_template($elm) } - set enroll_groups [simulation::template::get_parties -workflow_id $workflow_id -rel_type auto-enroll] + set enroll_groups [simulation::template::get_parties -workflow_id $workflow_id -rel_type auto_enroll] # Default values if { [empty_string_p $enroll_start] } { @@ -115,15 +115,10 @@ } } -on_submit { - # TODO: Use underscore in "auto-enroll" -> "auto_enroll" for consistency - - foreach elm { enroll_start enroll_end send_start_note_date case_start case_end enroll_type casting_type } { + foreach elm { enroll_start enroll_end send_start_note_date case_start case_end enroll_type casting_type auto_enroll } { set row($elm) [set $elm] } - # TODO: Rename "auto-enroll" property to "auto_enroll", and rename the form element to the same - set row(auto-enroll) $enroll_groups - # TODO: add invite_gropus to list of elements above simulation::template::edit \ Index: openacs-4/contrib/packages/simulation/www/siminst/simulation-start.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/simulation/www/siminst/Attic/simulation-start.tcl,v diff -u -r1.3 -r1.4 --- openacs-4/contrib/packages/simulation/www/siminst/simulation-start.tcl 18 Dec 2003 15:22:56 -0000 1.3 +++ openacs-4/contrib/packages/simulation/www/siminst/simulation-start.tcl 19 Dec 2003 13:03:21 -0000 1.4 @@ -10,3 +10,4 @@ simulation::template::force_start -workflow_id $workflow_id ad_returnredirect "../simplay" +return Index: openacs-4/contrib/packages/simulation/www/simplay/case.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/simulation/www/simplay/Attic/case.adp,v diff -u -r1.1 -r1.2 --- openacs-4/contrib/packages/simulation/www/simplay/case.adp 18 Dec 2003 15:39:03 -0000 1.1 +++ openacs-4/contrib/packages/simulation/www/simplay/case.adp 19 Dec 2003 13:03:22 -0000 1.2 @@ -1,11 +1,14 @@ @title;noquote@ @context;noquote@ +

Tasks

- + +

Messages

- + +

Portfolio

TODO: show list of case/role-specific documents Index: openacs-4/contrib/packages/simulation/www/simplay/index.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/simulation/www/simplay/Attic/index.adp,v diff -u -r1.9 -r1.10 --- openacs-4/contrib/packages/simulation/www/simplay/index.adp 18 Dec 2003 15:39:03 -0000 1.9 +++ openacs-4/contrib/packages/simulation/www/simplay/index.adp 19 Dec 2003 13:03:22 -0000 1.10 @@ -3,11 +3,15 @@ @context;noquote@ Show list of cases and make user pick one before proceeding. However, if there is only one valid case, use it. + +

- -

- +

Administrators

+ +

+ -

TODO: how can a player access completed cases? + +

TODO: how can a player access completed cases?

Index: openacs-4/contrib/packages/simulation/www/simplay/play-master.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/simulation/www/simplay/Attic/play-master.adp,v diff -u -r1.1 -r1.2 --- openacs-4/contrib/packages/simulation/www/simplay/play-master.adp 18 Nov 2003 09:44:32 -0000 1.1 +++ openacs-4/contrib/packages/simulation/www/simplay/play-master.adp 19 Dec 2003 13:03:22 -0000 1.2 @@ -4,10 +4,10 @@ - - Index: openacs-4/packages/simulation/lib/cases.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/simulation/lib/cases.tcl,v diff -u -r1.2 -r1.3 --- openacs-4/packages/simulation/lib/cases.tcl 2 Dec 2003 13:46:53 -0000 1.2 +++ openacs-4/packages/simulation/lib/cases.tcl 19 Dec 2003 13:03:19 -0000 1.3 @@ -13,8 +13,13 @@ set package_id [ad_conn package_id] set elements { + label { + label "Case" + orderby upper(w.pretty_name) + link_url_eval {[export_vars -base case { case_id }]} + } pretty_name { - label "Cases" + label "Simulation" orderby upper(w.pretty_name) } } @@ -26,13 +31,16 @@ -elements $elements db_multirow cases select_cases " - select wc.case_id, + select distinct wc.case_id, + sc.label, w.pretty_name from workflow_cases wc, + sim_cases sc, workflow_case_role_party_map wcrpm, workflows w where wcrpm.party_id = :party_id and wc.case_id = wcrpm.case_id + and sc.sim_case_id = wc.object_id and w.workflow_id = wc.workflow_id [template::list::orderby_clause -orderby -name "cases"] -" \ No newline at end of file +" Index: openacs-4/packages/simulation/sql/postgresql/simulation-tables-create.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/simulation/sql/postgresql/simulation-tables-create.sql,v diff -u -r1.19 -r1.20 --- openacs-4/packages/simulation/sql/postgresql/simulation-tables-create.sql 19 Dec 2003 10:23:11 -0000 1.19 +++ openacs-4/packages/simulation/sql/postgresql/simulation-tables-create.sql 19 Dec 2003 13:03:20 -0000 1.20 @@ -105,9 +105,9 @@ references parties on delete cascade, type varchar(20) constraint sim_party_sim_map_type_ck - check (type in ('enrolled', 'invited', 'auto-enroll')), + check (type in ('enrolled', 'invited', 'auto_enroll')), constraint sim_party_sim_map_pk - primary key (simulation_id, party_id) + primary key (simulation_id, party_id, type) ); comment on table sim_party_sim_map is 'Each record is an invitation to a party to participate in a simulation.'; @@ -160,7 +160,7 @@ 'acs_object', -- supertype 'sim_cases', -- table_name 'sim_case_id' , -- id_column - null, -- package_name + 'sim_case', -- package_name 'f', -- abstract_p null, -- type_extension_table 'sim_case__name' -- name_method Index: openacs-4/packages/simulation/tcl/simulation-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/simulation/tcl/simulation-procs.tcl,v diff -u -r1.18 -r1.19 --- openacs-4/packages/simulation/tcl/simulation-procs.tcl 18 Dec 2003 15:22:56 -0000 1.18 +++ openacs-4/packages/simulation/tcl/simulation-procs.tcl 19 Dec 2003 13:03:20 -0000 1.19 @@ -189,7 +189,7 @@ from sim_party_sim_map where party_id = g.group_id and simulation_id = :workflow_id - and type = 'auto-enroll' + and type = 'auto_enroll' )"] set groups_list [list] db_foreach subsite_group_options " Index: openacs-4/packages/simulation/tcl/template-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/simulation/tcl/template-procs.tcl,v diff -u -r1.29 -r1.30 --- openacs-4/packages/simulation/tcl/template-procs.tcl 19 Dec 2003 11:25:20 -0000 1.29 +++ openacs-4/packages/simulation/tcl/template-procs.tcl 19 Dec 2003 13:03:20 -0000 1.30 @@ -126,7 +126,7 @@ # Handle auxillary rows array set aux [list] foreach attr { - enrolled invited auto-enroll + enrolled invited auto_enroll } { if { [info exists row($attr)] } { set aux($attr) $row($attr) @@ -173,7 +173,7 @@ } # Update sim_party_sim_map table - foreach map_type { enrolled invited auto-enroll } { + foreach map_type { enrolled invited auto_enroll } { if { [info exists aux($map_type)] } { # Clear out old mappings first db_dml clear_old_mappings { @@ -332,20 +332,20 @@ ad_proc -public simulation::template::get_parties { {-members:boolean} {-workflow_id:required} - {-rel_type "auto-enroll"} + {-rel_type "auto_enroll"} } { Return a list of parties related to the given simulation. @param rel_type The type of relationship of the party to the simulation template. Permissible values are - enrolled, invited, and auto-enroll + enrolled, invited, and auto_enroll @param members Provide this switch if you want all members of the simulation parties rather than the parties themselves. @return A list of party_id:s } { - ad_assert_arg_value_in_list rel_type {enrolled invited auto-enroll} + ad_assert_arg_value_in_list rel_type { enrolled invited auto_enroll } if { $members_p } { return [db_list template_parties { @@ -500,13 +500,20 @@ } { simulation::template::get -workflow_id $workflow_id -array simulation + if { ![string equal $simulation(sim_type) "casting_sim"] } { + error "This simulation is in state $simulation(sim_type), it must be in 'casting_sim'" + } + db_transaction { - # Auto enroll users in auto-enroll groups + # Auto enroll users in auto_enroll groups set simulation_edit(enrolled) [list] - foreach users_list [simulation::template::get_parties -members -rel_type auto-enroll -workflow_id $workflow_id] { + foreach users_list [simulation::template::get_parties -members -rel_type auto_enroll -workflow_id $workflow_id] { set simulation_edit(enrolled) [concat $simulation_edit(enrolled) $users_list] } + # Remove duplicates + set simulation_edit(enrolled) [lsort -unique $simulation_edit(enrolled)] + # Change sim_type to live_sim set simulation_edit(sim_type) live_sim @@ -555,11 +562,15 @@ set workflow_short_name [workflow::get_element -workflow_id $workflow_id -element short_name] + set case_counter 0 + # Create the cases and for each case assign users to roles while { $total_users > 0 } { + incr case_counter set sim_case_id [simulation::case::new \ - -workflow_id $workflow_id] + -workflow_id $workflow_id \ + -label "Case \#$case_counter"] set case_id [workflow::case::get_id \ -object_id $sim_case_id \ -workflow_short_name $workflow_short_name] @@ -599,6 +610,11 @@ set row($role_short_name($role_id)) $assignees } + #foreach { short_name users } { + # Remove duplicates, otherwise the call below bombs + # set role($short_name) [lsort -unique $role($short_name)] + #} + ns_log Notice "pm debug case_id=$case_id role::assign [array get row]" workflow::case::role::assign \ -case_id $case_id \ Index: openacs-4/packages/simulation/www/siminst/index.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/simulation/www/siminst/index.tcl,v diff -u -r1.21 -r1.22 --- openacs-4/packages/simulation/www/siminst/index.tcl 18 Dec 2003 09:58:28 -0000 1.21 +++ openacs-4/packages/simulation/www/siminst/index.tcl 19 Dec 2003 13:03:21 -0000 1.22 @@ -185,7 +185,7 @@ party_approved_member_map pamm, users u where spsm.simulation_id = w.workflow_id - and spsm.type = 'auto-enroll' + and spsm.type = 'auto_enroll' and spsm.party_id = pamm.party_id and pamm.member_id = u.user_id) as n_users, to_char(ss.case_start, 'YYYY-MM-DD') as case_start Index: openacs-4/packages/simulation/www/siminst/simulation-casting-2.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/simulation/www/siminst/Attic/simulation-casting-2.tcl,v diff -u -r1.13 -r1.14 --- openacs-4/packages/simulation/www/siminst/simulation-casting-2.tcl 18 Dec 2003 12:39:55 -0000 1.13 +++ openacs-4/packages/simulation/www/siminst/simulation-casting-2.tcl 19 Dec 2003 13:03:21 -0000 1.14 @@ -50,7 +50,7 @@ {label "Casting type"} {options {{Automatic auto} {Group group} {Open open}}} } - {enroll_groups:integer(checkbox),multiple,optional + {auto_enroll:integer(checkbox),multiple,optional {label "Enroll all users in these groups"} {options $eligible_groups} {help_text {Use Group Administration to add groups}} @@ -74,7 +74,7 @@ set $elm $sim_template($elm) } - set enroll_groups [simulation::template::get_parties -workflow_id $workflow_id -rel_type auto-enroll] + set enroll_groups [simulation::template::get_parties -workflow_id $workflow_id -rel_type auto_enroll] # Default values if { [empty_string_p $enroll_start] } { @@ -115,15 +115,10 @@ } } -on_submit { - # TODO: Use underscore in "auto-enroll" -> "auto_enroll" for consistency - - foreach elm { enroll_start enroll_end send_start_note_date case_start case_end enroll_type casting_type } { + foreach elm { enroll_start enroll_end send_start_note_date case_start case_end enroll_type casting_type auto_enroll } { set row($elm) [set $elm] } - # TODO: Rename "auto-enroll" property to "auto_enroll", and rename the form element to the same - set row(auto-enroll) $enroll_groups - # TODO: add invite_gropus to list of elements above simulation::template::edit \ Index: openacs-4/packages/simulation/www/siminst/simulation-start.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/simulation/www/siminst/simulation-start.tcl,v diff -u -r1.3 -r1.4 --- openacs-4/packages/simulation/www/siminst/simulation-start.tcl 18 Dec 2003 15:22:56 -0000 1.3 +++ openacs-4/packages/simulation/www/siminst/simulation-start.tcl 19 Dec 2003 13:03:21 -0000 1.4 @@ -10,3 +10,4 @@ simulation::template::force_start -workflow_id $workflow_id ad_returnredirect "../simplay" +return Index: openacs-4/packages/simulation/www/simplay/case.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/simulation/www/simplay/case.adp,v diff -u -r1.1 -r1.2 --- openacs-4/packages/simulation/www/simplay/case.adp 18 Dec 2003 15:39:03 -0000 1.1 +++ openacs-4/packages/simulation/www/simplay/case.adp 19 Dec 2003 13:03:22 -0000 1.2 @@ -1,11 +1,14 @@ @title;noquote@ @context;noquote@ +

Tasks

- + +

Messages

- + +

Portfolio

TODO: show list of case/role-specific documents Index: openacs-4/packages/simulation/www/simplay/index.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/simulation/www/simplay/index.adp,v diff -u -r1.9 -r1.10 --- openacs-4/packages/simulation/www/simplay/index.adp 18 Dec 2003 15:39:03 -0000 1.9 +++ openacs-4/packages/simulation/www/simplay/index.adp 19 Dec 2003 13:03:22 -0000 1.10 @@ -3,11 +3,15 @@ @context;noquote@ Show list of cases and make user pick one before proceeding. However, if there is only one valid case, use it. + +

- -

- +

Administrators

+ +

+ -

TODO: how can a player access completed cases? + +

TODO: how can a player access completed cases?

Index: openacs-4/packages/simulation/www/simplay/play-master.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/simulation/www/simplay/play-master.adp,v diff -u -r1.1 -r1.2 --- openacs-4/packages/simulation/www/simplay/play-master.adp 18 Nov 2003 09:44:32 -0000 1.1 +++ openacs-4/packages/simulation/www/simplay/play-master.adp 19 Dec 2003 13:03:22 -0000 1.2 @@ -4,10 +4,10 @@
+ +
- -
+ +