You are here

function quiz_stats_revision_selector_page in Quiz 7.6

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

Page for selecting between several quiz revisions

Parameters

$nid: Quiz node id

Return value

Themed html

1 string reference to 'quiz_stats_revision_selector_page'
quiz_stats_menu in modules/quiz_stats/quiz_stats.module
Implements hook_menu().

File

modules/quiz_stats/quiz_stats.admin.inc, line 17
Administration file for Quiz stats Module

Code

function quiz_stats_revision_selector_page($quiz) {
  $res = db_query('SELECT vid FROM {node_revision} WHERE nid = :nid ORDER BY vid', array(
    ':nid' => $quiz->nid,
  ));
  $count = 0;

  //uses this variable to slightly increase performance
  $vids = array();
  while ($res_o = $res
    ->fetch()) {
    $vids[] = $res_o->vid;
    $count++;
  }
  if ($count < 1) {
    return t('Something went wrong. Please try again');
  }
  elseif ($count == 1) {

    // If there is only one revision we jump directly to that revision
    drupal_goto("node/{$quiz->nid}/quiz/statistics/{$vids[0]}");
  }
  else {
    $content = array();
    $content['explanation'] = t('There are !num revisions of this quiz that have been taken.
    Different revisions may have different scoring, difficulity and other differences affecting its statistics.
    Because of this you have to choose the revision you want to see statistics from.', array(
      '!num' => $count,
    ));
    $content['links'] = array();
    foreach ($vids as $key => $value) {
      $content['links'][] = 'node/' . $quiz->nid . '/quiz/statistics/' . $value;
    }
    return theme('quiz_stats_revision_selector', array(
      'content' => $content,
    ));
  }
}