Index: openacs-4/packages/assessment/lib/session-items.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/assessment/lib/session-items.tcl,v diff -u -r1.8 -r1.9 --- openacs-4/packages/assessment/lib/session-items.tcl 8 Dec 2005 11:20:45 -0000 1.8 +++ openacs-4/packages/assessment/lib/session-items.tcl 20 May 2006 16:38:05 -0000 1.9 @@ -32,18 +32,65 @@ if {![empty_string_p $default_value]} { array set values $default_value set result_points $values(points) + set item_data_id $values(item_data_id) array unset values set answered_p t - if {$result_points < $points} { - if {$show_feedback != "correct"} { - set feedback "$feedback_wrong" - } + if { $points != 0 } { + if {$result_points < $points} { + if {$show_feedback != "correct"} { + set feedback "$feedback_wrong" + } + } else { + if {$show_feedback != "incorrect"} { + set feedback "$feedback_right" + } + } } else { - if {$show_feedback != "incorrect"} { - set feedback "$feedback_right" + if {$presentation_type == "rb" || $presentation_type == "cb"} { + set user_answers [db_list get_user_choice_answers {}] + + set correct_answers [db_list get_correct_choice_answers {}] + + if { $presentation_type == "rb" } { + set user_answers [lindex $user_answers 0] + + if { [lsearch $correct_answers $user_answers] == -1 } { + if {$show_feedback != "correct"} { + set feedback "$feedback_wrong" + } + } else { + if {$show_feedback != "incorrect"} { + set feedback "$feedback_right" + } + } + } else { + # Checkbox, all answers must be correct if no + # points are set + if { [llength $user_answers] != [llength $correct_answers] } { + set correct_p 0 + } else { + set correct_p 1 + foreach one_answer $user_answers { + if { [lsearch $correct_answers $one_answer] == -1 } { + set correct_p 0 + break + } + } + } + + if { !$correct_p } { + if {$show_feedback != "correct"} { + set feedback "$feedback_wrong" + } + } else { + if {$show_feedback != "incorrect"} { + set feedback "$feedback_right" + } + } + } } - } + } } else { set result_points "" set feedback "" Index: openacs-4/packages/assessment/lib/session-items.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/assessment/lib/session-items.xql,v diff -u -r1.6 -r1.7 --- openacs-4/packages/assessment/lib/session-items.xql 15 Apr 2005 17:26:45 -0000 1.6 +++ openacs-4/packages/assessment/lib/session-items.xql 20 May 2006 16:38:05 -0000 1.7 @@ -21,4 +21,30 @@ + + + select choice_id + from as_item_data_choices + where item_data_id = :item_data_id + + + + + + select c.choice_id + + from as_item_choices c + + where c.mc_id = (select max(t.as_item_type_id) + from as_item_type_mc t, cr_revisions c, as_item_rels r + where t.as_item_type_id = r.target_rev_id + and r.item_rev_id = :as_item_id + and r.rel_type = 'as_item_type_rel' + and c.revision_id = t.as_item_type_id + group by c.title, t.increasing_p, t.allow_negative_p, + t.num_correct_answers, t.num_answers) + and c.correct_answer_p = 't' + + +