Index: openacs-4/packages/assessment/assessment.info =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/assessment/assessment.info,v diff -u -r1.12 -r1.13 --- openacs-4/packages/assessment/assessment.info 11 Dec 2004 11:23:06 -0000 1.12 +++ openacs-4/packages/assessment/assessment.info 22 Dec 2004 20:52:23 -0000 1.13 @@ -7,7 +7,7 @@ f f - + oracle postgresql @@ -20,11 +20,12 @@ 0 E-LANE Create assessments and evalueate. - + + Index: openacs-4/packages/assessment/lib/section-items.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/assessment/lib/section-items.tcl,v diff -u -r1.2 -r1.3 --- openacs-4/packages/assessment/lib/section-items.tcl 10 Dec 2004 11:42:22 -0000 1.2 +++ openacs-4/packages/assessment/lib/section-items.tcl 22 Dec 2004 20:52:17 -0000 1.3 @@ -3,17 +3,13 @@ } db_multirow -extend { presentation_type html } items section_items {} { - set presentation_type [as::item_form::add_item_to_form admin_section $as_item_id] + set presentation_type [as::item_form::add_item_to_form admin_section "" $section_id $as_item_id] if {$presentation_type == "fitb"} { regsub -all -line -nocase -- { 0} { + return $section_list + } + + # get all sections of assessment + set all_sections [db_list_of_lists assessment_sections {}] + + # sort section positions + switch -exact $sort_order_type { + randomized { + set all_sections [util::randomize_list $all_sections] + } + } + + # save section order + set section_list "" + set count 0 + foreach one_section $all_sections { + incr count + util_unlist $one_section section_id title + lappend section_list $section_id + db_dml save_order {} + } + + return $section_list +} + +ad_proc as::assessment::pretty_time { + {-seconds} +} { + @author Timo Hentschel (timo@timohentschel.de) + @creation-date 2004-12-14 + + Returns a pretty string of min:sec +} { + set time "" + if {![empty_string_p $seconds]} { + set time_min [expr $seconds / 60] + set time_sec [expr $seconds - ($time_min * 60)] + set time "$time_min\:$time_sec min" + } + return $time +} 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.4 -r1.5 --- openacs-4/packages/assessment/tcl/as-assessment-procs.xql 10 Dec 2004 11:42:23 -0000 1.4 +++ openacs-4/packages/assessment/tcl/as-assessment-procs.xql 22 Dec 2004 20:52:17 -0000 1.5 @@ -44,4 +44,36 @@ + + + + select section_id + from as_session_sections + where session_id = :session_id + order by sort_order + + + + + + + + select m.section_id, r.title + from as_assessment_section_map m, cr_revisions r + where m.assessment_id = :assessment_id + and r.revision_id = m.section_id + order by m.sort_order + + + + + + + + insert into as_session_sections (session_id, section_id, sort_order) + values (:session_id, :section_id, :count) + + + + Index: openacs-4/packages/assessment/tcl/as-item-form-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/assessment/tcl/as-item-form-procs.tcl,v diff -u -r1.9 -r1.10 --- openacs-4/packages/assessment/tcl/as-item-form-procs.tcl 10 Dec 2004 20:21:50 -0000 1.9 +++ openacs-4/packages/assessment/tcl/as-item-form-procs.tcl 22 Dec 2004 20:52:17 -0000 1.10 @@ -8,6 +8,8 @@ ad_proc -public as::item_form::add_item_to_form { form + session_id + section_id item_id } { @author Timo Hentschel (timo@timohentschel.de) @@ -21,7 +23,7 @@ set item_type [string range $item_type end-1 end] set display_type [string range $display_type end-1 end] - util_unlist [as::item_type_$item_type\::render -type_id $item_type_id] default_value data + util_unlist [as::item_type_$item_type\::render -type_id $item_type_id -session_id $session_id -section_id $section_id -as_item_id $item_id] default_value data as::item_display_$display_type\::render \ -form $form \ Index: openacs-4/packages/assessment/tcl/as-item-type-mc-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/assessment/tcl/as-item-type-mc-procs.tcl,v diff -u -r1.7 -r1.8 --- openacs-4/packages/assessment/tcl/as-item-type-mc-procs.tcl 11 Dec 2004 11:23:00 -0000 1.7 +++ openacs-4/packages/assessment/tcl/as-item-type-mc-procs.tcl 22 Dec 2004 20:52:17 -0000 1.8 @@ -132,6 +132,11 @@ ad_proc -public as::item_type_mc::render { -type_id:required + -section_id:required + -as_item_id:required + -default_provided:boolean + {-default_value ""} + {-session_id ""} } { @author Timo Hentschel (timo@timohentschel.de) @creation-date 2004-12-10 @@ -157,7 +162,19 @@ lappend wrong_choices [list $title $choice_id] } } - + + if {$default_provided_p} { + set defaults $default_value + } + + if {![empty_string_p $session_id]} { + set choice_list [db_list get_sorted_choices {}] + + if {[llength $choice_list] > 0} { + return [list $defaults $choice_list] + } + } + if {![empty_string_p $num_answers] && $num_answers < $total} { # display fewer choices, select random set correct_choices [util::randomize_list $correct_choices] @@ -176,10 +193,20 @@ set display_choices [util::randomize_list $display_choices] } + # save choice order + if {![empty_string_p $session_id]} { + set count 0 + foreach one_choice $display_choices { + util_unlist $one_choice title choice_id + incr count + db_dml save_order {} + } + } + return [list $defaults $display_choices] } -ad_proc -public as::item_type_sa::process { +ad_proc -public as::item_type_mc::process { -type_id:required -session_id:required -as_item_id:required @@ -250,6 +277,7 @@ } } - set points [expr round($max_points * percent / 100)] + set points [expr round($max_points * $percent / 100)] + as::item_data::new -session_id $session_id -subject_id $subject_id -staff_id $staff_id -as_item_id $as_item_id -choice_answer $response -points $points } Index: openacs-4/packages/assessment/tcl/as-item-type-mc-procs.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/assessment/tcl/as-item-type-mc-procs.xql,v diff -u -r1.4 -r1.5 --- openacs-4/packages/assessment/tcl/as-item-type-mc-procs.xql 11 Dec 2004 11:23:00 -0000 1.4 +++ openacs-4/packages/assessment/tcl/as-item-type-mc-procs.xql 22 Dec 2004 20:52:17 -0000 1.5 @@ -77,6 +77,28 @@ + + + + select r.title, c.choice_id + from as_session_choices c, cr_revisions r + where c.session_id = :session_id + and c.section_id = :section_id + and c.as_item_id = :as_item_id + and r.revision_id = c.choice_id + + + + + + + + insert into as_session_choices (session_id, section_id, as_item_id, choice_id, sort_order) + values (:session_id, :section_id, :as_item_id, :choice_id, :count) + + + + Index: openacs-4/packages/assessment/tcl/as-item-type-oq-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/assessment/tcl/as-item-type-oq-procs.tcl,v diff -u -r1.6 -r1.7 --- openacs-4/packages/assessment/tcl/as-item-type-oq-procs.tcl 11 Dec 2004 11:23:00 -0000 1.6 +++ openacs-4/packages/assessment/tcl/as-item-type-oq-procs.tcl 22 Dec 2004 20:52:17 -0000 1.7 @@ -83,6 +83,11 @@ ad_proc -public as::item_type_oq::render { -type_id:required + -section_id:required + -as_item_id:required + -default_provided:boolean + {-default_value ""} + {-session_id ""} } { @author Timo Hentschel (timo@timohentschel.de) @creation-date 2004-12-10 @@ -101,6 +106,7 @@ -subject_id:required {-staff_id ""} {-response ""} + {-max_points 0} } { @author Timo Hentschel (timo@timohentschel.de) @creation-date 2004-12-11 Index: openacs-4/packages/assessment/tcl/as-item-type-sa-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/assessment/tcl/as-item-type-sa-procs.tcl,v diff -u -r1.6 -r1.7 --- openacs-4/packages/assessment/tcl/as-item-type-sa-procs.tcl 11 Dec 2004 11:23:00 -0000 1.6 +++ openacs-4/packages/assessment/tcl/as-item-type-sa-procs.tcl 22 Dec 2004 20:52:17 -0000 1.7 @@ -83,6 +83,11 @@ ad_proc -public as::item_type_sa::render { -type_id:required + -section_id:required + -as_item_id:required + -default_provided:boolean + {-default_value ""} + {-session_id ""} } { @author Timo Hentschel (timo@timohentschel.de) @creation-date 2004-12-10 @@ -99,6 +104,7 @@ -subject_id:required {-staff_id ""} {-response ""} + {-max_points 0} } { @author Timo Hentschel (timo@timohentschel.de) @creation-date 2004-12-11 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.8 -r1.9 --- openacs-4/packages/assessment/tcl/as-section-procs.tcl 17 Dec 2004 15:56:28 -0000 1.8 +++ openacs-4/packages/assessment/tcl/as-section-procs.tcl 22 Dec 2004 20:52:17 -0000 1.9 @@ -164,3 +164,84 @@ } { db_dml copy_items {} } + +ad_proc as::section::items { + {-section_id:required} + {-session_id:required} + {-sort_order_type ""} +} { + @author Timo Hentschel (timo@timohentschel.de) + @creation-date 2004-12-14 + + Returns all items of a section in the correct order. + may vary from session to session +} { + set item_list [db_list_of_lists get_sorted_items {}] + + if {[llength $item_list] > 0} { + return $item_list + } + + # get all items of section + set open_positions "" + set max_pos 0 + db_foreach section_items {} { + set section_items($as_item_id) [list $name $title $description $subtext $required_p $max_time_to_complete] + if {![empty_string_p $fixed_position] && $fixed_position != "0"} { + set fixed_positions($fixed_position) $as_item_id + if {$max_pos < $fixed_position} { + set max_pos $fixed_position + } + } else { + lappend open_positions [list $as_item_id $title] + } + } + if {$max_pos < [array size section_items]} { + set max_pos [array size section_items] + } + + # sort item positions that are not fixed + switch -exact $sort_order_type { + alphabetical { + set open_positions [lsort -dictionary -index 1 $open_positions] + } + randomized { + set open_positions [util::randomize_list $open_positions] + } + } + + # generate list of sorted items + set sorted_items "" + for {set position 1} {$position <= $max_pos} {incr position} { + if {[info exists fixed_position($position)]} { + lappend sorted_items $fixed_position($position) + array unset fixed_position $position + } elseif {[llength $open_positions] > 0} { + lappend sorted_items [lindex [lindex $open_positions 0] 0] + set open_positions [lreplace $open_positions 0 0] + } + } + # set negative fixed positions relative to the end of the item list + if {[array exists fixed_position]} { + foreach position [lsort -integer [array names fixed_positions]] { + if {$position < 0} { + lappend sorted_items $fixed_positions($position) + } + } + } + + # save item order + set count 0 + foreach as_item_id $sorted_items { + incr count + db_dml save_order {} + } + + # generate returned item-list + set item_list "" + foreach as_item_id $sorted_items { + lappend item_list [concat $as_item_id $section_items($as_item_id)] + } + + return $item_list +} 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.3 -r1.4 --- openacs-4/packages/assessment/tcl/as-section-procs.xql 10 Dec 2004 11:42:23 -0000 1.3 +++ openacs-4/packages/assessment/tcl/as-section-procs.xql 22 Dec 2004 20:52:17 -0000 1.4 @@ -49,4 +49,44 @@ + + + + select s.as_item_id, r.title, r.description, i.subtext, m.required_p, m.max_time_to_complete + from as_session_items s, as_items i, as_item_section_map m, cr_revisions r + where s.session_id = :session_id + and s.section_id = :section_id + and i.as_item_id = s.as_item_id + and r.revision_id = i.as_item_id + and m.as_item_id = s.as_item_id + and m.section_id = s.section_id + order by s.sort_order + + + + + + + + select i.as_item_id, ci.name, cr.title, cr.description, i.subtext, + m.required_p, m.max_time_to_complete, m.fixed_position + from as_item_section_map m, as_items i, cr_revisions cr, cr_items ci + where cr.revision_id = i.as_item_id + and i.as_item_id = m.as_item_id + and m.section_id = :section_id + and ci.item_id = cr.item_id + order by m.sort_order + + + + + + + + insert into as_session_items (session_id, section_id, as_item_id, sort_order) + values (:session_id, :section_id, :as_item_id, :count) + + + + 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.2 -r1.3 --- openacs-4/packages/assessment/www/assessment-oracle.xql 10 Dec 2004 20:23:00 -0000 1.2 +++ openacs-4/packages/assessment/www/assessment-oracle.xql 22 Dec 2004 20:52:17 -0000 1.3 @@ -7,7 +7,7 @@ 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_id + 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 @@ -20,7 +20,7 @@ UPDATE as_sessions SET creation_datetime = sysdate - WHERE session_id = :as_session_id + WHERE session_id = :session_id 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.6 -r1.7 --- openacs-4/packages/assessment/www/assessment-postgresql.xql 10 Dec 2004 20:21:50 -0000 1.6 +++ openacs-4/packages/assessment/www/assessment-postgresql.xql 22 Dec 2004 20:52:17 -0000 1.7 @@ -9,7 +9,7 @@ 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_id + WHERE a.assessment_id = :assessment_rev_id ORDER BY s.section_id, ism.sort_order @@ -18,7 +18,7 @@ UPDATE as_sessions SET creation_datetime = NOW() - WHERE session_id = :as_session_id + WHERE session_id = :session_id Index: openacs-4/packages/assessment/www/assessment.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/assessment/www/assessment.adp,v diff -u -r1.12 -r1.13 --- openacs-4/packages/assessment/www/assessment.adp 20 Dec 2004 13:56:53 -0000 1.12 +++ openacs-4/packages/assessment/www/assessment.adp 22 Dec 2004 20:52:17 -0000 1.13 @@ -3,60 +3,59 @@ @context;noquote@ - - + +
@assessment_name@
@assessment_instruction@
@assessment_data.title@
@assessment_data.instructions@

- - - - - -
#assessment.section#: @items.section_title@
@items.section_description@
+ + + + + +
#assessment.section#: @section.title@
@section.description@
@section.instructions@
-
   - #assessment.Items#

- +
   + #assessment.Items#

+
- - - - - - + + + + +
#assessment.Question# @items.rownum@:@items.title;noquote@
-
- - - @formgroup.widget;noquote@ - @formgroup.label;noquote@ -
-
-
- - @items.html;noquote@ - - - - - -
- [i] - @items.subtext@ -
-
-
-
-
@items.name@:#assessment.Question# @items.rownum@:@items.title;noquote@
+
+ + + @formgroup.widget;noquote@ + @formgroup.label;noquote@ +
+
+
+ + @items.html;noquote@ + + + + -
+ +
+ [i] + @items.subtext@ +
+
+ + +
+
+ +
-
-
- + 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.13 -r1.14 --- openacs-4/packages/assessment/www/assessment.tcl 20 Dec 2004 13:55:50 -0000 1.13 +++ openacs-4/packages/assessment/www/assessment.tcl 22 Dec 2004 20:52:17 -0000 1.14 @@ -5,43 +5,108 @@ @author Eduardo P�rez Ureta (eperez@it.uc3m.es) @creation-date 2004-09-13 } -query { - assessment_id:notnull + assessment_id:integer,notnull + {session_id:integer,optional ""} + {section_order:integer,optional ""} + {item_order:integer,optional ""} } -properties { - as_session_id + session_id context:onevalue } +set user_id [ad_conn user_id] set context [list "[_ assessment.Show_Items]"] -set as_session_id [as::session::new -assessment_id $assessment_id -subject_id [ad_conn user_id]] +# Get the assessment data +as::assessment::data -assessment_id $assessment_id -set assessment_name [db_string assessment_name { - SELECT title - FROM as_assessmentsx - WHERE assessment_id = :assessment_id -}] +if {![info exists assessment_data(assessment_id)]} { + ad_return_complaint 1 "[_ assessment.Requested_assess_does]" + ad_script_abort +} -set assessment_instruction [db_string assessment_instruction { - SELECT instructions - FROM as_assessmentsx - WHERE assessment_id = :assessment_id -}] +set assessment_rev_id $assessment_data(assessment_rev_id) -# update the creation_datetime col of as_sessions table to set the time when the subject initiated the Assessment -db_dml session_start {} +db_transaction { + if {[empty_string_p $session_id]} { + # todo: check if there's an old session that could be continued + set session_id [as::session::new -assessment_id $assessment_rev_id -subject_id $user_id] -# form for display an assessment with sections and items -ad_form -name show_item_form -action process-response -html {enctype multipart/form-data} -form { - { as_session_id:text {value $as_session_id} } -} + # update the creation_datetime col of as_sessions table to set the time when the subject initiated the Assessment + db_dml session_start {} + } -# get all items from an assessment -db_multirow -extend {presentation_type html} items query_all_items {} { - set presentation_type [as::item_form::add_item_to_form show_item_form $as_item_id] - # Fill in the blank item. Replace all that appear in the title by an of type="text" - if {$presentation_type == {tb}} { - regsub -all -line -nocase -- { $display(num_items)} { + # next page: more items of this section + if {[empty_string_p $item_order]} { + set item_order 0 + } + set item_order [expr $item_order + $display(num_items)] + + # show only a few items per page + set item_list [lreplace $item_list $display(num_items) end] + } else { + # next page: next section + set item_order "" + incr section_order + } + } else { + # next page: next section + incr section_order + } + + if {$section_order == [llength $section_list]} { + set section_order "" + } + + # form for display an assessment with sections and items + ad_form -name show_item_form -action process-response -html {enctype multipart/form-data} -export {assessment_id section_id section_order item_order} -form { + { session_id:text {value $session_id} } + } + + multirow create items as_item_id name title description subtext required_p max_time_to_complete presentation_type html + + foreach one_item $item_list { + util_unlist $one_item as_item_id name title description subtext required_p max_time_to_complete + + # todo: pass required_p, reuse_responses, mode:edit/display + set presentation_type [as::item_form::add_item_to_form show_item_form $session_id $section_id $as_item_id] + # Fill in the blank item. Replace all that appear in the title by an of type="text" + if {$presentation_type == {tb}} { + regsub -all -line -nocase -- { - SELECT assessment_id, name, title, description - FROM as_assessmentsx + select cr.item_id as assessment_id, cr.title, cr.description + from as_assessments a, cr_revisions cr, cr_items ci + where a.assessment_id = cr.revision_id + and cr.revision_id = ci.latest_revision Index: openacs-4/packages/assessment/www/process-response-oracle.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/assessment/www/Attic/process-response-oracle.xql,v diff -u -r1.1 -r1.2 --- openacs-4/packages/assessment/www/process-response-oracle.xql 26 Nov 2004 20:46:51 -0000 1.1 +++ openacs-4/packages/assessment/www/process-response-oracle.xql 22 Dec 2004 20:52:17 -0000 1.2 @@ -2,12 +2,19 @@ oracle8.1.6 + + + UPDATE as_sessions + SET last_mod_datetime = sysdate + WHERE session_id = :session_id + + + UPDATE as_sessions - SET last_mod_datetime = sysdate, - completed_datetime = sysdate - WHERE session_id = :as_session_id + SET completed_datetime = sysdate + WHERE session_id = :session_id Index: openacs-4/packages/assessment/www/process-response-postgresql.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/assessment/www/Attic/process-response-postgresql.xql,v diff -u -r1.1 -r1.2 --- openacs-4/packages/assessment/www/process-response-postgresql.xql 26 Nov 2004 20:46:51 -0000 1.1 +++ openacs-4/packages/assessment/www/process-response-postgresql.xql 22 Dec 2004 20:52:17 -0000 1.2 @@ -2,12 +2,19 @@ postgresql7.4 + + + UPDATE as_sessions + SET last_mod_datetime = NOW() + WHERE session_id = :session_id + + + UPDATE as_sessions - SET last_mod_datetime = NOW(), - completed_datetime = NOW() - WHERE session_id = :as_session_id + SET completed_datetime = NOW() + WHERE session_id = :session_id Index: openacs-4/packages/assessment/www/process-response.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/assessment/www/Attic/process-response.adp,v diff -u -r1.4 -r1.5 --- openacs-4/packages/assessment/www/process-response.adp 28 Sep 2004 14:17:15 -0000 1.4 +++ openacs-4/packages/assessment/www/process-response.adp 22 Dec 2004 20:52:17 -0000 1.5 @@ -3,6 +3,6 @@ @context_bar;noquote@

#assessment.Response_Submitted#

-

#assessment.View_results#

+

#assessment.View_results#

Index: openacs-4/packages/assessment/www/process-response.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/assessment/www/Attic/process-response.tcl,v diff -u -r1.13 -r1.14 --- openacs-4/packages/assessment/www/process-response.tcl 22 Dec 2004 11:01:33 -0000 1.13 +++ openacs-4/packages/assessment/www/process-response.tcl 22 Dec 2004 20:52:17 -0000 1.14 @@ -7,69 +7,40 @@ @author eperez@it.uc3m.es @date 2004-09-12 } { - as_session_id:integer,notnull + session_id:integer,notnull response_to_item:array,optional,multiple,html + assessment_id:integer,notnull + section_id:integer,notnull + section_order + item_order } set context_bar [list] +set user_id [ad_conn user_id] # FIXME Check staff_id or subject_id against user_id -# update the last_mod_datetime col of as_sessions table to set the time when the most recent submission of assessment was done -db_dml session_finished {} +db_transaction { + db_dml session_updated {} -foreach response_to_item_name [array names response_to_item] { - #reset variables - set rb__display_id {} - unset rb__display_id - set tb__display_id {} - unset tb__display_id - set ta__display_id {} - unset ta__display_id - #get the choice identifier from response_to_item array - regsub -all -line -nocase -- {.*_} $response_to_item_name {} response_to_item_choice_id - #get the item identifier from response_to_item array - regsub -all -line -nocase -- {_.*} $response_to_item_name {} response_to_item_id - set item_display_id [as::item_rels::get_target -item_rev_id $response_to_item_id -type as_item_display_rel] - db_0or1row as_item_display_rbx "SELECT as_item_display_id AS rb__display_id FROM as_item_display_rb WHERE as_item_display_id=:item_display_id" - db_0or1row as_item_display_tbx "SELECT as_item_display_id AS tb__display_id FROM as_item_display_tb WHERE as_item_display_id=:item_display_id" - db_0or1row as_item_display_tax "SELECT as_item_display_id AS ta__display_id FROM as_item_display_ta WHERE as_item_display_id=:item_display_id" - set presentation_type "checkbox" ;# DEFAULT - #set the presentation type - if {[info exists rb__display_id]} {set presentation_type "radio"} - if {[info exists tb__display_id]} {set presentation_type "fitb"} - if {[info exists ta__display_id]} {set presentation_type "textarea"} + foreach response_to_item_name [array names response_to_item] { + #get the choice identifier from response_to_item array + regsub -all -line -nocase -- {.*_} $response_to_item_name {} response_to_item_choice_id + #get the item identifier from response_to_item array + regsub -all -line -nocase -- {_.*} $response_to_item_name {} response_to_item_id - # the presentation type is textbox (fill in the blank item) - if {[info exists tb__display_id]} { - db_foreach session_responses_to_item {SELECT as_item_datax.item_id FROM as_item_datax WHERE as_item_datax.as_item_id=:response_to_item_id AND as_item_datax.choice_answer=:response_to_item_choice_id AND as_item_datax.session_id=:as_session_id} { - content::item::delete -item_id $item_id - } - #insert the answered responses by user in the CR (and as_item_data table) - foreach response $response_to_item($response_to_item_name) { - as::item_data::new -session_id $as_session_id -as_item_id $response_to_item_id -choice_answer $response_to_item_choice_id -text_answer $response - } - } else { - #the presentation type is textarea (short answer item) - if {[info exists ta__display_id]} { - db_foreach session_responses_to_item {SELECT as_item_datax.item_id FROM as_item_datax WHERE as_item_datax.as_item_id=:response_to_item_id AND as_item_datax.session_id=:as_session_id} { - content::item::delete -item_id $item_id - } - #insert the response in the CR (and as_item_data table) - foreach response $response_to_item($response_to_item_name) { - as::item_data::new -session_id $as_session_id -as_item_id $response_to_item_id -text_answer $response - } - #other types of items (presentation type is checkbox or radio) - } else { - db_foreach session_responses_to_item {SELECT as_item_datax.item_id FROM as_item_datax WHERE as_item_datax.as_item_id=:response_to_item_id AND as_item_datax.session_id=:as_session_id} { - content::item::delete -item_id $item_id - } - #insert the answered responses by user in the CR (and as_item_data table) - foreach response $response_to_item($response_to_item_name) { - as::item_data::new -session_id $as_session_id -as_item_id $response_to_item_id -choice_answer $response - } - } + db_1row item_type {} + set item_type [string range $item_type end-1 end] + + as::item_type_$item_type\::process -type_id $item_type_id -session_id $session_id -as_item_id $response_to_item_id -subject_id $user_id -response $response_to_item($response_to_item_name) -max_points $points } } +if {![empty_string_p $section_order]} { + ad_returnredirect [export_vars -base assessment {assessment_id session_id section_order item_order}] + ad_script_abort +} + +db_dml session_finished {} + ad_return_template Index: openacs-4/packages/assessment/www/process-response.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/assessment/www/Attic/process-response.xql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/assessment/www/process-response.xql 22 Dec 2004 20:52:17 -0000 1.1 @@ -0,0 +1,19 @@ + + + + + + + select o.object_type as item_type, r.target_rev_id as item_type_id, + m.points + from acs_objects o, as_item_rels r, as_item_section_map m + where r.item_rev_id = :response_to_item_id + and r.rel_type = 'as_item_type_rel' + and o.object_id = r.target_rev_id + and m.as_item_id = r.item_rev_id + and m.section_id = :section_id + + + + + Index: openacs-4/packages/assessment/www/session.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/assessment/www/session.adp,v diff -u -r1.13 -r1.14 --- openacs-4/packages/assessment/www/session.adp 20 Dec 2004 13:33:14 -0000 1.13 +++ openacs-4/packages/assessment/www/session.adp 22 Dec 2004 20:52:17 -0000 1.14 @@ -4,7 +4,7 @@ - + Index: openacs-4/packages/assessment/www/session.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/assessment/www/session.tcl,v diff -u -r1.25 -r1.26 --- openacs-4/packages/assessment/www/session.tcl 20 Dec 2004 14:04:00 -0000 1.25 +++ openacs-4/packages/assessment/www/session.tcl 22 Dec 2004 20:52:17 -0000 1.26 @@ -10,36 +10,31 @@ @author Eduardo P�rez Ureta (eperez@it.uc3m.es) @creation-date 2004-09-13 } -query { - session_id:notnull + session_id:notnull } -properties { context:onevalue } set context [list "[_ assessment.View_Results]"] -#get survey_p in order to find out whether it's an assessment or a survey -set survey_p [db_string survey_p { - SELECT a.survey_p - FROM as_assessmentsx a, as_sessionsx ss - WHERE a.assessment_id = ss.assessment_id - AND ss.session_id = :session_id -}] +db_1row find_assessment { + select r.item_id as assessment_id + from as_sessions s, cr_revisions r + where s.session_id = :session_id + and r.revision_id = s.assessment_id +} -set assessment_name [db_string assessment_name { - SELECT a.title - FROM as_assessmentsx a, as_sessionsx ss - WHERE a.assessment_id = ss.assessment_id - AND ss.session_id = :session_id -}] +# Get the assessment data +as::assessment::data -assessment_id $assessment_id -set assessment_show_feedback [db_string assessment_show_feedback { - SELECT a.show_feedback - FROM as_assessmentsx a, as_sessionsx ss - WHERE a.assessment_id = ss.assessment_id - AND ss.session_id = :session_id -}] +if {![info exists assessment_data(assessment_id)]} { + ad_return_complaint 1 "[_ assessment.Requested_assess_does]" + ad_script_abort +} -if {[empty_string_p $assessment_show_feedback]} { +set assessment_rev_id $assessment_data(assessment_rev_id) + +if {[empty_string_p $assessment_data(show_feedback)]} { set assessment_show_feedback "all" } @@ -69,7 +64,7 @@ SELECT COUNT(*) FROM as_sessionsx ss WHERE ss.subject_id = :subject_id - AND ss.assessment_id = :assessment_id + AND ss.assessment_id = :assessment_rev_id }] set assessment_score 100 ;# FIXME @@ -82,7 +77,7 @@ AND s.section_id = asm.section_id AND i.as_item_id = ism.as_item_id AND s.section_id = ism.section_id - AND a.assessment_id = :assessment_id + AND a.assessment_id = :assessment_rev_id }] #set maximum score by each item 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.1 -r1.2 --- openacs-4/packages/assessment/www/sessions-oracle.xql 26 Nov 2004 20:46:51 -0000 1.1 +++ openacs-4/packages/assessment/www/sessions-oracle.xql 22 Dec 2004 20:52:17 -0000 1.2 @@ -5,26 +5,28 @@ - SELECT s.session_id, s.name, s.title, s.completed_datetime, + SELECT s.session_id, s.name, s.title, s.completed_datetime, s.percent_score, p.first_names || ' ' || p.last_name AS subject_name, a.title AS assessment_name, s.subject_id FROM as_sessionsx s, as_assessmentsx a, persons p - WHERE s.assessment_id = :assessment_id + WHERE s.assessment_id = :assessment_rev_id AND s.assessment_id = a.assessment_id AND s.subject_id = p.person_id + ORDER BY s.completed_datetime desc, s.creation_datetime desc - SELECT s.session_id, s.name, s.title, s.completed_datetime, + SELECT s.session_id, s.name, s.title, s.completed_datetime, s.percent_score, p.first_names || ' ' || p.last_name AS subject_name, a.title AS assessment_name, s.subject_id FROM as_sessionsx s, as_assessmentsx a, persons p - WHERE s.assessment_id = :assessment_id + WHERE s.assessment_id = :assessment_rev_id AND s.assessment_id = a.assessment_id AND s.subject_id = p.person_id AND s.subject_id = :subject_id + ORDER BY s.completed_datetime desc, s.creation_datetime desc 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.3 -r1.4 --- openacs-4/packages/assessment/www/sessions-postgresql.xql 20 Dec 2004 14:01:46 -0000 1.3 +++ openacs-4/packages/assessment/www/sessions-postgresql.xql 22 Dec 2004 20:52:17 -0000 1.4 @@ -10,8 +10,22 @@ a.title AS assessment_name, s.subject_id FROM as_sessionsx s INNER JOIN as_assessmentsx a USING (assessment_id) INNER JOIN persons p ON (s.subject_id = p.person_id) - WHERE s.assessment_id = :assessment_id + WHERE s.assessment_id = :assessment_rev_id AND s.subject_id = :subject_id + ORDER BY s.completed_datetime desc, s.creation_datetime desc + + + + SELECT s.session_id, s.name, s.title, s.completed_datetime, s.percent_score, + p.first_names || ' ' || p.last_name AS subject_name, + a.title AS assessment_name, s.subject_id + FROM as_sessionsx s INNER JOIN as_assessmentsx a USING (assessment_id) + INNER JOIN persons p ON (s.subject_id = p.person_id) + WHERE s.assessment_id = :assessment_rev_id + ORDER BY s.completed_datetime desc, s.creation_datetime desc + + + Index: openacs-4/packages/assessment/www/sessions.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/assessment/www/sessions.tcl,v diff -u -r1.10 -r1.11 --- openacs-4/packages/assessment/www/sessions.tcl 22 Dec 2004 11:12:27 -0000 1.10 +++ openacs-4/packages/assessment/www/sessions.tcl 22 Dec 2004 20:52:17 -0000 1.11 @@ -7,98 +7,105 @@ @author Eduardo P�rez Ureta (eperez@it.uc3m.es) @creation-date 2004-09-03 } { - assessment_id:notnull - subject_id:notnull + assessment_id:notnull + {subject_id:integer,optional ""} } -properties { - context:onevalue - assessment_info:multirow + context:onevalue + assessment_info:multirow } set context [list "[_ assessment.Show_Sessions]"] set package_id [ad_conn package_id] -#get the user that take an assessment -#set subject_id [ad_conn user_id] -set subject_id $subject_id +if {[empty_string_p $subject_id]} { + set subject_id [ad_conn user_id] +} -#if it's an assessment or a survey -set assessment_or_survey [db_string assessment_or_survey { - SELECT survey_p - FROM as_assessmentsx - WHERE assessment_id = :assessment_id -}] +# Get the assessment data +as::assessment::data -assessment_id $assessment_id -if {$assessment_or_survey == {t}} { -#Lists the identifier of sessions, the name of subjects that took this assessment, the name of assessment and the finished time -#of assessment for an assessment. -template::list::create \ - -name sessions \ - -multirow sessions \ - -key sessions_id \ - -elements { - session_id { - label {[_ assessment.Session]} - link_url_eval {[export_vars -base "session" {session_id}]} - } - subject_name { - label {[_ assessment.Subject_Name]} - link_url_eval {[acs_community_member_url -user_id $subject_id]} +if {![info exists assessment_data(assessment_id)]} { + ad_return_complaint 1 "[_ assessment.Requested_assess_does]" + ad_script_abort +} - } - assessment_name { - label {Assessment} - link_url_eval {[export_vars -base "assessment" {assessment_id}]} +set assessment_rev_id $assessment_data(assessment_rev_id) + +if {$assessment_data(survey_p) == "t"} { + # Lists the identifier of sessions, the name of subjects that took this assessment, + # the name of assessment and the finished time + # of assessment for an assessment. + + template::list::create \ + -name sessions \ + -multirow sessions \ + -key sessions_id \ + -elements { + session_id { + label {[_ assessment.Session]} + link_url_eval {[export_vars -base "session" {session_id}]} + } + subject_name { + label {[_ assessment.Subject_Name]} + link_url_eval {[acs_community_member_url -user_id $subject_id]} + + } + assessment_name { + label {Assessment} + link_url_eval {[export_vars -base "assessment" {assessment_id}]} + } + completed_datetime { + label {[_ assessment.Finish_Time]} + html {nowrap} + } + } -main_class { + narrow } - completed_datetime { - label {[_ assessment.Finish_Time]} - html {nowrap} - } - } \ - -main_class { - narrow - } } else { -template::list::create \ - -name sessions \ - -multirow sessions \ - -key sessions_id \ - -elements { - session_id { - label {[_ assessment.Session]} - link_url_eval {[export_vars -base "session" {session_id}]} - } - subject_name { - label {[_ assessment.Subject_Name]} - link_url_eval {[acs_community_member_url -user_id $subject_id]} + template::list::create \ + -name sessions \ + -multirow sessions \ + -key sessions_id \ + -elements { + session_id { + label {[_ assessment.Session]} + link_url_eval {[export_vars -base "session" {session_id}]} + } + subject_name { + label {[_ assessment.Subject_Name]} + link_url_eval {[acs_community_member_url -user_id $subject_id]} - } - assessment_name { - label {Assessment} - link_url_eval {[export_vars -base "assessment" {assessment_id}]} + } + assessment_name { + label {Assessment} + link_url_eval {[export_vars -base "assessment" {assessment_id}]} + } + completed_datetime { + label {[_ assessment.Finish_Time]} + html {nowrap} + } + percent_score { + label {[_ assessment.Percent_Score]} + html {nowrap} + } + } -main_class { + narrow } - completed_datetime { - label {[_ assessment.Finish_Time]} - html {nowrap} - } - percent_score { - label {[_ assessment.Percent_Score]} - html {nowrap} - } - } \ - -main_class { - narrow - } } -set assessment_id_multi $assessment_id #if the user is admin he will display all sessions from all subjects -db_multirow -extend { item_url assessment_id } sessions sessions_of_assessment { +if {[ad_permission_p [acs_magic_object "security_context_root"] "admin"]} { + set query "sessions_of_assessment_of_subject" +} else { + set query "sessions_of_assessment" +} + +db_multirow -extend { item_url assessment_id } sessions $query { } { set item_url [export_vars -base "session" {session_id}] - set assessment_id $assessment_id_multi } 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.4 -r1.5 --- openacs-4/packages/assessment/www/admin/assessment-form.tcl 6 Dec 2004 12:26:53 -0000 1.4 +++ openacs-4/packages/assessment/www/admin/assessment-form.tcl 22 Dec 2004 20:52:18 -0000 1.5 @@ -12,7 +12,8 @@ if {[info exists assessment_id]} { set page_title [_ assessment.Edit_Assessment] - set _assessment_id [db_string rev_id_from_item_id {}] + set _assessment_id 0 + db_0or1row rev_id_from_item_id {} } else { set page_title [_ assessment.New_Assessment2] set _assessment_id 0 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.3 -r1.4 --- openacs-4/packages/assessment/www/admin/assessment-form.xql 6 Dec 2004 12:26:53 -0000 1.3 +++ openacs-4/packages/assessment/www/admin/assessment-form.xql 22 Dec 2004 20:52:18 -0000 1.4 @@ -30,7 +30,7 @@ - select latest_revision + select latest_revision as _assessment_id from cr_items where item_id = :assessment_id Index: openacs-4/packages/assessment/www/admin/catalog-item-add.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/assessment/www/admin/Attic/catalog-item-add.tcl,v diff -u -r1.2 -r1.3 --- openacs-4/packages/assessment/www/admin/catalog-item-add.tcl 10 Dec 2004 11:42:23 -0000 1.2 +++ openacs-4/packages/assessment/www/admin/catalog-item-add.tcl 22 Dec 2004 20:52:18 -0000 1.3 @@ -69,18 +69,14 @@ } db_multirow -extend { presentation_type html } items items {} { - set presentation_type [as::item_form::add_item_to_form show_items $as_item_id] + set presentation_type [as::item_form::add_item_to_form show_items "" $section_id $as_item_id] if {$presentation_type == "fitb"} { regsub -all -line -nocase -- { update as_item_section_map - set as_item_id = :new_item_id + set as_item_id = :new_item_id, + points = :points where section_id = :new_section_id and as_item_id = :as_item_id Index: openacs-4/packages/assessment/www/admin/item-edit-mc.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/assessment/www/admin/Attic/item-edit-mc.tcl,v diff -u -r1.1 -r1.2 --- openacs-4/packages/assessment/www/admin/item-edit-mc.tcl 8 Dec 2004 15:30:34 -0000 1.1 +++ openacs-4/packages/assessment/www/admin/item-edit-mc.tcl 22 Dec 2004 20:52:18 -0000 1.2 @@ -37,7 +37,7 @@ {title:text {label "[_ assessment.Title]"} {html {size 80 maxlength 1000}} {help_text "[_ assessment.mc_Title_help]"}} {increasing_p:text(select) {label "[_ assessment.Increasing]"} {options $boolean_options} {help_text "[_ assessment.Increasing_help]"}} {negative_p:text(select) {label "[_ assessment.Allow_Negative]"} {options $boolean_options} {help_text "[_ assessment.Allow_Negative_help]"}} - {num_correct_answers:text {label "[_ assessment.num_Correct_Answer]"} {html {size 5 maxlength 5}} {help_text "[_ assessment.num_Correct_help]"}} + {num_correct_answers:text,optional {label "[_ assessment.num_Correct_Answer]"} {html {size 5 maxlength 5}} {help_text "[_ assessment.num_Correct_help]"}} {num_answers:text,optional {label "[_ assessment.num_Answers]"} {html {size 5 maxlength 5}} {help_text "[_ assessment.num_Answers_help]"}} } Index: openacs-4/packages/assessment/www/admin/one-a.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/assessment/www/admin/Attic/one-a.tcl,v diff -u -r1.4 -r1.5 --- openacs-4/packages/assessment/www/admin/one-a.tcl 10 Dec 2004 11:42:23 -0000 1.4 +++ openacs-4/packages/assessment/www/admin/one-a.tcl 22 Dec 2004 20:52:18 -0000 1.5 @@ -48,11 +48,7 @@ if {[empty_string_p $points]} { set points 0 } - if {![empty_string_p $max_time_to_complete]} { - set max_min [expr $max_time_to_complete / 60] - set max_sec [expr $max_time_to_complete - ($max_min * 60)] - set max_time_to_complete "$max_min\:$max_sec min" - } + set max_time_to_complete [as::assessment::pretty_time -seconds $max_time_to_complete] } ad_return_template Index: openacs-4/packages/assessment/www/admin/section-form.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/assessment/www/admin/Attic/section-form.tcl,v diff -u -r1.4 -r1.5 --- openacs-4/packages/assessment/www/admin/section-form.tcl 10 Dec 2004 11:42:24 -0000 1.4 +++ openacs-4/packages/assessment/www/admin/section-form.tcl 22 Dec 2004 20:52:18 -0000 1.5 @@ -47,7 +47,7 @@ } } else { ad_form -extend -name section_form -form { - {name:text {label "[_ assessment.Name]"} {html {size 80 maxlength 1000}} {help_text "[_ assessment.section_Name_help]"}} + {name:text,optional {label "[_ assessment.Name]"} {html {size 80 maxlength 1000}} {help_text "[_ assessment.section_Name_help]"}} } } @@ -83,22 +83,22 @@ db_transaction { set new_assessment_rev_id [as::assessment::new_revision -assessment_id $assessment_id] - set section_id [as::section::new \ - -name $name \ - -title $title \ - -description $description \ - -instructions $instructions \ - -feedback_text $feedback_text \ - -max_time_to_complete $max_time_to_complete \ - -points $points_p \ - -display_type_id $display_type_id] + set new_section_id [as::section::new \ + -name $name \ + -title $title \ + -description $description \ + -instructions $instructions \ + -feedback_text $feedback_text \ + -max_time_to_complete $max_time_to_complete \ + -points $points \ + -display_type_id $display_type_id] db_dml move_down_sections {} set sort_order [expr $after + 1] db_dml add_section_to_assessment {} if {[exists_and_not_null category_ids]} { - category::map_object -object_id $section_id $category_ids + category::map_object -object_id $new_section_id $category_ids } } } -edit_data {
#assessment.Review_Asessment# @assessment_name@
#assessment.Review_Asessment# @assessment_data.title@
#assessment.User_ID#: @session_user_name@ #assessment.Attempt#: @session_attempt@ / Unlimited #assessment.Out_of#: @assessment_score@