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.21 -r1.22 --- openacs-4/contrib/packages/simulation/tcl/simulation-procs.tcl 6 Jan 2004 18:36:27 -0000 1.21 +++ openacs-4/contrib/packages/simulation/tcl/simulation-procs.tcl 7 Jan 2004 12:22:40 -0000 1.22 @@ -153,9 +153,9 @@ set options_list [list] # We only want the label and the id, i.e. strip off the count - array set groups [casting_groups_with_counts -enrolled_only=$enrolled_only_p -workflow_id $workflow_id] - foreach group_id [array names groups] { - lappend options_list [list "[lindex $groups($group_id) 0] ([lindex $groups($group_id) 1] users)" $group_id] + set groups [casting_groups_with_counts -enrolled_only=$enrolled_only_p -workflow_id $workflow_id] + foreach { group_id val } $groups { + lappend options_list [list "[lindex $val 0] ([lindex $val 1] users)" $group_id] } return $options_list @@ -190,6 +190,7 @@ )"] set groups_list [list] set permission_group_name [permission_group_name] + db_foreach subsite_group_options " select g.group_name, g.group_id, @@ -200,7 +201,7 @@ and pamm.member_id = u.user_id ) as n_users from acs_rels ar, - groups g + groups g where ar.object_id_one = :subsite_group_id and ar.object_id_two = g.group_id and exists (select 1 @@ -211,6 +212,7 @@ ) and g.group_name <> :permission_group_name $enrollment_clause + order by lower(g.group_name) " { lappend groups_list $group_id [list $group_name $n_users] } 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.32 -r1.33 --- openacs-4/contrib/packages/simulation/tcl/template-procs.tcl 6 Jan 2004 18:36:27 -0000 1.32 +++ openacs-4/contrib/packages/simulation/tcl/template-procs.tcl 7 Jan 2004 12:22:40 -0000 1.33 @@ -761,7 +761,6 @@ } { simulation::template::get -workflow_id $workflow_id -array sim_template - switch $sim_template(sim_type) { dev_sim { @@ -813,3 +812,41 @@ return $state } + +ad_proc -public simulation::template::get_state_pretty { + -state:required +} { + Get pretty version of state. +} { + array set pretty { + none "Not started" + roles_complete "Roles completed" + tasks_complete "Tasks completed" + settings_complete "Settings completed" + enrollment_complete "Enrollment completed" + participants_complete "Participants completed" + } + + return $pretty($state) +} + +ad_proc -public simulation::template::pretty_name_unique_p { + -package_id:required + -pretty_name:required + {-workflow_id {}} +} { + Check if suggested pretty_name is unique. + + @return 1 if unique, 0 if not unique. +} { + set exists_p [db_string name_exists { + select count(*) + from workflows + where package_key = 'simulation' + and object_id = :package_id + and pretty_name = :pretty_name + and (:workflow_id is null or workflow_id != :workflow_id) + }] + return [expr !$exists_p] +} + Index: openacs-4/contrib/packages/simulation/www/siminst/index.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/simulation/www/siminst/Attic/index.adp,v diff -u -r1.13 -r1.14 --- openacs-4/contrib/packages/simulation/www/siminst/index.adp 5 Jan 2004 10:31:41 -0000 1.13 +++ openacs-4/contrib/packages/simulation/www/siminst/index.adp 7 Jan 2004 12:22:40 -0000 1.14 @@ -2,6 +2,8 @@ @page_title;noquote@ @context;noquote@ +

Simulations in Development

+

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.25 -r1.26 --- openacs-4/contrib/packages/simulation/www/siminst/index.tcl 6 Jan 2004 14:56:42 -0000 1.25 +++ openacs-4/contrib/packages/simulation/www/siminst/index.tcl 7 Jan 2004 12:22:40 -0000 1.26 @@ -21,52 +21,39 @@ -no_data "No Simulations are in Development" \ -sub_class "narrow" \ -elements { + edit { + sub_class narrow + link_url_eval {[export_vars -base wizard { workflow_id }]} + display_template { + Edit + } + } pretty_name { label "Simulation" orderby upper(w.pretty_name) link_url_eval {[export_vars -base wizard { workflow_id }]} } + state_pretty { + label "State" + } description { label "Description" display_template {@dev_sims.description;noquote@} } - role_count { - label "Roles" - link_url_col map_roles_url + copy { + sub_class narrow display_template { - @dev_sims.role_count@ (@dev_sims.role_empty_count@ incomplete) + Copy } } - tasks { - label "Tasks" - link_url_col sim_tasks_url - display_template { - @dev_sims.tasks@, with @dev_sims.prop_empty_count@ incomplete props - } - } delete { sub_class narrow link_url_col delete_url display_template { - Edit + Delete } } - copy { - display_template { - Copy - } - } - cast { - display_template { - - Begin casting - - - Not Ready for Casting - - } - } } # if user is admin, show all. otherwise, show only records owned by user @@ -76,7 +63,7 @@ set sim_in_dev_filter_sql "and ao.creation_user = :user_id" } -db_multirow -extend { cast_url map_roles_url map_props_url sim_tasks_url delete_url prop_empty_count } dev_sims select_dev_sims " +db_multirow -extend { state state_pretty cast_url map_roles_url map_props_url sim_tasks_url delete_url prop_empty_count } dev_sims select_dev_sims " select w.workflow_id, w.pretty_name, w.description, @@ -124,6 +111,8 @@ set map_roles_url [export_vars -base "${base_url}siminst/map-characters" { workflow_id }] set sim_tasks_url [export_vars -base "${base_url}siminst/map-tasks" { workflow_id }] set delete_url [export_vars -base "${base_url}siminst/simulation-delete" { workflow_id }] + set state [simulation::template::get_inst_state -workflow_id $workflow_id] + set state_pretty [simulation::template::get_state_pretty -state $state] } @@ -139,36 +128,30 @@ pretty_name { label "Simulation" orderby upper(w.pretty_name) - link_url_col edit_url } - groups { - label {Groups} - display_template { - Edit groups - } - } n_users { label "Users enrolled" html { align center } } case_start { label "Start date" } - delete { - sub_class narrow - link_url_col delete_url + start_now { display_template { - Edit + Start immediately } } copy { + sub_class narrow display_template { - Copy + Copy } } - start_now { + delete { + sub_class narrow + link_url_col delete_url display_template { - Start immediately + Edit } } } @@ -180,7 +163,7 @@ set sim_in_dev_filter_sql "and ao.creation_user = :user_id" } -db_multirow -extend { edit_url delete_url start_url groups_url } casting_sims select_casting_sims " +db_multirow -extend { delete_url start_url } casting_sims select_casting_sims " select w.workflow_id, w.pretty_name, (select count(*) @@ -201,8 +184,6 @@ and ss.sim_type = 'casting_sim' $sim_in_dev_filter_sql " { - set edit_url [export_vars -base "${base_url}siminst/simulation-casting-2" { workflow_id }] set delete_url [export_vars -base "${base_url}siminst/simulation-delete" { workflow_id }] set start_url [export_vars -base "simulation-start" { workflow_id }] - set groups_url [export_vars -base "simulation-casting-3" { workflow_id }] } Index: openacs-4/contrib/packages/simulation/www/siminst/map-create.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/simulation/www/siminst/Attic/map-create.tcl,v diff -u -r1.6 -r1.7 --- openacs-4/contrib/packages/simulation/www/siminst/map-create.tcl 17 Dec 2003 20:23:48 -0000 1.6 +++ openacs-4/contrib/packages/simulation/www/siminst/map-create.tcl 7 Jan 2004 12:22:40 -0000 1.7 @@ -23,11 +23,22 @@ {pretty_name:text {label "Template name"} {value $name_default} - {html {size 50}} + {html {size 60}} + {help_text "Please choose a new name for your new simulation"} } } -on_submit { - # Create a new template that is clone of the existing one + # Check that pretty_name is unique + set unique_p [simulation::template::pretty_name_unique_p \ + -package_id [ad_conn package_id] \ + -pretty_name $pretty_name] + + if { !$unique_p } { + form set_error template pretty_name "This name is already used by another simulation" + break + } + + # Create a new template that is clone of the existing one set new_workflow_array(pretty_name) $pretty_name set new_workflow_array(short_name) {} set new_workflow_array(sim_type) "dev_sim" @@ -40,7 +51,7 @@ # Proceed to the task page - ad_returnredirect [export_vars -base map-characters {workflow_id}] + ad_returnredirect [export_vars -base wizard { workflow_id }] ad_script_abort } Index: openacs-4/contrib/packages/simulation/www/siminst/simulation-casting-3.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/simulation/www/siminst/Attic/simulation-casting-3.adp,v diff -u -r1.6 -r1.7 --- openacs-4/contrib/packages/simulation/www/siminst/simulation-casting-3.adp 6 Jan 2004 14:56:42 -0000 1.6 +++ openacs-4/contrib/packages/simulation/www/siminst/simulation-casting-3.adp 7 Jan 2004 12:22:40 -0000 1.7 @@ -1,13 +1,9 @@ - -

- You haven't picked any groups yet. -

- Pick groups now -
- - - +

+ Pick which groups can be cast in which roles below. +

+ +

TODO: Display the actor list and group size in parallel columns instead of in pairs of rows Index: openacs-4/contrib/packages/simulation/www/siminst/simulation-casting-3.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/simulation/www/siminst/Attic/simulation-casting-3.tcl,v diff -u -r1.11 -r1.12 --- openacs-4/contrib/packages/simulation/www/siminst/simulation-casting-3.tcl 6 Jan 2004 18:36:28 -0000 1.11 +++ openacs-4/contrib/packages/simulation/www/siminst/simulation-casting-3.tcl 7 Jan 2004 12:22:40 -0000 1.12 @@ -13,26 +13,50 @@ set form [list] -set eligible_groups [simulation::casting_groups -enrolled_only -workflow_id $workflow_id] +lappend form {casting_type:text(radio) + {label "Casting type"} + {options {{Automatic auto} {Group group} {Open open}}} + {section "Casting type"} +} -set pick_groups_url [export_vars -base simulation-casting-2 { workflow_id }] +set eligible_groups [simulation::casting_groups -workflow_id $workflow_id] + foreach role_id [workflow::get_roles -workflow_id $workflow_id] { set role_${role_id}_pretty_name [workflow::role::get_element -role_id $role_id -element pretty_name] lappend form [list parties_${role_id}:text(checkbox),multiple,optional \ - [list help_text "Only users in these groups can be cast in this role"] \ [list label \$role_${role_id}_pretty_name] \ - [list options $eligible_groups] - ] - lappend form [list users_per_case_${role_id}:integer [list label "Target number of users for this role per case"] [list value 1] [list html {size 2}]] + {options $eligible_groups} \ + {section "Roles"} + ] + lappend form [list \ + users_per_case_${role_id}:integer \ + {label "Number of users per role"} \ + {value 1} \ + {html {size 2}} \ + {section "Roles"} + ] + } ad_form \ -name actors \ -export { workflow_id } \ -form $form \ -on_request { + simulation::template::get -workflow_id $workflow_id -array sim_template + + foreach elm { + casting_type + } { + set $elm $sim_template($elm) + } + + if { [empty_string_p $casting_type] } { + set casting_type "auto" + } + simulation::template::role_party_mappings -workflow_id $workflow_id -array roles foreach role_id [array names roles] { @@ -41,43 +65,53 @@ element::set_values actors parties_${role_id} $one_role(parties) element set_properties actors users_per_case_${role_id} -value $one_role(users_per_case) } + + } -on_submit { # Validation # Make sure the number of users per case does not exceed the total number of users # in the selected parties - array set groups [simulation::casting_groups_with_counts -enrolled_only -workflow_id $workflow_id] + array set groups [simulation::casting_groups_with_counts -workflow_id $workflow_id] set error_p 0 foreach role_id [workflow::get_roles -workflow_id $workflow_id] { set users_per_case [set users_per_case_$role_id] - set n_members 0 - foreach party_id [set parties_$role_id] { - set n_members [expr $n_members + [lindex $groups($party_id) 1]] - } + if { [llength [set parties_$role_id]] > 0 } { + set n_members 0 + foreach party_id [set parties_$role_id] { + set n_members [expr $n_members + [lindex $groups($party_id) 1]] + } - if { $users_per_case > $n_members } { - template::form::set_error actors users_per_case_$role_id "Number of users per case is larger than the number of users in the selected groups: $n_members" - set error_p 1 - break + if { $users_per_case > $n_members } { + template::form::set_error actors users_per_case_$role_id "Number of users per case is larger than the number of users in the selected groups: $n_members" + set error_p 1 + } } } if { $error_p } { break } - simulation::template::delete_role_party_mappings -workflow_id $workflow_id - foreach role_id [workflow::get_roles -workflow_id $workflow_id] { - set role_edit(users_per_case) [set users_per_case_$role_id] - simulation::role::edit -role_id $role_id -array role_edit - - simulation::template::new_role_party_mappings \ - -role_id $role_id \ - -parties [set parties_$role_id] \ - } + db_transaction { + set row(casting_type) $casting_type + simulation::template::edit \ + -workflow_id $workflow_id \ + -array row + + simulation::template::delete_role_party_mappings -workflow_id $workflow_id + foreach role_id [workflow::get_roles -workflow_id $workflow_id] { + set role_edit(users_per_case) [set users_per_case_$role_id] + simulation::role::edit -role_id $role_id -array role_edit + + simulation::template::new_role_party_mappings \ + -role_id $role_id \ + -parties [set parties_$role_id] \ + } + } wizard forward } -wizard submit actors -buttons { back next } +wizard submit actors -buttons { back next finish } Index: openacs-4/contrib/packages/simulation/www/siminst/simulation-edit.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/simulation/www/siminst/Attic/simulation-edit.tcl,v diff -u -r1.3 -r1.4 --- openacs-4/contrib/packages/simulation/www/siminst/simulation-edit.tcl 6 Jan 2004 18:36:28 -0000 1.3 +++ openacs-4/contrib/packages/simulation/www/siminst/simulation-edit.tcl 7 Jan 2004 12:22:40 -0000 1.4 @@ -9,7 +9,7 @@ ad_form -export { workflow_id } -name simulation -form { {pretty_name:text {label "Simulation Name"} - {html {size 40}} + {html {size 60}} } {send_start_note_date:date,to_sql(ansi),from_sql(ansi),optional {label "Date to send start notification (mockup only)"} @@ -45,6 +45,16 @@ set case_end [clock format [expr [clock seconds] + 4*$one_month] -format "%Y-%m-%d"] } } -on_submit { + set unique_p [simulation::template::pretty_name_unique_p \ + -workflow_id $workflow_id \ + -package_id [ad_conn package_id] \ + -pretty_name $pretty_name] + + if { !$unique_p } { + form set_error simulation pretty_name "This name is already used by another simulation" + break + } + foreach elm { send_start_note_date case_start case_end pretty_name } { set row($elm) [set $elm] } Index: openacs-4/contrib/packages/simulation/www/siminst/simulation-participants.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/simulation/www/siminst/Attic/simulation-participants.tcl,v diff -u -r1.1 -r1.2 --- openacs-4/contrib/packages/simulation/www/siminst/simulation-participants.tcl 6 Jan 2004 18:36:28 -0000 1.1 +++ openacs-4/contrib/packages/simulation/www/siminst/simulation-participants.tcl 7 Jan 2004 12:22:40 -0000 1.2 @@ -46,7 +46,7 @@ where ar.object_id_one = :subsite_group_id and ar.object_id_two = g.group_id and g.group_name <> :permission_group_name - order by g.group_name + order by lower(g.group_name) } { ad_form -extend -name simulation -form \ [list [list __auto_enroll_$group_id:text,optional]] @@ -80,6 +80,7 @@ } html { align center } + hide_p {[ad_decode $sim_template(enroll_type) "closed" 1 0]} } auto_enroll_p { label "Auto-Enroll" @@ -110,6 +111,13 @@ } \ -on_submit { + # First, drop all "invited" check marks if the user is also auto-enrolled + foreach group_id $groups { + if { [exists_and_equal __invited_${group_id} "t"] && [exists_and_equal __auto_enroll_${group_id} "t"] } { + unset __invited_${group_id} + } + } + db_transaction { foreach group_id $groups { foreach type { invited auto_enroll } { Index: openacs-4/contrib/packages/simulation/www/siminst/wizard.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/simulation/www/siminst/Attic/wizard.tcl,v diff -u -r1.3 -r1.4 --- openacs-4/contrib/packages/simulation/www/siminst/wizard.tcl 6 Jan 2004 18:36:28 -0000 1.3 +++ openacs-4/contrib/packages/simulation/www/siminst/wizard.tcl 7 Jan 2004 12:22:40 -0000 1.4 @@ -19,6 +19,8 @@ workflow_id } +wizard set_finish_url [export_vars -base "simulation-casting" { workflow_id }] + array set title { 1 "Assign Roles to Characters" 2 "Populate Tasks" 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.21 -r1.22 --- openacs-4/packages/simulation/tcl/simulation-procs.tcl 6 Jan 2004 18:36:27 -0000 1.21 +++ openacs-4/packages/simulation/tcl/simulation-procs.tcl 7 Jan 2004 12:22:40 -0000 1.22 @@ -153,9 +153,9 @@ set options_list [list] # We only want the label and the id, i.e. strip off the count - array set groups [casting_groups_with_counts -enrolled_only=$enrolled_only_p -workflow_id $workflow_id] - foreach group_id [array names groups] { - lappend options_list [list "[lindex $groups($group_id) 0] ([lindex $groups($group_id) 1] users)" $group_id] + set groups [casting_groups_with_counts -enrolled_only=$enrolled_only_p -workflow_id $workflow_id] + foreach { group_id val } $groups { + lappend options_list [list "[lindex $val 0] ([lindex $val 1] users)" $group_id] } return $options_list @@ -190,6 +190,7 @@ )"] set groups_list [list] set permission_group_name [permission_group_name] + db_foreach subsite_group_options " select g.group_name, g.group_id, @@ -200,7 +201,7 @@ and pamm.member_id = u.user_id ) as n_users from acs_rels ar, - groups g + groups g where ar.object_id_one = :subsite_group_id and ar.object_id_two = g.group_id and exists (select 1 @@ -211,6 +212,7 @@ ) and g.group_name <> :permission_group_name $enrollment_clause + order by lower(g.group_name) " { lappend groups_list $group_id [list $group_name $n_users] } 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.32 -r1.33 --- openacs-4/packages/simulation/tcl/template-procs.tcl 6 Jan 2004 18:36:27 -0000 1.32 +++ openacs-4/packages/simulation/tcl/template-procs.tcl 7 Jan 2004 12:22:40 -0000 1.33 @@ -761,7 +761,6 @@ } { simulation::template::get -workflow_id $workflow_id -array sim_template - switch $sim_template(sim_type) { dev_sim { @@ -813,3 +812,41 @@ return $state } + +ad_proc -public simulation::template::get_state_pretty { + -state:required +} { + Get pretty version of state. +} { + array set pretty { + none "Not started" + roles_complete "Roles completed" + tasks_complete "Tasks completed" + settings_complete "Settings completed" + enrollment_complete "Enrollment completed" + participants_complete "Participants completed" + } + + return $pretty($state) +} + +ad_proc -public simulation::template::pretty_name_unique_p { + -package_id:required + -pretty_name:required + {-workflow_id {}} +} { + Check if suggested pretty_name is unique. + + @return 1 if unique, 0 if not unique. +} { + set exists_p [db_string name_exists { + select count(*) + from workflows + where package_key = 'simulation' + and object_id = :package_id + and pretty_name = :pretty_name + and (:workflow_id is null or workflow_id != :workflow_id) + }] + return [expr !$exists_p] +} + Index: openacs-4/packages/simulation/www/siminst/index.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/simulation/www/siminst/index.adp,v diff -u -r1.13 -r1.14 --- openacs-4/packages/simulation/www/siminst/index.adp 5 Jan 2004 10:31:41 -0000 1.13 +++ openacs-4/packages/simulation/www/siminst/index.adp 7 Jan 2004 12:22:40 -0000 1.14 @@ -2,6 +2,8 @@ @page_title;noquote@ @context;noquote@ +

Simulations in Development

+

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.25 -r1.26 --- openacs-4/packages/simulation/www/siminst/index.tcl 6 Jan 2004 14:56:42 -0000 1.25 +++ openacs-4/packages/simulation/www/siminst/index.tcl 7 Jan 2004 12:22:40 -0000 1.26 @@ -21,52 +21,39 @@ -no_data "No Simulations are in Development" \ -sub_class "narrow" \ -elements { + edit { + sub_class narrow + link_url_eval {[export_vars -base wizard { workflow_id }]} + display_template { + Edit + } + } pretty_name { label "Simulation" orderby upper(w.pretty_name) link_url_eval {[export_vars -base wizard { workflow_id }]} } + state_pretty { + label "State" + } description { label "Description" display_template {@dev_sims.description;noquote@} } - role_count { - label "Roles" - link_url_col map_roles_url + copy { + sub_class narrow display_template { - @dev_sims.role_count@ (@dev_sims.role_empty_count@ incomplete) + Copy } } - tasks { - label "Tasks" - link_url_col sim_tasks_url - display_template { - @dev_sims.tasks@, with @dev_sims.prop_empty_count@ incomplete props - } - } delete { sub_class narrow link_url_col delete_url display_template { - Edit + Delete } } - copy { - display_template { - Copy - } - } - cast { - display_template { - - Begin casting - - - Not Ready for Casting - - } - } } # if user is admin, show all. otherwise, show only records owned by user @@ -76,7 +63,7 @@ set sim_in_dev_filter_sql "and ao.creation_user = :user_id" } -db_multirow -extend { cast_url map_roles_url map_props_url sim_tasks_url delete_url prop_empty_count } dev_sims select_dev_sims " +db_multirow -extend { state state_pretty cast_url map_roles_url map_props_url sim_tasks_url delete_url prop_empty_count } dev_sims select_dev_sims " select w.workflow_id, w.pretty_name, w.description, @@ -124,6 +111,8 @@ set map_roles_url [export_vars -base "${base_url}siminst/map-characters" { workflow_id }] set sim_tasks_url [export_vars -base "${base_url}siminst/map-tasks" { workflow_id }] set delete_url [export_vars -base "${base_url}siminst/simulation-delete" { workflow_id }] + set state [simulation::template::get_inst_state -workflow_id $workflow_id] + set state_pretty [simulation::template::get_state_pretty -state $state] } @@ -139,36 +128,30 @@ pretty_name { label "Simulation" orderby upper(w.pretty_name) - link_url_col edit_url } - groups { - label {Groups} - display_template { - Edit groups - } - } n_users { label "Users enrolled" html { align center } } case_start { label "Start date" } - delete { - sub_class narrow - link_url_col delete_url + start_now { display_template { - Edit + Start immediately } } copy { + sub_class narrow display_template { - Copy + Copy } } - start_now { + delete { + sub_class narrow + link_url_col delete_url display_template { - Start immediately + Edit } } } @@ -180,7 +163,7 @@ set sim_in_dev_filter_sql "and ao.creation_user = :user_id" } -db_multirow -extend { edit_url delete_url start_url groups_url } casting_sims select_casting_sims " +db_multirow -extend { delete_url start_url } casting_sims select_casting_sims " select w.workflow_id, w.pretty_name, (select count(*) @@ -201,8 +184,6 @@ and ss.sim_type = 'casting_sim' $sim_in_dev_filter_sql " { - set edit_url [export_vars -base "${base_url}siminst/simulation-casting-2" { workflow_id }] set delete_url [export_vars -base "${base_url}siminst/simulation-delete" { workflow_id }] set start_url [export_vars -base "simulation-start" { workflow_id }] - set groups_url [export_vars -base "simulation-casting-3" { workflow_id }] } Index: openacs-4/packages/simulation/www/siminst/map-create.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/simulation/www/siminst/map-create.tcl,v diff -u -r1.6 -r1.7 --- openacs-4/packages/simulation/www/siminst/map-create.tcl 17 Dec 2003 20:23:48 -0000 1.6 +++ openacs-4/packages/simulation/www/siminst/map-create.tcl 7 Jan 2004 12:22:40 -0000 1.7 @@ -23,11 +23,22 @@ {pretty_name:text {label "Template name"} {value $name_default} - {html {size 50}} + {html {size 60}} + {help_text "Please choose a new name for your new simulation"} } } -on_submit { - # Create a new template that is clone of the existing one + # Check that pretty_name is unique + set unique_p [simulation::template::pretty_name_unique_p \ + -package_id [ad_conn package_id] \ + -pretty_name $pretty_name] + + if { !$unique_p } { + form set_error template pretty_name "This name is already used by another simulation" + break + } + + # Create a new template that is clone of the existing one set new_workflow_array(pretty_name) $pretty_name set new_workflow_array(short_name) {} set new_workflow_array(sim_type) "dev_sim" @@ -40,7 +51,7 @@ # Proceed to the task page - ad_returnredirect [export_vars -base map-characters {workflow_id}] + ad_returnredirect [export_vars -base wizard { workflow_id }] ad_script_abort } Index: openacs-4/packages/simulation/www/siminst/simulation-casting-3.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/simulation/www/siminst/simulation-casting-3.adp,v diff -u -r1.6 -r1.7 --- openacs-4/packages/simulation/www/siminst/simulation-casting-3.adp 6 Jan 2004 14:56:42 -0000 1.6 +++ openacs-4/packages/simulation/www/siminst/simulation-casting-3.adp 7 Jan 2004 12:22:40 -0000 1.7 @@ -1,13 +1,9 @@ - -

- You haven't picked any groups yet. -

- Pick groups now -
- - - +

+ Pick which groups can be cast in which roles below. +

+ +

TODO: Display the actor list and group size in parallel columns instead of in pairs of rows Index: openacs-4/packages/simulation/www/siminst/simulation-casting-3.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/simulation/www/siminst/simulation-casting-3.tcl,v diff -u -r1.11 -r1.12 --- openacs-4/packages/simulation/www/siminst/simulation-casting-3.tcl 6 Jan 2004 18:36:28 -0000 1.11 +++ openacs-4/packages/simulation/www/siminst/simulation-casting-3.tcl 7 Jan 2004 12:22:40 -0000 1.12 @@ -13,26 +13,50 @@ set form [list] -set eligible_groups [simulation::casting_groups -enrolled_only -workflow_id $workflow_id] +lappend form {casting_type:text(radio) + {label "Casting type"} + {options {{Automatic auto} {Group group} {Open open}}} + {section "Casting type"} +} -set pick_groups_url [export_vars -base simulation-casting-2 { workflow_id }] +set eligible_groups [simulation::casting_groups -workflow_id $workflow_id] + foreach role_id [workflow::get_roles -workflow_id $workflow_id] { set role_${role_id}_pretty_name [workflow::role::get_element -role_id $role_id -element pretty_name] lappend form [list parties_${role_id}:text(checkbox),multiple,optional \ - [list help_text "Only users in these groups can be cast in this role"] \ [list label \$role_${role_id}_pretty_name] \ - [list options $eligible_groups] - ] - lappend form [list users_per_case_${role_id}:integer [list label "Target number of users for this role per case"] [list value 1] [list html {size 2}]] + {options $eligible_groups} \ + {section "Roles"} + ] + lappend form [list \ + users_per_case_${role_id}:integer \ + {label "Number of users per role"} \ + {value 1} \ + {html {size 2}} \ + {section "Roles"} + ] + } ad_form \ -name actors \ -export { workflow_id } \ -form $form \ -on_request { + simulation::template::get -workflow_id $workflow_id -array sim_template + + foreach elm { + casting_type + } { + set $elm $sim_template($elm) + } + + if { [empty_string_p $casting_type] } { + set casting_type "auto" + } + simulation::template::role_party_mappings -workflow_id $workflow_id -array roles foreach role_id [array names roles] { @@ -41,43 +65,53 @@ element::set_values actors parties_${role_id} $one_role(parties) element set_properties actors users_per_case_${role_id} -value $one_role(users_per_case) } + + } -on_submit { # Validation # Make sure the number of users per case does not exceed the total number of users # in the selected parties - array set groups [simulation::casting_groups_with_counts -enrolled_only -workflow_id $workflow_id] + array set groups [simulation::casting_groups_with_counts -workflow_id $workflow_id] set error_p 0 foreach role_id [workflow::get_roles -workflow_id $workflow_id] { set users_per_case [set users_per_case_$role_id] - set n_members 0 - foreach party_id [set parties_$role_id] { - set n_members [expr $n_members + [lindex $groups($party_id) 1]] - } + if { [llength [set parties_$role_id]] > 0 } { + set n_members 0 + foreach party_id [set parties_$role_id] { + set n_members [expr $n_members + [lindex $groups($party_id) 1]] + } - if { $users_per_case > $n_members } { - template::form::set_error actors users_per_case_$role_id "Number of users per case is larger than the number of users in the selected groups: $n_members" - set error_p 1 - break + if { $users_per_case > $n_members } { + template::form::set_error actors users_per_case_$role_id "Number of users per case is larger than the number of users in the selected groups: $n_members" + set error_p 1 + } } } if { $error_p } { break } - simulation::template::delete_role_party_mappings -workflow_id $workflow_id - foreach role_id [workflow::get_roles -workflow_id $workflow_id] { - set role_edit(users_per_case) [set users_per_case_$role_id] - simulation::role::edit -role_id $role_id -array role_edit - - simulation::template::new_role_party_mappings \ - -role_id $role_id \ - -parties [set parties_$role_id] \ - } + db_transaction { + set row(casting_type) $casting_type + simulation::template::edit \ + -workflow_id $workflow_id \ + -array row + + simulation::template::delete_role_party_mappings -workflow_id $workflow_id + foreach role_id [workflow::get_roles -workflow_id $workflow_id] { + set role_edit(users_per_case) [set users_per_case_$role_id] + simulation::role::edit -role_id $role_id -array role_edit + + simulation::template::new_role_party_mappings \ + -role_id $role_id \ + -parties [set parties_$role_id] \ + } + } wizard forward } -wizard submit actors -buttons { back next } +wizard submit actors -buttons { back next finish } Index: openacs-4/packages/simulation/www/siminst/simulation-edit.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/simulation/www/siminst/simulation-edit.tcl,v diff -u -r1.3 -r1.4 --- openacs-4/packages/simulation/www/siminst/simulation-edit.tcl 6 Jan 2004 18:36:28 -0000 1.3 +++ openacs-4/packages/simulation/www/siminst/simulation-edit.tcl 7 Jan 2004 12:22:40 -0000 1.4 @@ -9,7 +9,7 @@ ad_form -export { workflow_id } -name simulation -form { {pretty_name:text {label "Simulation Name"} - {html {size 40}} + {html {size 60}} } {send_start_note_date:date,to_sql(ansi),from_sql(ansi),optional {label "Date to send start notification (mockup only)"} @@ -45,6 +45,16 @@ set case_end [clock format [expr [clock seconds] + 4*$one_month] -format "%Y-%m-%d"] } } -on_submit { + set unique_p [simulation::template::pretty_name_unique_p \ + -workflow_id $workflow_id \ + -package_id [ad_conn package_id] \ + -pretty_name $pretty_name] + + if { !$unique_p } { + form set_error simulation pretty_name "This name is already used by another simulation" + break + } + foreach elm { send_start_note_date case_start case_end pretty_name } { set row($elm) [set $elm] } Index: openacs-4/packages/simulation/www/siminst/simulation-participants.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/simulation/www/siminst/simulation-participants.tcl,v diff -u -r1.1 -r1.2 --- openacs-4/packages/simulation/www/siminst/simulation-participants.tcl 6 Jan 2004 18:36:28 -0000 1.1 +++ openacs-4/packages/simulation/www/siminst/simulation-participants.tcl 7 Jan 2004 12:22:40 -0000 1.2 @@ -46,7 +46,7 @@ where ar.object_id_one = :subsite_group_id and ar.object_id_two = g.group_id and g.group_name <> :permission_group_name - order by g.group_name + order by lower(g.group_name) } { ad_form -extend -name simulation -form \ [list [list __auto_enroll_$group_id:text,optional]] @@ -80,6 +80,7 @@ } html { align center } + hide_p {[ad_decode $sim_template(enroll_type) "closed" 1 0]} } auto_enroll_p { label "Auto-Enroll" @@ -110,6 +111,13 @@ } \ -on_submit { + # First, drop all "invited" check marks if the user is also auto-enrolled + foreach group_id $groups { + if { [exists_and_equal __invited_${group_id} "t"] && [exists_and_equal __auto_enroll_${group_id} "t"] } { + unset __invited_${group_id} + } + } + db_transaction { foreach group_id $groups { foreach type { invited auto_enroll } { Index: openacs-4/packages/simulation/www/siminst/wizard.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/simulation/www/siminst/wizard.tcl,v diff -u -r1.3 -r1.4 --- openacs-4/packages/simulation/www/siminst/wizard.tcl 6 Jan 2004 18:36:28 -0000 1.3 +++ openacs-4/packages/simulation/www/siminst/wizard.tcl 7 Jan 2004 12:22:40 -0000 1.4 @@ -19,6 +19,8 @@ workflow_id } +wizard set_finish_url [export_vars -base "simulation-casting" { workflow_id }] + array set title { 1 "Assign Roles to Characters" 2 "Populate Tasks"