Problem/Motivation

A user cannot resume a quiz because after clicking "Start quiz," the following message appears: " Resuming a previous quiz in-progress.
You are not authorized to access this page."

Steps to reproduce

  1. Create a quiz and set allow resume to be checked.
  2. Add several questions.
  3. Start quiz and answer the first question.
  4. Log out.
  5. Log back in.
  6. Click "Start quiz"

The URL when resuming is node/####/take/0

Comments

ezraw’s picture

In case it's related, the same issue happens with a quiz that has allow skipping to be set.

Steps to reproduce

  1. Create a quiz and set allow resume and allow skipping to be checked.
  2. Add several questions.
  3. Start quiz and answer the first question by selecting "leave blank."

The URL after "leave blank" is node/####/take/3

djdevin’s picture

Status: Active » Needs work

Fixed, but the current question is not stored anywhere, so it defaults to Question 1.

The user's answers however are preserved.

  • Commit b53b723 on 7.x-5.x by djdevin:
    Issue #2270019 by ezraw: Access denied when resuming quiz.
    
ezraw’s picture

Confirmed fixed.

  1. Created a quiz and set allow resume and allowed skipping to be checked.
  2. Added several questions.
  3. Started quiz and answered the first question (multiple choice)
  4. Logged out
  5. Logged back in and returned to the quiz
  6. Clicked start quiz and was returned to the first question with the selected answer selected.

General feedback

  • Would be nice if "Start quiz" button said "Resume quiz" when the user returns
  • Maybe display some additional detail on the view quiz page such as "Returning to a Quiz attempt in progress. X of X questions answered."

  • Commit b53b723 on 7.x-5.x, 2269219 by djdevin:
    Issue #2270019 by ezraw: Access denied when resuming quiz.
    

  • Commit b53b723 on 7.x-5.x, 2269219 by djdevin:
    Issue #2270019 by ezraw: Access denied when resuming quiz.
    
jim22’s picture

Is there any reason why this would work when I create a new Quiz, but doesn't work when I update an existing Quiz?

I updated from Quiz module from 7.x-4.x to 7.x-5.x, and checked the "Allow Resume" and "Allow Skipping questions". But I still get the following error after logging out, logging back in, and trying to resume the quiz.

You have already taken this quiz 1 time. You may not take it again.

Thanks for any help.

djdevin’s picture

Status: Needs work » Fixed

Hi,

I don't think that's the same issue. The max amount of takes is controlled by "Allowed number of attempts" and not skipping/resuming.

However if you find out what "allowed number of attempts" doesn't work, feel free to open an issue.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

sarhugo’s picture

Status: Closed (fixed) » Active

I'm having the same issue. When setting the max amount of takes it prevents to resume the quiz because it checks against every result (ended and not ended).
At function quiz_start_check($quiz):

$taken = db_query("SELECT COUNT(*) AS takes FROM {quiz_node_results} WHERE uid = :uid AND nid = :nid", array(':uid' => $user->uid, ':nid' => $quiz->nid))->fetchField();

should be replaced by:

$taken = db_query("SELECT COUNT(*) AS takes FROM {quiz_node_results} WHERE uid = :uid AND nid = :nid AND time_end IS NOT NULL", array(':uid' => $user->uid, ':nid' => $quiz->nid))->fetchField();
djdevin’s picture

Status: Active » Closed (duplicate)
_shelest’s picture

Status: Closed (duplicate) » Active

Error in quiz_take_page when
$_SESSION['quiz'][$quiz_result->nid]['current'] =1
But in quiz_access_question we have

if (!$quiz->backwards_navigation) {
    // No backwards navigation.
    if (quiz_result_is_question_answered($quiz_result, $question_node)) {
      // Already have an answer for the requested question.
      return FALSE;
    }
  }

And that mean if backwards navigation is disabled and we already answered on this question number "1", this function return FALSE.

As solution:
$_SESSION['quiz'][$quiz_result->nid]['current'] = quiz_result_get_resume_next_question($quiz_result->result_id);
and

function quiz_result_get_resume_next_question($result_id) {
  $last = 0;
  
  $sql = 'SELECT display_number from {quiz_node_results_answers} WHERE result_id = :result_id AND answer_timestamp IS NOT NULL ORDER BY display_number DESC LIMIT 1';
  $result = db_query($sql, array(':result_id' => $result_id));
  
  if($result) $last = $result->fetchField();
  return $last + 1;
}
djdevin’s picture

Status: Active » Closed (duplicate)

This issue was already fixed in 5.x-dev, please open a new issue with steps to reproduce.