Index: openacs-4/packages/evaluation/tcl/evaluation-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/evaluation/tcl/evaluation-procs.tcl,v diff -u -N -r1.48 -r1.49 --- openacs-4/packages/evaluation/tcl/evaluation-procs.tcl 26 Jul 2018 14:53:26 -0000 1.48 +++ openacs-4/packages/evaluation/tcl/evaluation-procs.tcl 26 Jul 2018 15:12:22 -0000 1.49 @@ -1,6 +1,6 @@ ad_library { Procedures in the evaluation namespace. - + @creation-date Feb 2004 @author jopez@galileo.edu and cesarhj@galileo.edu @cvs-id $Id$ @@ -16,77 +16,77 @@ # ##### -ad_proc -public evaluation::notification::get_url { +ad_proc -public evaluation::notification::get_url { {-task_id ""} {-notif_type ""} {-evaluation_id ""} {object_id ""} -} { - Returns a full url to the object_id. - Handles assignments and evaluations. -} { - +} { + Returns a full url to the object_id. + Handles assignments and evaluations. +} { + if {([info exists object_id] && $object_id ne "")} { return "[ad_url][apm_package_url_from_id $object_id]" } - set base_url "[ad_url][ad_conn package_url]" + set base_url "[ad_url][ad_conn package_url]" switch $notif_type { - "one_assignment_notif" { - db_1row get_grade_id { *SQL* } - return [export_vars -base "${base_url}task-view" { task_id grade_id }] - } - "one_evaluation_notif" { - set evaluation_mode display - return [export_vars -base "${base_url}" { task_id evaluation_id evaluation_mode }] - } - default { - error "[_ evaluation.lt_Unrecognized_value_fo]" - ad_script_abort - } + "one_assignment_notif" { + db_1row get_grade_id { *SQL* } + return [export_vars -base "${base_url}task-view" { task_id grade_id }] + } + "one_evaluation_notif" { + set evaluation_mode display + return [export_vars -base "${base_url}" { task_id evaluation_id evaluation_mode }] + } + default { + error "[_ evaluation.lt_Unrecognized_value_fo]" + ad_script_abort + } } -} +} -ad_proc -public evaluation::get_user_portrait { +ad_proc -public evaluation::get_user_portrait { -user_id:required {-tag_attributes ""} -} { +} { Returns the portrait for the given user or a default portrait if not found. -} { - +} { + if { [db_0or1row user_portrait { *SQL* }] } { - set output "" return $output -} +} -ad_proc -public evaluation::safe_url_name { +ad_proc -public evaluation::safe_url_name { -name:required -} { +} { Returns the filename replacing some characters. -} { +} { regsub -all {[<>:\"|/@\\\#%&+\\ ,\?]} $name {_} name return $name -} +} ad_proc -public evaluation::delete_grade { @@ -169,9 +169,9 @@ ad_proc -public evaluation::set_live_task { -task_item_id:required -} { +} { For this task and its related student evaluations, answers, - solutions and grades, promote best revision to the live revision. + solutions and grades, promote best revision to the live revision. } { db_foreach evaluation_deleted_student_eval { select evaluation_item_id @@ -182,7 +182,7 @@ latest_revision = evaluation_id) and evaluation_item_id = item_id } { - evaluation::set_live_item -item_id $evaluation_item_id + evaluation::set_live_item -item_id $evaluation_item_id } db_foreach evaluation_deleted_answer { @@ -194,7 +194,7 @@ latest_revision = answer_id) and answer_item_id = item_id } { - evaluation::set_live_item -item_id $answer_item_id + evaluation::set_live_item -item_id $answer_item_id } db_foreach evaluation_deleted_task_sol { @@ -206,9 +206,9 @@ latest_revision = solution_id) and solution_item_id = item_id } { - evaluation::set_live_item -item_id $solution_item_id + evaluation::set_live_item -item_id $solution_item_id } - + db_foreach evaluation_deleted_grades_sheet { select grades_sheet_item_id from evaluation_grades_sheets, @@ -218,7 +218,7 @@ latest_revision = grades_sheet_id) and grades_sheet_item_id = item_id } { - evaluation::set_live_item -item_id $grades_sheet_item_id + evaluation::set_live_item -item_id $grades_sheet_item_id } evaluation::set_live_item -item_id $task_item_id @@ -231,16 +231,16 @@ } { db_1row get_task_id { select task_item_id from evaluation_tasks where task_id = :task_id } db_foreach evaluation_delete_student_eval { select evaluation_id from evaluation_student_evals where task_item_id = :task_item_id } { - evaluation::revision_delete -revision_id $evaluation_id + evaluation::revision_delete -revision_id $evaluation_id } db_foreach evaluation_delete_answer { select answer_id from evaluation_answers where task_item_id = :task_item_id } { - evaluation::revision_delete -revision_id $answer_id + evaluation::revision_delete -revision_id $answer_id } db_foreach evaluation_delete_task_sol { select solution_id from evaluation_tasks_sols where task_item_id = :task_item_id } { - evaluation::revision_delete -revision_id $solution_id + evaluation::revision_delete -revision_id $solution_id } db_foreach evaluation_delete_grades_sheet { select grades_sheet_id from evaluation_grades_sheets where task_item_id = :task_item_id } { - evaluation::revision_delete -revision_id $grades_sheet_id + evaluation::revision_delete -revision_id $grades_sheet_id } evaluation::revision_delete -revision_id $task_id } @@ -253,7 +253,7 @@ evaluation::revision_delete -revision_id $evaluation_id } -ad_proc -public evaluation::notification::do_notification { +ad_proc -public evaluation::notification::do_notification { -task_id:required -package_id:required -notif_type:required @@ -264,16 +264,16 @@ Issues notifications. } { - db_1row select_names { *SQL* } - + db_1row select_names { *SQL* } + set community_name "" set community_id [dotlrn_community::get_community_id] if { $community_id ne "" } { set community_name [db_string get_community_name "select pretty_name from dotlrn_communities_all where community_id = :community_id"] - } + } switch $notif_type { - "one_assignment_notif" { + "one_assignment_notif" { if {$edit_p eq "0"} { set notif_subject "[_ evaluation.lt_New_Assignment_grade_]" set notif_text "[_ evaluation.lt_A_new_assignment_was_] \n" @@ -283,7 +283,7 @@ } append notif_text "[_ evaluation.click_on_this_link_] [evaluation::notification::get_url -task_id $task_id -notif_type one_assignment_notif] \n" set response_id $task_id - + } "one_evaluation_notif" { db_1row get_eval_info { *SQL* } @@ -294,13 +294,13 @@ set response_id $evaluation_id } default { - error "[_ evaluation.lt_Unrecognized_value_fo]" + error "[_ evaluation.lt_Unrecognized_value_fo]" ad_script_abort } } - + # Notifies the users that requested notification for the specific object - + notification::new \ -type_id [notification::type::get_type_id -short_name $notif_type] \ -object_id $package_id \ @@ -309,7 +309,7 @@ -notif_text $notif_text \ -subset $subset \ -action_id $response_id -} +} ad_proc -public evaluation::package_key { } { @@ -329,46 +329,46 @@ -name:required -plural_name:required {-package_id ""} -} { +} { Build a new content revision of a evaluation subtype. If new_item_p is set true then a new item is first created, otherwise a new revision is created for the item indicated by item_id. - + @param item_id The item to update or create. @param content_type The type to make @param content_table - @param new_item_p If true make a new item using item_id + @param new_item_p If true make a new item using item_id } { if { $package_id eq "" } { - set package_id [ad_conn package_id] + set package_id [ad_conn package_id] } set creation_user [ad_conn user_id] set creation_ip [ad_conn peeraddr] set creation_date [db_string get_date { *SQL* }] set item_name "${content_type}_${item_id}" - + set revision_id [db_nextval acs_object_id_seq] set revision_name "${content_type}_${revision_id}" set folder_id [content::item::get_id -item_path "${content_type}_${package_id}" -resolve_index f] if { $new_item_p && ![db_string double_click { *SQL* }] } { set item_id [content::item::new -item_id $item_id -parent_id $folder_id -content_type $content_type -name $item_name -context_id $package_id -creation_date $creation_date] } set revision_id [content::revision::new \ - -item_id $item_id \ - -content_type $content_type \ - -description $description \ - -creation_date $creation_date \ - -attributes [list [list weight $weight] \ - [list grade_name $name] \ - [list grade_item_id $item_id] \ - [list grade_plural_name $plural_name]] ] + -item_id $item_id \ + -content_type $content_type \ + -description $description \ + -creation_date $creation_date \ + -attributes [list [list weight $weight] \ + [list grade_name $name] \ + [list grade_item_id $item_id] \ + [list grade_plural_name $plural_name]] ] return $revision_id -} +} ad_proc -private evaluation::now_plus_days { -ndays } { - Create a new Date object for the current date and time + Create a new Date object for the current date and time plus the number of days given with the default interval for minutes. @@ -377,29 +377,29 @@ } { set now [list] foreach v [clock format [clock seconds] -format "%Y %m %d %H %M %S"] { - lappend now [util::trim_leading_zeros $v] + lappend now [util::trim_leading_zeros $v] } - + set day [lindex $now 2] set month [lindex $now 1] set interval_def [template::util::date::defaultInterval day] for { set i [lindex $interval_def 0] } { $i <= 15 } { incr i 1 } { - incr day - if { $day + $i >= [lindex $interval_def 1] } { - incr month 1 - set day 1 - } + incr day + if { $day + $i >= [lindex $interval_def 1] } { + incr month 1 + set day 1 + } } - + # replace the hour and minute values in the now list with new values set now [lreplace $now 2 2 $day] set now [lreplace $now 1 1 $month] - + # set default time - set now [lreplace $now 3 3 23] - set now [lreplace $now 4 4 59] - set now [lreplace $now 5 5 59] - + set now [lreplace $now 3 3 23] + set now [lreplace $now 4 4 59] + set now [lreplace $now 5 5 59] + return [eval template::util::date::create $now] } @@ -421,10 +421,10 @@ db_1row from_task_info { *SQL* } if { $creation_user eq "" } { - set creation_user [ad_conn user_id] + set creation_user [ad_conn user_id] } if { $creation_ip eq "" } { - set creation_ip [ad_conn peeraddr] + set creation_ip [ad_conn peeraddr] } set item_name "${item_id}_${title}" @@ -433,37 +433,37 @@ -resolve_index f] set item_id [content::item::new -item_id $item_id \ - -parent_id $to_folder_id \ - -content_type evaluation_tasks \ - -creation_user $creation_user \ - -name $item_name \ - -context_id $to_package_id \ - -creation_ip $creation_ip \ - -mime_type $mime_type \ - -storage_type $storage_type] - + -parent_id $to_folder_id \ + -content_type evaluation_tasks \ + -creation_user $creation_user \ + -name $item_name \ + -context_id $to_package_id \ + -creation_ip $creation_ip \ + -mime_type $mime_type \ + -storage_type $storage_type] + set revision_id [content::revision::new \ - -item_id $item_id \ - -content_type evaluation_tasks \ - -mime_type $mime_type \ - -title $title \ - -description $description \ - -creation_user $creation_user \ - -creation_ip $creation_ip \ - -attributes [list [list weight $weight] \ - [list task_name $task_name] \ - [list task_item_id $item_id] \ - [list number_of_members $number_of_members] \ - [list online_p $online_p] \ - [list grade_item_id $to_grade_item_id] \ - [list due_date $due_date] \ - [list late_submit_p $late_submit_p] \ - [list requires_grade_p $requires_grade_p] \ - [list estimated_time $estimated_time] \ - [list points $points] \ - [list perfect_score $perfect_score] \ - [list relative_weight $relative_weight] \ - [list forums_related_p $forums_related_p]]] + -item_id $item_id \ + -content_type evaluation_tasks \ + -mime_type $mime_type \ + -title $title \ + -description $description \ + -creation_user $creation_user \ + -creation_ip $creation_ip \ + -attributes [list [list weight $weight] \ + [list task_name $task_name] \ + [list task_item_id $item_id] \ + [list number_of_members $number_of_members] \ + [list online_p $online_p] \ + [list grade_item_id $to_grade_item_id] \ + [list due_date $due_date] \ + [list late_submit_p $late_submit_p] \ + [list requires_grade_p $requires_grade_p] \ + [list estimated_time $estimated_time] \ + [list points $points] \ + [list perfect_score $perfect_score] \ + [list relative_weight $relative_weight] \ + [list forums_related_p $forums_related_p]]] db_exec_plsql clone_content { *SQL* } @@ -512,52 +512,52 @@ @param storage_type File or text, depending on what are we going to store } { if { $creation_user eq "" } { - set creation_user [ad_conn user_id] + set creation_user [ad_conn user_id] } if { $creation_ip eq "" } { - set creation_ip [ad_conn peeraddr] + set creation_ip [ad_conn peeraddr] } if {$package_id eq ""} { - set package_id [ad_conn package_id] + set package_id [ad_conn package_id] } set folder_id [content::item::get_id -item_path "${content_type}_${package_id}" -resolve_index f] if { $item_name eq "" } { - set item_name "${item_id}_${title}" + set item_name "${item_id}_${title}" } if { $new_item_p && ![db_string double_click { *SQL* }] } { - set item_id [content::item::new -item_id $item_id \ - -parent_id $folder_id \ - -content_type $content_type \ - -name $item_name \ - -context_id $package_id \ - -mime_type $mime_type \ - -storage_type $storage_type] + set item_id [content::item::new -item_id $item_id \ + -parent_id $folder_id \ + -content_type $content_type \ + -name $item_name \ + -context_id $package_id \ + -mime_type $mime_type \ + -storage_type $storage_type] } set revision_id [content::revision::new \ - -item_id $item_id \ - -content_type $content_type \ - -mime_type $mime_type \ - -title $title \ - -description $description \ - -attributes [list [list weight $weight] \ - [list task_name $name] \ - [list task_item_id $item_id] \ - [list online_p $online_p] \ - [list grade_item_id $grade_item_id] \ - [list due_date $due_date] \ - [list late_submit_p $late_submit_p] \ - [list requires_grade_p $requires_grade_p] \ - [list number_of_members $number_of_members]]] + -item_id $item_id \ + -content_type $content_type \ + -mime_type $mime_type \ + -title $title \ + -description $description \ + -attributes [list [list weight $weight] \ + [list task_name $name] \ + [list task_item_id $item_id] \ + [list online_p $online_p] \ + [list grade_item_id $grade_item_id] \ + [list due_date $due_date] \ + [list late_submit_p $late_submit_p] \ + [list requires_grade_p $requires_grade_p] \ + [list number_of_members $number_of_members]]] # in order to find the file we have to set the name in cr_items the same that in cr_revisions db_dml update_item_name { *SQL* } return $revision_id -} +} ad_proc -public evaluation::new_solution { -item_id:required @@ -590,10 +590,10 @@ } { if { $creation_user eq "" } { - set creation_user [ad_conn user_id] + set creation_user [ad_conn user_id] } if { $creation_ip eq "" } { - set creation_ip [ad_conn peeraddr] + set creation_ip [ad_conn peeraddr] } set package_id [ad_conn package_id] @@ -603,41 +603,41 @@ set revision_id [db_nextval acs_object_id_seq] if { $publish_date eq "" } { - set publish_date [db_string get_date { *SQL* }] + set publish_date [db_string get_date { *SQL* }] } if { $creation_date eq "" } { - set creation_date [db_string get_date { *SQL* }] + set creation_date [db_string get_date { *SQL* }] } if { $new_item_p && ![db_string double_click { *SQL* }] } { set item_id [content::item::new -item_id $item_id \ - -parent_id $folder_id \ - -content_type $content_type \ - -name $item_name \ - -context_id $package_id \ - -mime_type $mime_type \ - -storage_type $storage_type \ - -creation_user $creation_user \ - -creation_ip $creation_ip \ - -creation_date $creation_date] + -parent_id $folder_id \ + -content_type $content_type \ + -name $item_name \ + -context_id $package_id \ + -mime_type $mime_type \ + -storage_type $storage_type \ + -creation_user $creation_user \ + -creation_ip $creation_ip \ + -creation_date $creation_date] } set revision_id [content::revision::new \ - -item_id $item_id \ - -content_type $content_type \ - -mime_type $mime_type \ - -title $title \ - -creation_user $creation_user \ - -creation_ip $creation_ip \ - -creation_date $creation_date \ - -attributes [list [list task_item_id $task_item_id] \ - [list solution_item_id $item_id]] ] + -item_id $item_id \ + -content_type $content_type \ + -mime_type $mime_type \ + -title $title \ + -creation_user $creation_user \ + -creation_ip $creation_ip \ + -creation_date $creation_date \ + -attributes [list [list task_item_id $task_item_id] \ + [list solution_item_id $item_id]] ] # in order to find the file we have to set the name in cr_items the same that in cr_revisions db_dml update_item_name { *SQL* } return $revision_id -} +} ad_proc -public evaluation::new_answer { @@ -673,10 +673,10 @@ } { if { $creation_user eq "" } { - set creation_user [ad_conn user_id] + set creation_user [ad_conn user_id] } if { $creation_ip eq "" } { - set creation_ip [ad_conn peeraddr] + set creation_ip [ad_conn peeraddr] } set package_id [ad_conn package_id] @@ -686,41 +686,41 @@ set revision_id [db_nextval acs_object_id_seq] if { $publish_date eq "" } { - set publish_date [db_string get_date { *SQL* }] + set publish_date [db_string get_date { *SQL* }] } - + if { $creation_date eq "" } { - set creation_date [db_string get_date { *SQL* }] + set creation_date [db_string get_date { *SQL* }] } if { $new_item_p && ![db_string double_click { *SQL* }] } { set item_id [content::item::new \ - -item_id $item_id \ - -parent_id $folder_id \ - -content_type $content_type \ - -name $item_name \ - -context_id $package_id \ - -mime_type $mime_type \ - -creation_user $creation_user \ - -creation_ip $creation_ip \ - -storage_type $storage_type \ - -creation_date $creation_date] + -item_id $item_id \ + -parent_id $folder_id \ + -content_type $content_type \ + -name $item_name \ + -context_id $package_id \ + -mime_type $mime_type \ + -creation_user $creation_user \ + -creation_ip $creation_ip \ + -storage_type $storage_type \ + -creation_date $creation_date] } set revision_id [content::revision::new \ - -item_id $item_id \ - -content_type $content_type \ - -mime_type $mime_type \ - -title $title \ - -creation_user $creation_user \ - -creation_ip $creation_ip \ - -creation_date $creation_date \ - -attributes [list [list answer_item_id $item_id] \ - [list party_id $party_id] \ - [list task_item_id $task_item_id]] ] + -item_id $item_id \ + -content_type $content_type \ + -mime_type $mime_type \ + -title $title \ + -creation_user $creation_user \ + -creation_ip $creation_ip \ + -creation_date $creation_date \ + -attributes [list [list answer_item_id $item_id] \ + [list party_id $party_id] \ + [list task_item_id $task_item_id]] ] # in order to find the file we have to set the name in cr_items the same that in cr_revisions db_dml update_item_name { *SQL* } return $revision_id -} +} ad_proc -public evaluation::new_evaluation { -item_id:required @@ -741,7 +741,7 @@ {-publish_date ""} {-creation_date ""} } { - + Build a new content revision of an evaluation. If new_item_p is set true then a new item is first created, otherwise a new revision is created for the item indicated by item_id. @@ -760,10 +760,10 @@ } { if { $creation_user eq "" } { - set creation_user [ad_conn user_id] + set creation_user [ad_conn user_id] } if { $creation_ip eq "" } { - set creation_ip [ad_conn peeraddr] + set creation_ip [ad_conn peeraddr] } set package_id [ad_conn package_id] @@ -773,42 +773,42 @@ set revision_id [db_nextval acs_object_id_seq] if { $publish_date eq "" } { - set publish_date [db_string get_date { *SQL* }] + set publish_date [db_string get_date { *SQL* }] } if { $creation_date eq "" } { - set creation_date [db_string get_date { *SQL* }] + set creation_date [db_string get_date { *SQL* }] } if { $new_item_p && ![db_string double_click { *SQL* }] } { set item_id [content::item::new -item_id $item_id \ - -parent_id $folder_id \ - -content_type $content_type \ - -name $item_name \ - -context_id $package_id \ - -mime_type $mime_type \ - -storage_type $storage_type \ - -creation_user $creation_user \ - -creation_ip $creation_ip \ - -description $description \ - -creation_date $creation_date] - } + -parent_id $folder_id \ + -content_type $content_type \ + -name $item_name \ + -context_id $package_id \ + -mime_type $mime_type \ + -storage_type $storage_type \ + -creation_user $creation_user \ + -creation_ip $creation_ip \ + -description $description \ + -creation_date $creation_date] + } set revision_id [content::revision::new \ - -item_id $item_id \ - -content_type $content_type \ - -mime_type $mime_type \ - -title $title\ - -creation_user $creation_user \ - -creation_ip $creation_ip \ - -creation_date $creation_date \ - -description $description \ - -attributes [list [list evaluation_item_id $item_id] \ - [list party_id $party_id] \ - [list grade $grade] \ - [list show_student_p $show_student_p] \ - [list task_item_id $task_item_id]]] + -item_id $item_id \ + -content_type $content_type \ + -mime_type $mime_type \ + -title $title\ + -creation_user $creation_user \ + -creation_ip $creation_ip \ + -creation_date $creation_date \ + -description $description \ + -attributes [list [list evaluation_item_id $item_id] \ + [list party_id $party_id] \ + [list grade $grade] \ + [list show_student_p $show_student_p] \ + [list task_item_id $task_item_id]]] -} +} ad_proc -public evaluation::new_evaluation_group { -group_id:required @@ -831,23 +831,23 @@ } { if { $creation_user eq "" } { - set creation_user [ad_conn user_id] + set creation_user [ad_conn user_id] } if { $creation_ip eq "" } { - set creation_ip [ad_conn peeraddr] + set creation_ip [ad_conn peeraddr] } if { $context eq "" } { - set context [ad_conn package_id] + set context [ad_conn package_id] } if { $creation_date eq "" } { - set creation_date [db_string get_date { *SQL* }] + set creation_date [db_string get_date { *SQL* }] } db_exec_plsql evaluation_group_new { *SQL* } - + return $group_id -} +} ad_proc -public evaluation::delete_evaluation_group { -group_id:required @@ -859,7 +859,7 @@ } { db_exec_plsql delete_evaluation_group { *SQL* } -} +} ad_proc -public evaluation::evaluation_group_name { -group_id:required @@ -869,7 +869,7 @@ } { return [db_exec_plsql evaluation_group_name { *SQL* }] -} +} ad_proc -public evaluation::new_grades_sheet { -item_id:required @@ -897,16 +897,16 @@ @param new_item_p If true make a new item using item_id @param task_item_id Task which "owns" the grades sheet @param title The name of the grades sheet - @param storage_type lob or file + @param storage_type lob or file @param mime_type Mime tipe of the grades sheet } { if { $creation_user eq "" } { - set creation_user [ad_conn user_id] + set creation_user [ad_conn user_id] } if { $creation_ip eq "" } { - set creation_ip [ad_conn peeraddr] + set creation_ip [ad_conn peeraddr] } set package_id [ad_conn package_id] set folder_id [content::item::get_id -item_path "${content_type}_${package_id}" -resolve_index f] @@ -915,36 +915,36 @@ set revision_id [db_nextval acs_object_id_seq] if { $publish_date eq "" } { - set publish_date [db_string get_date { *SQL* }] + set publish_date [db_string get_date { *SQL* }] } if { $creation_date eq "" } { - set creation_date [db_string get_date { *SQL* }] + set creation_date [db_string get_date { *SQL* }] } if { $new_item_p && ![db_string double_click { *SQL* }] } { set item_id [content::item::new -item_id $item_id \ - -parent_id $folder_id \ - -content_type $content_type \ - -name $item_name \ - -context_id $package_id \ - -mime_type $mime_type \ - -creation_user $creation_user \ - -creation_ip $creation_ip \ - -storage_type $storage_type] + -parent_id $folder_id \ + -content_type $content_type \ + -name $item_name \ + -context_id $package_id \ + -mime_type $mime_type \ + -creation_user $creation_user \ + -creation_ip $creation_ip \ + -storage_type $storage_type] - } + } set revision_id [content::revision::new \ - -item_id $item_id \ - -content_type $content_type \ - -title $title \ - -mime_type $mime_type \ - -creation_user $creation_user \ - -creation_ip $creation_ip \ - -attributes [list [list grades_sheet_item_id $item_id] \ - [list task_item_id $task_item_id]] ] + -item_id $item_id \ + -content_type $content_type \ + -title $title \ + -mime_type $mime_type \ + -creation_user $creation_user \ + -creation_ip $creation_ip \ + -attributes [list [list grades_sheet_item_id $item_id] \ + [list task_item_id $task_item_id]] ] return $revision_id -} +} ad_proc -public evaluation::generate_grades_sheet { } { @@ -953,63 +953,63 @@ @return text/csv to the client connection } { - # Get file_path from url - set url [ns_conn url] - - regexp {/grades-sheet-csv-([^.]+).csv$} $url match task_id - - if { ![db_0or1row get_task_info { *SQL* }] } { - # this should never happen + # Get file_path from url + set url [ns_conn url] + + regexp {/grades-sheet-csv-([^.]+).csv$} $url match task_id + + if { ![db_0or1row get_task_info { *SQL* }] } { + # this should never happen ad_return_error "No information" "There has been an error, there is no infomraiton about the task $task_id" - return - } - - set csv_content [list] - lappend csv_content "[_ evaluation.lt_Grades_sheet_for_assi]" + return + } + set csv_content [list] + lappend csv_content "[_ evaluation.lt_Grades_sheet_for_assi]" + lappend csv_content "\n[_ evaluation.Max_Grade_]" lappend csv_content "100" lappend csv_content "\n[_ evaluation.lt_Will_the_student_be_a]" lappend csv_content "1" - lappend csv_content "\n\n[_ evaluation.Id_]" - lappend csv_content "[_ evaluation.Name_]" - lappend csv_content "[_ evaluation.Grade_]" + lappend csv_content "\n\n[_ evaluation.Id_]" + lappend csv_content "[_ evaluation.Name_]" + lappend csv_content "[_ evaluation.Grade_]" lappend csv_content "[_ evaluation.CommentsEdit_reason_]" - + if { $number_of_members == 1 } { - # the task is individual + # the task is individual - set community_id [dotlrn_community::get_community_id] - if { $community_id eq "" } { - set sql_query [db_map sql_query_individual] - } else { - set sql_query [db_map sql_qyery_comm_ind] - } + set community_id [dotlrn_community::get_community_id] + if { $community_id eq "" } { + set sql_query [db_map sql_query_individual] + } else { + set sql_query [db_map sql_qyery_comm_ind] + } - } else { - # the task is in groups - - set sql_query [db_map sql_query_groups] + } else { + # the task is in groups + + set sql_query [db_map sql_query_groups] } - + db_foreach parties_with_to_grade { *SQL* } { - if { $grade ne "" } { - set grade [lc_numeric $grade] - } - lappend csv_content "\n$party_id" - lappend csv_content "$party_name" - lappend csv_content "$grade" - lappend csv_content "$comments" - } if_no_rows { - ad_return_error "[_ evaluation.No_parties_to_grade_]" "[_ evaluation.lt_In_order_to_generate_]" - return - } - - set csv_formatted_content [join $csv_content ","] - - doc_return 200 text/csv " - $csv_formatted_content" + if { $grade ne "" } { + set grade [lc_numeric $grade] + } + lappend csv_content "\n$party_id" + lappend csv_content "$party_name" + lappend csv_content "$grade" + lappend csv_content "$comments" + } if_no_rows { + ad_return_error "[_ evaluation.No_parties_to_grade_]" "[_ evaluation.lt_In_order_to_generate_]" + return + } + + set csv_formatted_content [join $csv_content ","] + + doc_return 200 text/csv " + $csv_formatted_content" } ad_proc -public evaluation::apm::delete_one_assignment_impl {} { @@ -1030,31 +1030,31 @@ ad_proc -public evaluation::apm::create_one_assignment_impl {} { Register the service contract implementation and return the impl_id. - @return impl_id of the created implementation + @return impl_id of the created implementation } { return [acs_sc::impl::new_from_spec -spec { - name one_assignment_notif_type - contract_name NotificationType - owner evaluation - aliases { - GetURL evaluation::notification::get_url - ProcessReply evaluation::notification::process_reply - } + name one_assignment_notif_type + contract_name NotificationType + owner evaluation + aliases { + GetURL evaluation::notification::get_url + ProcessReply evaluation::notification::process_reply + } }] } ad_proc -public evaluation::apm::create_one_evaluation_impl {} { Register the service contract implementation and return the impl_id. - @return impl_id of the created implementation + @return impl_id of the created implementation } { return [acs_sc::impl::new_from_spec -spec { - name one_evaluation_notif_type - contract_name NotificationType - owner evaluation - aliases { - GetURL evaluation::notification::get_url - ProcessReply evaluation::notification::process_reply - } + name one_evaluation_notif_type + contract_name NotificationType + owner evaluation + aliases { + GetURL evaluation::notification::get_url + ProcessReply evaluation::notification::process_reply + } }] } @@ -1065,10 +1065,10 @@ @return the type_id of the created type } { return [notification::type::new \ - -sc_impl_id $impl_id \ - -short_name one_assignment_notif \ - -pretty_name "[_ evaluation.One_Assignment_]" \ - -description "[_ evaluation.lt_Notification_for_assi]"] + -sc_impl_id $impl_id \ + -short_name one_assignment_notif \ + -pretty_name "[_ evaluation.One_Assignment_]" \ + -description "[_ evaluation.lt_Notification_for_assi]"] } ad_proc -public evaluation::apm::create_one_evaluation_type { @@ -1078,10 +1078,10 @@ @return the type_id of the created type } { return [notification::type::new \ - -sc_impl_id $impl_id \ - -short_name one_evaluation_notif \ - -pretty_name "[_ evaluation.One_Evaluation_]" \ - -description "[_ evaluation.lt_Notification_for_eval]"] + -sc_impl_id $impl_id \ + -short_name one_evaluation_notif \ + -pretty_name "[_ evaluation.One_Evaluation_]" \ + -description "[_ evaluation.lt_Notification_for_eval]"] } ad_proc -public evaluation::apm::enable_intervals_and_methods { @@ -1091,21 +1091,21 @@ } { # Enable the various intervals and delivery method notification::type::interval_enable \ - -type_id $type_id \ - -interval_id [notification::interval::get_id_from_name -name instant] - + -type_id $type_id \ + -interval_id [notification::interval::get_id_from_name -name instant] + notification::type::interval_enable \ - -type_id $type_id \ - -interval_id [notification::interval::get_id_from_name -name hourly] - + -type_id $type_id \ + -interval_id [notification::interval::get_id_from_name -name hourly] + notification::type::interval_enable \ - -type_id $type_id \ - -interval_id [notification::interval::get_id_from_name -name daily] - + -type_id $type_id \ + -interval_id [notification::interval::get_id_from_name -name daily] + # Enable the delivery methods notification::type::delivery_method_enable \ - -type_id $type_id \ - -delivery_method_id [notification::delivery::get_id -short_name email] + -type_id $type_id \ + -delivery_method_id [notification::delivery::get_id -short_name email] } @@ -1117,18 +1117,18 @@ their respective values. } { set cmd [parameter::get -parameter ArchiveCommand -default "cat `find {in_file} -type f` > {out_file}"] - + regsub -all {(\W)} $in_file {\\\1} in_file regsub -all {\\/} $in_file {/} in_file regsub -all {\\\.} $in_file {.} in_file - + regsub -all {(\W)} $out_file {\\\1} out_file regsub -all {\\/} $out_file {/} out_file regsub -all {\\\.} $out_file {.} out_file - + regsub -all {{in_file}} $cmd $in_file cmd regsub -all {{out_file}} $cmd $out_file cmd - + return $cmd } @@ -1144,37 +1144,37 @@ file mkdir $dir db_foreach get_answers_for_task { *SQL* } { - if { $storage_type eq "lob" || $storage_type eq "file" } { - # it is a file - - regsub -all {[<>:\"|/@\\\#%&+\\ ,]} $party_name {_} file_name - append file_name [file extension $answer_title] - - if {$storage_type eq "file"} { - # its a file - - file copy -- "[cr_fs_path $cr_path]${cr_file_name}" [file join ${dir} ${file_name}] - } else { - # its a lob - db_blob_get_file select_object_content { *SQL* } -file [file join ${dir} ${file_name}] - } - - } else { - # it is a url + if { $storage_type eq "lob" || $storage_type eq "file" } { + # it is a file - set url [db_string url { *SQL* }] + regsub -all {[<>:\"|/@\\\#%&+\\ ,]} $party_name {_} file_name + append file_name [file extension $answer_title] - - set file_name "${party_name}.url" - - regsub -all {[<>:\"|/@\\\#%&+\\ ,]} $file_name {_} file_name - set fp [open [file join ${dir} ${file_name}] w] - puts $fp {[InternetShortcut]} - puts $fp URL=$url - close $fp - } + if {$storage_type eq "file"} { + # its a file + + file copy -- "[cr_fs_path $cr_path]${cr_file_name}" [file join ${dir} ${file_name}] + } else { + # its a lob + db_blob_get_file select_object_content { *SQL* } -file [file join ${dir} ${file_name}] + } + + } else { + # it is a url + + set url [db_string url { *SQL* }] + + + set file_name "${party_name}.url" + + regsub -all {[<>:\"|/@\\\#%&+\\ ,]} $file_name {_} file_name + set fp [open [file join ${dir} ${file_name}] w] + puts $fp {[InternetShortcut]} + puts $fp URL=$url + close $fp + } } - + return $dir db_foreach get_answers_for_task} @@ -1190,21 +1190,21 @@ } { Proc called in after upgrade callback from version 0.4d3 to 0.4d4. Sets points field in table evaluation_tasks. - + } { - + set grades [db_list_of_lists get_grades {}] foreach grade $grades { - set grade_id [lindex $grade 0] - set tasks [db_list_of_lists get_grade_tasks {}] - set grade_weight [lindex $grade 1] - - foreach task $tasks { - set task_id [lindex $task 0] - set task_weight [lindex $task 1] - set points [format %0.2f [expr ($task_weight*$grade_weight)/100.00]] - db_dml update_task {} - } + set grade_id [lindex $grade 0] + set tasks [db_list_of_lists get_grade_tasks {}] + set grade_weight [lindex $grade 1] + + foreach task $tasks { + set task_id [lindex $task 0] + set task_weight [lindex $task 1] + set points [format %0.2f [expr ($task_weight*$grade_weight)/100.00]] + db_dml update_task {} + } } } @@ -1216,9 +1216,9 @@ # } { # set enable_p 0 # set enable_p [db_string enable {} -default 1] - + # if {$enable_p > 1} { -# set enable_p 0 +# set enable_p 0 # } # return $enable_p # } @@ -1227,16 +1227,16 @@ } { Proc called in after upgrade callback from version 0.4d4 to 0.4d5. Sets perfect_score field in table evaluation_tasks. - + } { set tasks [db_list_of_lists get_tasks {}] set perfect_score 100 db_transaction { - foreach task_id $tasks { - db_dml update_task {} - } - } + foreach task_id $tasks { + db_dml update_task {} + } + } } ad_proc -public evaluation::clone_grade { @@ -1251,71 +1251,71 @@ -plural_name:required -package_id:required } { - + Build a new content revision of a evaluation subtype. If new_item_p is set true then a new item is first created, otherwise a new revision is created for the item indicated by item_id. - + @param item_id The item to update or create. @param content_type The type to make @param content_table @param new_item_p If true make a new item using item_id - + } { - + set creation_user [ad_conn user_id] set creation_ip [ad_conn peeraddr] - + set item_name "${content_type}_${item_id}" - + set revision_id [db_nextval acs_object_id_seq] set revision_name "${content_type}_${revision_id}" - + if { $new_item_p } { - db_exec_plsql content_item_new { *SQL* } - + db_exec_plsql content_item_new { *SQL* } + } - + db_exec_plsql content_revision_new { *SQL* } - + return $revision_id -} +} ad_proc -public evaluation::set_relative_weight { } { Proc called in after upgrade callback from version 0.4d5 to 0.4d6. Sets relative_weight field in table evaluation_tasks. - + } { set tasks [db_list_of_lists get_tasks {}] set relative_weight 1 db_transaction { foreach task_id $tasks { - db_dml update_task {} - } + db_dml update_task {} + } } } ad_proc -public evaluation::set_forums_related { } { Proc called in after upgrade callback from version 0.4d7 to 0.4d8. Sets forums_related_p field in table evaluation_tasks. - + } { set tasks [db_list_of_lists get_tasks {}] set forums_related_p "f" db_transaction { foreach task_id $tasks { - db_dml update_task {} - } + db_dml update_task {} + } } } -ad_register_proc GET /grades-sheet-csv* evaluation::generate_grades_sheet +ad_register_proc GET /grades-sheet-csv* evaluation::generate_grades_sheet ad_register_proc POST /grades-sheet-csv* evaluation::generate_grades_sheet # Local variables: