Index: openacs-4/packages/assessment/tcl/as-checks-procs-postgresql.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/assessment/tcl/as-checks-procs-postgresql.xql,v diff -u -N -r1.2 -r1.3 --- openacs-4/packages/assessment/tcl/as-checks-procs-postgresql.xql 27 Jan 2005 18:07:37 -0000 1.2 +++ openacs-4/packages/assessment/tcl/as-checks-procs-postgresql.xql 28 Jan 2005 20:31:32 -0000 1.3 @@ -17,14 +17,14 @@ - select inter_item_check_id,action_p,check_sql,postcheck_p,section_id_from,section_id_to,item_id,name,description from as_inter_item_checks where section_id_from=:section_id + select inter_item_check_id,action_p,check_sql,postcheck_p,section_id_from,section_id_to,item_id,name,description,assessment_id from as_inter_item_checks where section_id_from=:section_id and assessment_id=:assessment_id - select as_inter_item_check__new (null,:action_p,:section_id_from,null,:check_sql,:name,:description,:postcheck_p,null,:user_id,null) + select as_inter_item_check__new (null,:action_p,:section_id_from,null,:check_sql,:name,:description,:postcheck_p,null,:user_id,null,:assessment_id) @@ -34,5 +34,10 @@ select as_inter_item_check__delete (:check_id) + + + select to_date(now(),'YYYY-MM-DD') as today, to_date(to_date(now(),'YYYY-MM-DD')-1,'YYYY-MM-DD') as yesterday, to_date (to_date(now(),'YYYY-MM-DD')-2,'YYYY-MM-DD') as two_days,to_date (to_date(now(),'YYYY-MM-DD')-7,'YYYY-MM-DD') as last_week, to_date (to_date(now(),'YYYY-MM-DD')-30,'YYYY-MM-DD') as last_month + + \ No newline at end of file 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 -N -r1.7 -r1.8 --- openacs-4/packages/assessment/tcl/as-checks-procs.tcl 27 Jan 2005 18:07:37 -0000 1.7 +++ openacs-4/packages/assessment/tcl/as-checks-procs.tcl 28 Jan 2005 20:31:32 -0000 1.8 @@ -20,8 +20,9 @@ } { set package_id [ad_conn package_id] set assessment_list [list [list "[_ assessment.all]" "all"]] - db_foreach assessment {} { - lappend assessment_list [list $title $assessment_id] + set assessments [db_list_of_lists assessment {}] + foreach assessment $assessments { + lappend assessment_list [list [lindex $assessment 0] [lindex $assessment 1]] } return $assessment_list @@ -39,13 +40,8 @@ } { Return the time intervals } { + db_1row intervals {} - set today [db_string today {}] - set yesterday [db_string yesterday {}] - set two_days [db_string two_days {}] - set last_week [db_string last_week {}] - set last_month [db_string last_month {}] - set intervals [list [list "[_ assessment.all]" "all"] [list "[_ assessment.today]" $today] [list "[_ assessment.yesterday]" $yesterday] [list "[_ assessment.two_days]" $two_days] [list "[_ assessment.last_week]" $last_week] [list "[_ assessment.last_month]" $last_month]] } @@ -68,7 +64,7 @@ } { Return the next value for order_by } { - set order [db_string get_max_order {}] + set order [db_string get_max_order {} -default 1] if { $order == ""} { set order 1 } else { @@ -101,7 +97,7 @@ } { } { - set exists_p [db_string get_check_id {select inter_item_check_id from as_param_map where parameter_id=:parameter_id and inter_item_check_id = :check_id } -default 0] + set exists_p [db_string get_check_id {} -default 0] if { $type == "n"} { if {$exists_p != 0} { @@ -179,11 +175,11 @@ } { } { + set user_id [ad_conn user_id] + set log_id [db_string get_next_val {}] + set action_id [db_string action_id {}] db_transaction { - set user_id [ad_conn user_id] - set log_id [db_string get_next_val {}] - set action_id [db_string action_id {}] db_dml insert_action {} } } @@ -195,13 +191,13 @@ } { } { - + set user_id [ad_conn user_id] + set log_id [db_string get_next_val {}] + set action_id [db_string action_id {}] + db_transaction { - set user_id [ad_conn user_id] - set log_id [db_string get_next_val {}] - set action_id [db_string action_id {}] db_dml insert_action {} - + } } @@ -218,7 +214,7 @@ set $varname "" if {$value == ""} { - set choice [db_0or1row get_item_choice {}] + set choice [db_list_of_lists get_item_choice {}] set answer [db_0or1row get_answer {}] if {[exists_and_not_null choice_id]} { set $varname "$choice_id" @@ -261,7 +257,7 @@ set $varname "" if {$value == ""} { - set choice [db_0or1row get_item_choice {}] + set choice [db_list_of_lists get_item_choice {}] set answer [db_0or1row get_answer {}] if {[exists_and_not_null choice_id]} { set $varname "$choice_id" @@ -303,10 +299,10 @@ } { set section_checks [db_list_of_lists section_checks { }] - ns_log notice "$section_checks" + foreach check $section_checks { set check_sql [lindex $check 1] - set perform [db_string check_sql $check_sql] + set perform [db_string check_sql $check_sql -default 0] if {[lindex $check 2] == "t"} { if {$perform == 1} { as::assessment::check::action_exec -inter_item_check_id [lindex $check 0] -session_id $session_id @@ -329,7 +325,8 @@ set perform 0 db_foreach section_checks {} { - set new_assessment_revision [db_string get_assessment_id {select max(revision_id) from cr_revisions where item_id=:assessment_id}] + as::assessment::data -assessment_id $assessment_id + set new_assessment_revision $assessment_data(assessment_rev_id) #parse condition_sql to get item_id set cond_list [split $check_sql "="] @@ -370,8 +367,6 @@ set assessment_rev_id [db_string get_assessment_id {}] - set section_list [db_list_of_lists sections {}] - foreach section_id $section_list { set checks [db_list_of_lists section_checks {}] foreach check $checks { set info [db_0or1row check_info {}] @@ -382,7 +377,7 @@ } } } - } + } @@ -393,10 +388,7 @@ } { - set assessment_rev_id [db_string get_assessment_id {}] - - db_foreach sections {} { - db_foreach section_checks {} { + db_foreach assessment_checks {} { if {$action_p == "t"} { set perform [db_string check_sql $check_sql] @@ -406,8 +398,8 @@ as::assessment::check::manual_action_log -check_id $inter_item_check_id -session_id $session_id } } + } - } } @@ -459,6 +451,7 @@ ad_proc -public as::assessment::check::copy_checks { {-section_id:required} {-new_section_id:required} + {-assessment_id:required} } { } { @@ -475,6 +468,7 @@ set item_id [lindex $check 6] set name [lindex $check 7] set description [lindex $check 8] + set insert_p [db_exec_plsql copy_check {}] @@ -518,7 +512,7 @@ } ad_proc -public as::assessment::check::delete_assessment_checks { - {-assessment_rev_id:required} + {-assessment_id:required} } { } { Index: openacs-4/packages/assessment/tcl/as-checks-procs.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/assessment/tcl/as-checks-procs.xql,v diff -u -N -r1.4 -r1.5 --- openacs-4/packages/assessment/tcl/as-checks-procs.xql 27 Jan 2005 18:07:37 -0000 1.4 +++ openacs-4/packages/assessment/tcl/as-checks-procs.xql 28 Jan 2005 20:31:32 -0000 1.5 @@ -8,34 +8,7 @@ - - - select to_date(now(),'YYYY-MM-DD') - - - - - select to_date (to_date(now(),'YYYY-MM-DD')-1,'YYYY-MM-DD') - - - - - - select to_date (to_date(now(),'YYYY-MM-DD')-2,'YYYY-MM-DD') - - - - - select to_date (to_date(now(),'YYYY-MM-DD')-7,'YYYY-MM-DD') - - - - - select to_date (to_date(now(),'YYYY-MM-DD')-30,'YYYY-MM-DD') - - - select max(am.order_by) from as_action_map am,as_inter_item_checks c @@ -62,6 +35,13 @@ + + + select inter_item_check_id from as_param_map where parameter_id=:parameter_id and inter_item_check_id = :check_id + + + + insert into as_param_map (parameter_id,inter_item_check_id,value,item_id) values (:parameter_id,:check_id,null,:value) @@ -256,25 +236,19 @@ select max(revision_id) from cr_revisions where item_id=:assessment_id - - - select s.section_id from as_sections s, cr_revisions cr, cr_items ci, as_assessment_section_map asm where ci.item_id = cr.item_id and cr.revision_id = s.section_id and s.section_id = asm.section_id and asm.assessment_id =:assessment_rev_id order by asm.sort_order - - + - select c.inter_item_check_id as check from as_inter_item_checks c,as_action_map am where c.inter_item_check_id=am.inter_item_check_id and am.action_perform='aa' and section_id_from=:section_id order by am.order_by + select c.inter_item_check_id as check from as_inter_item_checks c,as_action_map am where c.inter_item_check_id=am.inter_item_check_id and am.action_perform='aa' and c.assessment_id=:assessment_id select * from as_inter_item_checks c,as_action_map am where c.inter_item_check_id=am.inter_item_check_id and am.action_perform='aa' - and section_id_from=:section_id and c.inter_item_check_id=:check order by am.order_by + and c.assessment_id=:assessment_id and c.inter_item_check_id=:check order by am.order_by - - select max(revision_id) from cr_revisions where item_id=:assessment_id @@ -285,9 +259,9 @@ select s.section_id from as_sections s, cr_revisions cr, cr_items ci, as_assessment_section_map asm where ci.item_id = cr.item_id and cr.revision_id = s.section_id and s.section_id = asm.section_id and asm.assessment_id =:assessment_rev_id order by asm.sort_order - + - select * from as_inter_item_checks c,as_action_map am where c.inter_item_check_id=am.inter_item_check_id and am.action_perform='m' and section_id_from=:section_id order by am.order_by + select * from as_inter_item_checks c,as_action_map am where c.inter_item_check_id=am.inter_item_check_id and am.action_perform='m' and c.assessment_id=:assessment_id order by am.order_by @@ -351,8 +325,7 @@ - select inter_item_check_id from as_inter_item_checks where section_id_from in (select s.section_id from as_sections s, cr_revisions cr, cr_items ci, as_assessment_section_map asm where ci.item_id = cr.item_id and cr.revision_id = s.section_id and s.section_id = asm.section_id and asm.assessment_id =:assessment_rev_id) + select inter_item_check_id from as_inter_item_checks where section_id_from in (select s.section_id from as_sections s, cr_revisions cr, cr_items ci, as_assessment_section_map asm where ci.item_id = cr.item_id and cr.revision_id = s.section_id and s.section_id = asm.section_id and asm.assessment_id =:assessment_id) - Index: openacs-4/packages/assessment/tcl/as-section-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/assessment/tcl/as-section-procs.tcl,v diff -u -N -r1.16 -r1.17 --- openacs-4/packages/assessment/tcl/as-section-procs.tcl 25 Jan 2005 12:47:22 -0000 1.16 +++ openacs-4/packages/assessment/tcl/as-section-procs.tcl 28 Jan 2005 20:31:32 -0000 1.17 @@ -16,6 +16,7 @@ {-num_items ""} {-display_type_id ""} {-points ""} + } { @author Eduardo Perez (eperez@it.uc3m.es) @creation-date 2004-07-26 @@ -59,6 +60,7 @@ {-num_items ""} {-display_type_id ""} {-points ""} + {-assessment_id:required} } { @author Timo Hentschel (timo@timohentschel.de) @creation-date 2004-10-26 @@ -82,13 +84,15 @@ [list points $points] ] ] copy_items -section_id $section_id -new_section_id $new_section_id + as::assessment::check::copy_checks -section_id $section_id -new_section_id $new_section_id -assessment_id $assessment_id } return $new_section_id } ad_proc -public as::section::new_revision { {-section_id:required} + {-assessment_id:required} } { @author Timo Hentschel (timo@timohentschel.de) @creation-date 2004-11-07 @@ -112,6 +116,7 @@ copy_items -section_id $section_id -new_section_id $new_section_id as::assessment::copy_categories -from_id $section_id -to_id $new_section_id + as::assessment::check::copy_checks -section_id $section_id -new_section_id $new_section_id -assessment_id $assessment_id } return $new_section_id @@ -136,6 +141,7 @@ ad_proc -public as::section::copy { {-section_id:required} {-name ""} + {-assessment_id:required} } { @author Timo Hentschel (timo@timohentschel.de) @creation-date 2004-11-07 @@ -170,6 +176,7 @@ copy_items -section_id $section_id -new_section_id $new_section_id as::assessment::copy_categories -from_id $section_id -to_id $new_section_id + as::assessment::check::copy_checks -section_id $section_id -new_section_id $new_section_id -assessment_id $assessment_id } return $new_section_id