xowf::test_item::Question_manager method question_statistics_block (public)

 <instance of xowf::test_item::Question_manager[i]> question_statistics_block \
    obj

Defined in packages/xowf/tcl/test-item-procs.tcl

When we have results, we can provide statistics

Parameters:
obj (required)

Testcases:
No testcase defined.
Source code:
set HTML ""
if {[$obj state] in {done submission_review}} {

  template::head::add_link -rel stylesheet -href /resources/xowf/test-item.css
  set combined_form_info [:combined_question_form -with_numbers $obj]

  #
  # Get the form-field objects with all alternatives (use flag
  # "-generic")
  #
  set form_field_objs [:AM answer_form_field_objs  -generic  -wf [:AM get_answer_wf $obj]  $combined_form_info]
  #
  # Get the persisted statistics from the workflow
  # instance. These statistics are computed when the exam
  # protocol is rendered.
  #
  set statistics [:AM get_exam_results -obj $obj statistics]
  if {$statistics ne ""} {
    foreach var {success_statistics count_statistics} key {success count} {
      if {[dict exists $statistics $key]} {
        set $var [dict get $statistics $key]
      } else {
        set $var ""
      }
    }

    #
    # Merge the statistics into the generic form-fields such we
    # can use the usual form-field based rendering.
    #
    foreach form_field_obj $form_field_objs {
      #
      # The linkage between the statistics and the form-fields
      # is performed via the form-field names. Note that in
      # cases, where multiple folders are used as a source, the
      # names have to be disambiguated.
      #
      set name [$form_field_obj name]
      set result_statistics ""
      if {[dict exists $success_statistics $name]} {
        set result_statistics [dict get $success_statistics $name]
      }
      if {[dict exists $count_statistics $name]} {
        #ns_log notice "statistics question_info_block $name count '[dict get $count_statistics $name]'"
        dict set result_statistics count [dict get $count_statistics $name]
        $form_field_obj set result_statistics $result_statistics
      }
    }
  }

  #
  # Substitute form-field place-holders ion the combined form.
  #
  set combined_form [:aggregated_form $combined_form_info]
  set form [$obj regsub_eval   [template::adp_variable_regexp$combined_form  {$obj form_field_as_html -mode display "\\\1" "\2" $form_field_objs}]

  append HTML $form
}
return $HTML
XQL Not present:
Generic, PostgreSQL, Oracle
[ hide source ] | [ make this the default ]
Show another procedure: