You are here

function theme_quiz_admin_quizzes in Quiz 6.4

Same name and namespace in other branches
  1. 8.4 quiz.admin.inc \theme_quiz_admin_quizzes()
  2. 6.6 quiz.admin.inc \theme_quiz_admin_quizzes()
  3. 6.3 quiz.admin.inc \theme_quiz_admin_quizzes()
  4. 6.5 quiz.admin.inc \theme_quiz_admin_quizzes()
  5. 7 quiz.admin.inc \theme_quiz_admin_quizzes()
  6. 7.4 quiz.admin.inc \theme_quiz_admin_quizzes()

Theme the admin quizzes table.

Parameters

$results: As returned by _quiz_get_quizzes().

1 theme call to theme_quiz_admin_quizzes()
quiz_admin_quizzes in ./quiz.admin.inc
Displays the quizzes by title with a link to the appropriate results for that specific quiz.

File

./quiz.admin.inc, line 1832
Administrator interface for Quiz module.

Code

function theme_quiz_admin_quizzes($results) {
  $output = '';

  // The export images
  $path_to_module_quiz = drupal_get_path('module', 'quiz');
  $png = array(
    'html' => theme('image', $path_to_module_quiz . '/images/html.png', t('Export as HTML'), t('Export as HTML')),
    'xml' => theme('image', $path_to_module_quiz . '/images/xml.png', t('Export as XML'), t('Export as XML')),
    'csv' => theme('image', $path_to_module_quiz . '/images/csv.png', t('Export as CSV'), t('Export as CSV')),
    'csv_full' => theme('image', $path_to_module_quiz . '/images/csv_complete.png', t('Export full data as CSV'), t('Export full data as CSV')),
  );
  $rows = array();
  $exp = module_exists('results_export');
  while (list($key, $result) = each($results)) {
    $cols = array(
      l($result['title'], 'node/' . $result['nid'] . '/results'),
      check_plain($result['name']),
      format_date($result['created'], 'small'),
    );

    // Add export links if the results export module is enabled
    if ($exp) {
      $cols[] = l($png['html'], 'admin/quiz/results_export_teaser_view/' . $result['nid'] . '/html', array(
        'html' => TRUE,
      )) . l($png['xml'], 'admin/quiz/results_export_teaser_view/' . $result['nid'] . '/xml', array(
        'html' => TRUE,
      )) . l($png['csv'], 'admin/quiz/results_export_teaser_view/' . $result['nid'] . '/csv', array(
        'html' => TRUE,
      )) . l($png['csv_full'], 'admin/quiz/results_export_full_view/' . $result['nid'] . '/csv', array(
        'html' => TRUE,
      ));
    }
    $rows[] = $cols;
  }
  $header = array(
    t('@quiz title', array(
      '@quiz' => QUIZ_NAME,
    )),
    t('Created by'),
    t('Created on'),
  );
  if ($exp) {
    $header[] = t('Export');
  }

  // Message if there are no quizzes available
  if (!user_access('view any quiz results')) {
    $no_quizzes = '<p>' . t('No @quiz that you have created was found. You do not have permission to see any other results.', array(
      '@quiz' => QUIZ_NAME,
    )) . '</p>';
  }
  else {
    $no_quizzes = '<p>' . t('No @quiz found.', array(
      '@quiz' => QUIZ_NAME,
    )) . '</p>';
  }
  $output = !empty($rows) ? theme('table', $header, $rows) : $no_quizzes;
  return $output;
}