You are here

function theme_og_quiz_quiz_admin_summary in OG Quiz 7

Theme the result summary. This is almost a verbatim copy of theme_quiz_admin_summary(). Add OG access control.

1 string reference to 'theme_og_quiz_quiz_admin_summary'
og_quiz_theme_registry_alter in ./og_quiz.module
Implements hook_theme_registry_alter().

File

./og_quiz.module, line 395
Module hooks and custom logic.

Code

function theme_og_quiz_quiz_admin_summary($variables) {
  global $user;
  $quiz = $variables['quiz'];
  $questions = $variables['questions'];
  $score = $variables['score'];
  $summary = $variables['summary'];
  $rid = $variables['rid'];
  $account = $variables['account'];

  // To adjust the title uncomment and edit the line below:
  // drupal_set_title(check_plain($quiz->title));
  if (!$score['is_evaluated']) {
    drupal_set_message(t('This lesson has not been scored yet.'), 'warning');
  }

  // Display overall result.
  $output = '';
  $params = array(
    '%num_correct' => $score['numeric_score'],
    '%question_count' => $score['possible_score'],
    '!username' => theme('username', array(
      'account' => $account,
    )),
  );
  $output .= '<div id="quiz_score_possible">' . t('!username got %num_correct of %question_count possible points.', $params) . '</div>' . "\n";
  $output .= '<div id="quiz_score_percent">' . t('Total score: @score %', array(
    '@score' => $score['percentage_score'],
  )) . '</div>' . "\n";
  $quiz_format = isset($quiz->body[LANGUAGE_NONE][0]['format']) ? $quiz->body[LANGUAGE_NONE][0]['format'] : NULL;
  if (isset($summary['passfail'])) {
    $output .= '<div id="quiz_summary">' . check_markup($summary['passfail'], $quiz_format) . '</div>' . "\n";
  }
  if (isset($summary['result'])) {
    $output .= '<div id="quiz_summary">' . check_markup($summary['result'], $quiz_format) . '</div>' . "\n";
  }

  // Get the feedback for all questions.
  require_once DRUPAL_ROOT . '/' . drupal_get_path('module', 'quiz') . '/quiz.pages.inc';
  if (!($access = og_quiz_ogs_access($quiz, 'score any quiz'))) {
    if ($access = og_quiz_ogs_access($quiz, 'score own quiz')) {
      $access = $access && $quiz->uid && $user->uid;
    }
  }
  $access = isset($access) ? $access : user_access('score any quiz') || user_access('score own quiz') && $quiz->uid && $user->uid;
  $report_form = drupal_get_form('quiz_report_form', $questions, TRUE, TRUE, $access);
  $output .= drupal_render($report_form);
  return $output;
}