You are here

function theme_quiz_grade_range in Quiz 7

Same name and namespace in other branches
  1. 8.6 modules/quiz_stats/quiz_stats.admin.inc \theme_quiz_grade_range()
  2. 8.4 modules/quiz_stats/quiz_stats.admin.inc \theme_quiz_grade_range()
  3. 8.5 modules/quiz_stats/quiz_stats.admin.inc \theme_quiz_grade_range()
  4. 6.6 includes/quiz_dashboard/quiz_dashboard.admin.inc \theme_quiz_grade_range()
  5. 6.4 includes/quiz_stats/quiz_stats.admin.inc \theme_quiz_grade_range()
  6. 7.6 modules/quiz_stats/quiz_stats.admin.inc \theme_quiz_grade_range()
  7. 7.4 includes/quiz_stats/quiz_stats.admin.inc \theme_quiz_grade_range()
  8. 7.5 modules/quiz_stats/quiz_stats.admin.inc \theme_quiz_grade_range()
  9. 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 includes/quiz_stats/quiz_stats.admin.inc
Generates grade range chart

File

includes/quiz_stats/quiz_stats.admin.inc, line 287
Administration file for Quiz stats Module

Code

function theme_quiz_grade_range($variables) {
  $range = $variables['range'];
  $chart_width = 600;
  $chart_height = 400;
  $chart = array(
    '#chart_id' => 'quiz_grade_range',
    '#type' => CHART_TYPE_BAR_V_GROUPED,
    '#size' => chart_size($chart_width, $chart_height),
    '#grid_lines' => chart_grid_lines(10, 10),
    '#bar_size' => chart_bar_size(20, 15),
    '#adjust_resolution' => TRUE,
    '#title' => '',
  );

  // chart data
  $chart['#data'][][] = $range->eighty_to_hundred;
  $chart['#data'][][] = $range->sixty_to_eighty;
  $chart['#data'][][] = $range->fourty_to_sixty;
  $chart['#data'][][] = $range->twenty_to_fourty;
  $chart['#data'][][] = $range->zero_to_twenty;
  $max = max($range->zero_to_twenty, $range->twenty_to_fourty, $range->fourty_to_sixty, $range->sixty_to_eighty, $range->eighty_to_hundred);

  // chart color
  $chart['#data_colors'][] = '00ff00';
  $chart['#data_colors'][] = '66ff00';
  $chart['#data_colors'][] = 'ffff00';
  $chart['#data_colors'][] = 'ff6600';
  $chart['#data_colors'][] = 'ff0000';

  // chart x-axis label
  $chart['#mixed_axis_labels'][CHART_AXIS_X_BOTTOM][2][] = chart_mixed_axis_label(t('Quiz Grade Range'), 50);

  // chart y-axis label and data
  $chart['#mixed_axis_labels'][CHART_AXIS_Y_LEFT][1][] = chart_mixed_axis_label(t('Attempts'), 100);
  $chart['#mixed_axis_labels'][CHART_AXIS_Y_LEFT][0][] = chart_mixed_axis_range_label(0, $max);

  // chart description on the right side
  $chart['#legends'][] = t('80 to 100 % - ') . $range->eighty_to_hundred;
  $chart['#legends'][] = t('60 to 80 % - ') . $range->sixty_to_eighty;
  $chart['#legends'][] = t('40 to 60 % - ') . $range->fourty_to_sixty;
  $chart['#legends'][] = t('20 to 40 % - ') . $range->twenty_to_fourty;
  $chart['#legends'][] = t('0 to 20 % - ') . $range->zero_to_twenty;
  return theme('chart', array(
    'chart' => $chart,
  ));
}