StudentQuiz export : error/moodle/invalidrecord

StudentQuiz export : error/moodle/invalidrecord

by Miro Iliaš -
Number of replies: 19

Hello,

within  my Moodle 3.5 and  up-to-date StudentQuiz activity, me and my students created a lot of questions there.

However, when I wanted to export them I get the error https://docs.moodle.org/35/en/error/moodle/invalidrecord .

I can duplicate questions and move them to other folder (category), but I would be glad to export the whole studentquiz category.

Any help, please ? 

---------

PS: In between I found this related bug , https://tracker.moodle.org/browse/MDL-54724  .  So my questions, grouped in StudentQuiz activity, must contain a faulty question_multianswer, because the error message says (translated from Slovak) says something about not possible to find record in database table for question_multianswer.



Average of ratings: -
In reply to Miro Iliaš

Re: StudentQuiz export : error/moodle/invalidrecord

by Miro Iliaš -

Well, in my studentquiz, there should be  a faulty question, because a student reported it once to me.  But now, from among 196 questions, it is difficult to find out which question is the faulty one.

In reply to Miro Iliaš

Re: StudentQuiz export : error/moodle/invalidrecord

by Miro Iliaš -

Well, in between I found the faulty question of cloze type, which  a student "succeeded" to create in the StudenQuiz. But as teacher I can do nothing - no editing, no deleting, no preview possible, it always throws out error message.

How can Moodle admin fix such issue ? 



In reply to Miro Iliaš

Re: StudentQuiz export : error/moodle/invalidrecord

by Frank Koch -
Picture of Plugin developers

Given your description I assume that as a teacher you do not see the icons (preview, edit, delete) next to the question. In this case go to the Question bank and delete the faulty question there.


In reply to Frank Koch

Re: StudentQuiz export : error/moodle/invalidrecord

by Miro Iliaš -

Frank, as teacher, I see delete/edit/preview buttons, but simply they do not work for this superfaulty question, neither in StudentQuiz nor in its Question Bank subarea.

How could a student create such fishy cloze-question  ?

In reply to Miro Iliaš

Re: StudentQuiz export : error/moodle/invalidrecord

by Frank Koch -
Picture of Plugin developers

Hi Miro

I have no idea how you got into this situation, but you wrote "I can duplicate questions and move them to other folder (category), but I would be glad to export the whole studentquiz category."

So what about if you move the problematic question into another category to get rid of this question within StudentQuiz? For this purpose you could create a dummy category within the course questionbank (not the StudentQuiz questionbank). Later you can see this dummy category within the StudentQuiz questionbank.

Maybe you can even delete the problematic question from the course questionbank.

Hope this works, Frank


In reply to Frank Koch

Re: StudentQuiz export : error/moodle/invalidrecord

by Miro Iliaš -

Hi Frank,

unfortunately, duplicating the fishy question does not work (sorry, I wrote it wrong), but  moving to a dummy category worked.  However, there, I still can not delete/edit/view this isolated question, as it throws the same error.

Likewise, the studentquiz category, even without the faulty question, still can not be exported, giving the very same error.




In reply to Miro Iliaš

Re: StudentQuiz export : error/moodle/invalidrecord

by Frank Koch -
Picture of Plugin developers

Could you please check whether there are any essay type questions in your set? Then please remove them as well.

In reply to Frank Koch

Re: StudentQuiz export : error/moodle/invalidrecord

by Miro Iliaš -

Hi,

there are no essay type questions in my set (now has 195 questions, including calculated), which has restricted question types to automatic ones. 

I am waiting for admin to delete the faulty cloze question, which is isolated in separate subfolder of the course.

I will keeep this thread updated, becase this seems to be a serious vulnerability of Moodle 3.5/cloze question.



In reply to Miro Iliaš

Re: StudentQuiz export : error/moodle/invalidrecord

by Matthias Giger -
Picture of Particularly helpful Moodlers

As far as I know the problem also occurs in other question types than the cloze question and in normal Moodle quizzes. I had a similar problem with a formulas question I generated myself. To get rid of the problem, it is best (as you have described) to move the question into another folder.

In reply to Matthias Giger

Re: StudentQuiz export : error/moodle/invalidrecord

by Miro Iliaš -

Hello, Matthias,

in between, our admin checked the quaestions database record table and made an artificiall fix (filling empty record) of presumably wrong question. It helped to the extent that fishy question was allowed to be moved elsewhere and deleted. Buf export the whole studentquiz category remains failing. Maybe this is related to the https://tracker.moodle.org/browse/MDL-54724 .



In reply to Miro Iliaš

Re: StudentQuiz export : error/moodle/invalidrecord

by Jean-Michel Védrine -

Hello Miro,

Can you ask your admin if he remember what artificial fix he did or if I can contact him ?

The problem with MDL-54724 is that despite many efforts I am unable to understand how broken multianwer questions are created in the first place.

My guess was that they could be created during backup/restore. But your problem with StudentQuiz clearly show that it is possible to create broken multianswer using the Moodle interface. I already fixed MDL-60897 that was one case where it was possible to create such broken questions, but as it was only fixed recently in Moodle 3.4.6 and 3.5.3 maybe that was that bug that permitted your student to create a broken question, but maybe not and maybe there are other undiscovered ways to create broken questions ?

So any information about broken multianswer questions could be useful. Don't hesitate to post your observations as comments to MDL-54724.

One thing that I don't understand is that if this faulty question was properly removed why are you still unable to export the whole studentquiz category ?

In reply to Jean-Michel Védrine

Re: StudentQuiz export : error/moodle/invalidrecord

by Miro Iliaš -

Hello, Jean-Michel,

following https://tracker.moodle.org/browse/MDL-60897 I found that with Moodle 3.5.2 I was able to create faulty embedded answers (Cloze) question.

Now admin upgraded our Moodle to 3.5.3+ (Build: 20190111) and creation of faulty cloze questions got blocked as well as I was able to delete all previously created faulty questions.

What remained, however, that I still can not export the whole StudentQuiz question set, getting "error/moodle/invalidrecord".

In between, upon checking all cloze questions created by students, I found another faulty type of cloze question, see https://tracker.moodle.org/browse/MDL-64558 .


In reply to Jean-Michel Védrine

Re: StudentQuiz export : error/moodle/invalidrecord

by Miro Iliaš -

Well, concerning the faulty export, it would be good to have some tool for fixing questions database.

In reply to Matthias Giger

Re: StudentQuiz export : error/moodle/invalidrecord

by Jean-Michel Védrine -

Hello Matthias,

I am interested (of course) in your problem.

Any information about how you managed to create a broken formulas question would be interesting.

Also re you able to look into the database and to find the record for this question in the mdl_question table , note it's id value, then see if there is a record in the mdl_qtype_formulas_options table with questionid equal to the id of the first record and finally find how many records there are in the mdl_qtype_formulas_answers table with questionid equal to the id of the first record.

I was already thinking to improve some functions to make formulas more robust so that broken question can be edited or deleted and all your results would help me, because I was never able to create a broken formulas question using the question editor from Moodle, I can only make "fake" formulas broken questions editing records directly in the database.

Thanks a lot for your help

In reply to Jean-Michel Védrine

Re: StudentQuiz export : error/moodle/invalidrecord

by Matthias Giger -
Picture of Particularly helpful Moodlers

Dear Jean-Michel

Can you give me some help with the SLQ queries?

I managed to get the ID and the record by this query:

SELECT * FROM `mdl_question` WHERE id=18572

result of data query

However, after that I get stuck. How exactly do I have to formulate the other two queries?


As for the question how I managed to produce a faulty Formulas question, I don't know what exactly happened. What I remember is that when I tried to save the question I had an error message from Moodle which I was not able to correct. I finally had to redo the question and ended up with two faulty versions of it which I removed to another category because the JSON error message showed up whenever I tried to access the question bank of the test in question. The most likely reason is a problem with the Internet connection.


But I will send you the results from the database query, as soon as I'm able to.


As for the time, it happened on the 8th of December which is after I had upgraded to Moodle 3.5.3.

In reply to Matthias Giger

Re: StudentQuiz export : error/moodle/invalidrecord

by Jean-Michel Védrine -

Thanks Matthias,

can you do the following queries (assuming that your first query with id=18572 return the broken question)

SELECT * FROM `mdl_qtype_formulas_options` WHERE questionid=18572

SELECT * FROM `mdl_qtype_formulas_answers` WHERE questionid=18572

The first one should return exactly 1 record

The second one should return 1 or several records depending on how many parts your question have

I am not only interested by the number of records but also by their content (if any). If you don't want to post the result here you can send them to me privately.

In reply to Jean-Michel Védrine

Re: StudentQuiz export : error/moodle/invalidrecord

by Matthias Giger -
Picture of Particularly helpful Moodlers

Both queries result in a blank, there seems to be no records in the database.


On that note: How does the question type control for complete questions?

Could it be that the problem is caused by a non standard SQL table prefix?

In my database I don't use the mdl_ prefix, but a different one.

In reply to Matthias Giger

Re: StudentQuiz export : error/moodle/invalidrecord

by Jean-Michel Védrine -

Thanks that is an indication of the place where the code has failed.

In my current work, I am trying to:

  • Warn the user that the formulas question is broken (usefull to help to correct the problem)
  • Permit to edit and delete the question by providing default record when one is missing.
Don't worry the code works with any prefix, I was just assuming that as most Moodle users you were using mdl_, but you can use whatever you want and the formulas plugin will work.

About the validation of questions: formulas uses a very sophisticated (thanks to Hon Wai Lau work smile) way to validate the question, after doing basic verifications on the contents of the different fields, it instanciate a sample of the question and verify that it can be evaluated with no apparent problem so that should catch most syntax errors even if there is a slight chance that a problem is left undetected.
Of course as mathematicians know well a sample doesn't prove that the question is working but if the sample fails surely the question is bad.