You are here

function _get_date_vs_takeup_count_chart in Quiz 6.4

Same name and namespace in other branches
  1. 8.6 modules/quiz_stats/quiz_stats.admin.inc \_get_date_vs_takeup_count_chart()
  2. 8.4 modules/quiz_stats/quiz_stats.admin.inc \_get_date_vs_takeup_count_chart()
  3. 8.5 modules/quiz_stats/quiz_stats.admin.inc \_get_date_vs_takeup_count_chart()
  4. 6.6 includes/quiz_dashboard/quiz_dashboard.admin.inc \_get_date_vs_takeup_count_chart()
  5. 7.6 modules/quiz_stats/quiz_stats.admin.inc \_get_date_vs_takeup_count_chart()
  6. 7 includes/quiz_stats/quiz_stats.admin.inc \_get_date_vs_takeup_count_chart()
  7. 7.4 includes/quiz_stats/quiz_stats.admin.inc \_get_date_vs_takeup_count_chart()
  8. 7.5 modules/quiz_stats/quiz_stats.admin.inc \_get_date_vs_takeup_count_chart()
  9. 6.x modules/quiz_stats/quiz_stats.admin.inc \_get_date_vs_takeup_count_chart()

Generates chart showing how often the quiz has been taken the last days

Parameters

$uid: user id

$vid: revision id of quiz

Return value

HTML to display chart

1 call to _get_date_vs_takeup_count_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 205

Code

function _get_date_vs_takeup_count_chart($vid, $uid = 0) {
  $start = 0;
  $end = 30;
  $takeup = array();
  $sql = "SELECT COUNT(result_id) AS count,\n            DATE_FORMAT(FROM_UNIXTIME(time_start), '%Y.%m.%e') AS date\n            FROM {quiz_node_results}\n            WHERE vid = %d";
  $sql_args = array(
    $vid,
  );
  if ($uid != 0) {
    $sql .= " AND uid = %d";
    $sql_args[] = $uid;
  }
  $sql .= " GROUP BY date ORDER BY time_start DESC";
  $results = db_query_range($sql, $sql_args, $start, $end);
  $days = _quiz_get_last_days($end);
  $res_o = db_fetch_object($results);
  foreach ($days as $date => &$value) {
    if ($date == $res_o->date) {
      $value->value = $res_o->count;
      if ($res_o->count > 0) {
        $valid_data = TRUE;
      }
      $res_o = db_fetch_object($results);
    }
  }
  if (!$valid_data) {
    return FALSE;
  }
  $chart = '<div id="date_vs_takeup_count" class="quiz-stats-chart-space">';

  // wrapping the chart output with div for custom theming.
  $chart .= theme('date_vs_takeup_count', $days);

  // generate date vs takeup count line chart
  $chart .= '</div>';
  return array(
    'chart' => $chart,
    'title' => t('Activity'),
    'explanation' => t('This chart shows how many times the quiz has been taken the last !days days.', array(
      '!days' => $end,
    )),
  );
}