Index: openacs-4/contrib/packages/simulation/lib/cases-admin.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/simulation/lib/Attic/cases-admin.tcl,v
diff -u -r1.4 -r1.5
--- openacs-4/contrib/packages/simulation/lib/cases-admin.tcl 12 Jan 2004 16:10:48 -0000 1.4
+++ openacs-4/contrib/packages/simulation/lib/cases-admin.tcl 21 Jan 2004 15:55:36 -0000 1.5
@@ -32,7 +32,7 @@
-elements $elements
db_multirow cases select_cases "
- select distinct wc.case_id,
+ select wc.case_id,
sc.label,
w.pretty_name
from workflow_cases wc,
@@ -43,4 +43,5 @@
and sc.sim_case_id = wc.object_id
and w.workflow_id = ao.object_id
and ao.creation_user = :user_id
+ order by w.workflow_id, wc.case_id
"
Index: openacs-4/contrib/packages/simulation/tcl/sim-role-procs.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/simulation/tcl/Attic/sim-role-procs.tcl,v
diff -u -r1.4 -r1.5
--- openacs-4/contrib/packages/simulation/tcl/sim-role-procs.tcl 13 Jan 2004 12:37:12 -0000 1.4
+++ openacs-4/contrib/packages/simulation/tcl/sim-role-procs.tcl 21 Jan 2004 15:55:36 -0000 1.5
@@ -168,7 +168,8 @@
}
db_1row select_sim_role {
- select character_id
+ select character_id,
+ users_per_case
from sim_roles
where role_id = :role_id
} -column_array local_row
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.56 -r1.57
--- openacs-4/contrib/packages/simulation/tcl/template-procs.tcl 20 Jan 2004 14:11:21 -0000 1.56
+++ openacs-4/contrib/packages/simulation/tcl/template-procs.tcl 21 Jan 2004 15:55:36 -0000 1.57
@@ -1298,3 +1298,26 @@
and pamm.member_id = :user_id
}]
}
+
+ad_proc -public simulation::template::user_mapped_to_role_p {
+ {-workflow_id:required}
+ {-role_id:required}
+} {
+ Return 1 if user is in a group mapped to the the given role
+ and 0 otherwise.
+
+ @author Peter Marklund
+} {
+ set user_id [ad_conn user_id]
+
+ return [db_string user_mapped_to_role_p {
+ select count(*)
+ from sim_role_party_map srpm,
+ workflow_roles wr,
+ party_approved_member_map pamm
+ where srpm.role_id = wr.role_id
+ and wr.workflow_id = :workflow_id
+ and srpm.party_id = pamm.party_id
+ and pamm.member_id = :user_id
+ }]
+}
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.22 -r1.23
--- openacs-4/contrib/packages/simulation/www/siminst/simulation-casting-3.tcl 20 Jan 2004 12:41:03 -0000 1.22
+++ openacs-4/contrib/packages/simulation/www/siminst/simulation-casting-3.tcl 21 Jan 2004 15:55:36 -0000 1.23
@@ -148,27 +148,23 @@
}
}
- if { [string equal $sim_template(enroll_type) "closed"] || [empty_string_p $sim_template(enroll_type)] } {
- # In closed enrollment we require the admin to map all groups to roles
-
- set uncast_mapped_groups [db_list uncast_mapped_groups_count "
- select g.group_name
- from sim_party_sim_map spsm,
- groups g
- where spsm.simulation_id = :workflow_id
- and g.group_id = spsm.party_id
- and not exists (select 1
- from sim_role_party_map srpm,
- workflow_roles wr
- where srpm.role_id = wr.role_id
- and wr.workflow_id = :workflow_id
- and srpm.party_id = spsm.party_id
- )
+ set uncast_mapped_groups [db_list uncast_mapped_groups_count "
+ select g.group_name
+ from sim_party_sim_map spsm,
+ groups g
+ where spsm.simulation_id = :workflow_id
+ and g.group_id = spsm.party_id
+ and not exists (select 1
+ from sim_role_party_map srpm,
+ workflow_roles wr
+ where srpm.role_id = wr.role_id
+ and wr.workflow_id = :workflow_id
+ and srpm.party_id = spsm.party_id
+ )
"]
- if { [llength $uncast_mapped_groups] > 0 } {
- template::form::set_error actors parties_$role_id "The following groups are not mapped to any roles: [join $uncast_mapped_groups ", "]."
- break
- }
+ if { [llength $uncast_mapped_groups] > 0 } {
+ template::form::set_error actors parties_$role_id "The following groups are not mapped to any roles: [join $uncast_mapped_groups ", "]."
+ break
}
simulation::template::enroll_and_invite_users -workflow_id $workflow_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.2 -r1.3
--- openacs-4/contrib/packages/simulation/www/simplay/case-admin.adp 15 Jan 2004 13:19:18 -0000 1.2
+++ openacs-4/contrib/packages/simulation/www/simplay/case-admin.adp 21 Jan 2004 15:55:36 -0000 1.3
@@ -4,16 +4,22 @@
@assigned_filter;noquote@
-
+
+
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.5 -r1.6 --- openacs-4/contrib/packages/simulation/www/simplay/case-admin.tcl 16 Jan 2004 17:31:45 -0000 1.5 +++ openacs-4/contrib/packages/simulation/www/simplay/case-admin.tcl 21 Jan 2004 15:55:36 -0000 1.6 @@ -6,12 +6,14 @@ {assigned_only_p 0} } +set package_id [ad_conn package_id] +permission::require_permission -object_id $package_id -privilege sim_adminplayer + 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 { @@ -65,6 +67,7 @@ and wa.assigned_role = wr.role_id" } +set cast_roles [list] db_multirow -extend {add_url move_url remove_url} roles select_case_info " select wr.role_id, wr.pretty_name as role, @@ -89,4 +92,24 @@ 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 }] + + lappend cast_roles $role_id } + +set role_options [workflow::role::get_options -id_values -workflow_id $case(workflow_id)] +set uncast_role_options [list] +foreach role_option $role_options { + if { [lsearch -exact $cast_roles [lindex $role_option 1]] == -1 } { + lappend uncast_role_options $role_option + } +} + +ad_form -name add_user \ + -action case-admin-user-add \ + -export { case_id } \ + -form { + {role_id:integer(select) + {label "Role"} + {options {$uncast_role_options}} + } + } Index: openacs-4/contrib/packages/simulation/www/simplay/cast-join.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/simulation/www/simplay/Attic/cast-join.tcl,v diff -u -r1.1 -r1.2 --- openacs-4/contrib/packages/simulation/www/simplay/cast-join.tcl 19 Jan 2004 14:02:33 -0000 1.1 +++ openacs-4/contrib/packages/simulation/www/simplay/cast-join.tcl 21 Jan 2004 15:55:36 -0000 1.2 @@ -1,6 +1,6 @@ ad_page_contract { This script will cast a user in a simulation case. If role id is provided the user - will be cast in that role. + will be cast in that role. If case_id is not provided a new case will be created. @author Peter Marklund } { @@ -17,7 +17,7 @@ # Get simulation info if { [empty_string_p $workflow_id] } { - workflow::case::get -case_id $case_id -array case + simulation::case::get -case_id $case_id -array case set workflow_id $case(workflow_id) } simulation::template::get -workflow_id $workflow_id -array simulation @@ -26,6 +26,7 @@ auth::require_login set user_id [ad_conn user_id] set enrolled_p [simulation::template::user_enrolled_p -workflow_id $workflow_id] +# Begin a series of checks and abort with an error message on the first failure if { !$enrolled_p } { ad_return_forbidden \ "Not enrolled in simulation \"$simulation(pretty_name)\"" \ @@ -37,7 +38,8 @@ if { ![empty_string_p $role_id] } { # Role id specified so cast to that role - + + # Check that user is allowed to cast himself in a role if { ![string equal $simulation(casting_type) "open"] } { ad_return_forbidden \ "Cannot choose role in \"$simulation(pretty_name)\"" \ @@ -49,8 +51,34 @@ ad_script_abort } - # TODO: Check the max number of users for the role? + # Check that there are empty spaces in the role + set max_n_users [simulation::role::get_element -role_id $role_id -element users_per_case] + set n_users [llength [workflow::case::role::get_assignees -case_id $case_id -role_id $role_id]] + set n_empty_spots [expr $max_n_users - $n_users] + if { $n_empty_spots <= "0" } { + simulation::role::get -role_id $role_id -array role + ad_return_forbidden \ + "No empty slots in role \"$role(pretty_name)\"" \ + "+ We are sorry, but there are no empty seats in role \"$role(pretty_name)\" in case \"$case(label)\" of simulation \"$simulation(pretty_name)\". This message means the system is not operating correctly. Please contact the system administrator. +Thank you! +" + ad_script_abort + } + + # Check that the user is in a group mapped to the role + if { ![simulation::template::user_mapped_to_role_p -workflow_id $workflow_id -role_id $role_id] } { + simulation::role::get -role_id $role_id -array role + ad_return_forbidden \ + "Not allowed to cast in role \"$role(pretty_name)\"" \ + "
+ We are sorry, but you are not in the group of users that can be cast in role \"$role(pretty_name)\" in case \"$case(label)\" of simulation \"$simulation(pretty_name)\". This message means the system is not operating correctly. Please contact the system administrator. + +Thank you! +" + ad_script_abort + } } else { # No role id specified @@ -81,8 +109,8 @@ -workflow_short_name $workflow_short_name] } - # Cast the user in the role with the most empty spaces. - # TODO: check for no empty spaces? + # Find the first role with empty slots and that is mapped + # to a group the user is a member of db_foreach role_with_most_empty_spaces { select wr.role_id, sr.users_per_case as max_n_users, @@ -95,6 +123,13 @@ sim_roles sr where wr.workflow_id = :workflow_id and wr.role_id = sr.role_id + and exists (select 1 + from sim_role_party_map srpm, + party_approved_member_map pamm + where srpm.party_id = pamm.party_id + and pamm.member_id = :user_id + and srpm.role_id = wr.role_id + ) } { set n_empty_spots [expr $max_n_users - $n_users] if { [expr $n_empty_spots <= 0] } { @@ -106,8 +141,7 @@ if { [empty_string_p $role_id] } { # We weren't able to find a role with empty slots - # TODO: what do we do now? - ad_return_error "No available roles" "We couldn't find any roles that you could join in the selected case (case_id=$case_id) in simulation $simulation(pretty_name). You would need to join a new case. Select your administrator if you have questions. + ad_return_error "No available roles" "We couldn't find any roles that you could join in case \"$case(label)\" of simulation \"$simulation(pretty_name)\". You would need to join a new case. Select your administrator about this. Thank you!" ad_script_abort @@ -117,9 +151,9 @@ # We now know the user is authorized to cast himself and we have a role to cast him to # so carry out the casting. set role_short_name [workflow::role::get_element -role_id $role_id -element short_name] -set role_array($role_short_name) [list $user_id] +set assign_array($role_short_name) [list $user_id] workflow::case::role::assign \ -case_id $case_id \ - -array role_array + -array assign_array ad_returnredirect [export_vars -base cast { workflow_id }] Index: openacs-4/contrib/packages/simulation/www/simplay/cast.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/simulation/www/simplay/Attic/cast.adp,v diff -u -r1.5 -r1.6 --- openacs-4/contrib/packages/simulation/www/simplay/cast.adp 19 Jan 2004 17:10:32 -0000 1.5 +++ openacs-4/contrib/packages/simulation/www/simplay/cast.adp 21 Jan 2004 15:55:36 -0000 1.6 @@ -10,7 +10,7 @@
- Below is a listing of all users in the simulation. + Below is a listing of all roles in the simulation.
@@ -137,5 +137,9 @@ -->-TODO: If casting type is group instead of open, do not display or group -by the role column. +TODO: Grouping by case and role +
+ ++TODO: Display listing of users assigned to each role/case, preferably on this page, alternatively on separate page +
Index: openacs-4/contrib/packages/simulation/www/simplay/cast.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/simulation/www/simplay/Attic/cast.tcl,v diff -u -r1.4 -r1.5 --- openacs-4/contrib/packages/simulation/www/simplay/cast.tcl 19 Jan 2004 14:02:33 -0000 1.4 +++ openacs-4/contrib/packages/simulation/www/simplay/cast.tcl 21 Jan 2004 15:55:36 -0000 1.5 @@ -89,46 +89,85 @@ case_pretty { label "Case" display_template { - @roles.case_pretty@+ TODO: fix bug with Your tasks count in simulation listing sometimes being too high +
Index: openacs-4/packages/simulation/lib/cases-admin.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/simulation/lib/cases-admin.tcl,v diff -u -r1.4 -r1.5 --- openacs-4/packages/simulation/lib/cases-admin.tcl 12 Jan 2004 16:10:48 -0000 1.4 +++ openacs-4/packages/simulation/lib/cases-admin.tcl 21 Jan 2004 15:55:36 -0000 1.5 @@ -32,7 +32,7 @@ -elements $elements db_multirow cases select_cases " - select distinct wc.case_id, + select wc.case_id, sc.label, w.pretty_name from workflow_cases wc, @@ -43,4 +43,5 @@ and sc.sim_case_id = wc.object_id and w.workflow_id = ao.object_id and ao.creation_user = :user_id + order by w.workflow_id, wc.case_id " Index: openacs-4/packages/simulation/tcl/sim-role-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/simulation/tcl/sim-role-procs.tcl,v diff -u -r1.4 -r1.5 --- openacs-4/packages/simulation/tcl/sim-role-procs.tcl 13 Jan 2004 12:37:12 -0000 1.4 +++ openacs-4/packages/simulation/tcl/sim-role-procs.tcl 21 Jan 2004 15:55:36 -0000 1.5 @@ -168,7 +168,8 @@ } db_1row select_sim_role { - select character_id + select character_id, + users_per_case from sim_roles where role_id = :role_id } -column_array local_row 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.56 -r1.57 --- openacs-4/packages/simulation/tcl/template-procs.tcl 20 Jan 2004 14:11:21 -0000 1.56 +++ openacs-4/packages/simulation/tcl/template-procs.tcl 21 Jan 2004 15:55:36 -0000 1.57 @@ -1298,3 +1298,26 @@ and pamm.member_id = :user_id }] } + +ad_proc -public simulation::template::user_mapped_to_role_p { + {-workflow_id:required} + {-role_id:required} +} { + Return 1 if user is in a group mapped to the the given role + and 0 otherwise. + + @author Peter Marklund +} { + set user_id [ad_conn user_id] + + return [db_string user_mapped_to_role_p { + select count(*) + from sim_role_party_map srpm, + workflow_roles wr, + party_approved_member_map pamm + where srpm.role_id = wr.role_id + and wr.workflow_id = :workflow_id + and srpm.party_id = pamm.party_id + and pamm.member_id = :user_id + }] +} 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.22 -r1.23 --- openacs-4/packages/simulation/www/siminst/simulation-casting-3.tcl 20 Jan 2004 12:41:03 -0000 1.22 +++ openacs-4/packages/simulation/www/siminst/simulation-casting-3.tcl 21 Jan 2004 15:55:36 -0000 1.23 @@ -148,27 +148,23 @@ } } - if { [string equal $sim_template(enroll_type) "closed"] || [empty_string_p $sim_template(enroll_type)] } { - # In closed enrollment we require the admin to map all groups to roles - - set uncast_mapped_groups [db_list uncast_mapped_groups_count " - select g.group_name - from sim_party_sim_map spsm, - groups g - where spsm.simulation_id = :workflow_id - and g.group_id = spsm.party_id - and not exists (select 1 - from sim_role_party_map srpm, - workflow_roles wr - where srpm.role_id = wr.role_id - and wr.workflow_id = :workflow_id - and srpm.party_id = spsm.party_id - ) + set uncast_mapped_groups [db_list uncast_mapped_groups_count " + select g.group_name + from sim_party_sim_map spsm, + groups g + where spsm.simulation_id = :workflow_id + and g.group_id = spsm.party_id + and not exists (select 1 + from sim_role_party_map srpm, + workflow_roles wr + where srpm.role_id = wr.role_id + and wr.workflow_id = :workflow_id + and srpm.party_id = spsm.party_id + ) "] - if { [llength $uncast_mapped_groups] > 0 } { - template::form::set_error actors parties_$role_id "The following groups are not mapped to any roles: [join $uncast_mapped_groups ", "]." - break - } + if { [llength $uncast_mapped_groups] > 0 } { + template::form::set_error actors parties_$role_id "The following groups are not mapped to any roles: [join $uncast_mapped_groups ", "]." + break } simulation::template::enroll_and_invite_users -workflow_id $workflow_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.2 -r1.3 --- openacs-4/packages/simulation/www/simplay/case-admin.adp 15 Jan 2004 13:19:18 -0000 1.2 +++ openacs-4/packages/simulation/www/simplay/case-admin.adp 21 Jan 2004 15:55:36 -0000 1.3 @@ -4,16 +4,22 @@ @assigned_filter;noquote@ -
+
+
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.5 -r1.6 --- openacs-4/packages/simulation/www/simplay/case-admin.tcl 16 Jan 2004 17:31:45 -0000 1.5 +++ openacs-4/packages/simulation/www/simplay/case-admin.tcl 21 Jan 2004 15:55:36 -0000 1.6 @@ -6,12 +6,14 @@ {assigned_only_p 0} } +set package_id [ad_conn package_id] +permission::require_permission -object_id $package_id -privilege sim_adminplayer + 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 { @@ -65,6 +67,7 @@ and wa.assigned_role = wr.role_id" } +set cast_roles [list] db_multirow -extend {add_url move_url remove_url} roles select_case_info " select wr.role_id, wr.pretty_name as role, @@ -89,4 +92,24 @@ 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 }] + + lappend cast_roles $role_id } + +set role_options [workflow::role::get_options -id_values -workflow_id $case(workflow_id)] +set uncast_role_options [list] +foreach role_option $role_options { + if { [lsearch -exact $cast_roles [lindex $role_option 1]] == -1 } { + lappend uncast_role_options $role_option + } +} + +ad_form -name add_user \ + -action case-admin-user-add \ + -export { case_id } \ + -form { + {role_id:integer(select) + {label "Role"} + {options {$uncast_role_options}} + } + } Index: openacs-4/packages/simulation/www/simplay/cast-join.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/simulation/www/simplay/cast-join.tcl,v diff -u -r1.1 -r1.2 --- openacs-4/packages/simulation/www/simplay/cast-join.tcl 19 Jan 2004 14:02:33 -0000 1.1 +++ openacs-4/packages/simulation/www/simplay/cast-join.tcl 21 Jan 2004 15:55:36 -0000 1.2 @@ -1,6 +1,6 @@ ad_page_contract { This script will cast a user in a simulation case. If role id is provided the user - will be cast in that role. + will be cast in that role. If case_id is not provided a new case will be created. @author Peter Marklund } { @@ -17,7 +17,7 @@ # Get simulation info if { [empty_string_p $workflow_id] } { - workflow::case::get -case_id $case_id -array case + simulation::case::get -case_id $case_id -array case set workflow_id $case(workflow_id) } simulation::template::get -workflow_id $workflow_id -array simulation @@ -26,6 +26,7 @@ auth::require_login set user_id [ad_conn user_id] set enrolled_p [simulation::template::user_enrolled_p -workflow_id $workflow_id] +# Begin a series of checks and abort with an error message on the first failure if { !$enrolled_p } { ad_return_forbidden \ "Not enrolled in simulation \"$simulation(pretty_name)\"" \ @@ -37,7 +38,8 @@ if { ![empty_string_p $role_id] } { # Role id specified so cast to that role - + + # Check that user is allowed to cast himself in a role if { ![string equal $simulation(casting_type) "open"] } { ad_return_forbidden \ "Cannot choose role in \"$simulation(pretty_name)\"" \ @@ -49,8 +51,34 @@ ad_script_abort } - # TODO: Check the max number of users for the role? + # Check that there are empty spaces in the role + set max_n_users [simulation::role::get_element -role_id $role_id -element users_per_case] + set n_users [llength [workflow::case::role::get_assignees -case_id $case_id -role_id $role_id]] + set n_empty_spots [expr $max_n_users - $n_users] + if { $n_empty_spots <= "0" } { + simulation::role::get -role_id $role_id -array role + ad_return_forbidden \ + "No empty slots in role \"$role(pretty_name)\"" \ + "+ We are sorry, but there are no empty seats in role \"$role(pretty_name)\" in case \"$case(label)\" of simulation \"$simulation(pretty_name)\". This message means the system is not operating correctly. Please contact the system administrator. +Thank you! +" + ad_script_abort + } + + # Check that the user is in a group mapped to the role + if { ![simulation::template::user_mapped_to_role_p -workflow_id $workflow_id -role_id $role_id] } { + simulation::role::get -role_id $role_id -array role + ad_return_forbidden \ + "Not allowed to cast in role \"$role(pretty_name)\"" \ + "
+ We are sorry, but you are not in the group of users that can be cast in role \"$role(pretty_name)\" in case \"$case(label)\" of simulation \"$simulation(pretty_name)\". This message means the system is not operating correctly. Please contact the system administrator. + +Thank you! +" + ad_script_abort + } } else { # No role id specified @@ -81,8 +109,8 @@ -workflow_short_name $workflow_short_name] } - # Cast the user in the role with the most empty spaces. - # TODO: check for no empty spaces? + # Find the first role with empty slots and that is mapped + # to a group the user is a member of db_foreach role_with_most_empty_spaces { select wr.role_id, sr.users_per_case as max_n_users, @@ -95,6 +123,13 @@ sim_roles sr where wr.workflow_id = :workflow_id and wr.role_id = sr.role_id + and exists (select 1 + from sim_role_party_map srpm, + party_approved_member_map pamm + where srpm.party_id = pamm.party_id + and pamm.member_id = :user_id + and srpm.role_id = wr.role_id + ) } { set n_empty_spots [expr $max_n_users - $n_users] if { [expr $n_empty_spots <= 0] } { @@ -106,8 +141,7 @@ if { [empty_string_p $role_id] } { # We weren't able to find a role with empty slots - # TODO: what do we do now? - ad_return_error "No available roles" "We couldn't find any roles that you could join in the selected case (case_id=$case_id) in simulation $simulation(pretty_name). You would need to join a new case. Select your administrator if you have questions. + ad_return_error "No available roles" "We couldn't find any roles that you could join in case \"$case(label)\" of simulation \"$simulation(pretty_name)\". You would need to join a new case. Select your administrator about this. Thank you!" ad_script_abort @@ -117,9 +151,9 @@ # We now know the user is authorized to cast himself and we have a role to cast him to # so carry out the casting. set role_short_name [workflow::role::get_element -role_id $role_id -element short_name] -set role_array($role_short_name) [list $user_id] +set assign_array($role_short_name) [list $user_id] workflow::case::role::assign \ -case_id $case_id \ - -array role_array + -array assign_array ad_returnredirect [export_vars -base cast { workflow_id }] Index: openacs-4/packages/simulation/www/simplay/cast.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/simulation/www/simplay/cast.adp,v diff -u -r1.5 -r1.6 --- openacs-4/packages/simulation/www/simplay/cast.adp 19 Jan 2004 17:10:32 -0000 1.5 +++ openacs-4/packages/simulation/www/simplay/cast.adp 21 Jan 2004 15:55:36 -0000 1.6 @@ -10,7 +10,7 @@
- Below is a listing of all users in the simulation. + Below is a listing of all roles in the simulation.
@@ -137,5 +137,9 @@ -->-TODO: If casting type is group instead of open, do not display or group -by the role column. +TODO: Grouping by case and role +
+ ++TODO: Display listing of users assigned to each role/case, preferably on this page, alternatively on separate page +
Index: openacs-4/packages/simulation/www/simplay/cast.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/simulation/www/simplay/cast.tcl,v diff -u -r1.4 -r1.5 --- openacs-4/packages/simulation/www/simplay/cast.tcl 19 Jan 2004 14:02:33 -0000 1.4 +++ openacs-4/packages/simulation/www/simplay/cast.tcl 21 Jan 2004 15:55:36 -0000 1.5 @@ -89,46 +89,85 @@ case_pretty { label "Case" display_template { - @roles.case_pretty@+ TODO: fix bug with Your tasks count in simulation listing sometimes being too high +