Index: openacs-4/packages/simulation/www/siminst/map-characters.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/simulation/www/siminst/map-characters.tcl,v diff -u -r1.2 -r1.3 --- openacs-4/packages/simulation/www/siminst/map-characters.tcl 28 Nov 2003 09:32:26 -0000 1.2 +++ openacs-4/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 + }