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.2.6.1 -r1.2.6.2 --- openacs-4/packages/assessment/tcl/as-item-type-mc-procs-postgresql.xql 5 Feb 2007 14:12:47 -0000 1.2.6.1 +++ openacs-4/packages/assessment/tcl/as-item-type-mc-procs-postgresql.xql 4 Jul 2007 01:42:08 -0000 1.2.6.2 @@ -42,7 +42,7 @@ - select c.choice_id, r.title, c.correct_answer_p, c.selected_p, c.fixed_position, + select c.choice_id, r.title, c.correct_answer_p, c.selected_p, c.fixed_position, c.feedback_text, r2.revision_id as content_rev_id, r2.title as content_filename, i.content_type from cr_revisions r, as_item_choices c 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.21.2.3 -r1.21.2.4 --- openacs-4/packages/assessment/tcl/as-item-type-mc-procs.tcl 29 Jun 2007 22:34:12 -0000 1.21.2.3 +++ openacs-4/packages/assessment/tcl/as-item-type-mc-procs.tcl 4 Jul 2007 01:42:08 -0000 1.21.2.4 @@ -155,7 +155,6 @@ array set values $default_value set defaults $values(choice_answer) } - if {![empty_string_p $session_id]} { if {[empty_string_p $show_feedback] || $show_feedback == "none"} { set choice_list "" @@ -166,6 +165,7 @@ } else { # incorrect correct set choice_list "" + db_foreach get_sorted_choices_with_feedback {} { set title [as::assessment::display_content -content_id $content_rev_id -filename $content_filename -content_type $content_type -title $title] set pos [lsearch -exact -integer $defaults $choice_id] @@ -197,7 +197,25 @@ db_foreach choices {} { incr total set title [as::assessment::display_content -content_id $content_rev_id -filename $content_filename -content_type $content_type -title $title] - lappend display_choices [list $title $choice_id] +selected_p = '${selected_p}' correct_answer_p = '${correct_answer_p}'" + if {$show_feedback ne "" && $show_feedback ne "none"} { + set pos [lsearch -exact -integer $defaults $choice_id] + if {$pos > -1 && $correct_answer_p == "t" && $show_feedback != "incorrect"} { + lappend display_choices [list "$title $feedback_text" $choice_id] + } elseif {$pos>-1 && $correct_answer_p == "f" && $show_feedback != "correct"} { + lappend display_choices [list "$title $feedback_text" $choice_id] + } else { + if {$correct_answer_p == "t" && $show_feedback != "incorrect" && $show_feedback != "correct"} { + lappend display_choices [list "$title " $choice_id] + } else { + lappend display_choices [list $title $choice_id] + } + } + } else { + lappend display_choices [list $title $choice_id] + } + +# lappend display_choices [list $title $choice_id] if {$selected_p == "t"} { lappend defaults $choice_id } @@ -244,7 +262,6 @@ set display_choices [concat $display_choices [lrange $wrong_choices 0 [expr $num_answers - [llength $display_choices] -1]]] set display_choices [util::randomize_list $display_choices] } - # now add fixed positions in result list if {[array exists fixed_pos]} { set max_pos [expr $num_answers + [array size fixed_pos]] @@ -503,7 +520,7 @@ as::item::update_item_type -item_type_id $mc_id -as_item_id $as_item_id } - ns_log notice "item-add inserting choices!! as_item_id = '${as_item_id}' mc_id='${mc_id}'" + set count 0 foreach i [lsort -integer [array names choice]] { if {![empty_string_p $choice($i)]} { @@ -518,7 +535,7 @@ -correct_answer_p [ad_decode [info exists correct($i)] 0 f t] \ -sort_order $count \ -percent_score ""] - ns_log notice "choice $count added for choice $i $choice($i) choice_id=${choice_id}" + } } #FIXME add a select one/select all that apply option @@ -581,7 +598,7 @@ [list delete.$id:text(submit) {label "Delete"}]] } ad_form -extend -name $form_id -form [list [list choice.$id:text,optional,nospell {label "[_ assessment.Choice] $id"} {html {style {width: 60%;} maxlength 1000}} {value "$value"} ]] -ns_log notice "--- $id ---" + if {[info exists correct($id)]} { ad_form -extend -name $form_id -form [list [list correct.$id:text(checkbox),optional {label "[_ assessment.Correct_Answer_Choice] $id"} {options $correct_options} {values t} ]] } else {