- Methods: All Methods Documented Methods Hide Methods
- Source: Display Source Hide Source
- Variables: Show Variables Hide Variables
Class ::xowiki::includelet::form-stats
::xowiki::includelet::form-statsInclude form statistics for the specofied Form page.create ... \
[ -__decoration (default "plain") ] \
[ -parameter_declaration (default " {-form} {-parent_id} {-property _state} {-orderby "count,desc"} {-renderer "table"} ") ]
Defined in /var/www/openacs.org/packages/xowiki/tcl/includelet-procs.tcl
Class Relations
::xowiki::IncludeletClass create ::xowiki::includelet::form-stats \ -superclass ::xowiki::IncludeletMethods (to be applied on instances)
__decoration (setter)
parameter_declaration (setter)
render (scripted)
:get_parameters set o ${:__including_page} if {![info exists parent_id]} {set parent_id [$o parent_id]} set form_item_ids [::$package_id instantiate_forms -forms $form -parent_id $parent_id] if {[llength $form_item_ids] != 1} { return "no such form $form<br>\n" } set items [::xowiki::FormPage get_form_entries -base_item_ids $form_item_ids -form_fields "" -always_queried_attributes "*" -initialize false -publish_status all -package_id $package_id] set sum 0 foreach i [$items children] { set value "" if {[string match _* $property]} { set varname [string range $property 1 end] if {[$i exists $varname]} {set value [$i set $varname]} } else { set instance_attributes [$i set instance_attributes] if {[dict exists $instance_attributes $property]} { set value [dict get $instance_attributes $property] } } if {[info exists __count($value)]} {incr __count($value)} else {set __count($value) 1} incr sum 1 } if {$sum == 0} { return "[_ xowiki.no_data]<br>\n" } if {$renderer eq "highcharts"} { # # experimental highcharts pie renderer # set percentages [list] foreach {value count} [array get __count] { lappend percentages $value [format %.2f [expr {$count*100.0/$sum}]] } set h [highcharts new -volatile -id [:js_name] -title [::xowiki::Includelet js_encode "$sum $total_text [_ xowiki.Answers_for_Survey] '[$form_item_ids title]'"]] return [$h pie [list value count] $percentages] } else { # # standard table encoder # [:tableWidget] create t1 -volatile -columns { Field create value -orderby value -label value Field create count -orderby count -label count } lassign [split $orderby ,] att order t1 orderby -order [expr {$order eq "asc" ? "increasing" : "decreasing"}] $att foreach {value count} [array get __count] { t1 add -value $value -count $count } return [t1 asHTML] }
- Methods: All Methods Documented Methods Hide Methods
- Source: Display Source Hide Source
- Variables: Show Variables Hide Variables