Unexpected Event code found for question X in attempt X

Re: Unexpected Event code found for question X in attempt X

by Raúl Garoña -
Number of replies: 0

Hi,

We have Moodle 2.0.10 on ubuntu 10.04 with php 5.3.

Our problem is that values in the table question_sessions of some attempts were not being stored in the database. You can check it with this query:

SELECT * FROM [prefix]question_sessions n where attemptid = (yout attempt id)

I solved this issue with this ugly hack in the file mod/quiz/attemptlib.php

public function get_question_status($questionid) {
        //************START PATCH **************
        if (!isset($this->states[$questionid])){
              $this->states[$questionid]->event = 0;
              $this->states[$questionid]->flagged = 0;
        }
        //************END PATCH ***************
        $state = $this->states[$questionid];
        switch ($state->event) {
            case QUESTION_EVENTOPEN:
                return 'open';

            case QUESTION_EVENTSAVE:
            case QUESTION_EVENTGRADE:
            case QUESTION_EVENTSUBMIT:
                return 'answered';

         ....