xowf::test_item::Answer_manager method grading_table (public)

 <instance of xowf::test_item::Answer_manager[i]> grading_table \
    [ -csv csv ] grade_dict

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

Produce HTML markup based on a dict with grades as keys and counts as values.

Switches:
-csv (optional)
Parameters:
grade_dict (required)

Testcases:
No testcase defined.
Source code:
set gradingTable {<div class="grading-info"><div class="table-responsive"><table class="table grading">}
append gradingTable  "<thead><th class='text-right col-md-1'>#xowf.Grade#</th><th class='col-md-1 text-right'>#</th></thead>"  "<tbody>\n"
set nrGrades 0
foreach v [dict values $grade_dict] { incr nrGrades $v}
set grades [lsort [dict keys $grade_dict]]
foreach k $grades {
  set count [dict get $grade_dict $k]
  set countPercentage [format %.2f [expr {$count *100.0 / $nrGrades}]]
  append gradingTable  <tr>  [subst {<td class="text-right">$k</td><td class="text-right">$count</td>}]  [subst {<td><div class="progress"><div class="progress-bar"
        style="width:$countPercentage%">$countPercentage%</div></td}]  </tr>\n
}
append gradingTable "</tbody></table></div>\n"
if {$csv ne "" } {
  append gradingTable "<pre>$csv</pre></div>\n"
}

if {[template::head::can_resolve_urn urn:ad:js:highcharts]} {
  #
  # The highcharts package is available
  #
  template::add_body_script -src urn:ad:js:highcharts
  set graphID pie-[incr ::__xotcl_highcharts_pie]
  append gradingTable "<div id='$graphID'></div>\n"
  set data ""
  foreach k $grades {
    set count [dict get $grade_dict $k]
    set countPercentage [format %.2f [expr {$count *100.0 / $nrGrades}]]
    lappend data [subst {{name:'$k', y: $countPercentage}}]
  }
  set gradeLabel [_ xowf.Grade]
  template::add_body_script -script [subst [ns_trim {
    Highcharts.chart('$graphID', {
      chart: {type: 'pie'},
      plotOptions: {pie: {size: 200}, series: {dataLabels: {enabled: true, format: '$gradeLabel {point.name}: {point.y:.1f}%'} }},
      title: {text: ''},
      credits: {enabled: true },
      series: \[{name: 'Percentage', data: \[ [join $data ,] \]}\]
    });
  }]]
}
return $gradingTable
XQL Not present:
Generic, PostgreSQL, Oracle
[ hide source ] | [ make this the default ]
Show another procedure: