Index: openacs-4/packages/assessment/assessment.info =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/assessment/assessment.info,v diff -u -r1.16 -r1.17 --- openacs-4/packages/assessment/assessment.info 8 Jan 2005 10:51:19 -0000 1.16 +++ openacs-4/packages/assessment/assessment.info 18 Jan 2005 12:42:49 -0000 1.17 @@ -7,7 +7,7 @@ f f - + oracle postgresql @@ -20,7 +20,7 @@ 0 E-LANE Create assessments and evalueate. - + Index: openacs-4/packages/assessment/sql/postgresql/assessment-collected-data-create.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/assessment/sql/postgresql/assessment-collected-data-create.sql,v diff -u -r1.5 -r1.6 --- openacs-4/packages/assessment/sql/postgresql/assessment-collected-data-create.sql 22 Dec 2004 20:52:17 -0000 1.5 +++ openacs-4/packages/assessment/sql/postgresql/assessment-collected-data-create.sql 18 Jan 2005 12:42:36 -0000 1.6 @@ -61,7 +61,8 @@ references persons(person_id), staff_id integer constraint as_section_data_staff_id_fk - references users(user_id) + references users(user_id), + points integer ); -- Assessment Item Data: is the "long skinny table" where all the primary data go Index: openacs-4/packages/assessment/sql/postgresql/upgrade/upgrade-0.09d-0.10d.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/assessment/sql/postgresql/upgrade/Attic/upgrade-0.09d-0.10d.sql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/assessment/sql/postgresql/upgrade/upgrade-0.09d-0.10d.sql 18 Jan 2005 12:42:36 -0000 1.1 @@ -0,0 +1 @@ +alter table as_section_data add points integer; Index: openacs-4/packages/assessment/tcl/as-assessment-procs-oracle.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/assessment/tcl/as-assessment-procs-oracle.xql,v diff -u -r1.3 -r1.4 --- openacs-4/packages/assessment/tcl/as-assessment-procs-oracle.xql 8 Dec 2004 15:30:34 -0000 1.3 +++ openacs-4/packages/assessment/tcl/as-assessment-procs-oracle.xql 18 Jan 2005 12:42:36 -0000 1.4 @@ -20,4 +20,19 @@ + + + + select count(*) + from as_assessment_section_map m, as_session_sections s, as_section_data d + where d.section_id(+) = s.section_id + and d.session_id(+) = s.session_id + and s.session_id = :session_id + and m.section_id = s.section_id + and m.assessment_id = :assessment_id + and d.points is null + + + + Index: openacs-4/packages/assessment/tcl/as-assessment-procs-postgresql.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/assessment/tcl/as-assessment-procs-postgresql.xql,v diff -u -r1.3 -r1.4 --- openacs-4/packages/assessment/tcl/as-assessment-procs-postgresql.xql 6 Dec 2004 12:26:53 -0000 1.3 +++ openacs-4/packages/assessment/tcl/as-assessment-procs-postgresql.xql 18 Jan 2005 12:42:36 -0000 1.4 @@ -20,4 +20,19 @@ + + + + select count(*) + from as_assessment_section_map m, as_session_sections s + left outer join as_section_data d on (d.section_id = s.section_id + and d.session_id = s.session_id) + where s.session_id = :session_id + and m.section_id = s.section_id + and m.assessment_id = :assessment_id + and d.points is null + + + + Index: openacs-4/packages/assessment/tcl/as-assessment-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/assessment/tcl/as-assessment-procs.tcl,v diff -u -r1.12 -r1.13 --- openacs-4/packages/assessment/tcl/as-assessment-procs.tcl 14 Jan 2005 13:13:37 -0000 1.12 +++ openacs-4/packages/assessment/tcl/as-assessment-procs.tcl 18 Jan 2005 12:42:36 -0000 1.13 @@ -272,6 +272,24 @@ return $section_list } +ad_proc -public as::assessment::calculate { + -assessment_id:required + -session_id:required +} { + @author Timo Hentschel (timo@timohentschel.de) + @creation-date 2005-01-14 + + Award points to this assessment if all sections are filled out +} { + if {[db_string check_sections_calculated {}] > 0} { + return + } + + db_1row sum_of_section_points {} + set percent_score [expr round(100 * $section_points / $section_max_points)] + db_dml update_assessment_percent {} +} + ad_proc as::assessment::pretty_time { {-seconds} } { @@ -358,3 +376,20 @@ return "$title" } } + +ad_proc -private as::assessment::compare_numbers {a b} { + @author Timo Hentschel (timo@timohentschel.de) + @creation-date 2005-01-18 + + Compares the first part of a pair of strings as numbers +} { + set a0 [expr double([lindex [lindex $a 0] 0])] + set b0 [expr double([lindex [lindex $b 0] 0])] + if {$a0 > $b0} { + return 1 + } elseif {$a0 == $b0} { + return 0 + } else { + return -1 + } +} Index: openacs-4/packages/assessment/tcl/as-assessment-procs.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/assessment/tcl/as-assessment-procs.xql,v diff -u -r1.7 -r1.8 --- openacs-4/packages/assessment/tcl/as-assessment-procs.xql 14 Jan 2005 13:13:37 -0000 1.7 +++ openacs-4/packages/assessment/tcl/as-assessment-procs.xql 18 Jan 2005 12:42:36 -0000 1.8 @@ -76,6 +76,29 @@ + + + + select sum(m.points) as section_max_points, sum(d.points) as section_points + from as_assessment_section_map m, as_section_data d + where m.assessment_id = :assessment_id + and m.section_id = d.section_id + and d.session_id = :session_id + + + + + + + + update as_sessions + set percent_score = :percent_score + where session_id = :session_id + and assessment_id = :assessment_id + + + + Index: openacs-4/packages/assessment/tcl/as-install-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/assessment/tcl/as-install-procs.tcl,v diff -u -r1.17 -r1.18 --- openacs-4/packages/assessment/tcl/as-install-procs.tcl 13 Jan 2005 17:51:59 -0000 1.17 +++ openacs-4/packages/assessment/tcl/as-install-procs.tcl 18 Jan 2005 12:42:36 -0000 1.18 @@ -175,6 +175,7 @@ content::type::attribute::new -content_type {as_section_data} -attribute_name {section_id} -datatype {number} -pretty_name {Section ID} -column_spec {integer} content::type::attribute::new -content_type {as_section_data} -attribute_name {subject_id} -datatype {number} -pretty_name {Subject ID} -column_spec {integer} content::type::attribute::new -content_type {as_section_data} -attribute_name {staff_id} -datatype {number} -pretty_name {Staff ID} -column_spec {integer} +content::type::attribute::new -content_type {as_section_data} -attribute_name {points} -datatype {number} -pretty_name {Points Awarded} -column_spec {integer} # Item data content::type::attribute::new -content_type {as_item_data} -attribute_name {session_id} -datatype {number} -pretty_name {Session ID} -column_spec {integer} @@ -245,5 +246,8 @@ } } } + 0.09d1 0.10d1 { + content::type::attribute::new -content_type {as_section_data} -attribute_name {points} -datatype {number} -pretty_name {Points Awarded} -column_spec {integer} + } } } Index: openacs-4/packages/assessment/tcl/as-item-display-cb-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/assessment/tcl/as-item-display-cb-procs.tcl,v diff -u -r1.7 -r1.8 --- openacs-4/packages/assessment/tcl/as-item-display-cb-procs.tcl 7 Jan 2005 16:10:44 -0000 1.7 +++ openacs-4/packages/assessment/tcl/as-item-display-cb-procs.tcl 18 Jan 2005 12:42:37 -0000 1.8 @@ -116,7 +116,7 @@ # numerical alphabetical randomized order_of_entry switch -exact $sort_order_type { numerical { - set data [lsort -real -index 0 $data] + set data [lsort -command as::assessment::compare_numbers $data] } alphabetical { set data [lsort -dictionary -index 0 $data] Index: openacs-4/packages/assessment/tcl/as-item-display-rb-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/assessment/tcl/as-item-display-rb-procs.tcl,v diff -u -r1.7 -r1.8 --- openacs-4/packages/assessment/tcl/as-item-display-rb-procs.tcl 7 Jan 2005 16:10:44 -0000 1.7 +++ openacs-4/packages/assessment/tcl/as-item-display-rb-procs.tcl 18 Jan 2005 12:42:37 -0000 1.8 @@ -116,7 +116,7 @@ # numerical alphabetical randomized order_of_entry switch -exact $sort_order_type { numerical { - set data [lsort -real -index 0 $data] + set data [lsort -command as::assessment::compare_numbers $data] } alphabetical { set data [lsort -dictionary -index 0 $data] Index: openacs-4/packages/assessment/tcl/as-item-display-sb-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/assessment/tcl/as-item-display-sb-procs.tcl,v diff -u -r1.5 -r1.6 --- openacs-4/packages/assessment/tcl/as-item-display-sb-procs.tcl 11 Jan 2005 16:29:23 -0000 1.5 +++ openacs-4/packages/assessment/tcl/as-item-display-sb-procs.tcl 18 Jan 2005 12:42:37 -0000 1.6 @@ -120,7 +120,7 @@ # numerical alphabetical randomized order_of_entry switch -exact $sort_order_type { numerical { - set data [lsort -real -index 0 $data] + set data [lsort -command as::assessment::compare_numbers $data] } alphabetical { set data [lsort -dictionary -index 0 $data] Index: openacs-4/packages/assessment/tcl/as-item-type-mc-procs-oracle.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/assessment/tcl/as-item-type-mc-procs-oracle.xql,v diff -u -r1.1 -r1.2 --- openacs-4/packages/assessment/tcl/as-item-type-mc-procs-oracle.xql 7 Jan 2005 16:10:44 -0000 1.1 +++ openacs-4/packages/assessment/tcl/as-item-type-mc-procs-oracle.xql 18 Jan 2005 12:42:37 -0000 1.2 @@ -16,6 +16,7 @@ and sc.as_item_id = :as_item_id and r.revision_id = sc.choice_id and c.choice_id = sc.choice_id + order by sc.sort_order @@ -35,6 +36,7 @@ and sc.as_item_id = :as_item_id and r.revision_id = sc.choice_id and c.choice_id = sc.choice_id + order by sc.sort_order Index: openacs-4/packages/assessment/tcl/as-item-type-mc-procs-postgresql.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/assessment/tcl/as-item-type-mc-procs-postgresql.xql,v diff -u -r1.1 -r1.2 --- openacs-4/packages/assessment/tcl/as-item-type-mc-procs-postgresql.xql 7 Jan 2005 16:10:44 -0000 1.1 +++ openacs-4/packages/assessment/tcl/as-item-type-mc-procs-postgresql.xql 18 Jan 2005 12:42:37 -0000 1.2 @@ -15,6 +15,7 @@ and sc.as_item_id = :as_item_id and r.revision_id = sc.choice_id and c.choice_id = sc.choice_id + order by sc.sort_order @@ -33,6 +34,7 @@ and sc.as_item_id = :as_item_id and r.revision_id = sc.choice_id and c.choice_id = sc.choice_id + order by sc.sort_order Index: openacs-4/packages/assessment/tcl/as-section-data-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/assessment/tcl/as-section-data-procs.tcl,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/assessment/tcl/as-section-data-procs.tcl 18 Jan 2005 12:42:37 -0000 1.1 @@ -0,0 +1,43 @@ +ad_library { + Item Data procs + @author timo@timohentschel.de + @creation-date 2005-01-14 +} + +namespace eval as::section_data {} + +ad_proc -public as::section_data::new { + -session_id:required + -section_id:required + {-subject_id ""} + {-staff_id ""} + {-points ""} +} { + @author Timo Hentschel (timo@timohentschel.de) + @creation-date 2005-01-14 + + New as_section_data +} { + set package_id [ad_conn package_id] + set folder_id [as::assessment::folder_id -package_id $package_id] + + if {[db_0or1row section_data_exists {}]} { + return + } + + # Insert as_section_data in the CR (and as_section_data table) getting the revision_id (section_data_id) + db_transaction { + set section_data_id [content::item::new -parent_id $folder_id -content_type {as_section_data} -name "$section_id-$session_id" -title "$section_id-$session_id" ] + set as_section_data_id [content::revision::new \ + -item_id $section_data_id \ + -content_type {as_section_data} \ + -title "$section_id-$session_id" \ + -attributes [list [list session_id $session_id] \ + [list section_id $section_id] \ + [list subject_id $subject_id] \ + [list staff_id $staff_id] \ + [list points $points] ] ] + } + + return $as_section_data_id +} Index: openacs-4/packages/assessment/tcl/as-section-data-procs.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/assessment/tcl/as-section-data-procs.xql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/assessment/tcl/as-section-data-procs.xql 18 Jan 2005 12:42:37 -0000 1.1 @@ -0,0 +1,15 @@ + + + + + + + select 1 + from as_section_data + where session_id = :session_id + and section_id = :section_id + + + + + Index: openacs-4/packages/assessment/tcl/as-section-procs-oracle.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/assessment/tcl/as-section-procs-oracle.xql,v diff -u -r1.1 -r1.2 --- openacs-4/packages/assessment/tcl/as-section-procs-oracle.xql 7 Jan 2005 16:10:44 -0000 1.1 +++ openacs-4/packages/assessment/tcl/as-section-procs-oracle.xql 18 Jan 2005 12:42:37 -0000 1.2 @@ -47,4 +47,22 @@ + + + + select asm.points as section_max_points + from as_assessment_section_map asm + where asm.assessment_id = :assessment_id + and asm.section_id = :section_id + and not exists (select 1 + from as_item_data d, as_session_items i + where i.session_id = :session_id + and d.as_item_id(+) = i.as_item_id + and d.session_id(+) = i.session_id + and i.section_id = :section_id + and d.points is null) + + + + Index: openacs-4/packages/assessment/tcl/as-section-procs-postgresql.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/assessment/tcl/as-section-procs-postgresql.xql,v diff -u -r1.1 -r1.2 --- openacs-4/packages/assessment/tcl/as-section-procs-postgresql.xql 7 Jan 2005 16:10:44 -0000 1.1 +++ openacs-4/packages/assessment/tcl/as-section-procs-postgresql.xql 18 Jan 2005 12:42:37 -0000 1.2 @@ -44,4 +44,22 @@ + + + + select asm.points as section_max_points + from as_assessment_section_map asm + where asm.assessment_id = :assessment_id + and asm.section_id = :section_id + and not exists (select 1 + from as_session_items i + left outer join as_item_data d on (d.as_item_id = i.as_item_id + and d.session_id = i.session_id) + where i.session_id = :session_id + and i.section_id = :section_id + and d.points is null) + + + + 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 -r1.11 -r1.12 --- openacs-4/packages/assessment/tcl/as-section-procs.tcl 14 Jan 2005 13:13:37 -0000 1.11 +++ openacs-4/packages/assessment/tcl/as-section-procs.tcl 18 Jan 2005 12:42:37 -0000 1.12 @@ -272,3 +272,22 @@ return $item_list } + +ad_proc -public as::section::calculate { + -section_id:required + -assessment_id:required + -session_id:required +} { + @author Timo Hentschel (timo@timohentschel.de) + @creation-date 2005-01-14 + + Award points to this section if all items are filled out in this section +} { + if {![db_0or1row max_section_points {}]} { + return + } + + db_1row sum_of_item_points {} + set section_points [expr round($section_max_points * $item_points / $item_max_points)] + db_dml update_section_points {} +} Index: openacs-4/packages/assessment/tcl/as-section-procs.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/assessment/tcl/as-section-procs.xql,v diff -u -r1.7 -r1.8 --- openacs-4/packages/assessment/tcl/as-section-procs.xql 14 Jan 2005 13:13:37 -0000 1.7 +++ openacs-4/packages/assessment/tcl/as-section-procs.xql 18 Jan 2005 12:42:37 -0000 1.8 @@ -71,4 +71,27 @@ + + + + select sum(m.points) as item_max_points, sum(d.points) as item_points + from as_item_data d, as_item_section_map m + where m.section_id = :section_id + and d.as_item_id = m.as_item_id + and d.session_id = :session_id + + + + + + + + update as_section_data + set points = :section_points + where session_id = :session_id + and section_id = :section_id + + + + Index: openacs-4/packages/assessment/www/assessment-oracle.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/assessment/www/Attic/assessment-oracle.xql,v diff -u -r1.4 -r1.5 --- openacs-4/packages/assessment/www/assessment-oracle.xql 7 Jan 2005 16:10:44 -0000 1.4 +++ openacs-4/packages/assessment/www/assessment-oracle.xql 18 Jan 2005 12:42:37 -0000 1.5 @@ -2,20 +2,6 @@ oracle8.1.6 - - - SELECT i.as_item_id, i.name, i.title, i.subtext, s.section_id as section_id, s.title as section_title, s.description as section_description - FROM as_sectionsx s, as_assessmentsx a, as_item_section_map ism, - as_itemsx i - WHERE a.assessment_id = :assessment_rev_id - AND s.section_id = asm.section_id - AND asm.assessment_id = a.assessment_id - AND s.section_id = ism.section_id - AND i.as_item_id = ism.as_item_id - ORDER BY s.section_id, ism.sort_order - - - UPDATE as_sessions Index: openacs-4/packages/assessment/www/assessment-postgresql.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/assessment/www/Attic/assessment-postgresql.xql,v diff -u -r1.8 -r1.9 --- openacs-4/packages/assessment/www/assessment-postgresql.xql 7 Jan 2005 16:10:44 -0000 1.8 +++ openacs-4/packages/assessment/www/assessment-postgresql.xql 18 Jan 2005 12:42:37 -0000 1.9 @@ -2,18 +2,6 @@ postgresql7.4 - - - SELECT i.as_item_id, i.name, i.title, i.subtext, s.section_id as section_id, s.title as section_title, s.description as section_description - FROM as_sectionsx s INNER JOIN as_assessment_section_map asm USING (section_id) - INNER JOIN as_assessmentsx a USING (assessment_id) - INNER JOIN as_item_section_map ism ON s.section_id = ism.section_id - INNER JOIN as_itemsx i USING (as_item_id) - WHERE a.assessment_id = :assessment_rev_id - ORDER BY s.section_id, ism.sort_order - - - UPDATE as_sessions Index: openacs-4/packages/assessment/www/assessment.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/assessment/www/assessment.adp,v diff -u -r1.16 -r1.17 --- openacs-4/packages/assessment/www/assessment.adp 7 Jan 2005 16:10:44 -0000 1.16 +++ openacs-4/packages/assessment/www/assessment.adp 18 Jan 2005 12:42:37 -0000 1.17 @@ -103,7 +103,6 @@ - Index: openacs-4/packages/assessment/www/assessment.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/assessment/www/Attic/assessment.tcl,v diff -u -r1.20 -r1.21 --- openacs-4/packages/assessment/www/assessment.tcl 10 Jan 2005 13:14:41 -0000 1.20 +++ openacs-4/packages/assessment/www/assessment.tcl 18 Jan 2005 12:42:37 -0000 1.21 @@ -65,6 +65,7 @@ # get all items of section in correct order set item_list [as::section::items -section_id $section_id -session_id $session_id -sort_order_type $display(sort_order_type) -num_items $section(num_items)] + as::section_data::new -section_id $section_id -session_id $session_id -subject_id $user_id if {![empty_string_p $item_order]} { # show next items on section page @@ -74,10 +75,12 @@ if {![empty_string_p $display(num_items)]} { if {[llength $item_list] > $display(num_items)} { # next page: more items of this section + set new_item_order $item_order + set new_section_order $section_order if {[empty_string_p $item_order]} { set new_item_order 0 } - set new_item_order [expr $item_order + $display(num_items)] + set new_item_order [expr $new_item_order + $display(num_items)] # show only a few items per page set item_list [lreplace $item_list $display(num_items) end] @@ -89,6 +92,7 @@ } else { # next page: next section set new_section_order [expr $section_order + 1] + set new_item_order "" } if {$new_section_order == [llength $section_list]} { @@ -98,8 +102,26 @@ # form for display an assessment with sections and items -ad_form -name show_item_form -action assessment -html {enctype multipart/form-data} -export {assessment_id section_id section_order item_order} -form { - { session_id:text(hidden) {value $session_id} } +if {$display(submit_answer_p) != "t"} { + ad_form -name show_item_form -action assessment -html {enctype multipart/form-data} -export {assessment_id section_id section_order item_order} -form { + {session_id:text(hidden) {value $session_id}} + } +} else { + ad_form -name show_item_form -action assessment -html {enctype multipart/form-data} -export {assessment_id section_id section_order item_order} -form { + {session_id:text(hidden) {value $session_id}} + } -after_submit { + if {![empty_string_p $new_section_order]} { + set section_order $new_section_order + set item_order $new_item_order + ad_returnredirect [export_vars -base assessment {assessment_id session_id section_order item_order}] + ad_script_abort + } else { + as::assessment::calculate -session_id $session_id -assessment_id $assessment_rev_id + db_dml session_finished {} + ad_returnredirect [export_vars -base finish {session_id assessment_id}] + ad_script_abort + } + } } multirow create items as_item_id name title description subtext required_p max_time_to_complete presentation_type html submitted_p content @@ -130,7 +152,7 @@ } } ad_form -name show_item_form_$as_item_id -mode $mode -action assessment -html {enctype multipart/form-data} -export {assessment_id section_id section_order item_order} -form { - { session_id:text(hidden) {value $session_id} } + {session_id:text(hidden) {value $session_id}} } set presentation_type [as::item_form::add_item_to_form -name show_item_form_$as_item_id -session_id $session_id -section_id $section_id -item_id $as_item_id -default_value $default_value -required_p $required_p] @@ -148,12 +170,17 @@ set points [ad_decode $points "" 0 $points] as::item_type_$item_type\::process -type_id $item_type_id -session_id $session_id -as_item_id $response_item_id -subject_id $user_id -response $response_to_item($as_item_id) -max_points $points + + if {$section_order != $new_section_order} { + as::section::calculate -section_id $section_id -assessment_id $assessment_rev_id -session_id $session_id + } } } -after_submit { if {![empty_string_p $section_order]} { ad_returnredirect [export_vars -base assessment {assessment_id session_id section_order item_order}] ad_script_abort } else { + as::assessment::calculate -session_id $session_id -assessment_id $assessment_rev_id db_dml session_finished {} ad_returnredirect [export_vars -base finish {session_id assessment_id}] ad_script_abort @@ -176,7 +203,7 @@ append validate_list "\{response_to_item.$as_item_id \{\[exist_and_not_null \$response_to_item.$as_item_id\]\} \"Answer missing\"\}\n" } # process multiple submit - eval ad_form -extend -name show_item_form -validate "{$validate_list}" +# eval ad_form -extend -name show_item_form -validate "{$validate_list}" ad_form -extend -name show_item_form -on_submit { db_transaction { db_dml session_updated {} @@ -188,6 +215,10 @@ set points [ad_decode $points "" 0 $points] as::item_type_$item_type\::process -type_id $item_type_id -session_id $session_id -as_item_id $response_item_id -subject_id $user_id -response $response_to_item($response_item_id) -max_points $points } + + if {$section_order != $new_section_order} { + as::section::calculate -section_id $section_id -assessment_id $assessment_rev_id -session_id $session_id + } } } -after_submit { if {![empty_string_p $new_section_order]} { @@ -196,6 +227,7 @@ ad_returnredirect [export_vars -base assessment {assessment_id session_id section_order item_order}] ad_script_abort } else { + as::assessment::calculate -session_id $session_id -assessment_id $assessment_rev_id db_dml session_finished {} ad_returnredirect [export_vars -base finish {session_id assessment_id}] ad_script_abort Index: openacs-4/packages/assessment/www/finish.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/assessment/www/finish.adp,v diff -u -r1.1 -r1.2 --- openacs-4/packages/assessment/www/finish.adp 7 Jan 2005 16:10:44 -0000 1.1 +++ openacs-4/packages/assessment/www/finish.adp 18 Jan 2005 12:42:37 -0000 1.2 @@ -2,7 +2,6 @@ #assessment.Response_Submitted# @context_bar;noquote@
-

#assessment.Response_Submitted#

#assessment.View_results#

Index: openacs-4/packages/assessment/www/session.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/assessment/www/session.adp,v diff -u -r1.18 -r1.19 --- openacs-4/packages/assessment/www/session.adp 8 Jan 2005 17:31:37 -0000 1.18 +++ openacs-4/packages/assessment/www/session.adp 18 Jan 2005 12:42:37 -0000 1.19 @@ -23,7 +23,7 @@ @@ -37,5 +37,5 @@
-#assessment.Total_score#: @session_score@ / @assessment_score@ +#assessment.Total_score#: @session_score@ / @assessment_score@ = @percent_score@% Index: openacs-4/packages/assessment/www/session.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/assessment/www/session.tcl,v diff -u -r1.30 -r1.31 --- openacs-4/packages/assessment/www/session.tcl 7 Jan 2005 16:10:44 -0000 1.30 +++ openacs-4/packages/assessment/www/session.tcl 18 Jan 2005 12:42:37 -0000 1.31 @@ -10,6 +10,7 @@ } set context [list "[_ assessment.View_Results]"] +set format "[lc_get formbuilder_date_format], [lc_get formbuilder_time_format]" db_1row find_assessment {} @@ -36,15 +37,18 @@ # show_feedback: none, all, incorrect, correct +set session_score 0 +set assessment_score 0 db_multirow sections sections {} { if {[empty_string_p $points]} { set points 0 } + if {[empty_string_p $max_points]} { + set max_points 0 + } set max_time_to_complete [as::assessment::pretty_time -seconds $max_time_to_complete] + incr session_score $points + incr assessment_score $max_points } -# todo: calculate result -set session_score 0 -set assessment_score 0 - ad_return_template Index: openacs-4/packages/assessment/www/session.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/assessment/www/session.xql,v diff -u -r1.16 -r1.17 --- openacs-4/packages/assessment/www/session.xql 7 Jan 2005 16:10:44 -0000 1.16 +++ openacs-4/packages/assessment/www/session.xql 18 Jan 2005 12:42:37 -0000 1.17 @@ -14,9 +14,9 @@ - SELECT creation_datetime AS session_start, - completed_datetime AS session_finish, - completed_datetime-creation_datetime AS session_time + SELECT percent_score, to_char(creation_datetime, :format) AS session_start, + to_char(completed_datetime, :format) AS session_finish, + to_char(completed_datetime-creation_datetime, 'HH24:MI:SS') AS session_time FROM as_sessions s WHERE s.session_id = :session_id @@ -34,15 +34,17 @@ select s.section_id, cr.title, cr.description, ci.name, s.instructions, - s.feedback_text, m.max_time_to_complete, m.points - from as_assessment_section_map m, as_session_sections ss, + s.feedback_text, m.max_time_to_complete, m.points as max_points, d.points + from as_assessment_section_map m, as_session_sections ss, as_section_data d, as_sections s, cr_revisions cr, cr_items ci where ci.item_id = cr.item_id and cr.revision_id = s.section_id and s.section_id = m.section_id and m.assessment_id = :assessment_rev_id and m.section_id = ss.section_id and ss.session_id = :session_id + and d.session_id = ss.session_id + and d.section_id = ss.section_id order by ss.sort_order Index: openacs-4/packages/assessment/www/sessions-oracle.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/assessment/www/sessions-oracle.xql,v diff -u -r1.3 -r1.4 --- openacs-4/packages/assessment/www/sessions-oracle.xql 28 Dec 2004 19:04:59 -0000 1.3 +++ openacs-4/packages/assessment/www/sessions-oracle.xql 18 Jan 2005 12:42:37 -0000 1.4 @@ -5,7 +5,8 @@ - SELECT s.session_id, s.completed_datetime, s.percent_score, + SELECT r.item_id as assessment_id, s.session_id, s.percent_score, + to_char(s.completed_datetime, :format) as completed_datetime, p.first_names || ' ' || p.last_name AS subject_name, r.title AS assessment_name, s.subject_id FROM as_sessions s, cr_revisions r, persons p @@ -19,7 +20,8 @@ - SELECT s.session_id, s.completed_datetime, s.percent_score, + SELECT r.item_id as assessment_id, s.session_id, s.percent_score, + to_char(s.completed_datetime, :format) as completed_datetime, p.first_names || ' ' || p.last_name AS subject_name, r.title AS assessment_name, s.subject_id FROM as_sessions s, cr_revisions r, persons p Index: openacs-4/packages/assessment/www/sessions-postgresql.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/assessment/www/sessions-postgresql.xql,v diff -u -r1.6 -r1.7 --- openacs-4/packages/assessment/www/sessions-postgresql.xql 8 Jan 2005 17:27:22 -0000 1.6 +++ openacs-4/packages/assessment/www/sessions-postgresql.xql 18 Jan 2005 12:42:37 -0000 1.7 @@ -5,7 +5,8 @@ - SELECT r.item_id as assessment_id,s.session_id, s.completed_datetime, s.percent_score, + SELECT r.item_id as assessment_id, s.session_id, s.percent_score, + to_char(s.completed_datetime, :format) as completed_datetime, p.first_names || ' ' || p.last_name AS subject_name, r.title AS assessment_name, s.subject_id FROM as_sessions s, cr_revisions r, persons p @@ -19,7 +20,8 @@ - SELECT r.item_id as assessment_id, s.session_id, s.completed_datetime, s.percent_score, + SELECT r.item_id as assessment_id, s.session_id, s.percent_score, + to_char(s.completed_datetime, :format) as completed_datetime, p.first_names || ' ' || p.last_name AS subject_name, r.title AS assessment_name, s.subject_id FROM as_sessions s, cr_revisions r, persons p Index: openacs-4/packages/assessment/www/sessions.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/assessment/www/sessions.tcl,v diff -u -r1.12 -r1.13 --- openacs-4/packages/assessment/www/sessions.tcl 8 Jan 2005 17:27:22 -0000 1.12 +++ openacs-4/packages/assessment/www/sessions.tcl 18 Jan 2005 12:42:37 -0000 1.13 @@ -15,8 +15,8 @@ } set context [list "[_ assessment.Show_Sessions]"] - set package_id [ad_conn package_id] +set format "[lc_get formbuilder_date_format], [lc_get formbuilder_time_format]" if {[empty_string_p $subject_id]} { set subject_id [ad_conn user_id] Index: openacs-4/packages/assessment/www/admin/assessment-form.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/assessment/www/admin/Attic/assessment-form.tcl,v diff -u -r1.7 -r1.8 --- openacs-4/packages/assessment/www/admin/assessment-form.tcl 14 Jan 2005 13:12:10 -0000 1.7 +++ openacs-4/packages/assessment/www/admin/assessment-form.tcl 18 Jan 2005 12:42:37 -0000 1.8 @@ -147,7 +147,12 @@ category::map_object -object_id $assessment_rev_id $category_ids } - db_dml update_time {} + if {![empty_string_p $start_time]} { + db_dml update_end_time {} + } + if {![empty_string_p $end_time]} { + db_dml update_end_time {} + } } } -edit_data { db_transaction { @@ -177,7 +182,12 @@ category::map_object -object_id $assessment_rev_id $category_ids } - db_dml update_time {} + if {![empty_string_p $start_time]} { + db_dml update_end_time {} + } + if {![empty_string_p $end_time]} { + db_dml update_end_time {} + } } } -after_submit { ad_returnredirect [export_vars -base one-a {assessment_id}] Index: openacs-4/packages/assessment/www/admin/assessment-form.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/assessment/www/admin/Attic/assessment-form.xql,v diff -u -r1.6 -r1.7 --- openacs-4/packages/assessment/www/admin/assessment-form.xql 14 Jan 2005 13:12:10 -0000 1.6 +++ openacs-4/packages/assessment/www/admin/assessment-form.xql 18 Jan 2005 12:42:37 -0000 1.7 @@ -37,15 +37,24 @@ - + update as_assessments - set start_time = $start_time, - end_time = $end_time + set start_time = $start_time where assessment_id = :assessment_rev_id + + + + update as_assessments + set end_time = $end_time + where assessment_id = :assessment_rev_id + + + + Index: openacs-4/packages/assessment/www/admin/item-add-display-cb.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/assessment/www/admin/Attic/item-add-display-cb.xql,v diff -u -r1.3 -r1.4 --- openacs-4/packages/assessment/www/admin/item-add-display-cb.xql 14 Jan 2005 13:13:37 -0000 1.3 +++ openacs-4/packages/assessment/www/admin/item-add-display-cb.xql 18 Jan 2005 12:42:37 -0000 1.4 @@ -4,7 +4,7 @@ - select r.target_rev_id, o.object_type + select r.target_rev_id as as_item_display_id, o.object_type from as_item_rels r, acs_objects o where r.item_rev_id = :as_item_id and r.rel_type = 'as_item_display_rel' Index: openacs-4/packages/assessment/www/admin/item-add-display-rb.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/assessment/www/admin/Attic/item-add-display-rb.xql,v diff -u -r1.3 -r1.4 --- openacs-4/packages/assessment/www/admin/item-add-display-rb.xql 14 Jan 2005 13:13:37 -0000 1.3 +++ openacs-4/packages/assessment/www/admin/item-add-display-rb.xql 18 Jan 2005 12:42:37 -0000 1.4 @@ -4,7 +4,7 @@ - select r.target_rev_id, o.object_type + select r.target_rev_id as as_item_display_id, o.object_type from as_item_rels r, acs_objects o where r.item_rev_id = :as_item_id and r.rel_type = 'as_item_display_rel' Index: openacs-4/packages/assessment/www/admin/item-add-display-sa.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/assessment/www/admin/Attic/item-add-display-sa.xql,v diff -u -r1.3 -r1.4 --- openacs-4/packages/assessment/www/admin/item-add-display-sa.xql 14 Jan 2005 13:13:37 -0000 1.3 +++ openacs-4/packages/assessment/www/admin/item-add-display-sa.xql 18 Jan 2005 12:42:37 -0000 1.4 @@ -4,7 +4,7 @@ - select r.target_rev_id, o.object_type + select r.target_rev_id as as_item_display_id, o.object_type from as_item_rels r, acs_objects o where r.item_rev_id = :as_item_id and r.rel_type = 'as_item_display_rel' Index: openacs-4/packages/assessment/www/admin/item-add-display-sb.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/assessment/www/admin/Attic/item-add-display-sb.xql,v diff -u -r1.3 -r1.4 --- openacs-4/packages/assessment/www/admin/item-add-display-sb.xql 14 Jan 2005 13:13:37 -0000 1.3 +++ openacs-4/packages/assessment/www/admin/item-add-display-sb.xql 18 Jan 2005 12:42:37 -0000 1.4 @@ -4,7 +4,7 @@ - select r.target_rev_id, o.object_type + select r.target_rev_id as as_item_display_id, o.object_type from as_item_rels r, acs_objects o where r.item_rev_id = :as_item_id and r.rel_type = 'as_item_display_rel' Index: openacs-4/packages/assessment/www/admin/item-add-display-ta.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/assessment/www/admin/Attic/item-add-display-ta.xql,v diff -u -r1.3 -r1.4 --- openacs-4/packages/assessment/www/admin/item-add-display-ta.xql 14 Jan 2005 13:13:37 -0000 1.3 +++ openacs-4/packages/assessment/www/admin/item-add-display-ta.xql 18 Jan 2005 12:42:37 -0000 1.4 @@ -4,7 +4,7 @@ - select r.target_rev_id, o.object_type + select r.target_rev_id as as_item_display_id, o.object_type from as_item_rels r, acs_objects o where r.item_rev_id = :as_item_id and r.rel_type = 'as_item_display_rel' Index: openacs-4/packages/assessment/www/admin/item-add-display-tb.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/assessment/www/admin/Attic/item-add-display-tb.xql,v diff -u -r1.3 -r1.4 --- openacs-4/packages/assessment/www/admin/item-add-display-tb.xql 14 Jan 2005 13:13:37 -0000 1.3 +++ openacs-4/packages/assessment/www/admin/item-add-display-tb.xql 18 Jan 2005 12:42:37 -0000 1.4 @@ -4,7 +4,7 @@ - select r.target_rev_id, o.object_type + select r.target_rev_id as as_item_display_id, o.object_type from as_item_rels r, acs_objects o where r.item_rev_id = :as_item_id and r.rel_type = 'as_item_display_rel' Index: openacs-4/packages/assessment/www/admin/item-add-mc.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/assessment/www/admin/Attic/item-add-mc.xql,v diff -u -r1.2 -r1.3 --- openacs-4/packages/assessment/www/admin/item-add-mc.xql 14 Jan 2005 13:13:37 -0000 1.2 +++ openacs-4/packages/assessment/www/admin/item-add-mc.xql 18 Jan 2005 12:42:37 -0000 1.3 @@ -14,7 +14,7 @@ - select r.target_rev_id, o.object_type + select r.target_rev_id as as_item_type_id, o.object_type from as_item_rels r, acs_objects o where r.item_rev_id = :as_item_id and r.rel_type = 'as_item_type_rel' Index: openacs-4/packages/assessment/www/admin/item-add-oq.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/assessment/www/admin/Attic/item-add-oq.xql,v diff -u -r1.2 -r1.3 --- openacs-4/packages/assessment/www/admin/item-add-oq.xql 14 Jan 2005 13:13:37 -0000 1.2 +++ openacs-4/packages/assessment/www/admin/item-add-oq.xql 18 Jan 2005 12:42:37 -0000 1.3 @@ -14,7 +14,7 @@ - select r.target_rev_id, o.object_type + select r.target_rev_id as as_item_type_id, o.object_type from as_item_rels r, acs_objects o where r.item_rev_id = :as_item_id and r.rel_type = 'as_item_type_rel' Index: openacs-4/packages/assessment/www/admin/item-add-sa.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/assessment/www/admin/Attic/item-add-sa.xql,v diff -u -r1.2 -r1.3 --- openacs-4/packages/assessment/www/admin/item-add-sa.xql 14 Jan 2005 13:13:37 -0000 1.2 +++ openacs-4/packages/assessment/www/admin/item-add-sa.xql 18 Jan 2005 12:42:37 -0000 1.3 @@ -14,7 +14,7 @@ - select r.target_rev_id, o.object_type + select r.target_rev_id as as_item_type_id, o.object_type from as_item_rels r, acs_objects o where r.item_rev_id = :as_item_id and r.rel_type = 'as_item_type_rel' Index: openacs-4/packages/assessment/www/admin/item-edit-display-cb.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/assessment/www/admin/Attic/item-edit-display-cb.tcl,v diff -u -r1.3 -r1.4 --- openacs-4/packages/assessment/www/admin/item-edit-display-cb.tcl 14 Jan 2005 13:13:37 -0000 1.3 +++ openacs-4/packages/assessment/www/admin/item-edit-display-cb.tcl 18 Jan 2005 12:42:37 -0000 1.4 @@ -68,7 +68,7 @@ set as_item_display_id 0 } } -validate { - {html_options {[as::assessment::check_html_options -options $html_options]} "[_ assessment.error_html_options]"} + {html_display_options {[as::assessment::check_html_options -options $html_display_options]} "[_ assessment.error_html_options]"} } -edit_data { db_transaction { set new_item_id [as::item::new_revision -as_item_id $as_item_id] Index: openacs-4/packages/assessment/www/admin/item-edit-display-rb.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/assessment/www/admin/Attic/item-edit-display-rb.tcl,v diff -u -r1.3 -r1.4 --- openacs-4/packages/assessment/www/admin/item-edit-display-rb.tcl 14 Jan 2005 13:13:37 -0000 1.3 +++ openacs-4/packages/assessment/www/admin/item-edit-display-rb.tcl 18 Jan 2005 12:42:37 -0000 1.4 @@ -68,7 +68,7 @@ set as_item_display_id 0 } } -validate { - {html_options {[as::assessment::check_html_options -options $html_options]} "[_ assessment.error_html_options]"} + {html_display_options {[as::assessment::check_html_options -options $html_display_options]} "[_ assessment.error_html_options]"} } -edit_data { db_transaction { set new_item_id [as::item::new_revision -as_item_id $as_item_id] Index: openacs-4/packages/assessment/www/admin/item-edit-display-sa.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/assessment/www/admin/Attic/item-edit-display-sa.tcl,v diff -u -r1.3 -r1.4 --- openacs-4/packages/assessment/www/admin/item-edit-display-sa.tcl 14 Jan 2005 13:13:37 -0000 1.3 +++ openacs-4/packages/assessment/www/admin/item-edit-display-sa.tcl 18 Jan 2005 12:42:37 -0000 1.4 @@ -49,7 +49,7 @@ set as_item_display_id 0 } } -validate { - {html_options {[as::assessment::check_html_options -options $html_options]} "[_ assessment.error_html_options]"} + {html_display_options {[as::assessment::check_html_options -options $html_display_options]} "[_ assessment.error_html_options]"} } -edit_data { db_transaction { set new_item_id [as::item::new_revision -as_item_id $as_item_id] Index: openacs-4/packages/assessment/www/admin/item-edit-display-sb.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/assessment/www/admin/Attic/item-edit-display-sb.tcl,v diff -u -r1.3 -r1.4 --- openacs-4/packages/assessment/www/admin/item-edit-display-sb.tcl 14 Jan 2005 13:13:37 -0000 1.3 +++ openacs-4/packages/assessment/www/admin/item-edit-display-sb.tcl 18 Jan 2005 12:42:37 -0000 1.4 @@ -65,7 +65,7 @@ set as_item_display_id 0 } } -validate { - {html_options {[as::assessment::check_html_options -options $html_options]} "[_ assessment.error_html_options]"} + {html_display_options {[as::assessment::check_html_options -options $html_display_options]} "[_ assessment.error_html_options]"} } -edit_data { db_transaction { set new_item_id [as::item::new_revision -as_item_id $as_item_id] Index: openacs-4/packages/assessment/www/admin/item-edit-display-ta.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/assessment/www/admin/Attic/item-edit-display-ta.tcl,v diff -u -r1.3 -r1.4 --- openacs-4/packages/assessment/www/admin/item-edit-display-ta.tcl 14 Jan 2005 13:13:37 -0000 1.3 +++ openacs-4/packages/assessment/www/admin/item-edit-display-ta.tcl 18 Jan 2005 12:42:37 -0000 1.4 @@ -49,7 +49,7 @@ set as_item_display_id 0 } } -validate { - {html_options {[as::assessment::check_html_options -options $html_options]} "[_ assessment.error_html_options]"} + {html_display_options {[as::assessment::check_html_options -options $html_display_options]} "[_ assessment.error_html_options]"} } -edit_data { db_transaction { set new_item_id [as::item::new_revision -as_item_id $as_item_id] Index: openacs-4/packages/assessment/www/admin/item-edit-display-tb.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/assessment/www/admin/Attic/item-edit-display-tb.tcl,v diff -u -r1.3 -r1.4 --- openacs-4/packages/assessment/www/admin/item-edit-display-tb.tcl 14 Jan 2005 13:13:37 -0000 1.3 +++ openacs-4/packages/assessment/www/admin/item-edit-display-tb.tcl 18 Jan 2005 12:42:37 -0000 1.4 @@ -49,7 +49,7 @@ set as_item_display_id 0 } } -validate { - {html_options {[as::assessment::check_html_options -options $html_options]} "[_ assessment.error_html_options]"} + {html_display_options {[as::assessment::check_html_options -options $html_display_options]} "[_ assessment.error_html_options]"} } -edit_data { db_transaction { set new_item_id [as::item::new_revision -as_item_id $as_item_id]
#assessment.section# @sections.title@ (#assessment.max_time# @sections.max_time_to_complete@) -(0 / @sections.points@ #assessment.points#) +(@sections.points@ / @sections.max_points@ #assessment.points#)
@sections.description@