Index: openacs-4/contrib/packages/simulation/tcl/simulation-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/simulation/tcl/Attic/simulation-procs.tcl,v diff -u -r1.14 -r1.15 --- openacs-4/contrib/packages/simulation/tcl/simulation-procs.tcl 16 Dec 2003 11:34:33 -0000 1.14 +++ openacs-4/contrib/packages/simulation/tcl/simulation-procs.tcl 16 Dec 2003 16:03:29 -0000 1.15 @@ -161,98 +161,6 @@ }] } -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 }