Option 1: use a custom tarball which includes those modules. In
that case, the custom tarball will have a file install.xml in
its root directory, so that installing OpenACS normally will
produce a simulation server.
Notes on custom tarball creation:
Index: openacs-4/contrib/packages/simulation/www/doc/permissions.html
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/simulation/www/doc/Attic/permissions.html,v
diff -u -r1.2 -r1.3
--- openacs-4/contrib/packages/simulation/www/doc/permissions.html 26 Nov 2003 16:44:50 -0000 1.2
+++ openacs-4/contrib/packages/simulation/www/doc/permissions.html 28 Nov 2003 16:55:52 -0000 1.3
@@ -1 +1,2 @@
-Permissions View comments on this page at openacs.org
+
+Permissions View comments on this page at openacs.org
Index: openacs-4/contrib/packages/simulation/www/doc/xml/Makefile
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/simulation/www/doc/xml/Attic/Makefile,v
diff -u -r1.4 -r1.5
--- openacs-4/contrib/packages/simulation/www/doc/xml/Makefile 26 Nov 2003 16:44:50 -0000 1.4
+++ openacs-4/contrib/packages/simulation/www/doc/xml/Makefile 28 Nov 2003 16:55:52 -0000 1.5
@@ -18,4 +18,4 @@
all:
- cd .. ; $(XSLTPROC) --nonet --novalid --xinclude ../../../../packages/acs-core-docs/www/xml/openacs.xsl xml/index.xml
\ No newline at end of file
+ cd .. ; $(XSLTPROC) --nonet --novalid --xinclude ../../../acs-core-docs/www/xml/openacs.xsl xml/index.xml
\ No newline at end of file
Index: openacs-4/contrib/packages/simulation/www/siminst/cast-actors.adp
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/simulation/www/siminst/Attic/cast-actors.adp,v
diff -u -r1.1 -r1.2
--- openacs-4/contrib/packages/simulation/www/siminst/cast-actors.adp 27 Nov 2003 16:43:36 -0000 1.1
+++ openacs-4/contrib/packages/simulation/www/siminst/cast-actors.adp 28 Nov 2003 16:55:52 -0000 1.2
@@ -2,17 +2,17 @@
@page_title;noquote@
@context;noquote@
+
+
+
+TODO: get desired layout, see below:
+
+
(this is just a mockup)
-Role Character Actor(s) In groups of
-Plaintiff
-
- Bob
- Jianing (Lawfirm X)
- Larry (Lawfirm Y)
-
-
+Role Actor(s) In groups of
+Plaintiff
Automatic Agent
Student
@@ -24,13 +24,7 @@
-Defendent
-
- Bob
- Jianing (Lawfirm X)
- Larry (Lawfirm Y)
-
-
+Defendent
Automatic Agent
Student
@@ -41,13 +35,7 @@
-Judge
-
- Bob
- Jianing (Lawfirm X)
- Larry (Lawfirm Y)
-
-
+Judge
Student
TA
Index: openacs-4/contrib/packages/simulation/www/siminst/cast-actors.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/simulation/www/siminst/Attic/cast-actors.tcl,v
diff -u -r1.1 -r1.2
--- openacs-4/contrib/packages/simulation/www/siminst/cast-actors.tcl 27 Nov 2003 16:43:36 -0000 1.1
+++ openacs-4/contrib/packages/simulation/www/siminst/cast-actors.tcl 28 Nov 2003 16:55:52 -0000 1.2
@@ -10,3 +10,45 @@
set page_title "Choose actors"
set context [list [list "." "SimInst"] $page_title]
+
+# Loop over all workflow roles and append the actor and "in groups of" widgets to the form
+set form {
+ {pretty_name:text
+ {label "Simulation name"}
+ {html {size 50}}
+ }
+}
+
+foreach role_id [workflow::get_roles -workflow_id $workflow_id] {
+ set role_pretty_name [workflow::role::get_element -role_id $role_id -element pretty_name]
+ lappend form [list actor_${role_id}:text(select) \
+ [list label $role_pretty_name] \
+ [list options {{Student student} {Professor professor}}]
+ ]
+ lappend form [list group_${role_id}:integer [list label "In groups of"] [list value 1]]
+}
+
+ad_form \
+ -name actors \
+ -export { workflow_id } \
+ -form $form \
+ -on_submit {
+
+ # Put the actor and grouping selections on array list formats
+ set actors_list [list]
+ set groups_list [list]
+ foreach role_id [workflow::get_roles -workflow_id $workflow_id] {
+ lappend actors_list $role_id [set actor_$role_id]
+ lappend groups_list $role_id [set group_$role_id]
+ }
+
+ simulation::cast \
+ -workflow_id $workflow_id \
+ -pretty_name $pretty_name \
+ -actors $actors_list \
+ -groups $groups_list
+
+ # Proceed to the instantiation complete page
+ ad_returnredirect [export_vars -base cast-complete {workflow_id}]
+ ad_script_abort
+ }
\ No newline at end of file
Index: openacs-4/contrib/packages/simulation/www/siminst/cast-edit.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/simulation/www/siminst/Attic/cast-edit.tcl,v
diff -u -r1.1 -r1.2
--- openacs-4/contrib/packages/simulation/www/siminst/cast-edit.tcl 27 Nov 2003 16:43:36 -0000 1.1
+++ openacs-4/contrib/packages/simulation/www/siminst/cast-edit.tcl 28 Nov 2003 16:55:52 -0000 1.2
@@ -5,37 +5,79 @@
}
set page_title "Create/edit simulation"
-set context [list $page_title]
+set context [list [list "." "SimInst"] $page_title]
set package_id [ad_conn package_id]
+# TODO: only one aplication group per package - need different solution
+set group_id [application_group::group_id_from_package_id -package_id $package_id]
+set group_name [group::get_element -group_id $group_id -element group_name]
+set group_options [list [list $group_name $group_id]]
+
+# TODO: Possible future casting_type options:
+# choose_role
+# choose_role_and_instance
+
+# TODO: provide more sensible default dates?
+# Notification send could be start date minus some parameter
+set in_a_month_date [clock format [expr [clock seconds] + 3600*24*31] -format "%Y %m %d"]
+set in_two_months_date [clock format [expr [clock seconds] + 2*3600*24*31] -format "%Y %m %d"]
+set in_two_and_a_half_months_date [clock format [expr [clock seconds] + 3*3600*24*31 - 3600*24*15] -format "%Y %m %d"]
+set in_three_months_date [clock format [expr [clock seconds] + 3*3600*24*31] -format "%Y %m %d"]
+set in_four_months_date [clock format [expr [clock seconds] + 4*3600*24*31] -format "%Y %m %d"]
ad_form -export { workflow_id } -name simulation \
-form {
- {enroll_start
+ {enroll_start:date,optional
{label "Enrollment start date"}
+ {value $in_a_month_date}
}
- {enroll_end
+ {enroll_end:date,optional
{label "Enrollment end date"}
+ {value $in_two_months_date}
}
- {notification_date
+ {notification_date:date
{label "Date to send start notification"}
+ {value $in_two_and_a_half_months_date}
}
- {case_start
+ {case_start:date
{label "Simulation start date"}
+ {value $in_three_months_date}
}
- {case_end
+ {case_end:date
{label "Simulation end date"}
+ {value $in_four_months_date}
}
- {enroll_type
- {label "Open Enrollment?"}
+ {enroll_type:text(radio)
+ {label "Enrollment type"}
+ {options {{Closed closed}}}
+ {value closed}
}
- {casting_type
- {label "Open casting?"}
+ {casting_type:text(radio)
+ {label "Casting type"}
+ {options {{Automatic automatic}}}
+ {value automatic}
}
- {tools
- {label "tools for enrollment and casting. (upload of user list csv, ... others?) TODO..."}
+ {user_group:integer(select)
+ {label "User Group"}
+ {options $group_options}
}
} -on_submit {
- # TODO (clone the template and create a new simulation record)
- ad_returnredirect simulation-casting
+ # Convert dates to ANSI format
+ foreach var_name {enroll_start enroll_end notification_date case_start case_end} {
+ set ${var_name}_ansi "[lindex [set $var_name] 0]-[lindex [set $var_name] 1]-[lindex [set $var_name] 2]"
+ }
+
+ simulation::template::instantiate_edit \
+ -workflow_id $workflow_id \
+ -enroll_start $enroll_start_ansi \
+ -enroll_end $enroll_end_ansi \
+ -notification_date $notification_date_ansi \
+ -case_start $case_start_ansi \
+ -case_end $case_end_ansi \
+ -enroll_type $enroll_type \
+ -casting_type $casting_type \
+ -parties $user_group
+
+ # Proceed to choosing actors
+ ad_returnredirect [export_vars -base cast-actors { workflow_id }]
ad_script_abort
}
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.6 -r1.7
--- openacs-4/contrib/packages/simulation/www/siminst/index.adp 27 Nov 2003 16:43:36 -0000 1.6
+++ openacs-4/contrib/packages/simulation/www/siminst/index.adp 28 Nov 2003 16:55:52 -0000 1.7
@@ -5,12 +5,14 @@
Templates Ready for Mapping
-
+
Mapped Templates
-TODO...
+
+
+
Current Simulations
@@ -20,7 +22,7 @@
Help
- The process of creating a simulation form a simulation template is referred to as instantiation. The
+ The process of creating a simulation form a simulation template is referred to as instantiation . The
instantiation process is divided into two steps:
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.3 -r1.4
--- openacs-4/contrib/packages/simulation/www/siminst/index.tcl 27 Nov 2003 16:43:36 -0000 1.3
+++ openacs-4/contrib/packages/simulation/www/siminst/index.tcl 28 Nov 2003 16:55:52 -0000 1.4
@@ -6,65 +6,112 @@
set context [list $page_title]
set package_id [ad_conn package_id]
-######################################################################
-#
-# avail_templates
-#
-# A list of templates that can be instantiated
-#
-######################################################################
-
#---------------------------------------------------------------------
-# avail_templates list
+# Templates ready for mapping
#---------------------------------------------------------------------
-set elements {
- pretty_name {
- label "Template"
- orderby upper(w.pretty_name)
- }
- suggested_duration {
- label "Suggested Duration"
- orderby suggested_duration
- }
- number_of_roles {
- label "Roles"
- orderby number_of_roles
- }
- min_number_of_human_roles {
- label "Min \# of players"
- orderby min_number_of_human_roles
- }
- instantiate {
- link_url_col inst_url
- display_template {
- Start mapping process
+# TODO: new columns:
+# number_of_roles
+# number_of_roles_not_cast
+# number_of_tasks
+# number_of_tasks_undescribed
+# number_of_prop_slots
+# number_of_prop_unfilled
+# TODO:
+# only show casting link if all the mapping parts are complete
+template::list::create \
+ -name ready_templates \
+ -multirow ready_templates \
+ -no_data "No templates are ready for mapping" \
+ -elements {
+ pretty_name {
+ label "Template"
+ orderby upper(w.pretty_name)
}
+ suggested_duration {
+ label "Suggested Duration"
+ orderby suggested_duration
+ }
+ number_of_roles {
+ label "Roles"
+ orderby number_of_roles
+ }
+ min_number_of_human_roles {
+ label "Min \# of players"
+ orderby min_number_of_human_roles
+ }
+ map {
+ link_url_col map_url
+ display_template {
+ Begin mapping
+ }
+ }
}
-}
-template::list::create \
- -name avail_templates \
- -multirow avail_templates \
- -no_data "No simulation templates available for instantiation." \
- -elements $elements
-
-#---------------------------------------------------------------------
-# avail_templates multirow
-#---------------------------------------------------------------------
-
-# TODO: number_of_roles, min_number_of_human_roles
-db_multirow -extend {inst_url} avail_templates select_avail_templates "
+# TODO: min_number_of_human_roles should take agents into account
+db_multirow -extend {map_url} ready_templates select_ready_templates {
select workflow_id,
suggested_duration,
pretty_name,
- (select 1) as number_of_roles,
- (select 1) as min_number_of_human_roles
+ (select count(*)
+ from workflow_roles
+ where workflow_id = w.workflow_id) as number_of_roles,
+ (select count(*)
+ from workflow_roles
+ where workflow_id = w.workflow_id) as min_number_of_human_roles
from sim_simulations ss,
workflows w
where ss.simulation_id = w.workflow_id
and w.object_id = :package_id
and ready_p = 't'
-" {
- set inst_url [export_vars -base "map-characters" { workflow_id }]
+} {
+ set map_url [export_vars -base "map-create" { workflow_id }]
+
+ if { [empty_string_p $suggested_duration] } {
+ set suggested_duration "none specified"
+ }
}
+
+#---------------------------------------------------------------------
+# Mapped templates
+#---------------------------------------------------------------------
+
+template::list::create \
+ -name mapped_templates \
+ -multirow mapped_templates \
+ -no_data "No templates have been mapped" \
+ -elements {
+ pretty_name {
+ label "Template"
+ orderby upper(w.pretty_name)
+ }
+ cast {
+ link_url_col cast_url
+ display_template {
+ Begin casting
+ }
+ }
+ }
+
+# TODO: update the mapped_p subquery for agents
+# Simpler solution:
+# type column with possible values:
+# incomplete_template
+# ready_template
+# mapped_template
+# simulation
+# and not exists (select 1
+# from sim_roles sr,
+# workflow_roles wr
+# where sr.role_id = wr.role_id
+# and sr.character_id is null
+# and wr.workflow_id = w.workflow_id
+# )
+db_multirow -extend { cast_url } mapped_templates select_mapped_templates {
+ select w.workflow_id,
+ w.pretty_name
+ from workflows w
+ where w.object_id = :package_id
+} {
+ set cast_url [export_vars -base "cast-edit" { workflow_id }]
+}
Index: openacs-4/contrib/packages/simulation/www/siminst/map-characters.adp
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/simulation/www/siminst/Attic/map-characters.adp,v
diff -u -r1.1 -r1.2
--- openacs-4/contrib/packages/simulation/www/siminst/map-characters.adp 27 Nov 2003 16:43:36 -0000 1.1
+++ openacs-4/contrib/packages/simulation/www/siminst/map-characters.adp 28 Nov 2003 16:55:52 -0000 1.2
@@ -2,64 +2,45 @@
@page_title;noquote@
@context;noquote@
-
-(this is just a mockup)
-
-
+
+
- Map to tasks
+TODO: get desired layout, see below:
+
+
+ (this is just a mockup)
+
+
+ Role
+ Character
+
+
+ Plaintiff
+
+
+ Bob
+ Jianing (Lawfirm X)
+ Larry (Lawfirm Y)
+
+
+
+ Defendent
+
+ Bob
+ Jianing (Lawfirm X)
+ Larry (Lawfirm Y)
+
+
+
+ Judge
+
+ Bob
+ Jianing (Lawfirm X)
+ Larry (Lawfirm Y)
+
+
+
+
+
Index: openacs-4/contrib/packages/simulation/www/siminst/map-characters.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/simulation/www/siminst/Attic/map-characters.tcl,v
diff -u -r1.2 -r1.3
--- openacs-4/contrib/packages/simulation/www/siminst/map-characters.tcl 28 Nov 2003 09:32:26 -0000 1.2
+++ openacs-4/contrib/packages/simulation/www/siminst/map-characters.tcl 28 Nov 2003 16:55:52 -0000 1.3
@@ -12,13 +12,35 @@
set context [list [list "." "SimInst"] $page_title]
# Loop over all workflow roles and add a character select widget for each
-# set form [list]
-# set character_options [simulation::get_object_options -content_type sim_character]
-# foreach role_id [workflow::get_roles -workflow_id $workflow_id] {
-# lappend form [list role_${role_id}:text(select) \
-# [list label [workflow::get_element -role_id $role_id -element pretty_name]] \
-# [list options $character_options]
-# ]
-# }
+set form [list]
+set character_options [simulation::get_object_options -content_type sim_character]
+foreach role_id [workflow::get_roles -workflow_id $workflow_id] {
+ set role_short_name [workflow::role::get_element -role_id $role_id -element short_name]
+ set role_pretty_name [workflow::role::get_element -role_id $role_id -element pretty_name]
+ lappend form [list role_${role_short_name}:text(select) \
+ [list label $role_pretty_name] \
+ [list options $character_options]
+ ]
+}
-# ad_form -name characters -form $form
+ad_form \
+ -name characters \
+ -export { workflow_id } \
+ -form $form \
+ -on_submit {
+
+ db_transaction {
+ # Create a new template that is clone of the existing one
+ set workflow_id [simulation::template::clone -workflow_id $workflow_id]
+
+ # Map each role to chosen character
+ foreach role_id [workflow::get_roles -workflow_id $workflow_id] {
+ set role_short_name [workflow::role::get_element -role_id $role_id -element short_name]
+ simulation::role::edit -role_id $role_id -character_id [set role_${role_short_name}]
+ }
+ }
+
+ # Proceed to the task page
+ ad_returnredirect [export_vars -base map-tasks {workflow_id}]
+ ad_script_abort
+ }
Index: openacs-4/contrib/packages/simulation/www/siminst/map-create.adp
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/simulation/www/siminst/Attic/map-create.adp,v
diff -u
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/contrib/packages/simulation/www/siminst/map-create.adp 28 Nov 2003 16:55:52 -0000 1.1
@@ -0,0 +1,6 @@
+
+ @page_title;noquote@
+ @context;noquote@
+ template.pretty_name
+
+
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
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/contrib/packages/simulation/www/siminst/map-create.tcl 28 Nov 2003 16:55:52 -0000 1.1
@@ -0,0 +1,35 @@
+ad_page_contract {
+ A page that creates a mapped template by cloning a ready template.
+ This is the first step in the mapping process.
+
+ @author Peter Marklund
+} {
+ workflow_id:integer
+}
+
+set page_title "Create mapped template"
+set context [list [list "." "SimInst"] $page_title]
+
+set old_name [workflow::get_element -workflow_id $workflow_id -element pretty_name]
+set name_default "$old_name Mapped"
+
+ad_form \
+ -name template \
+ -export { workflow_id } \
+ -form {
+ {pretty_name:text
+ {label "Template name"}
+ {value $name_default}
+ {html {size 50}}
+ }
+ } -on_submit {
+ # Create a new template that is clone of the existing one
+ set workflow_id [simulation::template::clone \
+ -workflow_id $workflow_id \
+ -pretty_name $pretty_name]
+
+ # Proceed to the task page
+ ad_returnredirect [export_vars -base map-tasks {workflow_id}]
+ ad_script_abort
+
+ }
Index: openacs-4/contrib/packages/simulation/www/siminst/map-tasks.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/simulation/www/siminst/Attic/map-tasks.tcl,v
diff -u -r1.1 -r1.2
--- openacs-4/contrib/packages/simulation/www/siminst/map-tasks.tcl 27 Nov 2003 16:43:36 -0000 1.1
+++ openacs-4/contrib/packages/simulation/www/siminst/map-tasks.tcl 28 Nov 2003 16:55:52 -0000 1.2
@@ -8,3 +8,4 @@
set page_title "Map to Tasks"
set context [list [list "." "SimInst" ] $page_title]
+
Index: openacs-4/packages/simulation/tcl/apm-callback-procs.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/simulation/tcl/apm-callback-procs.tcl,v
diff -u -r1.7 -r1.8
--- openacs-4/packages/simulation/tcl/apm-callback-procs.tcl 10 Nov 2003 16:56:56 -0000 1.7
+++ openacs-4/packages/simulation/tcl/apm-callback-procs.tcl 28 Nov 2003 16:55:52 -0000 1.8
@@ -19,7 +19,7 @@
ad_proc -private simulation::apm::after_instantiate {
{-package_id:required}
} {
- Create the package root folder.
+ Create data associated with a simulation package instance.
} {
set instance_name [apm_instance_name_from_id $package_id]
@@ -30,4 +30,20 @@
-package_id $package_id \
-context_id $package_id \
-content_types { sim_character sim_prop sim_location sim_stylesheet image }]
+
+ application_group::new \
+ -group_name "Simulation Test Class" \
+ -package_id $package_id
}
+
+ad_proc -private simulation::apm::before_uninstantiate {
+ {-package_id:required}
+} {
+ Tear down data associated with a package instance.
+} {
+ set folder_id [bcms::folder::get_id_by_package_id -parent_id 0]
+ bcms::folder::delete_folder -folder_id $folder_id
+
+ set group_id [application_group::group_id_from_package_id -package_id $package_id]
+ group::delete $group_id
+}
Index: openacs-4/packages/simulation/tcl/object-procs.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/simulation/tcl/object-procs.tcl,v
diff -u -r1.5 -r1.6
--- openacs-4/packages/simulation/tcl/object-procs.tcl 18 Nov 2003 13:31:32 -0000 1.5
+++ openacs-4/packages/simulation/tcl/object-procs.tcl 28 Nov 2003 16:55:52 -0000 1.6
@@ -9,6 +9,12 @@
namespace eval simulation::object {}
namespace eval simulation::object::xml {}
+###############################
+#
+# simulation::object namespace
+#
+###############################
+
ad_proc -private simulation::object::url {
{-package_id ""}
{-name:required}
@@ -43,6 +49,12 @@
return "${package_url}object-content/${name}"
}
+###############################
+#
+# simulation::object::xml namespace
+#
+###############################
+
ad_proc -private simulation::object::xml::file_sweeper {} {
Loop over all simulation package instances and re-generate
XML map files for them.
Index: openacs-4/packages/simulation/tcl/role-procs.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/simulation/tcl/Attic/role-procs.tcl,v
diff -u -r1.4 -r1.5
--- openacs-4/packages/simulation/tcl/role-procs.tcl 18 Nov 2003 12:19:39 -0000 1.4
+++ openacs-4/packages/simulation/tcl/role-procs.tcl 28 Nov 2003 16:55:52 -0000 1.5
@@ -20,17 +20,39 @@
@author Peter Marklund
} {
db_transaction {
- # create the role
+ set role_short_name [util_text_to_url -replacement "_" $role_short_name]
set role_id [workflow::role::new \
-workflow_id $template_id \
-short_name $role_short_name \
-pretty_name $role_pretty_name]
+ db_dml insert_sim_role {
+ insert into sim_roles (role_id) values (:role_id)
+ }
}
}
ad_proc -public simulation::role::delete {
{-role_id:required}
} {
- workflow::role::delete -role_id $role_id
+ db_transaction {
+ workflow::role::delete -role_id $role_id
+
+ db_dml delete_sim_role {
+ delete from sim_roles where role_id = :role_id
+ }
+ }
}
+
+ad_proc -public simulation::role::edit {
+ {-role_id:required}
+ {-character_id:required}
+} {
+ Edit a simulation role.
+} {
+ db_dml edit_sim_role {
+ update sim_roles
+ set character_id = :character_id
+ where role_id = :role_id
+ }
+}
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.12 -r1.13
--- openacs-4/packages/simulation/tcl/simulation-procs.tcl 14 Nov 2003 11:40:35 -0000 1.12
+++ openacs-4/packages/simulation/tcl/simulation-procs.tcl 28 Nov 2003 16:55:52 -0000 1.13
@@ -108,6 +108,124 @@
}
}
+ad_proc simulation::get_object_options {
+ {-content_type:required}
+} {
+ Returns a list of cr_revision.title, cr_item.item_id pairs
+ for all cr_items of the given content_type in the root
+ folder of the current package. Suitable for ad_form options for
+ select boxes.
+
+ @return [list [list cr_revision.title1 cr_item.item_id1] [list cr_revision.title2 cr_item.item_id2] ....]
+
+ @author Peter Marklund
+} {
+ set package_id [ad_conn package_id]
+ set parent_id [bcms::folder::get_id_by_package_id -package_id $package_id]
+
+ return [db_list_of_lists character_options {
+ select cr.title,
+ ci.item_id
+ from cr_items ci,
+ cr_revisions cr
+ where ci.live_revision = cr.revision_id
+ and ci.parent_id = :parent_id
+ and ci.content_type = :content_type
+ }]
+}
+
+ad_proc -public simulation::cast {
+ {-workflow_id:required}
+ {-pretty_name:required}
+ {-actors:required}
+ {-groupings:required}
+} {
+ Takes a mapped simulation template and creates a casted simulation
+ with simulation cases. It does this by cloning the simulation
+ template.
+
+ TODO: agent support
+
+ TODO: taking actor type into account
+
+ @param actors An array list with the actors of the simulation. The keys
+ of the list are role_ids and the values ids of the actor to play the role.
+ @param groups An array list with the groupings of the simulation. The keys
+ of the list are role_ids and the values are integers indicaing
+ a number of users to play that role.
+
+ @return workflow_id of the simulation created.
+
+ @author Peter Marklund
+} {
+ array set actors_array $actors
+ array set groupings_array $groupings
+
+ # TODO: make sure this is a proper clone also after mapping (tasks and characters...)
+ set workflow_id [simulation::template::clone \
+ -pretty_name $pretty_name \
+ -workflow_id $workflow_id]
+
+ set user_list [db_list select_users {
+ select member_id
+ from party_approved_member_map
+ where party_id in (select
+ party_id from sim_party_sim_map
+ where simulation_id = :workflow_id
+ )
+ }]
+ set total_n_users [llength $user_list]
+
+ set n_users_per_case 0
+ foreach role_id [array names groupings_array] {
+ set n_users_per_case [expr $n_users_per_case + $groupings_array($role_id)]
+ }
+
+ set mod_n_users [expr $total_n_users % $n_users_per_case]
+ set n_cases [expr ($total_n_users - $mod_n_users) / $n_users_per_case]
+
+
+ if { $mod_n_users == "0" } {
+ # No rest in dividing, the cases add up nicely
+
+ } else {
+ # We are missing mod_n_users to fill up the simulation. Create a new simulation
+ # for those students.
+ set n_cases [expr $n_cases + 1]
+ }
+
+ # Create the cases and for each case assign roles to parties
+ set users_start_index 0
+ for { set case_counter 0 } { $case_counter < $n_cases } { incr case_counter } {
+ # TODO: what should object_id be here?
+ set object_id [ad_conn package_id]
+ set case_id [workflow::case::new \
+ -workflow_id $workflow_id \
+ -object_id $object_id]
+
+ # Assign a group of users to each role in the case
+ set party_array_list [list]
+ foreach role_id [array names actors] {
+ set role_short_name [workflow::role::get_element -role_id $role_id -element short_name]
+
+ set users_end_index [expr $users_start_index + $groupings_array($role_id) - 1]
+
+ set parties_list [lrange $user_list $users_start_index $users_end_index]
+
+ lappend parties_array_list $role_short_name $users_list
+
+ set users_start_index [expr $users_end_index + 1]
+ }
+
+ workflow::case::role::assign \
+ -case_id $case_id \
+ -array $party_array_list \
+ -replace
+ }
+
+ return $workflow_id
+}
+
template_tag relation { params } {
publish::process_tag relation $params
}
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.4 -r1.5
--- openacs-4/packages/simulation/tcl/template-procs.tcl 28 Nov 2003 11:12:39 -0000 1.4
+++ openacs-4/packages/simulation/tcl/template-procs.tcl 28 Nov 2003 16:55:52 -0000 1.5
@@ -26,6 +26,8 @@
set ready_p "f"
}
db_transaction {
+ set short_name [util_text_to_url -replacement "_" $short_name]
+
set workflow_id [workflow::new \
-short_name $short_name \
-pretty_name $pretty_name \
@@ -42,24 +44,40 @@
-short_name "dummy action" \
-pretty_name "dummy action"
- set suggested_duration [string trim $suggested_duration]
- if { [empty_string_p $suggested_duration] } {
- db_dml new_sim {
- insert into sim_simulations
- (simulation_id, ready_p)
- values (:workflow_id, :ready_p)
- }
- } else {
- db_dml new_sim "
- insert into sim_simulations
- (simulation_id, ready_p, suggested_duration)
- values ('$workflow_id', '$ready_p', interval '$suggested_duration')"
- }
+ insert_sim \
+ -workflow_id $workflow_id \
+ -ready_p $ready_p \
+ -suggested_duration $suggested_duration
}
return $workflow_id
}
+ad_proc -private simulation::template::insert_sim {
+ {-workflow_id:required}
+ {-ready_p:required}
+ {-suggested_duration:required}
+} {
+ Internal proc for inserting values into the sim_simulations
+ table that are set prior to a template being mapped.
+
+ @author Peter Marklund
+} {
+ set suggested_duration [string trim $suggested_duration]
+ if { [empty_string_p $suggested_duration] } {
+ db_dml new_sim {
+ insert into sim_simulations
+ (simulation_id, ready_p)
+ values (:workflow_id, :ready_p)
+ }
+ } else {
+ db_dml new_sim "
+ insert into sim_simulations
+ (simulation_id, ready_p, suggested_duration)
+ values ('$workflow_id', '$ready_p', interval '$suggested_duration')"
+ }
+}
+
ad_proc -public simulation::template::edit {
{-workflow_id:required}
{-short_name:required}
@@ -106,6 +124,98 @@
}
}
+ad_proc -public simulation::template::instantiate_edit {
+ {-workflow_id:required}
+ {-enroll_start:required}
+ {-enroll_end:required}
+ {-notification_date:required}
+ {-case_start:required}
+ {-case_end:required}
+ {-enroll_type:required}
+ {-casting_type:required}
+ {-parties:required}
+} {
+ Edit properties of a simulation set during instantiation.
+
+ TODO: merge this proc with ::edit?
+
+ @author Peter Marklund
+} {
+ db_dml update_instantiate_template {
+ update sim_simulations
+ set enroll_start = to_date(:enroll_start, 'YYYY-MM-DD'),
+ enroll_end = to_date(:enroll_end, 'YYYY-MM-DD'),
+ send_start_note_date = to_date(:notification_date, 'YYYY-MM-DD'),
+ case_start = to_date(:case_start, 'YYYY-MM-DD'),
+ case_end = to_date(:case_end, 'YYYY-MM-DD'),
+ enroll_type = :enroll_type,
+ casting_type = :casting_type
+ where simulation_id = :workflow_id
+ }
+
+ # Clear out old mappings first
+ db_dml clear_old_mappings {
+ delete from sim_party_sim_map
+ where simulation_id = :workflow_id
+ }
+
+ foreach party_id $parties {
+ db_dml map_party_to_template {
+ insert into sim_party_sim_map
+ (simulation_id, party_id)
+ values (:workflow_id, :party_id)
+ }
+ }
+}
+ad_proc -public simulation::template::clone {
+ {-workflow_id:required}
+ {-pretty_name:required}
+} {
+ Create a new simulation template which is a clone of the template with
+ given id. The clone will be mapped to the package of the current request.
+
+ @param workflow_id The id of the template that you wish to clone.
+ @param pretty_name The pretty name of the clone you are creating.
+
+ @return The id of the clone.
+
+ @author Peter Marklund
+} {
+ # If we set object_id here and leave short_name unchanged we
+ # get a unique constraint violation
+ set clone_workflow_id [workflow::fsm::clone \
+ -workflow_id $workflow_id]
+
+ # Set names of clones workflow and update the object_id
+ # TODO: create workflow::edit proc
+ set clone_short_name [util_text_to_url -replacement "_" $pretty_name]
+ set object_id [ad_conn package_id]
+ db_dml update_short_name {
+ update workflows
+ set short_name = :clone_short_name,
+ pretty_name = :pretty_name,
+ object_id = :object_id
+ where workflow_id = :clone_workflow_id
+ }
+
+ # Add the role_id:s to the sim_roles table
+ set role_id_list [workflow::get_roles -workflow_id $clone_workflow_id]
+ foreach role_id $role_id_list {
+ db_dml insert_sim_role {
+ insert into sim_roles (role_id) values (:role_id)
+ }
+ }
+
+ # Clone the values in the simulation table
+ get -workflow_id $workflow_id -array workflow
+ insert_sim \
+ -workflow_id $clone_workflow_id \
+ -ready_p $workflow(ready_p) \
+ -suggested_duration $workflow(suggested_duration)
+
+ return $clone_workflow_id
+}
+
ad_proc -public simulation::template::get {
{-workflow_id:required}
{-array:required}
Index: openacs-4/packages/simulation/test/crawl-links.test
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/simulation/test/Attic/crawl-links.test,v
diff -u -r1.2 -r1.3
--- openacs-4/packages/simulation/test/crawl-links.test 19 Nov 2003 10:05:07 -0000 1.2
+++ openacs-4/packages/simulation/test/crawl-links.test 28 Nov 2003 16:55:52 -0000 1.3
@@ -9,7 +9,7 @@
::twt::log_section "Login the site wide admin"
::twt::user::login_site_wide_admin
- ::twt::set_crawler_exclude_links {delete}
+ ::twt::set_crawler_exclude_links {delete remove}
# NOTE: The crawler needs the trailing slash when first invoked
set simulation_uri /simulation/
Index: openacs-4/packages/simulation/test/demo-data-setup.test
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/simulation/test/demo-data-setup.test,v
diff -u -r1.6 -r1.7
--- openacs-4/packages/simulation/test/demo-data-setup.test 19 Nov 2003 07:40:46 -0000 1.6
+++ openacs-4/packages/simulation/test/demo-data-setup.test 28 Nov 2003 16:55:52 -0000 1.7
@@ -75,6 +75,8 @@
do_request /simulation/simbuild/template-edit
set template_name "Elementary Private Law"
field fill $template_name ~n name
+ field find ~n ready_p
+ field fill t
form submit
::twt::log_section "Create roles for template"
Index: openacs-4/packages/simulation/www/doc/admin.html
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/simulation/www/doc/admin.html,v
diff -u -r1.2 -r1.3
--- openacs-4/packages/simulation/www/doc/admin.html 14 Nov 2003 14:03:11 -0000 1.2
+++ openacs-4/packages/simulation/www/doc/admin.html 28 Nov 2003 16:55:52 -0000 1.3
@@ -1 +1,2 @@
-Admin Guide View comments on this page at openacs.org
+
+Admin Guide View comments on this page at openacs.org
Index: openacs-4/packages/simulation/www/doc/design.html
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/simulation/www/doc/design.html,v
diff -u -r1.6 -r1.7
--- openacs-4/packages/simulation/www/doc/design.html 14 Nov 2003 14:03:11 -0000 1.6
+++ openacs-4/packages/simulation/www/doc/design.html 28 Nov 2003 16:55:52 -0000 1.7
@@ -1 +1,2 @@
-Design View comments on this page at openacs.org
+
+Design View comments on this page at openacs.org
Index: openacs-4/packages/simulation/www/doc/index.html
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/simulation/www/doc/index.html,v
diff -u -r1.8 -r1.9
--- openacs-4/packages/simulation/www/doc/index.html 26 Nov 2003 16:44:50 -0000 1.8
+++ openacs-4/packages/simulation/www/doc/index.html 28 Nov 2003 16:55:52 -0000 1.9
@@ -1 +1,2 @@
-Simulation View comments on this page at openacs.org
+
+Simulation View comments on this page at openacs.org
Index: openacs-4/packages/simulation/www/doc/install.html
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/simulation/www/doc/install.html,v
diff -u -r1.4 -r1.5
--- openacs-4/packages/simulation/www/doc/install.html 14 Nov 2003 14:03:11 -0000 1.4
+++ openacs-4/packages/simulation/www/doc/install.html 28 Nov 2003 16:55:52 -0000 1.5
@@ -1 +1,2 @@
-Installation View comments on this page at openacs.org
+
+Installation View comments on this page at openacs.org
Index: openacs-4/packages/simulation/www/doc/interfaces.html
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/simulation/www/doc/interfaces.html,v
diff -u -r1.2 -r1.3
--- openacs-4/packages/simulation/www/doc/interfaces.html 14 Nov 2003 11:30:37 -0000 1.2
+++ openacs-4/packages/simulation/www/doc/interfaces.html 28 Nov 2003 16:55:52 -0000 1.3
@@ -1,2 +1,3 @@
-Interfaces TCL API
Each TCL API item should include inputs, outputs, and a
- comment block describing any non-obvious internal issues.
View comments on this page at openacs.org
+
+Interfaces TCL API
Each TCL API item should include inputs, outputs, and a
+ comment block describing any non-obvious internal issues.
View comments on this page at openacs.org
Index: openacs-4/packages/simulation/www/doc/internals.html
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/simulation/www/doc/internals.html,v
diff -u -r1.3 -r1.4
--- openacs-4/packages/simulation/www/doc/internals.html 14 Nov 2003 14:03:11 -0000 1.3
+++ openacs-4/packages/simulation/www/doc/internals.html 28 Nov 2003 16:55:52 -0000 1.4
@@ -1 +1,2 @@
-Internal Design View comments on this page at openacs.org
+
+Internal Design View comments on this page at openacs.org
Index: openacs-4/packages/simulation/www/doc/licensing.html
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/simulation/www/doc/licensing.html,v
diff -u -r1.1 -r1.2
--- openacs-4/packages/simulation/www/doc/licensing.html 14 Nov 2003 14:03:11 -0000 1.1
+++ openacs-4/packages/simulation/www/doc/licensing.html 28 Nov 2003 16:55:52 -0000 1.2
@@ -1 +1,2 @@
-Appendix�A.�Licencing View comments on this page at openacs.org
+
+Appendix A. Licencing View comments on this page at openacs.org
Index: openacs-4/packages/simulation/www/doc/map_xml.html
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/simulation/www/doc/map_xml.html,v
diff -u -r1.1 -r1.2
--- openacs-4/packages/simulation/www/doc/map_xml.html 12 Nov 2003 11:17:28 -0000 1.1
+++ openacs-4/packages/simulation/www/doc/map_xml.html 28 Nov 2003 16:55:52 -0000 1.2
@@ -1,4 +1,5 @@
-Map XML
+
+
Map XML
The simulation package will nightly generate an XML file with information needed
for the SIMBUILD flash map. The objects in the XML file will be those that are supposed
to appear on the map, i.e. those that have the on_map_p attribute set to true. The file
Index: openacs-4/packages/simulation/www/doc/object-orientation-notes.html
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/simulation/www/doc/object-orientation-notes.html,v
diff -u -r1.8 -r1.9
--- openacs-4/packages/simulation/www/doc/object-orientation-notes.html 26 Nov 2003 16:44:50 -0000 1.8
+++ openacs-4/packages/simulation/www/doc/object-orientation-notes.html 28 Nov 2003 16:55:52 -0000 1.9
@@ -1,4 +1,5 @@
-
Notes on an object-oriented simulated space Notes on an object-oriented simulated space
An OpenACS simulation is a collection of interactive
+
+
Notes on an object-oriented simulated space Notes on an object-oriented simulated spaceAn OpenACS simulation is a collection of interactive
objects, plus a set of roles and tasks. In the first part, it
is conceptually similar to a MOO (Multiple-User Dungeon,
Object-Oriented). This is a technology dating to 1990, in which
@@ -10,7 +11,7 @@
Games), which are essentially MOOs with graphical instead of
textual interfaces. Given their lineage and success, it makes
sense to draw on MOO technology when designing our simulation
- object model.
Basic MOO objects
+ object model.Basic MOO objects
Root Class
Room
Thing
@@ -27,13 +28,13 @@
Exit
Container
Openable Container
- (From the LambdaMOO Programmer's Manual
+ (From the LambdaMOO Programmer's Manual
There are three fundamental attributes to every object:
1. A flag (either true or false) specifying whether or not the object represents a player,
2. The object that is its parent, and
3. A list of the objects that are its children; that is, those
- objects for which this object is their parent. "Every object has eight built-in properties whose values are constrained to be of particular types. "
+ objects for which this object is their parent. "Every object has eight built-in properties whose values are constrained to be of particular types. "
name a string, the usual name for this object
owner an object, the player who controls access to it
location an object, where the object is in virtual reality
@@ -43,4 +44,4 @@
r a bit, is the object publicly readable?
w a bit, is the object publicly writable?
f a bit, is the object fertile?
- View comments on this page at openacs.org
+ View comments on this page at openacs.org
Index: openacs-4/packages/simulation/www/doc/package-install.html
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/simulation/www/doc/package-install.html,v
diff -u -r1.1 -r1.2
--- openacs-4/packages/simulation/www/doc/package-install.html 14 Nov 2003 14:03:11 -0000 1.1
+++ openacs-4/packages/simulation/www/doc/package-install.html 28 Nov 2003 16:55:52 -0000 1.2
@@ -1,4 +1,5 @@
-
Package installation Requires workflow and bcms and their prerequisites.