Index: openacs-4/packages/assessment/tcl/as-checks-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/assessment/tcl/as-checks-procs.tcl,v diff -u -r1.31 -r1.31.2.1 --- openacs-4/packages/assessment/tcl/as-checks-procs.tcl 9 May 2018 15:33:29 -0000 1.31 +++ openacs-4/packages/assessment/tcl/as-checks-procs.tcl 17 Jun 2020 15:16:02 -0000 1.31.2.1 @@ -15,7 +15,7 @@ ad_proc -public as::assessment::check::get_assessments { } { - + } { set package_id [ad_conn package_id] set user_id [ad_conn user_id] @@ -27,13 +27,13 @@ foreach assessment $assessments { lappend assessment_list [list [lindex $assessment 0] [lindex $assessment 1]] } - + return $assessment_list } ad_proc -public as::assessment::check::state_options { } { - + } { set approved_options [list [list "[_ assessment.approved]" "t"] [list "[_ assessment.approved_with]" "ae"] [list "[_ assessment.not_approved]" "f"] ] return $approved_options @@ -48,7 +48,7 @@ set two_days [clock format [clock scan "2 days ago"] -format %Y-%m-%d] set last_week [clock format [clock scan "1 week ago"] -format %Y-%m-%d] set last_month [clock format [clock scan "1 month ago"] -format %Y-%m-%d] - + return [list [list [_ assessment.all] "all"] \ [list [_ assessment.today] $today] \ [list [_ assessment.yesterday] $yesterday] \ @@ -95,7 +95,7 @@ return [db_string get_param_n {} -default " "] } else { return [db_string get_param_q {} -default " "] - + } } @@ -106,10 +106,10 @@ {-check_id} {-type} } { - + } { set exists_p [db_string get_check_id {} -default 0] - + if { $type eq "n"} { if {$exists_p != 0} { db_dml param_value_update_n {} @@ -122,17 +122,17 @@ } else { db_dml param_value_insert_q {} } - + } - + } ad_proc -public as::assessment::check::re_order_actions { {-check_id} {-action_perform} {-section_id} } { - + } { set order_by [db_string get_order_by {}] set count 0 @@ -141,19 +141,19 @@ db_dml update_order {} incr count } - + } ad_proc -public as::assessment::check::get_sql { {-item_id} {-condition} } { - + } { set as_item_id [db_string get_item_id {select item_id from cr_revisions where revision_id=:item_id}] - + set check_sql "select (case when idc.choice_id in (select revision_id from cr_revisions where item_id=$condition) then \'1\' else \'0\' end) as perform_p from as_item_data id, as_item_data_choices idc where id.as_item_id in (select revision_id from cr_revisions where item_id=$as_item_id) and id.item_data_id=idc.item_data_id and id.session_id=:session_id" - + return $check_sql } @@ -165,7 +165,7 @@ {-direction} {-order_by} } { - + } { if { $direction eq "d"} { set order_p [expr {$order_by + 1}] @@ -177,16 +177,16 @@ set swap_check_id [db_string get_swap_check_e {}] db_dml update_1_e {} db_dml update_2_e {} - + } - + } ad_proc -public as::assessment::check::action_log { {-session_id} {-check_id} {-failed } } { - + } { set user_id [ad_conn user_id] set log_id [db_string get_next_val {}] @@ -199,15 +199,15 @@ db_transaction { db_dml insert_action {} } - + } ad_proc -public as::assessment::check::manual_action_log { {-session_id} {-check_id} - + } { - + } { set user_id [ad_conn user_id] set log_id [db_string get_next_val {}] @@ -216,27 +216,27 @@ db_transaction { db_dml insert_action {} - + } } ad_proc -public as::assessment::check::action_exec { {-inter_item_check_id} {-session_id} -} { - } { + +} { set error_txt "" db_foreach get_check_params {} { set parameter_name [db_1row select_name {}] - + set $varname "" - + if {$value eq ""} { set choice [db_list_of_lists get_item_choice {}] - set answer [db_0or1row get_answer {}] + set answer [db_0or1row get_answer {}] if {([info exists choice_id] && $choice_id ne "")} { set $varname "$choice_id" } else { @@ -265,47 +265,47 @@ } - + set tcl_code_p [db_1row select_tcl {}] set failed_p "f" if {[catch $tcl_code errorMsg]} { set failed_p "t" ns_log error "Error running assessment action $action_name '${errorMsg}'" } set admin [db_list_of_lists get_assessment_admin {}] - + set to [list] foreach notify_user $admin { lappend to $notify_user } - + if {$failed_p} { notification::new -type_id [notification::type::get_type_id -short_name inter_item_check_notif] -object_id $inter_item_check_id -notif_subject "$action_name has been executed" -notif_text "The action $action_name has encountered an error: $errorMsg" -subset $to -force -action_id $inter_item_check_id } - - + + as::assessment::check::action_log -session_id $session_id -check_id $inter_item_check_id -failed $failed_p - + } ad_proc -public as::assessment::check::manual_action_exec { {-inter_item_check_id} {-session_id} {-action_log_id} -} { - } { + +} { db_0or1row subject_id {select subject_id from as_sessions where session_id=:session_id} db_foreach get_check_params {} { set parameter_name [db_1row select_name {}] - + set $varname "" - + if {$value eq ""} { set choice [db_list_of_lists get_item_choice {}] - set answer [db_0or1row get_answer {}] + set answer [db_0or1row get_answer {}] if {([info exists choice_id] && $choice_id ne "")} { set $varname "$choice_id" } else { @@ -327,27 +327,27 @@ if { [info exists content_answer] } { append $varname $content_answer } - + } } else { set $varname $value } } - + set tcl_code_p [db_1row select_tcl {}] set failed_p "t" set failed [catch $tcl_code] if { $failed > 0 } { set failed_p "f" } - + set user_id [ad_conn user_id] db_dml update_actions_log {} set admin [db_list_of_lists get_assessment_admin {}] - + set to [list] foreach notify_user $admin { lappend to $notify_user @@ -356,7 +356,7 @@ notification::new -type_id [notification::type::get_type_id -short_name inter_item_check_notif] -object_id $inter_item_check_id -notif_subject "$action_name has been executed" -notif_text "The action $action_name has been executed. This message has been showed to the user: $user_message" -subset $to -force -action_id $inter_item_check_id } - + } @@ -365,9 +365,9 @@ {-session_id} {-section_id} } { - + } { - + set section_checks [db_list_of_lists section_checks {}] foreach check $section_checks { @@ -387,24 +387,24 @@ {-section_id} {-assessment_id} } { - + } { set order "f" set perform 0 set checks [db_list_of_lists section_checks {}] - + foreach check $checks { as::assessment::data -assessment_id $assessment_id set new_assessment_revision $assessment_data(assessment_rev_id) set section_id_to [lindex $check 2] set perform [db_string check_sql "[lindex $check 0]" -default 0] - + if {$perform == 1} { set order [db_string get_order {}] } - + } - + if {$order == "f"} { return $order } { @@ -419,7 +419,7 @@ {-session_id} {-assessment_id} } { - + } { set assessment_rev_id [db_string get_assessment_id {}] @@ -435,41 +435,41 @@ } } } - + } ad_proc -public as::assessment::check::eval_m_checks { {-session_id} {-assessment_id} } { - + } { db_foreach assessment_checks {} { if {$action_p == "t"} { set perform [db_string check_sql $check_sql -default 0] - + if {$perform == 1} { set failed "" - as::assessment::check::manual_action_log -check_id $inter_item_check_id -session_id $session_id + as::assessment::check::manual_action_log -check_id $inter_item_check_id -session_id $session_id } } - + } - + } ad_proc -public as::assessment::check::eval_or_checks { {-session_id} {-section_id} } { - + } { - + set section_checks [db_list_of_lists section_checks {}] - + foreach check $section_checks { set check_sql [lindex $check 1] set perform [db_string check_sql $check_sql -default 0] @@ -486,7 +486,7 @@ {-session_id} {-assessment_id} } { - + } { set assessment_rev_id [db_string get_assessment_id {}] @@ -502,35 +502,35 @@ } } } - + } ad_proc -public as::assessment::check::confirm_display { {-check_id} {-index} } { - + } { set show_check_info "" set mod "" - + set info [db_0or1row get_check_info {}] - - + + set mod [expr {$index%2}] - + if {$mod==0} { set class "odd" } else { set class "even" } - + set action "" set parameter_list "" if { $action_p=="t"} { set info [db_0or1row get_check_info_a {}] - + db_foreach parameters {} { append parameter_list "
  • $varname: " if {$type eq "q"} { @@ -539,14 +539,14 @@ append parameter_list "$item_id" } } - + set action "$name$action_name" } else { set section_name_to [db_string get_section_name {} ] - set action "$name$section_name_to" + set action "$name$section_name_to" } - - + + set display_info $action return $display_info } @@ -556,12 +556,12 @@ {-new_section_id:required} {-assessment_id:required} } { - + } { set user_id [ad_conn user_id] set checks [db_list_of_lists get_checks {}] foreach check $checks { - + set inter_item_check_id [lindex $check 0] db_dml update_checks {} } @@ -573,7 +573,7 @@ {-section_id:required} {-new_section_id:required} } { - + } { set checks [db_list_of_lists checks {}] foreach check_id $checks { @@ -584,7 +584,7 @@ ad_proc -public as::assessment::check::delete_assessment_checks { {-assessment_id:required} } { - + } { set checks [db_list_of_lists assessment_checks {}] foreach check_id $checks { @@ -596,7 +596,7 @@ {-section_id} {-as_item_id} } { - + } { set checks [db_list_of_lists related_checks {}] foreach check $checks { @@ -616,23 +616,23 @@ {-as_item_id} {-new_item_id} } { - + } { set checks [db_list_of_lists related_checks {}] set user_id [ad_conn user_id] foreach check $checks { - + set cond_list [split [lindex $check 1] "="] set item_id [lindex [split [lindex $cond_list 2] ")"] 0] set condition [lindex [split [lindex $cond_list 1] ")"] 0] - + if {$item_id == $as_item_id} { set inter_item_check_id [lindex $check 0] set check_sql [as::assessment::check::get_sql -item_id $new_item_id -condition $condition] - + db_dml update_checks {} - + } } } @@ -643,15 +643,15 @@ {-assessment_id} {-inter_item_check_id} } { - + } { - db_1row get_check_info {} - + db_1row get_check_info {} + set perform [db_string check_sql $check_sql -default 0] ns_log notice "$check_sql $perform" if {$perform == 1} { set failed "" - as::assessment::check::manual_action_log -check_id $inter_item_check_id -session_id $session_id + as::assessment::check::manual_action_log -check_id $inter_item_check_id -session_id $session_id } } @@ -660,7 +660,7 @@ {-assessment_id:required} {-inter_item_check_id:required} } { - + } { set sessions [db_list_of_lists get_sessions {select session_id from as_sessions where assessment_id=:assessment_id}] foreach session_id $sessions {