You are here

function theme_quiz_stats_get_basic_stats in Quiz 6.4

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

Generates table of results from quiz data structure.

Parameters

@results: Array containing quiz results data structure

Return value

HTML table containing quiz title, author, questions count, attempt count

1 theme call to theme_quiz_stats_get_basic_stats()
quiz_stats_get_basic_stats in includes/quiz_stats/quiz_stats.admin.inc
Returns statistics for all available quizzes

File

includes/quiz_stats/quiz_stats.admin.inc, line 432

Code

function theme_quiz_stats_get_basic_stats($results = array()) {
  if (empty($results)) {
    return '<p>' . t('No questions were found.') . '</p>';
  }
  $header = $rows = array();
  $header = array(
    'title' => t('Quiz'),
    'creator' => t('Author'),
    'created' => t('Created'),
  );
  if (user_access('access author stats')) {
    $header['questions_count'] = t('Questions');
    $header['attempt_count'] = t('Attempts');
  }
  $p = drupal_get_path('module', 'quiz_stats');
  $chart_icon = theme('image', "{$p}/chart.png", t('Charts'), t('See charts'));
  foreach ($results as $result) {
    $title_link = user_access('access author stats') ? 'node/' . $result['nid'] . '/statistics' : 'user/' . arg(1) . '/stats/';
    $row = array(
      'title' => l($chart_icon . ' ' . $result['title'], $title_link, array(
        'html' => TRUE,
      )),
      'creator' => l($result['name'], 'user/' . $result['uid']),
      'created' => format_date($result['created'], 'small'),
    );
    if (user_access('access author stats')) {
      $row['questions_count'] = quiz_get_number_of_questions($result['vid']);
      $row['attempt_count'] = _quiz_get_attempt_count($result['nid']);
    }
    $rows[] = $row;
  }
  module_load_include('inc', 'quiz', 'quiz.pages');
  $cc = '<em>' . t('Chart icon from !url', array(
    '!url' => 'pinvoke.com',
  )) . '</em>';
  return theme('table', $header, $rows, array(
    'id' => 'tablesorter',
  )) . $cc;
}