::xowiki::IncludeletClass
::xowiki::includelet::form-stats
Class Hierarchy of ::xowiki::includelet::form-stats
- ::xotcl::Object
- Meta-class:
- ::xotcl::Class
![[i]](/resources/acs-subsite/ZoomIn16.gif)
- Methods for instances:
- __api_make_doc, __api_make_forward_doc, __timediff, abstract, ad_doc, ad_forward, ad_proc, appendC, arrayC, asHTML, autonameC, check, classC, cleanupC, configureC, containsC, copyC, db_0or1rowC, db_1rowC, debug, defaultmethodC, destroyC, destroy_on_cleanup, ds, evalC, existsC, extractConfigureArg, filterC, filterguardC, filtersearch, forward, hasclass, incrC, infoC, init, instvarC, invarC, isclass, ismetaclass, ismixin, isobject, istype, lappendC, log, method, mixinC, mixinguardC, moveC, msg, noinitC, objectparameter, parametercmdC, proc, procsearch, qn, requireNamespaceC, residualargsC, self, serialize, setC, set_instance_vars_defaults, show-object, substC, traceC, unknown, unsetC, uplevelC, upvarC, volatileC, vwait
- Methods to be applied on the class (in addition to the methods provided by the meta-class):
- getExitHandler, setExitHandler, unsetExitHandler
- ::xo::Context
- Meta-class:
- ::xotcl::Class
![[i]](/resources/acs-subsite/ZoomIn16.gif)
- Parameter for instances:
- actual_query (default " "), locale, package_id (default "0"), parameter_declaration (default "")
- Methods for instances:
- exists_query_parameter, export_vars, get_all_query_parameter, get_parameters, initialize, original_url_and_query, process_query_parameter, query_parameter
- Methods to be applied on the class:
- Methods provided by the meta-class
- ::xowiki::Includelet
- Meta-class:
- ::xotcl::Class
![[i]](/resources/acs-subsite/ZoomIn16.gif)
- Parameter for instances:
- __decoration (default "portlet"), id, name (default ""), parameter_declaration (default ""), title (default "")
- Methods for instances:
- category_clause, get_page_order, include_head_entries, initialize, js_name, resolve_page_name, screen_name
- Methods to be applied on the class (in addition to the methods provided by the meta-class):
- available_includelets, describe_includelets, glob_clause, html_encode, html_id, html_to_text, js_encode, js_name, listing, locale_clause, parent_id_clause, publish_status_clause, require_YUI_CSS, require_YUI_JS
- ::xowiki::includelet::form-stats
- Meta-class:
- ::xowiki::IncludeletClass
![[i]](/resources/acs-subsite/ZoomIn16.gif)
- Parameter for instances:
- __decoration (default "plain"), parameter_declaration (default "
{-form}
{-parent_id}
{-property _state}
{-orderby "count,desc"}
{-renderer "table"}
")
- Methods for instances:
- render
- Methods to be applied on the class:
- Methods provided by the meta-class
Class Relations
- superclass: ::xowiki::Includelet
![[i]](/resources/acs-subsite/ZoomIn16.gif)
::xowiki::IncludeletClass create ::xowiki::includelet::form-stats \
-superclass ::xowiki::Includelet \
-parameter {{__decoration plain} {parameter_declaration {
{-form}
{-parent_id}
{-property _state}
{-orderby "count,desc"}
{-renderer "table"}
}}}
Methods
instproc render
::102042 instproc render {} {
my get_parameters
set o [my set __including_page]
if {![info exists parent_id]} {set parent_id [$o parent_id]}
set form_item_ids [::xowiki::Weblog instantiate_forms -forms $form -package_id $package_id -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 {
array set __ia [$i set instance_attributes]
set varname __ia($property)
if {[info exists $varname]} {set value [set $varname]}
}
if {[info exists __count($value)]} {incr __count($value)} else {set __count($value) 1}
incr sum 1
}
if {$sum == 0} {
return "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 [my js_name] -title [::xowiki::Includelet js_encode "$sum Answers for Survey '[$form_item_ids title]'"]]
return [$h pie [list value count] $percentages]
} else {
#
# standard table encoder
#
TableWidget t1 -volatile -columns {
Field value -orderby value -label value
Field count -orderby count -label count
}
foreach {att order} [split $orderby ,] break
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]
}
}