can't create a quiz

can't create a quiz

Erik Ringmar -
Erantzun kopurua: 15
Hi,

I can't create a quiz and get this debug message:

Debug info: Unknown column 'quiz' in 'where clause'
SELECT * FROM mdl_quiz_attempts WHERE quiz = ? AND userid = ? AND state IN (?, ?) ORDER BY attempt ASC
[array (
0 => '52',
1 => '543',
2 => 'finished',
3 => 'abandoned',
)]
Error code: dmlreadexception

I'm using Moodle 2.8. What to do?

Erik
Puntuazioen batez bestekoa: -
Erik Ringmar(e)ri erantzunda

Re: can't create a quiz

Erik Ringmar -
There seems to be some kind of problem with the database -- some tables are missing or something like that. Is there a way to reinstall the entire quiz plugin and start again (I'm running a new course and no submissions have been made yet)?

Yeah, and there is more debug info:

Stack trace:

line 443 of /lib/dml/moodle_database.php: dml_read_exception thrown
line 1080 of /lib/dml/mysqli_native_moodle_database.php: call to moodle_database->query_end()
line 1305 of /lib/dml/moodle_database.php: call to mysqli_native_moodle_database->get_records_sql()
line 585 of /mod/quiz/lib.php: call to moodle_database->get_records_select()
line 93 of /mod/quiz/view.php: call to quiz_get_user_attempts()
Erik Ringmar(e)ri erantzunda

Re: can't create a quiz

Tim Hunt -
Core developers-ren irudia Documentation writers-ren irudia Particularly helpful Moodlers-ren irudia Peer reviewers-ren irudia Plugin developers-ren irudia

What exactly are you doing when you get that error?

Can you temporarily set Debugging (<- this is a link) on your server to DEVELOPER level, and copy the full error message here. Thanks.

Puntuazioen batez bestekoa:Useful (1)
Tim Hunt(e)ri erantzunda

Re: can't create a quiz

Erik Ringmar -
Hi Tim,

Great to have you online! This is the full monty debug:

Debug info: Unknown column 'quiz' in 'where clause'
SELECT * FROM mdl_quiz_attempts WHERE quiz = ? AND userid = ? AND state IN (?, ?) ORDER BY attempt ASC
[array (
0 => '51',
1 => '543',
2 => 'finished',
3 => 'abandoned',
)]
Error code: dmlreadexception
Stack trace:

line 443 of /lib/dml/moodle_database.php: dml_read_exception thrown
line 1080 of /lib/dml/mysqli_native_moodle_database.php: call to moodle_database->query_end()
line 1305 of /lib/dml/moodle_database.php: call to mysqli_native_moodle_database->get_records_sql()
line 585 of /mod/quiz/lib.php: call to moodle_database->get_records_select()
line 93 of /mod/quiz/view.php: call to quiz_get_user_attempts()

I created a quiz without any problems but when I'm trying to go into it to add questions, it gives me this error message. I can't delete the quiz I created.

thankful for any help/insight,

Erik
Erik Ringmar(e)ri erantzunda

Re: can't create a quiz

Tim Hunt -
Core developers-ren irudia Documentation writers-ren irudia Particularly helpful Moodlers-ren irudia Peer reviewers-ren irudia Plugin developers-ren irudia

The odd thing is, the mdl_quiz_attempts certainly should have a 'quiz' column. It always has has one, and I can't think how it might have gone missing.

Can you access your database directly? If so, can you look at the structure of that table, and compare that to what it is supposed to be, which is defined in mod/quiz/db/install.xml.

Puntuazioen batez bestekoa:Useful (1)
Tim Hunt(e)ri erantzunda

Re: can't create a quiz

Erik Ringmar -
Hi again,

I added a "quiz" column to the quiz_attempts table, but nothing seems to have improved. Any ideas what to do next?

The latest debug info is:

Debug info: Unknown column 'userid' in 'where clause'
SELECT * FROM mdl_quiz_attempts WHERE quiz = ? AND userid = ? AND state IN (?, ?) ORDER BY attempt ASC
[array (
0 => '51',
1 => '543',
2 => 'finished',
3 => 'abandoned',
)]
Error code: dmlreadexception
Stack trace:

line 443 of /lib/dml/moodle_database.php: dml_read_exception thrown
line 1080 of /lib/dml/mysqli_native_moodle_database.php: call to moodle_database->query_end()
line 1305 of /lib/dml/moodle_database.php: call to mysqli_native_moodle_database->get_records_sql()
line 585 of /mod/quiz/lib.php: call to moodle_database->get_records_select()
line 93 of /mod/quiz/view.php: call to quiz_get_user_attempts()
Erik Ringmar(e)ri erantzunda

Re: can't create a quiz

Tim Hunt -
Core developers-ren irudia Documentation writers-ren irudia Particularly helpful Moodlers-ren irudia Peer reviewers-ren irudia Plugin developers-ren irudia

What does your quiz_attempts table look like? Do you have any theory to explain why it got messed up in the first place.

Randomly editing the table difinition to add columns is unlikely to work. (There is no feasible way to fill those columns with the correct values.)

Puntuazioen batez bestekoa:Useful (1)
Tim Hunt(e)ri erantzunda

Re: can't create a quiz

Erik Ringmar -
Hi again Tim,

I'm very grateful for your help. OK, I'll stop trying to add columns. The mdl_quiz_attempts table is enclosed. I've racked my brain, but I can't figure out what could have happened. No doubt something I did though ...

yours,

Erik
Erik Ringmar(e)ri erantzunda

Re: can't create a quiz

Tim Hunt -
Core developers-ren irudia Documentation writers-ren irudia Particularly helpful Moodlers-ren irudia Peer reviewers-ren irudia Plugin developers-ren irudia

From the list of columns, that looks like the mdl_quiz table, not mdl_quiz_attempts.


Puntuazioen batez bestekoa:Useful (1)
Tim Hunt(e)ri erantzunda

Re: can't create a quiz

Erik Ringmar -
Hi Tim,

This is so strange. Are you saying that mdl_quiz disappeared because it somehow was renamed into mdl_quiz_attempts? Btw, is there a way to reinstall the whole quiz module? Maybe I should start from the beginning (I don't currently used it in any of my courses, and no vital data would disappear)

thanks again,

Erik
Erik Ringmar(e)ri erantzunda

Re: can't create a quiz

Tim Hunt -
Core developers-ren irudia Documentation writers-ren irudia Particularly helpful Moodlers-ren irudia Peer reviewers-ren irudia Plugin developers-ren irudia

I am not saying that. I am saying that what is currently called mdl_quiz_attempts in your database looks more like what mdl_quiz should look like in a normal database, but I have no idea how that would happen.

Anyway, the good news is that you can completely re-install any activity, providing you don't mind losing all the related data. Go to Site administration -> Plugins -> Activity modules -> Manage activities, and click the Uninstall link in the Quiz row.

After it has finished you should see a message like:

All data associated with the plugin mod_book has been deleted from the database. To prevent the plugin re-installing itself, its folder /Users/tim/Documents/workspace/moodle_head/mod/book must be manually removed from your server now. Moodle itself cannot remove the folder due to write permissions.

Then you can click Continue to let the module install itself again.

If the web server does have permission to delete those files, well, that is a dangerous set-up. See https://docs.moodle.org/24/en/Security_recommendations#Most_secure.2Fparanoid_file_permissions. Anyway, if the files get deleted, you will need to download the ZIP file for exactly the version of Moodle you are using. Unzip it, and copy the files from the mod/quiz folder in the zip into a folder mod/quiz in your Moodle install.

Puntuazioen batez bestekoa:Useful (1)
Tim Hunt(e)ri erantzunda

Re: can't create a quiz

Erik Ringmar -
Tim,

I hate to say this: I don't have an "uninstall" option. I do for the other modules, but not for the quiz one. This is no doubt related to the original problem in some fashion. Is there some other reinstall method?

Sorry to take up your time like this. Hopefully my problems relate to those of others.

Erik
Erik Ringmar(e)ri erantzunda

Re: can't create a quiz

Tim Hunt -
Core developers-ren irudia Documentation writers-ren irudia Particularly helpful Moodlers-ren irudia Peer reviewers-ren irudia Plugin developers-ren irudia

Oh, that's irritating. If you go toSite administration -> Plugins ->Plugins overview, then you get a bit more information. block_quiz_results requires mod_quiz, so

  1. On the overview page.
  2. Right click the Uninstall link by block_quiz_results and choose "Open in new tab"
  3. In that new tab, click through until the plugin is deleted, but do no click Continue so the plugin re-installs itself.
  4. In the original tab, press F5 to reload.
  5. Now you should have an Uninstall link for the Quiz, which you can click.
  6. Follow through the uninstall and reinstall process.

Puntuazioen batez bestekoa:Useful (1)
Tim Hunt(e)ri erantzunda

Re: can't create a quiz

Erik Ringmar -
Hi again Tim,

I followed your instructions and it worked! (although I also had to delete the block_quiz_results directory from the server) I can now create new quizzes. Thank you so very much for your help and your time!

The only remaining problem now is to create the actual quiz, but I'm not expecting you to help me with that begi-keinua

yours, very gratefully indeed,

Erik
Erik Ringmar(e)ri erantzunda

Re: can't create a quiz

Tim Hunt -
Core developers-ren irudia Documentation writers-ren irudia Particularly helpful Moodlers-ren irudia Peer reviewers-ren irudia Plugin developers-ren irudia

Have you seen that Moodle HQ are running a MOOC this month about the basics of using Moodle? https://learn.moodle.net/

This weeks topic happens to be about creating quizzes and other graded activites, and it is not too late for you to join and play catch-up, if you like.