xowf::WorkflowPage instproc post_process_dom_tree (public)
<instance of xowf::WorkflowPage> post_process_dom_tree dom_doc \ dom_root form_fields
Defined in /var/www/openacs.org/packages/xowf/tcl/xowf-procs.tcl
post-process form in edit mode to provide feedback in feedback mode
- Parameters:
- dom_doc (required)
- dom_root (required)
- form_fields (required)
- Testcases:
- create_workflow_with_instance
Source code: # In feedback mode, we set the CSS class to correct or incorrect if {[info exists :__feedback_mode]} { unset :__feedback_mode ::xo::Page requireCSS /resources/xowf/feedback.css set form [lindex [$dom_root selectNodes "//form"] 0] $form setAttribute class "[$form getAttribute class] feedback" # # In cases, where the HTML exercise was given, we process the HTML # to flag the result. # # TODO: What should we do with the feedback. "util_user_message" is # not optimal... # foreach f $form_fields { if {[$f exists __rendered]} continue if {[$f exists evaluated_answer_result]} { set result [$f set evaluated_answer_result] foreach n [$dom_root selectNodes "//form//*\[@name='[$f name]'\]"] { set oldCSSClass [expr {[$n hasAttribute class] ? [$n getAttribute class] : ""}] $n setAttribute class [string trim "$oldCSSClass [$f form_widget_CSSclass]"] $f form_widget_CSSclass $result set helpText [$f help_text] if {$helpText ne ""} { #set divNode [$dom_doc createElement div] #$divNode setAttribute class [$f form_widget_CSSclass] #$divNode appendChild [$dom_doc createTextNode $helpText] #[$n parentNode] insertBefore $divNode [$n nextSibling] #set spanNode [$dom_doc createElement span] #$spanNode setAttribute class "glyphicon glyphicon-ok [$f form_widget_CSSclass]" #[$n parentNode] insertBefore $spanNode [$n nextSibling] set parentNode [$n parentNode] set oldClass [$parentNode getAttribute class ""] $parentNode setAttribute class "selection [$f form_widget_CSSclass]" $parentNode setAttribute title $helpText #util_user_message -message "field [$f name], value [$f value]: $helpText" } } } } # # Provide feedback for the whole exercise. # if {[:answer_is_correct]} { set feedback [:get_from_template feedback_correct] } else { set feedback [:get_from_template feedback_incorrect] } if {$feedback ne ""} { $dom_root appendFromScript { html::div -class feedback { html::t -disableOutputEscaping $feedback } } } }XQL Not present: Generic, PostgreSQL, Oracle