Index: openacs-4/packages/evaluation/www/admin/tasks/task-add-edit.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/evaluation/www/admin/tasks/task-add-edit.tcl,v diff -u -r1.4 -r1.5 --- openacs-4/packages/evaluation/www/admin/tasks/task-add-edit.tcl 22 May 2004 01:20:25 -0000 1.4 +++ openacs-4/packages/evaluation/www/admin/tasks/task-add-edit.tcl 31 May 2004 17:04:58 -0000 1.5 @@ -14,225 +14,239 @@ upload_file.tmpfile:tmpfile,optional {mode "edit"} return_url + admin_groups_p:optional } set package_id [ad_conn package_id] if { [ad_form_new_p -key task_id] } { - set page_title "Add Task" + set page_title "Add Task" } else { - set page_title "Edit Task" + set page_title "Edit Task" } +if { [info exists admin_groups_p] } { + set div_visibility visible + set checked_p checked +} else { + set div_visibility hidden + set checked_p "" +} + db_1row get_grade_info { *SQL* } set context [list [list [export_vars -base grades { package_id }] "Grades"] $page_title] set attached_p "f" ad_form -html { enctype multipart/form-data } -name task -cancel_url $return_url -export { return_url item_id storage_type grade_id attached_p } -mode $mode -form { - task_id:key + task_id:key - {task_name:text - {label "Task Name"} - {html {size 30}} - } - + {task_name:text + {label "Task Name"} + {html {size 30}} + } + } if { ![ad_form_new_p -key task_id] } { - db_1row get_task_info { *SQL* } - - if { [string eq $storage_type "lob"] } { + db_1row get_task_info { *SQL* } + + if { [string eq $storage_type "lob"] } { - if { [string eq $mode "edit"] } { - set attached_p "t" - - ad_form -extend -name task -form { - {upload_file:file,optional - {label "File"} - {html "size 30"} - {help_text "Currently $title is attached to this task, but you can attach a different file/url just by adding it here"} - } - {unattach_p:text(checkbox),optional - {label "Unattach file?"} - {options {{"" "t"}}} - {help_text "Check this if you want to unattach the file"} - } - {url:text(text),optional - {label "URL"} - {value "http://"} - } - } - } else { - ad_form -extend -name task -form { - {upload_file:text,optional - {label "File"} - {html "size 30"} - {value "$title"} - } - {unattach_p:text(hidden) - } - {url:text(hidden) - } - } + if { [string eq $mode "edit"] } { + set attached_p "t" + + ad_form -extend -name task -form { + {upload_file:file,optional + {label "File"} + {html "size 30"} + {help_text "Currently $title is attached to this task, but you can attach a different file/url just by adding it here"} } - } elseif { [regexp "http://" $content] } { - - if { [string eq $mode "edit"] } { - - set attached_p "t" - - ad_form -extend -name task -form { - - {upload_file:file,optional - {label "File"} - {html "size 30"} - } - {url:text(text),optional - {label "URL"} - {value "http://"} - {help_text "Currently $content is associated to this task, but you can associate a different url/file just by adding it here"} - } - {unattach_p:text(checkbox), optional - {label "Unassociate url?"} - {options {{"" "t"}}} - {help_text "Check this if you want to unattach the file"} - } - } - } else { - ad_form -extend -name task -form { - - {upload_file:hidden - } - {url:text(text),optional - {label "URL"} - {value "$content"} - } - {unattach_p:text(hidden) - } - } + {unattach_p:text(checkbox),optional + {label "Unattach file?"} + {options {{"" "t"}}} + {help_text "Check this if you want to unattach the file"} } + {url:text(text),optional + {label "URL"} + {value "http://"} + } + } } else { - ad_form -extend -name task -form { - - {upload_file:file,optional - {label "File"} - {html "size 30"} - } - - {url:text(text),optional - {label "URL"} - {value "http://"} - } - - {unattach_p:text(hidden),optional - {value ""} - } + ad_form -extend -name task -form { + {upload_file:text,optional + {label "File"} + {html "size 30"} + {value "$title"} } - - } -} else { - - ad_form -extend -name task -form { - - {upload_file:file,optional - {label "File"} - {html "size 30"} + {unattach_p:text(hidden) } + {url:text(hidden) + } + } } + } elseif { [regexp "http://" $content] } { - ad_form -extend -name task -form { + if { [string eq $mode "edit"] } { + + set attached_p "t" + + ad_form -extend -name task -form { + {upload_file:file,optional + {label "File"} + {html "size 30"} + } {url:text(text),optional - {label "URL"} - {value "http://"} + {label "URL"} + {value "http://"} + {help_text "Currently $content is associated to this task, but you can associate a different url/file just by adding it here"} + } + {unattach_p:text(checkbox),optional + {label "Unassociate url?"} + {options {{"" "t"}}} + {help_text "Check this if you want to unattach the file"} } - - {unattach_p:text(hidden),optional - {value ""} + } + } else { + ad_form -extend -name task -form { + + {upload_file:hidden } + {url:text(text),optional + {label "URL"} + {value "$content"} + } + {unattach_p:text(hidden) + } + } } + } else { + ad_form -extend -name task -form { + + {upload_file:file,optional + {label "File"} + {html "size 30"} + {help_text "You can upload a file associated to this task by using the browse button (optional)"} + } + + {url:text(text),optional + {label "URL"} + {value "http://"} + {help_text "You can associate a link to this task by entering the absolute url here (also optional)"} + } + + {unattach_p:text(hidden),optional + {value ""} + } + } + + } +} else { + + ad_form -extend -name task -form { + + {upload_file:file,optional + {label "File"} + {html "size 30"} + {help_text "You can upload a file associated to this task by using the browse button and select the file from your computer (optional)"} + } + } + + ad_form -extend -name task -form { + + {url:text(text),optional + {label "URL"} + {value "http://"} + {help_text "You can associate a link to this task by entering the absolute url here (also optional)"} + } + + {unattach_p:text(hidden),optional + {value ""} + } + } } ad_form -extend -name task -form { - {description:richtext,optional - {label "Task's Description"} - {html {rows 4 cols 40 wrap soft}} - } + {description:richtext,optional + {label "Task's Description"} + {html {rows 4 cols 40 wrap soft}} + } - {due_date:date,to_sql(linear_date),from_sql(sql_date) - {label "Due Date"} - {format "MONTH DD YYYY"} - {today} - {help} - {value {[evaluation::now_plus_days -ndays 15]}} - } + {due_date:date,to_sql(linear_date),from_sql(sql_date) + {label "Due Date"} + {format "MONTH DD YYYY"} + {today} + {help} + {value {[evaluation::now_plus_days -ndays 15]}} + } - {weight:text - {label "Weight"} - {html {size 5}} - {help_text "over $grade_weight% of $grade_name"} - } + {number_of_members:text + {label "Number of Members"} + {value "1"} + {html {size 5 onChange TaskInGroups()}} + {help_text "1 = Individual"} + {after_html {
Check this if you want to go to the groups admin page after submitting the task
}} + } - {number_of_members:text - {label "Number of Members"} - {value "1"} - {html {size 5}} - {help_text "1 = Individual"} - } + {weight:text + {label "Weight"} + {html {size 5}} + {help_text "over $grade_weight% of $grade_name"} + } + + {online_p:text(radio) + {label "Will the task be submitted online?"} + {options {{Yes t} {No f}}} + {value t} + } - {online_p:text(radio) - {label "Will the task be submitted online?"} - {options {{Yes t} {No f}}} - {value t} - } + {late_submit_p:text(radio) + {label "Can the student submit the answer
after the due date?"} + {options {{Yes t} {"No" f}}} + {value t} + } - {late_submit_p:text(radio) - {label "Can the student submit the answer
after the due date?"} - {options {{Yes t} {"No" f}}} - {value t} - } + {requires_grade_p:text(radio) + {label "Will this task require a grade on the course?"} + {options {{Yes t} {"No" f}}} + {value t} + } - {requires_grade_p:text(radio) - {label "Will this task require a grade on the course?"} - {options {{Yes t} {"No" f}}} - {value t} - } - } -edit_request { - - db_1row task_info { *SQL* } + + db_1row task_info { *SQL* } - set due_date [template::util::date::from_ansi $due_date] + set due_date [template::util::date::from_ansi $due_date] } -validate { - {weight - { [ad_var_type_check_number_p $weight] } - {Weight is not a real number} - } - {due_date - { [template::util::date::compare $due_date [template::util::date::now]] > 0 } - {Due date must be in the future} - } - {url - { ([string eq $url "http://"] && ![empty_string_p $upload_file]) || (![string eq $url "http://"] && [empty_string_p $upload_file]) || ([string eq $url "http://"] && [empty_string_p $upload_file]) || (![string eq $url "http://"] && [util_url_valid_p $url]) } - {Upload a file OR a url, not both} - } - {upload_file - { ([string eq $url "http://"] && ![empty_string_p $upload_file]) || (![string eq $url "http://"] && [empty_string_p $upload_file]) || ([string eq $url "http://"] && [empty_string_p $upload_file]) } - {Upload a file OR a url, not both} - } - {number_of_members - { [ad_var_type_check_integer_p $number_of_members] } - {Number of members must be an integer} - } - {unattach_p - { ([string eq $unattach_p "t"] && [empty_string_p $upload_file] && [string eq $url "http://"]) || [empty_string_p $unattach_p] } - {First unattach the file/url, then submit another one or just upload a new file/url and leave this in blank} - } + {weight + { [ad_var_type_check_number_p $weight] } + {Weight is not a real number} + } + {due_date + { [template::util::date::compare $due_date [template::util::date::now]] > 0 } + {Due date must be in the future} + } + {url + { ([string eq $url "http://"] && ![empty_string_p $upload_file]) || (![string eq $url "http://"] && [empty_string_p $upload_file]) || ([string eq $url "http://"] && [empty_string_p $upload_file]) || (![string eq $url "http://"] && [util_url_valid_p $url]) } + {Upload a file OR a url, not both} + } + {upload_file + { ([string eq $url "http://"] && ![empty_string_p $upload_file]) || (![string eq $url "http://"] && [empty_string_p $upload_file]) || ([string eq $url "http://"] && [empty_string_p $upload_file]) } + {Upload a file OR a url, not both} + } + {number_of_members + { [ad_var_type_check_integer_p $number_of_members] } + {Number of members must be an integer} + } + {unattach_p + { ([string eq $unattach_p "t"] && [empty_string_p $upload_file] && [string eq $url "http://"]) || [empty_string_p $unattach_p] } + {First unattach the file/url, then submit another one or just upload a new file/url and leave this in blank} + } } -new_data { evaluation::notification::do_notification -task_id $revision_id -package_id [ad_conn package_id] -edit_p 0 -notif_type one_assignment_notif @@ -298,8 +312,13 @@ } } } -after_submit { - ad_returnredirect "$return_url" - ad_script_abort + if { [info exists admin_groups_p] && $number_of_members > 1 } { + ad_returnredirect [export_vars -base "../groups/one-task" { {task_id $revision_id} }] + ad_script_abort + } else { + ad_returnredirect "$return_url" + ad_script_abort + } } ad_return_template