xowf::test_item::Answer_manager method render_submission=edit_history (protected)
<instance of xowf::test_item::Answer_manager> render_submission=edit_history \ [ -submission submission ] [ -examWf examWf ] \ [ -nameToQuestionObj nameToQuestionObj ]
Defined in packages/xowf/tcl/test-item-procs.tcl
- Switches:
- -submission (optional, object)
- -examWf (optional, object)
- -nameToQuestionObj (optional)
- Testcases:
- No testcase defined.
Source code: set last_answers {} set rev_nr 1 set q_nr 0 set qnames "" set report "" set student_href [$examWf pretty_link -query m=print-answers&id=[$submission set item_id]] set revision_sets [$submission get_revision_sets -with_instance_attributes] foreach s $revision_sets { set msgs {} set ia [ns_set get $s instance_attributes] foreach key [dict keys $ia *_] { if {![dict exists $qnames $key]} { dict set qnames $key [incr q_nr] } set value [dict get $ia $key] # # Determine the question type # set form_obj [dict get $nameToQuestionObj $key] set template_obj [$form_obj page_template] if {[$template_obj name] eq "en:edit-interaction.wf"} { set item_type [dict get [$form_obj instance_attributes] item_type] } else { switch [$template_obj name] { en:TestItemShortText.form {set item_type ShortText} en:TestItemText.form {set item_type Text} default {set item_type unknown} } } #ns_log notice "Template name = [$template_obj name] -> item_type '$item_type'" # # For the time being, compute the differences just for short text questions # if {$item_type in {ShortText}} { foreach answer_key [dict keys $value] { set answer_value [string trim [dict get $value $answer_key]] set what "" set last_value [:dict_value $last_answers $answer_key ""] if {$last_value ne ""} { if {$answer_value eq ""} { set what cleared ns_log notice " ==> $answer_key: answer_value '$last_value' cleared in revision $rev_nr" } elseif {$answer_value ne $last_value} { set what updated } } else { # last answer was empty if {$answer_value ne ""} { set what added } } # # Remember last answer values # dict set last_answers $answer_key $answer_value if {$what ne ""} { if {$what eq "cleared"} { set answer_value $last_value } lappend msgs [subst { <span class='alert-[dict get {cleared warning added success updated info "" ""} $what]'> q[string map [list answer "" {*}$qnames] $answer_key] $what [ns_quotehtml '$answer_value'] </span> }] } } } else { # # Show the full content of the field # if {$value ne ""} { lappend msgs [subst { <span class=''>q[string map [list answer "" {*}$qnames] $key]: [ns_quotehtml '$value']</span> }] } } } append report [subst { <a href='[ns_quotehtml $student_href&rid=[ns_set get $s revision_id]]'>[format %02d $rev_nr]</a>: [join $msgs {; }]<br> }] incr rev_nr } append HTML [subst { <tr> <td><a href='[ns_quotehtml $student_href]'>[$submission set online-exam-userName]</td> <td>[$submission set online-exam-fullName]</td> <td>$report</td> </tr> }] return $HTMLXQL Not present: Generic, PostgreSQL, Oracle