function theme_quiz_grade_range in Quiz 7.5
Same name and namespace in other branches
- 8.6 modules/quiz_stats/quiz_stats.admin.inc \theme_quiz_grade_range()
- 8.4 modules/quiz_stats/quiz_stats.admin.inc \theme_quiz_grade_range()
- 8.5 modules/quiz_stats/quiz_stats.admin.inc \theme_quiz_grade_range()
- 6.6 includes/quiz_dashboard/quiz_dashboard.admin.inc \theme_quiz_grade_range()
- 6.4 includes/quiz_stats/quiz_stats.admin.inc \theme_quiz_grade_range()
- 7.6 modules/quiz_stats/quiz_stats.admin.inc \theme_quiz_grade_range()
- 7 includes/quiz_stats/quiz_stats.admin.inc \theme_quiz_grade_range()
- 7.4 includes/quiz_stats/quiz_stats.admin.inc \theme_quiz_grade_range()
- 6.x modules/quiz_stats/quiz_stats.admin.inc \theme_quiz_grade_range()
Theme function for quiz grade range chart.
Generates Chart using CHART API function.
Parameters
$range: array containg quiz results data structure.
Return value
HTML to render/display chart.
1 theme call to theme_quiz_grade_range()
- _get_quiz_grade_range_chart in modules/
quiz_stats/ quiz_stats.admin.inc - Generates grade range chart.
File
- modules/
quiz_stats/ quiz_stats.admin.inc, line 295 - Administration file for Quiz stats Module.
Code
function theme_quiz_grade_range($variables) {
$range = $variables['range'];
$max = max((array) $range);
$count = array_sum((array) $range);
$chart = array(
'#type' => 'chart',
'#chart_type' => 'column',
'#title' => t('Score distribution'),
);
$chart['range'] = array(
'#type' => 'chart_data',
'#title' => t('% of quiz takers'),
'#data' => array(
round($range->zero_to_twenty / $count * 100),
round($range->twenty_to_fourty / $count * 100),
round($range->fourty_to_sixty / $count * 100),
round($range->sixty_to_eighty / $count * 100),
round($range->eighty_to_hundred / $count * 100),
),
);
$chart['xaxis'] = array(
'#title' => t('Score'),
'#type' => 'chart_xaxis',
'#labels' => array(
'0-20%',
'20-40%',
'40-60%',
'60-80%',
'80-100%',
),
);
$chart['yaxis'] = array(
'#title' => t('Grade istribution'),
'#type' => 'chart_yaxis',
'#max' => 100,
);
return drupal_render($chart);
}