Index: openacs-4/contrib/packages/simulation/www/siminst/simulation-edit.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/simulation/www/siminst/Attic/simulation-edit.tcl,v diff -u -r1.7 -r1.8 --- openacs-4/contrib/packages/simulation/www/siminst/simulation-edit.tcl 12 Jan 2004 11:35:33 -0000 1.7 +++ openacs-4/contrib/packages/simulation/www/siminst/simulation-edit.tcl 12 Jan 2004 14:46:30 -0000 1.8 @@ -22,6 +22,18 @@ {case_end:date,to_sql(ansi),from_sql(ansi),optional {label "Simulation end date"} } + {enroll_type:text(radio) + {label "Allow Self Enrollment"} + {options {{"Yes" open} {"No" closed}}} + {html {onChange "javascript:acs_FormRefresh('simulation');"}} + {help_text "If self-enrollment is allowed, this simulation will be publicly listed on the Simulation home page and anybody can enroll themself."} + } + {enroll_start:date,to_sql(ansi),from_sql(ansi),optional + {label "Enrollment start date"} + } + {enroll_end:date,to_sql(ansi),from_sql(ansi),optional + {label "Enrollment end date"} + } {description:richtext(richtext),optional {label "Description"} {html {cols 60 rows 8}} @@ -35,12 +47,19 @@ case_start case_end pretty_name + enroll_type + enroll_start + enroll_end } { set $elm $sim_template($elm) } set description [template::util::richtext::create $sim_template(description) $sim_template(description_mime_type)] + if { ![exists_and_not_null sim_template(enroll_type)] } { + set enroll_type closed + } + # Default values set one_week [expr 3600*24*7] @@ -61,7 +80,52 @@ if { [empty_string_p $case_end] } { set case_end [clock format [expr [clock seconds] + 2*$one_week + $default_duration] -format "%Y-%m-%d"] } + if { [empty_string_p $enroll_start] } { + set enroll_start [clock format [expr [clock seconds] + 1*$one_week] -format "%Y-%m-%d"] + } + if { [empty_string_p $enroll_end] } { + set enroll_end [clock format [expr [clock seconds] + 2*$one_week + $default_duration] -format "%Y-%m-%d"] + } + } -on_submit { + + # Date validation + set error_p 0 + if { [clock scan $send_start_note_date] > [clock scan $case_start] } { + template::form::set_error simulation send_start_note_date "Send start note date must be before simulation start date" + set error_p 1 + } + if { [clock scan $case_start] > [clock scan $case_end] } { + template::form::set_error simulation case_start "Simulation start date must be before simulation end date" + set error_p 1 + } + if { [string equal $enroll_type "open"] } { + if { [empty_string_p $enroll_start] } { + template::form::set_error simulation enroll_start "When self enrollment is allowed you need to specify an enrollment start date" + set error_p 1 + } + if { [empty_string_p $enroll_end] } { + template::form::set_error simulation enroll_end "When self enrollment is allowed you need to specify an enrollment end date" + set error_p 1 + } + + if { [clock scan $enroll_start] > [clock scan $case_start] } { + template::form::set_error simulation enroll_start "Enrollment start date must be before simulation start date" + set error_p 1 + } + if { [clock scan $enroll_end] > [clock scan $case_start] } { + template::form::set_error simulation enroll_start "Enrollment start date must be before simulation start date" + set error_p 1 + } + if { [clock scan $enroll_start] > [clock scan $enroll_end] } { + template::form::set_error simulation enroll_start "Enrollment start date must be before enrollment end date" + set error_p 1 + } + } + if { $error_p } { + break + } + set description_mime_type [template::util::richtext::get_property format $description] set description [template::util::richtext::get_property contents $description] @@ -75,7 +139,7 @@ break } - foreach elm { send_start_note_date case_start case_end pretty_name description description_mime_type } { + foreach elm { send_start_note_date case_start case_end pretty_name description description_mime_type enroll_type enroll_start enroll_end } { set row($elm) [set $elm] } @@ -86,5 +150,14 @@ wizard forward } +# Want this to be executed both on_refresh and on_request +if { [string equal $enroll_type "closed"] } { + element set_properties simulation enroll_start -widget hidden + element set_properties simulation enroll_end -widget hidden +} else { + element set_properties simulation enroll_start -widget date + element set_properties simulation enroll_end -widget date +} + wizard submit simulation -buttons { back next } Index: openacs-4/contrib/packages/simulation/www/siminst/simulation-participants.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/simulation/www/siminst/Attic/simulation-participants.adp,v diff -u -r1.7 -r1.8 --- openacs-4/contrib/packages/simulation/www/siminst/simulation-participants.adp 12 Jan 2004 13:24:57 -0000 1.7 +++ openacs-4/contrib/packages/simulation/www/siminst/simulation-participants.adp 12 Jan 2004 14:46:30 -0000 1.8 @@ -1,14 +1,18 @@ -

TODO: (0.5h) implement the enrollment type and optional enrollment date -fields from simulation-enrollment.tcl and cvs remove simulation-enrollment.adp/tcl

TODO: (0.5h) change invited/mandatory checkboxes to a single radio button set per row: invited/mandatory/neither invited nor mandatory or preferably use Javascript with checkboxes + + -Manage groups -

Auto-Enroll takes effect, and - invitations are sent, when this wizard is completed and - casting begins.

+ Manage groups + +

+ Auto-Enroll takes effect, and invitations are sent, + when this wizard is completed and + casting begins. +

+ Index: openacs-4/contrib/packages/simulation/www/siminst/simulation-participants.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/simulation/www/siminst/Attic/simulation-participants.tcl,v diff -u -r1.5 -r1.6 --- openacs-4/contrib/packages/simulation/www/siminst/simulation-participants.tcl 12 Jan 2004 11:35:33 -0000 1.5 +++ openacs-4/contrib/packages/simulation/www/siminst/simulation-participants.tcl 12 Jan 2004 14:46:30 -0000 1.6 @@ -93,7 +93,6 @@ html { align center } } } -# wizard submit simulation -buttons { back next } @@ -102,11 +101,7 @@ -name simulation \ -form { {groups:text(hidden),optional {value $groups}} - } \ - -on_request { - # Grab values from local vars - } \ - -on_submit { + } -on_submit { # First, drop all "invited" check marks if the user is also auto-enrolled foreach group_id $groups { Index: openacs-4/packages/simulation/www/siminst/simulation-edit.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/simulation/www/siminst/simulation-edit.tcl,v diff -u -r1.7 -r1.8 --- openacs-4/packages/simulation/www/siminst/simulation-edit.tcl 12 Jan 2004 11:35:33 -0000 1.7 +++ openacs-4/packages/simulation/www/siminst/simulation-edit.tcl 12 Jan 2004 14:46:30 -0000 1.8 @@ -22,6 +22,18 @@ {case_end:date,to_sql(ansi),from_sql(ansi),optional {label "Simulation end date"} } + {enroll_type:text(radio) + {label "Allow Self Enrollment"} + {options {{"Yes" open} {"No" closed}}} + {html {onChange "javascript:acs_FormRefresh('simulation');"}} + {help_text "If self-enrollment is allowed, this simulation will be publicly listed on the Simulation home page and anybody can enroll themself."} + } + {enroll_start:date,to_sql(ansi),from_sql(ansi),optional + {label "Enrollment start date"} + } + {enroll_end:date,to_sql(ansi),from_sql(ansi),optional + {label "Enrollment end date"} + } {description:richtext(richtext),optional {label "Description"} {html {cols 60 rows 8}} @@ -35,12 +47,19 @@ case_start case_end pretty_name + enroll_type + enroll_start + enroll_end } { set $elm $sim_template($elm) } set description [template::util::richtext::create $sim_template(description) $sim_template(description_mime_type)] + if { ![exists_and_not_null sim_template(enroll_type)] } { + set enroll_type closed + } + # Default values set one_week [expr 3600*24*7] @@ -61,7 +80,52 @@ if { [empty_string_p $case_end] } { set case_end [clock format [expr [clock seconds] + 2*$one_week + $default_duration] -format "%Y-%m-%d"] } + if { [empty_string_p $enroll_start] } { + set enroll_start [clock format [expr [clock seconds] + 1*$one_week] -format "%Y-%m-%d"] + } + if { [empty_string_p $enroll_end] } { + set enroll_end [clock format [expr [clock seconds] + 2*$one_week + $default_duration] -format "%Y-%m-%d"] + } + } -on_submit { + + # Date validation + set error_p 0 + if { [clock scan $send_start_note_date] > [clock scan $case_start] } { + template::form::set_error simulation send_start_note_date "Send start note date must be before simulation start date" + set error_p 1 + } + if { [clock scan $case_start] > [clock scan $case_end] } { + template::form::set_error simulation case_start "Simulation start date must be before simulation end date" + set error_p 1 + } + if { [string equal $enroll_type "open"] } { + if { [empty_string_p $enroll_start] } { + template::form::set_error simulation enroll_start "When self enrollment is allowed you need to specify an enrollment start date" + set error_p 1 + } + if { [empty_string_p $enroll_end] } { + template::form::set_error simulation enroll_end "When self enrollment is allowed you need to specify an enrollment end date" + set error_p 1 + } + + if { [clock scan $enroll_start] > [clock scan $case_start] } { + template::form::set_error simulation enroll_start "Enrollment start date must be before simulation start date" + set error_p 1 + } + if { [clock scan $enroll_end] > [clock scan $case_start] } { + template::form::set_error simulation enroll_start "Enrollment start date must be before simulation start date" + set error_p 1 + } + if { [clock scan $enroll_start] > [clock scan $enroll_end] } { + template::form::set_error simulation enroll_start "Enrollment start date must be before enrollment end date" + set error_p 1 + } + } + if { $error_p } { + break + } + set description_mime_type [template::util::richtext::get_property format $description] set description [template::util::richtext::get_property contents $description] @@ -75,7 +139,7 @@ break } - foreach elm { send_start_note_date case_start case_end pretty_name description description_mime_type } { + foreach elm { send_start_note_date case_start case_end pretty_name description description_mime_type enroll_type enroll_start enroll_end } { set row($elm) [set $elm] } @@ -86,5 +150,14 @@ wizard forward } +# Want this to be executed both on_refresh and on_request +if { [string equal $enroll_type "closed"] } { + element set_properties simulation enroll_start -widget hidden + element set_properties simulation enroll_end -widget hidden +} else { + element set_properties simulation enroll_start -widget date + element set_properties simulation enroll_end -widget date +} + wizard submit simulation -buttons { back next } Index: openacs-4/packages/simulation/www/siminst/simulation-participants.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/simulation/www/siminst/simulation-participants.adp,v diff -u -r1.7 -r1.8 --- openacs-4/packages/simulation/www/siminst/simulation-participants.adp 12 Jan 2004 13:24:57 -0000 1.7 +++ openacs-4/packages/simulation/www/siminst/simulation-participants.adp 12 Jan 2004 14:46:30 -0000 1.8 @@ -1,14 +1,18 @@ -

TODO: (0.5h) implement the enrollment type and optional enrollment date -fields from simulation-enrollment.tcl and cvs remove simulation-enrollment.adp/tcl

TODO: (0.5h) change invited/mandatory checkboxes to a single radio button set per row: invited/mandatory/neither invited nor mandatory or preferably use Javascript with checkboxes + + -Manage groups -

Auto-Enroll takes effect, and - invitations are sent, when this wizard is completed and - casting begins.

+ Manage groups + +

+ Auto-Enroll takes effect, and invitations are sent, + when this wizard is completed and + casting begins. +

+ Index: openacs-4/packages/simulation/www/siminst/simulation-participants.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/simulation/www/siminst/simulation-participants.tcl,v diff -u -r1.5 -r1.6 --- openacs-4/packages/simulation/www/siminst/simulation-participants.tcl 12 Jan 2004 11:35:33 -0000 1.5 +++ openacs-4/packages/simulation/www/siminst/simulation-participants.tcl 12 Jan 2004 14:46:30 -0000 1.6 @@ -93,7 +93,6 @@ html { align center } } } -# wizard submit simulation -buttons { back next } @@ -102,11 +101,7 @@ -name simulation \ -form { {groups:text(hidden),optional {value $groups}} - } \ - -on_request { - # Grab values from local vars - } \ - -on_submit { + } -on_submit { # First, drop all "invited" check marks if the user is also auto-enrolled foreach group_id $groups {