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.51 -r1.52
--- openacs-4/contrib/packages/simulation/tcl/template-procs.tcl 16 Jan 2004 12:47:55 -0000 1.51
+++ openacs-4/contrib/packages/simulation/tcl/template-procs.tcl 16 Jan 2004 17:31:45 -0000 1.52
@@ -1107,3 +1107,45 @@
}]
return [expr !$exists_p]
}
+
+ad_proc -public simulation::template::user_enrolled_p {
+ {-workflow_id:required}
+ {-user_id ""}
+} {
+ Return 1 if the user is enrolled in the given simulation and 0 otherwise.
+
+ @author Peter Marklund
+} {
+ if { [empty_string_p $user_id] } {
+ set user_id [ad_conn user_id]
+ }
+
+ return [db_string user_enrolled_p {
+ select count(*)
+ from sim_party_sim_map
+ where simulation_id = :workflow_id
+ and party_id = :user_id
+ and type = 'enrolled'
+ }]
+}
+
+ad_proc -public simulation::template::user_invited_p {
+ {-workflow_id:required}
+ {-user_id ""}
+} {
+ Return 1 if the user is invited in the given simulation and 0 otherwise.
+
+ @author Peter Marklund
+} {
+ if { [empty_string_p $user_id] } {
+ set user_id [ad_conn user_id]
+ }
+
+ return [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'
+ }]
+}
Index: openacs-4/contrib/packages/simulation/www/map-master.adp
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/simulation/www/Attic/map-master.adp,v
diff -u -r1.6 -r1.7
--- openacs-4/contrib/packages/simulation/www/map-master.adp 17 Dec 2003 19:03:10 -0000 1.6
+++ openacs-4/contrib/packages/simulation/www/map-master.adp 16 Jan 2004 17:31:45 -0000 1.7
@@ -16,4 +16,3 @@
-
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.4 -r1.5
--- openacs-4/contrib/packages/simulation/www/simplay/case-admin.tcl 15 Jan 2004 13:19:18 -0000 1.4
+++ openacs-4/contrib/packages/simulation/www/simplay/case-admin.tcl 16 Jan 2004 17:31:45 -0000 1.5
@@ -44,13 +44,6 @@
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 \
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.2 -r1.3
--- openacs-4/contrib/packages/simulation/www/simplay/cast.adp 12 Jan 2004 09:23:10 -0000 1.2
+++ openacs-4/contrib/packages/simulation/www/simplay/cast.adp 16 Jan 2004 17:31:45 -0000 1.3
@@ -1,11 +1,20 @@
Select a case (if casting type=group, then say, "and role") to join, or create a new case for yourself. If you do not select a case to join, you will be automatically
- assigned a case (... and role)
- when the simulation begins.
+
+ Select which case
+Mockup below: +
+
@@ -96,4 +105,4 @@
Show new text at the bottom: "You are participating in this simulation
as a player in case #X. The simulation will start XXX."
If casting type is group instead of open, do not display or group -by the role column. \ No newline at end of file +by the role column. 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.2 -r1.3 --- openacs-4/contrib/packages/simulation/www/simplay/cast.tcl 16 Jan 2004 12:47:56 -0000 1.2 +++ openacs-4/contrib/packages/simulation/www/simplay/cast.tcl 16 Jan 2004 17:31:45 -0000 1.3 @@ -4,10 +4,54 @@ {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] +auth::require_login 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/ +simulation::template::get -workflow_id $workflow_id -array simulation + +set page_title "Join a Case in Simulation SIMNAME" +set context [list [list "." "SimPlay"] $page_title] + +set enrolled_p [simulation::template::user_enrolled_p -workflow_id $workflow_id] +if { !$enrolled_p } { + ad_return_forbidden \ + "Not enrolled in simulation \"$simulation(pretty_name)\"" \ + " + We are sorry, but since you are not enrolled in simulation \"$simulation(pretty_name)\" you can not choose case or role in it. +" + ad_script_abort +} + +if { [string equal $simulation(casting_type) "auto"] } { + ad_return_forbidden \ + "You will be automatically cast in \"$simulation(pretty_name)\"" \ + " +The simulation \"$simulation(pretty_name)\" is configured to use automatic casting. This means that a simulation case and simulation role will be chosen +automatically for you right before the simulation starts. You will be notified by email. + +" + ad_script_abort +} + +template::list::create \ + -name roles \ + -multirow roles \ + -no_data "There are no cases in this simulation yet" \ + -elements { + case_pretty { + label "Case" + } + } + +db_multirow -extend { join_url } roles select_case_info { + select sc.label as case_pretty + from workflow_cases wc, + sim_cases sc + where wc.case_id = sc.sim_case_id + and wc.workflow_id = :workflow_id +} { + set join_url [export_vars -base cast-join { case_id role_id }] +} 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 -r1.3 -r1.4 --- openacs-4/contrib/packages/simulation/www/simplay/enroll.tcl 16 Jan 2004 12:47:56 -0000 1.3 +++ openacs-4/contrib/packages/simulation/www/simplay/enroll.tcl 16 Jan 2004 17:31:45 -0000 1.4 @@ -17,13 +17,7 @@ # 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' - }] + set user_invited_p [simulation::template::user_invited_p -workflow_id $workflow_id] if { !$user_invited_p } { acs_user::get -user_id $user_id -array user 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.51 -r1.52 --- openacs-4/packages/simulation/tcl/template-procs.tcl 16 Jan 2004 12:47:55 -0000 1.51 +++ openacs-4/packages/simulation/tcl/template-procs.tcl 16 Jan 2004 17:31:45 -0000 1.52 @@ -1107,3 +1107,45 @@ }] return [expr !$exists_p] } + +ad_proc -public simulation::template::user_enrolled_p { + {-workflow_id:required} + {-user_id ""} +} { + Return 1 if the user is enrolled in the given simulation and 0 otherwise. + + @author Peter Marklund +} { + if { [empty_string_p $user_id] } { + set user_id [ad_conn user_id] + } + + return [db_string user_enrolled_p { + select count(*) + from sim_party_sim_map + where simulation_id = :workflow_id + and party_id = :user_id + and type = 'enrolled' + }] +} + +ad_proc -public simulation::template::user_invited_p { + {-workflow_id:required} + {-user_id ""} +} { + Return 1 if the user is invited in the given simulation and 0 otherwise. + + @author Peter Marklund +} { + if { [empty_string_p $user_id] } { + set user_id [ad_conn user_id] + } + + return [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' + }] +} Index: openacs-4/packages/simulation/www/map-master.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/simulation/www/map-master.adp,v diff -u -r1.6 -r1.7 --- openacs-4/packages/simulation/www/map-master.adp 17 Dec 2003 19:03:10 -0000 1.6 +++ openacs-4/packages/simulation/www/map-master.adp 16 Jan 2004 17:31:45 -0000 1.7 @@ -16,4 +16,3 @@ |
---|
Select a case (if casting type=group, then say, "and role") to join, or create a new case for yourself. If you do not select a case to join, you will be automatically - assigned a case (... and role) - when the simulation begins. +
+ Select which case
+Mockup below: +
+
@@ -96,4 +105,4 @@
Show new text at the bottom: "You are participating in this simulation
as a player in case #X. The simulation will start XXX."
If casting type is group instead of open, do not display or group -by the role column. \ No newline at end of file +by the role column. 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.2 -r1.3 --- openacs-4/packages/simulation/www/simplay/cast.tcl 16 Jan 2004 12:47:56 -0000 1.2 +++ openacs-4/packages/simulation/www/simplay/cast.tcl 16 Jan 2004 17:31:45 -0000 1.3 @@ -4,10 +4,54 @@ {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] +auth::require_login 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/ +simulation::template::get -workflow_id $workflow_id -array simulation + +set page_title "Join a Case in Simulation SIMNAME" +set context [list [list "." "SimPlay"] $page_title] + +set enrolled_p [simulation::template::user_enrolled_p -workflow_id $workflow_id] +if { !$enrolled_p } { + ad_return_forbidden \ + "Not enrolled in simulation \"$simulation(pretty_name)\"" \ + " + We are sorry, but since you are not enrolled in simulation \"$simulation(pretty_name)\" you can not choose case or role in it. +" + ad_script_abort +} + +if { [string equal $simulation(casting_type) "auto"] } { + ad_return_forbidden \ + "You will be automatically cast in \"$simulation(pretty_name)\"" \ + " +The simulation \"$simulation(pretty_name)\" is configured to use automatic casting. This means that a simulation case and simulation role will be chosen +automatically for you right before the simulation starts. You will be notified by email. + +" + ad_script_abort +} + +template::list::create \ + -name roles \ + -multirow roles \ + -no_data "There are no cases in this simulation yet" \ + -elements { + case_pretty { + label "Case" + } + } + +db_multirow -extend { join_url } roles select_case_info { + select sc.label as case_pretty + from workflow_cases wc, + sim_cases sc + where wc.case_id = sc.sim_case_id + and wc.workflow_id = :workflow_id +} { + set join_url [export_vars -base cast-join { case_id role_id }] +} 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 -r1.3 -r1.4 --- openacs-4/packages/simulation/www/simplay/enroll.tcl 16 Jan 2004 12:47:56 -0000 1.3 +++ openacs-4/packages/simulation/www/simplay/enroll.tcl 16 Jan 2004 17:31:45 -0000 1.4 @@ -17,13 +17,7 @@ # 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' - }] + set user_invited_p [simulation::template::user_invited_p -workflow_id $workflow_id] if { !$user_invited_p } { acs_user::get -user_id $user_id -array user |
---|