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 -N -r1.50 -r1.51 --- openacs-4/contrib/packages/simulation/tcl/template-procs.tcl 15 Jan 2004 16:09:51 -0000 1.50 +++ openacs-4/contrib/packages/simulation/tcl/template-procs.tcl 16 Jan 2004 12:47:55 -0000 1.51 @@ -691,11 +691,13 @@ {-workflow_id:required} } { Takes a mapped simulation template and converts it into a cast simulation - with simulation cases. This procedure expects to be called after enrollment is complete. + with simulation cases. This procedure expects to be called right before the simulation starts. @author Peter Marklund } { - # TODO (8h): also handle auto-casting when casting_type is not auto, but not all users self-cast + # TODO (8h): also handle casting when casting_type is not auto, but not all users self-cast + # TODO (3h): handle casting when casting_type is auto, and some users have enrolled, either through + # invitation or because enroll_type is open. simulation::template::role_party_mappings \ -workflow_id $workflow_id \ 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 -N -r1.1 -r1.2 --- openacs-4/contrib/packages/simulation/www/simplay/cast.tcl 8 Jan 2004 14:27:56 -0000 1.1 +++ openacs-4/contrib/packages/simulation/www/simplay/cast.tcl 16 Jan 2004 12:47:56 -0000 1.2 @@ -1,9 +1,11 @@ ad_page_contract { This page allows users to choose which group to join. It is only relevant for simulations with casting type of group. } { - {case_id:integer ""} + {workflow_id:integer ""} } +# TODO: check that user is enrolled and that casting_type is not auto_cast + set title "Join a Case in Simulation SIMNAME" set context [list $title] set user_id [ad_conn user_id] Index: openacs-4/contrib/packages/simulation/www/simplay/enroll.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/simulation/www/simplay/Attic/enroll.adp,v diff -u -N -r1.2 -r1.3 --- openacs-4/contrib/packages/simulation/www/simplay/enroll.adp 12 Jan 2004 09:23:10 -0000 1.2 +++ openacs-4/contrib/packages/simulation/www/simplay/enroll.adp 16 Jan 2004 12:47:56 -0000 1.3 @@ -1,10 +1,12 @@ + @page_title;noquote@ + @context;noquote@ -Does enrollment and then displays results based on sim type - \ No newline at end of file +

+ Thank you! +

Index: openacs-4/contrib/packages/simulation/www/simplay/enroll.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/simulation/www/simplay/Attic/enroll.tcl,v diff -u -N -r1.2 -r1.3 --- openacs-4/contrib/packages/simulation/www/simplay/enroll.tcl 12 Jan 2004 15:37:28 -0000 1.2 +++ openacs-4/contrib/packages/simulation/www/simplay/enroll.tcl 16 Jan 2004 12:47:56 -0000 1.3 @@ -6,26 +6,50 @@ workflow_id:integer } +# We need to identify the user auth::require_login -# TODO (.25h): integrate sim title into page title -set page_title "Enrollment complete" -set context [list [list "." "SimPlay"] $page_title] +set user_id [ad_conn user_id] -# TODO (5h): implement the pseudocode in this page +simulation::template::get -workflow_id $workflow_id -array simulation -# verify that the user has permission to enroll: -# simulation is open enrollment OR -# user has invitation for this sim -# if not, display error message "sorry, you don't have permission to enroll in this simulation" and link to openacs page for the simulation's owner or email or something +# Check that the user has permission to enroll +if { [string equal $simulation(enroll_type) "open"] } { + # Open simulation - anybody can enroll so the user is authorized +} else { + # Closed enrollment. The user needs to be invited to enroll + set user_invited_p [db_string user_invited_p { + select count(*) + from sim_party_sim_map + where simulation_id = :workflow_id + and party_id = :user_id + and type = 'invited' + }] -# enroll the user in the simulation -# simulation::template::enroll -workflow_id $workflow_id (should auto-detect user_id) + if { !$user_invited_p } { + acs_user::get -user_id $user_id -array user -# case simulation casting type: -# :auto-casting -# display this message now -# "You have been enrolled in @simulation.name@. This simulation will begin on @begin_date@" -# :group casting -# redirect to cast -# :open casting -# redirect to cast + ad_return_forbidden \ + "Cannot enroll in simulation \"$simulation(pretty_name)\"" \ + "
+ We are sorry, but simulation \"$simulation(pretty_name)\" is not open to enrollment and you are not invited to join the simulation so you cannot enroll at this time. +
" + ad_script_abort + } +} + +# The user is allowed to enroll, so enroll him +set simulation_edit(enrolled) $user_id +simulation::template::edit -workflow_id $workflow_id -array simulation_edit + +# If there are casting decisions open to the user, redirect to the casting page (casting_type group or open) +if { [string equal $simulation(casting_type) "auto"] } { + # Auto casting + # The user will be automatically cast right before the simulation starts +} else { + # Open or group casting, redirect to casting page + ad_returnredirect [export_vars -base cast { workflow_id }] + ad_script_abort +} + +set page_title "You have been enrolled in simulation \"$simulation(pretty_name)\"" +set context [list [list "." "SimPlay"] $page_title] 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 -N -r1.50 -r1.51 --- openacs-4/packages/simulation/tcl/template-procs.tcl 15 Jan 2004 16:09:51 -0000 1.50 +++ openacs-4/packages/simulation/tcl/template-procs.tcl 16 Jan 2004 12:47:55 -0000 1.51 @@ -691,11 +691,13 @@ {-workflow_id:required} } { Takes a mapped simulation template and converts it into a cast simulation - with simulation cases. This procedure expects to be called after enrollment is complete. + with simulation cases. This procedure expects to be called right before the simulation starts. @author Peter Marklund } { - # TODO (8h): also handle auto-casting when casting_type is not auto, but not all users self-cast + # TODO (8h): also handle casting when casting_type is not auto, but not all users self-cast + # TODO (3h): handle casting when casting_type is auto, and some users have enrolled, either through + # invitation or because enroll_type is open. simulation::template::role_party_mappings \ -workflow_id $workflow_id \ 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 -N -r1.1 -r1.2 --- openacs-4/packages/simulation/www/simplay/cast.tcl 8 Jan 2004 14:27:56 -0000 1.1 +++ openacs-4/packages/simulation/www/simplay/cast.tcl 16 Jan 2004 12:47:56 -0000 1.2 @@ -1,9 +1,11 @@ ad_page_contract { This page allows users to choose which group to join. It is only relevant for simulations with casting type of group. } { - {case_id:integer ""} + {workflow_id:integer ""} } +# TODO: check that user is enrolled and that casting_type is not auto_cast + set title "Join a Case in Simulation SIMNAME" set context [list $title] set user_id [ad_conn user_id] Index: openacs-4/packages/simulation/www/simplay/enroll.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/simulation/www/simplay/enroll.adp,v diff -u -N -r1.2 -r1.3 --- openacs-4/packages/simulation/www/simplay/enroll.adp 12 Jan 2004 09:23:10 -0000 1.2 +++ openacs-4/packages/simulation/www/simplay/enroll.adp 16 Jan 2004 12:47:56 -0000 1.3 @@ -1,10 +1,12 @@ + @page_title;noquote@ + @context;noquote@ -Does enrollment and then displays results based on sim type - \ No newline at end of file +

+ Thank you! +

Index: openacs-4/packages/simulation/www/simplay/enroll.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/simulation/www/simplay/enroll.tcl,v diff -u -N -r1.2 -r1.3 --- openacs-4/packages/simulation/www/simplay/enroll.tcl 12 Jan 2004 15:37:28 -0000 1.2 +++ openacs-4/packages/simulation/www/simplay/enroll.tcl 16 Jan 2004 12:47:56 -0000 1.3 @@ -6,26 +6,50 @@ workflow_id:integer } +# We need to identify the user auth::require_login -# TODO (.25h): integrate sim title into page title -set page_title "Enrollment complete" -set context [list [list "." "SimPlay"] $page_title] +set user_id [ad_conn user_id] -# TODO (5h): implement the pseudocode in this page +simulation::template::get -workflow_id $workflow_id -array simulation -# verify that the user has permission to enroll: -# simulation is open enrollment OR -# user has invitation for this sim -# if not, display error message "sorry, you don't have permission to enroll in this simulation" and link to openacs page for the simulation's owner or email or something +# Check that the user has permission to enroll +if { [string equal $simulation(enroll_type) "open"] } { + # Open simulation - anybody can enroll so the user is authorized +} else { + # Closed enrollment. The user needs to be invited to enroll + set user_invited_p [db_string user_invited_p { + select count(*) + from sim_party_sim_map + where simulation_id = :workflow_id + and party_id = :user_id + and type = 'invited' + }] -# enroll the user in the simulation -# simulation::template::enroll -workflow_id $workflow_id (should auto-detect user_id) + if { !$user_invited_p } { + acs_user::get -user_id $user_id -array user -# case simulation casting type: -# :auto-casting -# display this message now -# "You have been enrolled in @simulation.name@. This simulation will begin on @begin_date@" -# :group casting -# redirect to cast -# :open casting -# redirect to cast + ad_return_forbidden \ + "Cannot enroll in simulation \"$simulation(pretty_name)\"" \ + "
+ We are sorry, but simulation \"$simulation(pretty_name)\" is not open to enrollment and you are not invited to join the simulation so you cannot enroll at this time. +
" + ad_script_abort + } +} + +# The user is allowed to enroll, so enroll him +set simulation_edit(enrolled) $user_id +simulation::template::edit -workflow_id $workflow_id -array simulation_edit + +# If there are casting decisions open to the user, redirect to the casting page (casting_type group or open) +if { [string equal $simulation(casting_type) "auto"] } { + # Auto casting + # The user will be automatically cast right before the simulation starts +} else { + # Open or group casting, redirect to casting page + ad_returnredirect [export_vars -base cast { workflow_id }] + ad_script_abort +} + +set page_title "You have been enrolled in simulation \"$simulation(pretty_name)\"" +set context [list [list "." "SimPlay"] $page_title]