Index: openacs-4/contrib/packages/simulation/www/simplay/case-admin-user-add.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/simulation/www/simplay/Attic/case-admin-user-add.adp,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/contrib/packages/simulation/www/simplay/case-admin-user-add.adp 15 Jan 2004 13:19:18 -0000 1.1 @@ -0,0 +1,5 @@ + + @page_title;noquote@ + @context;noquote@ + + Index: openacs-4/contrib/packages/simulation/www/simplay/case-admin-user-add.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/simulation/www/simplay/Attic/case-admin-user-add.tcl,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/contrib/packages/simulation/www/simplay/case-admin-user-add.tcl 15 Jan 2004 13:19:18 -0000 1.1 @@ -0,0 +1,45 @@ +ad_page_contract { + Offers a selection of users for an admin to add to a role in a simulation case. + + @author Peter Marklund +} { + case_id:integer + role_id:integer +} + +simulation::case::get -case_id $case_id -array case +set simulation_id $case(workflow_id) + +workflow::role::get -role_id $role_id -array role + +set page_title "Choose new users for role $role(pretty_name)" +set context [list [list . "SimPlay"] [list [export_vars -base case-admin { case_id }] "Administer $case(label)"] $page_title] + +set user_options [db_list_of_lists user_options_for_case { + select cu.first_names || ' ' || cu.last_name, + cu.user_id + from cc_users cu, + sim_party_sim_map spsm + where spsm.party_Id = cu.user_id + and spsm.type = 'enrolled' + and spsm.simulation_id = :simulation_id +}] + +ad_form \ + -name new_user \ + -form { + {users:integer(checkbox),multiple + {label "New Users"} + {options {$user_options}} + } + } \ + -export { case_id role_id } \ + -on_submit { + + workflow::case::role::assignee_insert \ + -case_id $case_id \ + -role_id $role_id \ + -party_ids $users + + ad_returnredirect [export_vars -base case-admin { case_id }] + } Index: openacs-4/contrib/packages/simulation/www/simplay/case-admin-user-move.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/simulation/www/simplay/Attic/case-admin-user-move.adp,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/contrib/packages/simulation/www/simplay/case-admin-user-move.adp 15 Jan 2004 13:19:18 -0000 1.1 @@ -0,0 +1,5 @@ + + @page_title;noquote@ + @context;noquote@ + + Index: openacs-4/contrib/packages/simulation/www/simplay/case-admin-user-move.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/simulation/www/simplay/Attic/case-admin-user-move.tcl,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/contrib/packages/simulation/www/simplay/case-admin-user-move.tcl 15 Jan 2004 13:19:18 -0000 1.1 @@ -0,0 +1,78 @@ +ad_page_contract { + Choose new roles for a user in a workflow case. + + @author Peter Marklund +} { + case_id:integer + user_id:integer +} + +simulation::case::get -case_id $case_id -array case +acs_user::get -user_id $user_id -array user + +set page_title "Choose new roles for user $user(name)" +set context [list [list . "SimPlay"] [list [export_vars -base case-admin { case_id }] "Administer $case(label)"] $page_title] + +workflow::case::get -case_id $case_id -array case + +set role_options [workflow::role::get_options -id_values -workflow_id $case(workflow_id)] + +ad_form \ + -name new_roles \ + -form { + {roles:integer(checkbox),multiple + {label "Roles"} + {options {$role_options}} + } + } \ + -export { case_id user_id } \ + -on_submit { + + db_transaction { + # Delete users old role assignments + set old_roles [db_list select_old_roles { + select role_id + from workflow_case_role_party_map + where case_id = :case_id + and party_id = :user_id + }] + foreach role_id $old_roles { + workflow::case::role::assignee_remove \ + -case_id $case_id \ + -role_id $role_id \ + -party_id $user_id + } + + # Insert new assigned roles + foreach role_id $roles { + workflow::case::role::assignee_insert \ + -case_id $case_id \ + -role_id $role_id \ + -party_ids [list $user_id] + } + + # TODO: this should removed because we don't want to put the admin user + # in when the admin is trying to swap two users + # Assign the admin to any unassigned roles after the move +# set unassigned_roles [db_list unassigned_roles { +# select wr.role_id +# from workflow_roles wr, +# workflow_cases wc +# where wc.case_id = :case_id +# and wc.workflow_id = wr.workflow_id +# and not exists (select 1 +# from workflow_case_role_party_map wcrpm +# where wcrpm.case_id = :case_id +# and wcrpm.role_id = wr.role_id +# ) +# }] +# foreach role_id $unassigned_roles { +# workflow::case::role::assignee_insert \ +# -case_id $case_id \ +# -role_id $role_id \ +# -party_ids [list [ad_conn user_id]] +# } + } + + ad_returnredirect [export_vars -base case-admin { case_id }] + } Index: openacs-4/contrib/packages/simulation/www/simplay/case-admin-user-remove.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/simulation/www/simplay/Attic/case-admin-user-remove.tcl,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/contrib/packages/simulation/www/simplay/case-admin-user-remove.tcl 15 Jan 2004 13:19:18 -0000 1.1 @@ -0,0 +1,31 @@ +ad_page_contract { + Remove a user from role in a workflow case. If this makes the role the user was playing + not mapped to any users it will be mapped to the admin removing the user. + + @author Peter Marklund +} { + case_id:integer + user_id:integer + role_id:integer +} + +# Remove the user +workflow::case::role::assignee_remove \ + -case_id $case_id \ + -role_id $role_id \ + -party_id $user_id + +# TODO: this should removed because we don't want to put the admin user +# in when the admin is trying to swap two users +# # Assign the admin if the role is now unmapped +# set remaining_assignees [workflow::case::role:get_assignees \ +# -case_id $case_id \ +# -role_id $role_id] +# if { [llength $remaining_assignees] == 0 } { +# workflow::case::role::assignee_insert \ +# -case_id $case_id \ +# -role_id $role_id \ +# -party_ids [list [ad_conn user_id]] +# } + +ad_returnredirect [export_vars -base case-admin { case_id }] Index: openacs-4/contrib/packages/simulation/www/simplay/case-admin.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/simulation/www/simplay/Attic/case-admin.adp,v diff -u -r1.1 -r1.2 --- openacs-4/contrib/packages/simulation/www/simplay/case-admin.adp 8 Jan 2004 14:27:56 -0000 1.1 +++ openacs-4/contrib/packages/simulation/www/simplay/case-admin.adp 15 Jan 2004 13:19:18 -0000 1.2 @@ -1,52 +1,19 @@ - + @title;noquote@ @context;noquote@ - - - - - - - - - - - - - - - - - - - -
- Case # - - Current Users - -
- Case #1 - - Bob -
______ -
- -
- Case #2 - - Lokman -
Peter -
-
-
-
+ @assigned_filter;noquote@ -If no rows, display this text: "There are no cases yet." +

+

-After clicking join, redirect back to this page. Hide all buttons. -Show new text at the bottom: "You are participating in this simulation -as a player in case #X. Your role will be determined when the -simulation begins. The simulation will start XXX." \ No newline at end of file +TODO: Remove the assigned filter and make the table always show all roles and any assigned actions for each role. Lars? +

+ +

+TODO: Group by role_id. Need some help from Lars. +

+ +

+TODO: Show roles with no users +

\ No newline at end of file Index: openacs-4/contrib/packages/simulation/www/simplay/case-admin.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/simulation/www/simplay/Attic/case-admin.tcl,v diff -u -r1.3 -r1.4 --- openacs-4/contrib/packages/simulation/www/simplay/case-admin.tcl 12 Jan 2004 15:14:36 -0000 1.3 +++ openacs-4/contrib/packages/simulation/www/simplay/case-admin.tcl 15 Jan 2004 13:19:18 -0000 1.4 @@ -1,11 +1,99 @@ ad_page_contract { - This page allows users to choose which group to join. It is only relevant for simulations with casting type of group. + This page allows admins to see all the roles in a simulation case and the user + playing each role. } { case_id:integer + {assigned_only_p 0} } -set title "Administer" +simulation::case::get -case_id $case_id -array case + +set title "Administer $case(label)" set context [list [list . "SimPlay"] $title] set user_id [ad_conn user_id] set package_id [ad_conn package_id] set section_uri [apm_package_url_from_id $package_id]simplay/ + +set elements { + role { + label "Role" + display_template { + @roles.role@ \[\add user] + } + } + user_name { + label "User" + display_template { + @roles.user_name@   \[move|remove\] + } + } + max_n_users { + label "Target # users" + } + } + +if { $assigned_only_p } { + lappend elements assigned_action { + label "Assigned action" + } +} + +if { $assigned_only_p } { + set assigned_filter "Show all roles" +} else { + set assigned_filter "Show only roles with assigned actions" +} + +# -filters { +# role_id { +# label "Role" +# } +# } -groupby { +# {"Role" {{groupby role_id}}} +# } +template::list::create \ + -name roles \ + -multirow roles \ + -no_data "There are no roles or users in this simulation case" \ + -elements $elements + +# Set clauses for the assigned only filter +set select_clause "" +set from_clause "" +set where_clause "" +if { $assigned_only_p } { + set select_clause ", + wa.pretty_name as assigned_action" + set from_clause ", + workflow_case_enabled_actions wcea, + workflow_actions wa" + set where_clause " and wcea.case_id = :case_id + and wcea.action_id = wa.action_id + and wa.assigned_role = wr.role_id" +} + +db_multirow -extend {add_url move_url remove_url} roles select_case_info " + select wr.role_id, + wr.pretty_name as role, + cu.user_id, + cu.first_names || ' ' || cu.last_name as user_name, + sr.users_per_case as max_n_users + $select_clause + from workflow_roles wr, + workflow_cases wc, + workflow_case_role_party_map wcrpm, + cc_users cu, + sim_roles sr + $from_clause + where wr.workflow_id = wc.workflow_id + and wc.case_id = :case_id + and wcrpm.case_id = wc.case_id + and wcrpm.role_id = wr.role_id + and cu.user_id = wcrpm.party_id + and sr.role_id = wr.role_id + $where_clause +" { + set add_url [export_vars -base case-admin-user-add { case_id role_id }] + set move_url [export_vars -base case-admin-user-move { case_id user_id }] + set remove_url [export_vars -base case-admin-user-remove { case_id role_id user_id }] +} Index: openacs-4/contrib/packages/simulation/www/simplay/index.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/simulation/www/simplay/Attic/index.tcl,v diff -u -r1.6 -r1.7 --- openacs-4/contrib/packages/simulation/www/simplay/index.tcl 5 Jan 2004 14:09:33 -0000 1.6 +++ openacs-4/contrib/packages/simulation/www/simplay/index.tcl 15 Jan 2004 13:19:18 -0000 1.7 @@ -12,15 +12,17 @@ set adminplayer_p [permission::permission_p -object_id $package_id -privilege sim_adminplayer] -set case_list [db_list case_count { - select distinct wc.case_id +set case_list [db_list_of_lists case_count { + select distinct wc.case_id, + wcrpm.role_id from workflow_cases wc, workflow_case_role_party_map wcrpm where wcrpm.party_id = :user_id and wc.case_id = wcrpm.case_id }] if { [llength $case_list] == 1 } { - ad_returnredirect [export_vars -base case { {case_id {[lindex $case_list 0]}} }] + set first_item [lindex $case_list 0] + ad_returnredirect [export_vars -base case { {case_id {[lindex $first_item 0]}} {role_id {[lindex $first_item 1]}} }] ad_script_abort } Index: openacs-4/packages/simulation/www/simplay/case-admin-user-add.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/simulation/www/simplay/case-admin-user-add.adp,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/simulation/www/simplay/case-admin-user-add.adp 15 Jan 2004 13:19:18 -0000 1.1 @@ -0,0 +1,5 @@ + + @page_title;noquote@ + @context;noquote@ + + Index: openacs-4/packages/simulation/www/simplay/case-admin-user-add.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/simulation/www/simplay/case-admin-user-add.tcl,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/simulation/www/simplay/case-admin-user-add.tcl 15 Jan 2004 13:19:18 -0000 1.1 @@ -0,0 +1,45 @@ +ad_page_contract { + Offers a selection of users for an admin to add to a role in a simulation case. + + @author Peter Marklund +} { + case_id:integer + role_id:integer +} + +simulation::case::get -case_id $case_id -array case +set simulation_id $case(workflow_id) + +workflow::role::get -role_id $role_id -array role + +set page_title "Choose new users for role $role(pretty_name)" +set context [list [list . "SimPlay"] [list [export_vars -base case-admin { case_id }] "Administer $case(label)"] $page_title] + +set user_options [db_list_of_lists user_options_for_case { + select cu.first_names || ' ' || cu.last_name, + cu.user_id + from cc_users cu, + sim_party_sim_map spsm + where spsm.party_Id = cu.user_id + and spsm.type = 'enrolled' + and spsm.simulation_id = :simulation_id +}] + +ad_form \ + -name new_user \ + -form { + {users:integer(checkbox),multiple + {label "New Users"} + {options {$user_options}} + } + } \ + -export { case_id role_id } \ + -on_submit { + + workflow::case::role::assignee_insert \ + -case_id $case_id \ + -role_id $role_id \ + -party_ids $users + + ad_returnredirect [export_vars -base case-admin { case_id }] + } Index: openacs-4/packages/simulation/www/simplay/case-admin-user-move.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/simulation/www/simplay/case-admin-user-move.adp,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/simulation/www/simplay/case-admin-user-move.adp 15 Jan 2004 13:19:18 -0000 1.1 @@ -0,0 +1,5 @@ + + @page_title;noquote@ + @context;noquote@ + + Index: openacs-4/packages/simulation/www/simplay/case-admin-user-move.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/simulation/www/simplay/case-admin-user-move.tcl,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/simulation/www/simplay/case-admin-user-move.tcl 15 Jan 2004 13:19:18 -0000 1.1 @@ -0,0 +1,78 @@ +ad_page_contract { + Choose new roles for a user in a workflow case. + + @author Peter Marklund +} { + case_id:integer + user_id:integer +} + +simulation::case::get -case_id $case_id -array case +acs_user::get -user_id $user_id -array user + +set page_title "Choose new roles for user $user(name)" +set context [list [list . "SimPlay"] [list [export_vars -base case-admin { case_id }] "Administer $case(label)"] $page_title] + +workflow::case::get -case_id $case_id -array case + +set role_options [workflow::role::get_options -id_values -workflow_id $case(workflow_id)] + +ad_form \ + -name new_roles \ + -form { + {roles:integer(checkbox),multiple + {label "Roles"} + {options {$role_options}} + } + } \ + -export { case_id user_id } \ + -on_submit { + + db_transaction { + # Delete users old role assignments + set old_roles [db_list select_old_roles { + select role_id + from workflow_case_role_party_map + where case_id = :case_id + and party_id = :user_id + }] + foreach role_id $old_roles { + workflow::case::role::assignee_remove \ + -case_id $case_id \ + -role_id $role_id \ + -party_id $user_id + } + + # Insert new assigned roles + foreach role_id $roles { + workflow::case::role::assignee_insert \ + -case_id $case_id \ + -role_id $role_id \ + -party_ids [list $user_id] + } + + # TODO: this should removed because we don't want to put the admin user + # in when the admin is trying to swap two users + # Assign the admin to any unassigned roles after the move +# set unassigned_roles [db_list unassigned_roles { +# select wr.role_id +# from workflow_roles wr, +# workflow_cases wc +# where wc.case_id = :case_id +# and wc.workflow_id = wr.workflow_id +# and not exists (select 1 +# from workflow_case_role_party_map wcrpm +# where wcrpm.case_id = :case_id +# and wcrpm.role_id = wr.role_id +# ) +# }] +# foreach role_id $unassigned_roles { +# workflow::case::role::assignee_insert \ +# -case_id $case_id \ +# -role_id $role_id \ +# -party_ids [list [ad_conn user_id]] +# } + } + + ad_returnredirect [export_vars -base case-admin { case_id }] + } Index: openacs-4/packages/simulation/www/simplay/case-admin-user-remove.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/simulation/www/simplay/case-admin-user-remove.tcl,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/simulation/www/simplay/case-admin-user-remove.tcl 15 Jan 2004 13:19:18 -0000 1.1 @@ -0,0 +1,31 @@ +ad_page_contract { + Remove a user from role in a workflow case. If this makes the role the user was playing + not mapped to any users it will be mapped to the admin removing the user. + + @author Peter Marklund +} { + case_id:integer + user_id:integer + role_id:integer +} + +# Remove the user +workflow::case::role::assignee_remove \ + -case_id $case_id \ + -role_id $role_id \ + -party_id $user_id + +# TODO: this should removed because we don't want to put the admin user +# in when the admin is trying to swap two users +# # Assign the admin if the role is now unmapped +# set remaining_assignees [workflow::case::role:get_assignees \ +# -case_id $case_id \ +# -role_id $role_id] +# if { [llength $remaining_assignees] == 0 } { +# workflow::case::role::assignee_insert \ +# -case_id $case_id \ +# -role_id $role_id \ +# -party_ids [list [ad_conn user_id]] +# } + +ad_returnredirect [export_vars -base case-admin { case_id }] Index: openacs-4/packages/simulation/www/simplay/case-admin.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/simulation/www/simplay/case-admin.adp,v diff -u -r1.1 -r1.2 --- openacs-4/packages/simulation/www/simplay/case-admin.adp 8 Jan 2004 14:27:56 -0000 1.1 +++ openacs-4/packages/simulation/www/simplay/case-admin.adp 15 Jan 2004 13:19:18 -0000 1.2 @@ -1,52 +1,19 @@ - + @title;noquote@ @context;noquote@ - - - - - - - - - - - - - - - - - - - -
- Case # - - Current Users - -
- Case #1 - - Bob -
______ -
- -
- Case #2 - - Lokman -
Peter -
-
-
-
+ @assigned_filter;noquote@ -If no rows, display this text: "There are no cases yet." +

+

-After clicking join, redirect back to this page. Hide all buttons. -Show new text at the bottom: "You are participating in this simulation -as a player in case #X. Your role will be determined when the -simulation begins. The simulation will start XXX." \ No newline at end of file +TODO: Remove the assigned filter and make the table always show all roles and any assigned actions for each role. Lars? +

+ +

+TODO: Group by role_id. Need some help from Lars. +

+ +

+TODO: Show roles with no users +

\ No newline at end of file Index: openacs-4/packages/simulation/www/simplay/case-admin.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/simulation/www/simplay/case-admin.tcl,v diff -u -r1.3 -r1.4 --- openacs-4/packages/simulation/www/simplay/case-admin.tcl 12 Jan 2004 15:14:36 -0000 1.3 +++ openacs-4/packages/simulation/www/simplay/case-admin.tcl 15 Jan 2004 13:19:18 -0000 1.4 @@ -1,11 +1,99 @@ ad_page_contract { - This page allows users to choose which group to join. It is only relevant for simulations with casting type of group. + This page allows admins to see all the roles in a simulation case and the user + playing each role. } { case_id:integer + {assigned_only_p 0} } -set title "Administer" +simulation::case::get -case_id $case_id -array case + +set title "Administer $case(label)" set context [list [list . "SimPlay"] $title] set user_id [ad_conn user_id] set package_id [ad_conn package_id] set section_uri [apm_package_url_from_id $package_id]simplay/ + +set elements { + role { + label "Role" + display_template { + @roles.role@ \[\add user] + } + } + user_name { + label "User" + display_template { + @roles.user_name@   \[move|remove\] + } + } + max_n_users { + label "Target # users" + } + } + +if { $assigned_only_p } { + lappend elements assigned_action { + label "Assigned action" + } +} + +if { $assigned_only_p } { + set assigned_filter "Show all roles" +} else { + set assigned_filter "Show only roles with assigned actions" +} + +# -filters { +# role_id { +# label "Role" +# } +# } -groupby { +# {"Role" {{groupby role_id}}} +# } +template::list::create \ + -name roles \ + -multirow roles \ + -no_data "There are no roles or users in this simulation case" \ + -elements $elements + +# Set clauses for the assigned only filter +set select_clause "" +set from_clause "" +set where_clause "" +if { $assigned_only_p } { + set select_clause ", + wa.pretty_name as assigned_action" + set from_clause ", + workflow_case_enabled_actions wcea, + workflow_actions wa" + set where_clause " and wcea.case_id = :case_id + and wcea.action_id = wa.action_id + and wa.assigned_role = wr.role_id" +} + +db_multirow -extend {add_url move_url remove_url} roles select_case_info " + select wr.role_id, + wr.pretty_name as role, + cu.user_id, + cu.first_names || ' ' || cu.last_name as user_name, + sr.users_per_case as max_n_users + $select_clause + from workflow_roles wr, + workflow_cases wc, + workflow_case_role_party_map wcrpm, + cc_users cu, + sim_roles sr + $from_clause + where wr.workflow_id = wc.workflow_id + and wc.case_id = :case_id + and wcrpm.case_id = wc.case_id + and wcrpm.role_id = wr.role_id + and cu.user_id = wcrpm.party_id + and sr.role_id = wr.role_id + $where_clause +" { + set add_url [export_vars -base case-admin-user-add { case_id role_id }] + set move_url [export_vars -base case-admin-user-move { case_id user_id }] + set remove_url [export_vars -base case-admin-user-remove { case_id role_id user_id }] +} Index: openacs-4/packages/simulation/www/simplay/index.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/simulation/www/simplay/index.tcl,v diff -u -r1.6 -r1.7 --- openacs-4/packages/simulation/www/simplay/index.tcl 5 Jan 2004 14:09:33 -0000 1.6 +++ openacs-4/packages/simulation/www/simplay/index.tcl 15 Jan 2004 13:19:18 -0000 1.7 @@ -12,15 +12,17 @@ set adminplayer_p [permission::permission_p -object_id $package_id -privilege sim_adminplayer] -set case_list [db_list case_count { - select distinct wc.case_id +set case_list [db_list_of_lists case_count { + select distinct wc.case_id, + wcrpm.role_id from workflow_cases wc, workflow_case_role_party_map wcrpm where wcrpm.party_id = :user_id and wc.case_id = wcrpm.case_id }] if { [llength $case_list] == 1 } { - ad_returnredirect [export_vars -base case { {case_id {[lindex $case_list 0]}} }] + set first_item [lindex $case_list 0] + ad_returnredirect [export_vars -base case { {case_id {[lindex $first_item 0]}} {role_id {[lindex $first_item 1]}} }] ad_script_abort }