function _get_quiz_grade_range_chart in Quiz 7
Same name and namespace in other branches
- 8.6 modules/quiz_stats/quiz_stats.admin.inc \_get_quiz_grade_range_chart()
- 8.4 modules/quiz_stats/quiz_stats.admin.inc \_get_quiz_grade_range_chart()
- 8.5 modules/quiz_stats/quiz_stats.admin.inc \_get_quiz_grade_range_chart()
- 6.6 includes/quiz_dashboard/quiz_dashboard.admin.inc \_get_quiz_grade_range_chart()
- 6.4 includes/quiz_stats/quiz_stats.admin.inc \_get_quiz_grade_range_chart()
- 7.6 modules/quiz_stats/quiz_stats.admin.inc \_get_quiz_grade_range_chart()
- 7.4 includes/quiz_stats/quiz_stats.admin.inc \_get_quiz_grade_range_chart()
- 7.5 modules/quiz_stats/quiz_stats.admin.inc \_get_quiz_grade_range_chart()
- 6.x modules/quiz_stats/quiz_stats.admin.inc \_get_quiz_grade_range_chart()
Generates grade range chart
Parameters
$uid: User id
$vid: revision id of quiz node
Return value
array with chart and metadata
1 call to _get_quiz_grade_range_chart()
- quiz_stats_get_adv_stats in includes/
quiz_stats/ quiz_stats.admin.inc - Get stats for a single quiz. Maybe also for a single user.
File
- includes/
quiz_stats/ quiz_stats.admin.inc, line 94 - Administration file for Quiz stats Module
Code
function _get_quiz_grade_range_chart($vid, $uid = 0) {
// @todo: make the ranges configurable
$sql = 'SELECT SUM(score >= 0 && score < 20) AS zero_to_twenty,
SUM(score >= 20 && score < 40) AS twenty_to_fourty,
SUM(score >= 40 && score < 60) AS fourty_to_sixty,
SUM(score >= 60 && score < 80) AS sixty_to_eighty,
SUM(score >= 80 && score <= 100) AS eighty_to_hundred
FROM {quiz_node_results}
WHERE vid = :vid';
$arg[':vid'] = $vid;
if ($uid != 0) {
$sql .= ' AND uid = :uid';
$arg[':uid'] = $uid;
}
$range = db_query($sql, $arg)
->fetch();
$count = $range->zero_to_twenty + $range->twenty_to_fourty + $range->fourty_to_sixty + $range->sixty_to_eighty + $range->eighty_to_hundred;
if ($count < 2) {
return FALSE;
}
// Get the charts
$chart = '<div id="quiz_top_scorers" class="quiz-stats-chart-space">';
$chart .= theme('quiz_grade_range', array(
'range' => $range,
));
$chart .= '</div>';
// Return the chart with some meta data
return array(
'chart' => $chart,
'title' => t('Distribution'),
'explanation' => t('This chart shows the distribution of the scores on this quiz.'),
);
}