Class ::xowiki::includelet::form-stats (public)

 ::xowiki::IncludeletClass ::xowiki::includelet::form-stats[i]

Defined in /var/www/openacs.org/packages/xowiki/tcl/includelet-procs.tcl

Include form statistics for the specofied Form page.

Testcases:
No testcase defined.
Source code:
namespace eval ::xowiki::includelet {}
::nsf::object::alloc ::xowiki::IncludeletClass ::xowiki::includelet::form-stats {set :__default_metaclass ::xotcl::Class
   set :__default_superclass ::xotcl::Object
   set :aggregating false
   set :cacheable false
   set :localized true
   set :personalized true}
::xowiki::includelet::form-stats instproc render {} {
    :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]
    }
  }
::xowiki::includelet::form-stats instparametercmd __decoration
::xowiki::includelet::form-stats instparametercmd parameter_declaration
::nsf::relation::set ::xowiki::includelet::form-stats superclass ::xowiki::Includelet

::nx::slotObj -container slot ::xowiki::includelet::form-stats
::xowiki::includelet::form-stats::slot eval {set :__parameter {
        {__decoration plain}
        {parameter_declaration {
          {-form}
          {-parent_id}
          {-property _state}
          {-orderby "count,desc"}
          {-renderer "table"}

        }}
      }}

::nsf::object::alloc ::xotcl::Attribute ::xowiki::includelet::form-stats::slot::parameter_declaration {set :accessor public
   set :configurable true
   set :convert false
   set :default {
          {-form}
          {-parent_id}
          {-property _state}
          {-orderby "count,desc"}
          {-renderer "table"}

        }
   set :defaultmethods {}
   set :disposition alias
   set :domain ::xowiki::includelet::form-stats
   set :incremental 0
   set :manager ::xowiki::includelet::form-stats::slot::parameter_declaration
   set :methodname parameter_declaration
   set :multiplicity 1..1
   set :name parameter_declaration
   set :per-object false
   set :position 0
   set :required false
   set :substdefault 0b111
   set :trace none
   : init}

::nsf::object::alloc ::xotcl::Attribute ::xowiki::includelet::form-stats::slot::__decoration {set :accessor public
   set :configurable true
   set :convert false
   set :default plain
   set :defaultmethods {}
   set :disposition alias
   set :domain ::xowiki::includelet::form-stats
   set :incremental 0
   set :manager ::xowiki::includelet::form-stats::slot::__decoration
   set :methodname __decoration
   set :multiplicity 1..1
   set :name __decoration
   set :per-object false
   set :position 0
   set :required false
   set :substdefault 0b111
   set :trace none
   : init}
XQL Not present:
Generic, PostgreSQL, Oracle
[ hide source ] | [ make this the default ]
Show another procedure: