You are here

function theme_quiz_admin_quizzes in Quiz 7.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.4 quiz.admin.inc \theme_quiz_admin_quizzes()
  5. 6.5 quiz.admin.inc \theme_quiz_admin_quizzes()
  6. 7 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 1747
Administrator interface for Quiz module.

Code

function theme_quiz_admin_quizzes($variables) {
  $results = $variables['results'];
  $output = '';

  // The export images
  $path_to_module_quiz = drupal_get_path('module', 'quiz');
  $png = array(
    'html' => theme('image', array(
      'path' => $path_to_module_quiz . '/images/html.png',
      'width' => t('Export as HTML'),
      'height' => t('Export as HTML'),
    )),
    'xml' => theme('image', array(
      'path' => $path_to_module_quiz . '/images/xml.png',
      'width' => t('Export as XML'),
      'height' => t('Export as XML'),
    )),
    'csv' => theme('image', array(
      'path' => $path_to_module_quiz . '/images/csv.png',
      'width' => t('Export as CSV'),
      'height' => t('Export as CSV'),
    )),
    'csv_full' => theme('image', array(
      'path' => $path_to_module_quiz . '/images/csv_complete.png',
      'width' => t('Export full data as CSV'),
      'height' => 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'], 'short'),
    );

    // 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', array(
    'header' => $header,
    'rows' => $rows,
  )) : $no_quizzes;
  return $output;
}