Moodle 3.2 quiz displays multiple choice answer on quiz attempt

Moodle 3.2 quiz displays multiple choice answer on quiz attempt

د Mario Modeste لخوا -
د ځوابونو شمیر: 15

Hello Guys,

After upgrading from version 2.7 to 3.2, I've noticed that during quizzes, for some questions, the answer would be checked automatically. The question preview works fine, but the problem occurs during quiz attempts. Any thoughts on what is causing this error. I've had to disable the quiz module because of this.

Thanks in advance.

د درجې بندۍ اوسط:  -
In reply to Mario Modeste

Re: Moodle 3.2 quiz displays multiple choice answer on quiz attempt

د Emma Richardson لخوا -
د Documentation writers انځور د Particularly helpful Moodlers انځور د Plugin developers انځور

Is this just using the core multiple choice question type or a plugin?

In reply to Emma Richardson

Re: Moodle 3.2 quiz displays multiple choice answer on quiz attempt

د Mario Modeste لخوا -

I'm using the core multiple choice.

I tried previewing a quiz on a development machine and it works fine. The only difference I can think of is, when I went into the database (quiz_attempts table) and changed the status of some hanging quizzes column from abandoned to finished. I'm not sure

In reply to Mario Modeste

Re: Moodle 3.2 quiz displays multiple choice answer on quiz attempt

د Emma Richardson لخوا -
د Documentation writers انځور د Particularly helpful Moodlers انځور د Plugin developers انځور

I would suspect that that has a lot to do with it.  If you take a look at the table layout for the quiz, there is nothing simple about it and so an innocent change of status could mess a bunch of stuff up.

In reply to Emma Richardson

Re: Moodle 3.2 quiz displays multiple choice answer on quiz attempt

د Mario Modeste لخوا -
Thanks Emma,
I thought that may have been the case, so I dumped the old values back into the quiz_attempts table, but the same thing happens.  I'm trying to debug it myself, but following the code takes a little while. I'm taking a look at the documentation in https://docs.moodle.org/dev/Using_the_question_engine_from_module and see where that takes me. If anyone has any incite feel free to let me know.
I'll post my findings, if its interesting.
Thanks again.  Appreciate the help.
In reply to Mario Modeste

Re: Moodle 3.2 quiz displays multiple choice answer on quiz attempt

د Emma Richardson لخوا -
د Documentation writers انځور د Particularly helpful Moodlers انځور د Plugin developers انځور

How about you share why you went into the database in the first place?  Was there an error coming up somewhere?

In reply to Emma Richardson

Re: Moodle 3.2 quiz displays multiple choice answer on quiz attempt

د Mario Modeste لخوا -

Sure. A couple days before, our server crashed and we had to migrate to another server. I restored the database from an SQL backup in a new MariaDb 10.1 system. The problem was noted then. I then did the following.

  • I ran the cron from the cli to see what was happening and it stopped at the quiz task.
  •  I looked at the quiz attempts table and saw a bunch of the quizzes statuses set to abandoned. I changed all the attempts statuses to finished. 
  • I ran admin/cli/fix_orphaned_question_categories.php ,fix_course_sequence.php.
  • I added to mtrace("Processing attempt {$attempt->id} at {$attempt->quiz} quiz:"); cronlib line 71 to which led me to an old quiz attempt. I deleted the quiz attempt and the cron job completes now.


In reply to Mario Modeste

Re: Moodle 3.2 quiz displays multiple choice answer on quiz attempt

د Emma Richardson لخوا -
د Documentation writers انځور د Particularly helpful Moodlers انځور د Plugin developers انځور

So did you upgrade at the same time as you migrated or did you get up and running first and then see the issue following the upgrade?  

Perhaps try a fresh download of code and see if that resolves it.  

Can you show a screenshot of how the quiz looks?

In reply to Emma Richardson

Re: Moodle 3.2 quiz displays multiple choice answer on quiz attempt

د Mario Modeste لخوا -

First, I upgraded from 2.7 to 3.2, then migrated, then upgraded to 3.2.1 after the migration. I'll try to download a fresh copy ASAP. I've attached an example. It shows the preview of questions 7 and 8 of a one page quiz.  No answers were selected by me.



Attachment quiz_error.png
In reply to Mario Modeste

Re: Moodle 3.2 quiz displays multiple choice answer on quiz attempt

د Emma Richardson لخوا -
د Documentation writers انځور د Particularly helpful Moodlers انځور د Plugin developers انځور

So that isn't showing the correct answer, just the first answer?  Is that what it is doing?  Have you tried clearing out all your caches?  I wonder if you are just getting some cached version showing up?

In reply to Emma Richardson

Re: Moodle 3.2 quiz displays multiple choice answer on quiz attempt

د Mario Modeste لخوا -

I "purge all caches" then ran the preview again. It is still checking options, but not necessarily the correct one. It seems to be checking A and B. I've attached a sample.

Attachment quiz_error.png
In reply to Mario Modeste

Re: Moodle 3.2 quiz displays multiple choice answer on quiz attempt

د Emma Richardson لخوا -
د Documentation writers انځور د Particularly helpful Moodlers انځور د Plugin developers انځور

I still think this might be caching.  I would suggest actually deleting out the cache and local cache folders from your moodledata folder (they will be recreated) and also clearing any cache on your computer too.  Not sure where you are hosted but if with a host, they may well have a cache too.

In reply to Emma Richardson

Re: Moodle 3.2 quiz displays multiple choice answer on quiz attempt

د Mario Modeste لخوا -
Ever since the server crash, we moved in-house. We're running on ubuntu 16.04, php 7.0-fpm, Apache2.4. I removed the two folders and "purged all caches" and restart the php-fpm.
I just reviewed some other quizzes and some essay questions wysiwyg box have 0 or 1 in the by default. So it seems that mod_q is adding a default value somewhere.
I downloaded a fresh copy of moodle3.2.1+ and copied mod/quiz folder into moodle, deleted the folders and tried a preview again. Its still the same.
Attachment quiz_error.png
In reply to Mario Modeste

Re: Moodle 3.2 quiz displays multiple choice answer on quiz attempt

د Emma Richardson لخوا -
د Documentation writers انځور د Particularly helpful Moodlers انځور د Plugin developers انځور

Interesting. I guess you could check the database for that field allowing null values and then update as necessary. Maybe Tim has some ideas on this?

In reply to Emma Richardson

Re: Moodle 3.2 quiz displays multiple choice answer on quiz attempt

د Mario Modeste لخوا -

Thanks Emma,

I will take a look at it in the morning and give an update.

In reply to Mario Modeste

Re: Moodle 3.2 quiz displays multiple choice answer on quiz attempt

د Mario Modeste لخوا -

Hello,

I upgraded to Moodle3.2.1+ this morning. That went well. I'm still the same problem. What's bugging me, is that when I preview the individual question, preview.php does not add any checks, but, when I preview the quiz attempt.php does add checks.

I'm thinking that there may be that a condition may not be evaluated properly somewhere. Just a thought...