Help with Fatal Error More than One Record in Fetch()

Help with Fatal Error More than One Record in Fetch()

by Rodney Wolford -
Number of replies: 9

Hello,

I am having a fetch() error and seem unable to solve it. I am using Moodle 2.6, latest release, with Essential 2.7.

 I initially thought this was a problem with question type I am using (drag and drop on image), but Tim Hunt said no. He said the errors are related to grade, as shown in the code.

The error appears after finishing a quiz associated with a Navigation Course on our site. I am logged in as trainee. Quiz finishes, but when I return to view grades, I get this fetch error. Here is debug information:

Debug info:
Error code: more than one record in fetch()

Stack trace:

  • line 463 of /lib/setuplib.php: moodle_exception thrown
  • line 163 of /lib/grade/grade_object.php: call to print_error()
  • line 326 of /lib/grade/grade_item.php: call to grade_object::fetch_helper()
  • line 980 of /lib/grade/grade_item.php: call to grade_item::fetch()
  • line 1010 of /lib/gradelib.php: call to grade_item::fetch_course_item()
  • line 84 of /grade/report/user/index.php: call to grade_regrade_final_grades()

What is even worse, I cannot redo the quiz, enter the quiz, or even create a new quiz activity in the related course area. It is impossible to do anything with it, except delete it, which would be devastating to my work schedule.

I did find an older post from 2012 in which this was discussed and a bug tracker was filed on it  https://tracker.moodle.org/browse/MDL-31441. It appears the bug is still open. However, the person who initially posted, developed a solution that involved deleting files in the database following the link she provided, but I am not familiar enough with mySql to find the potentially offending data.

I did post a similar request for help in the general help forum, but that was before I saw that gradebook has its own forum. I imagine this is the better place to get the answer. And I hope my double posting transgression can be forgiven this once.

I really, really, need someone who can help me with this.

Rod Wolford

In reply to Rodney Wolford

Re: Help with Fatal Error More than One Record in Fetch()

by Bob Puffer -

You need to post this in the Moodle jobs section where someone knowledgeable will assist you for a fee:

https://moodle.org/mod/data/view.php?d=54

In reply to Bob Puffer

Re: Help with Fatal Error More than One Record in Fetch()

by Rodney Wolford -

I was unaware of this service. I will check it out because all I want is to get the problem solved. However, I believe there remains a moodle bug, as reported earlier in tracker that maybe someone should also try to resolve.

 

In reply to Rodney Wolford

Re: Help with Fatal Error More than One Record in Fetch()

by Tim Hunt -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

In the terms of this blog post http://tjhunt.blogspot.co.uk/2013/11/bug-fixing-as-knowledge-creation.html, we are just at "Step 1. Something's wrong", which is not enough information to know what the problem is or fix it.

Someone needs to generate some more knowledge.

In reply to Tim Hunt

Re: Help with Fatal Error More than One Record in Fetch()

by Rodney Wolford -

I wouldn't argue with you. But it is a bug and the immediate solution to my issue resided in the database which I know you could have helped me decode as you have done for many over the years. Of course, I understand you may tire of helping on the tasks which for you have become mostly trivial and I know you have many, many irons in the fire. Also, I think this code took us beyond stage one in the debugging steps: "line 163 of /lib/grade/grade_object.php: call to print_error()" I think this might have placed us at Step 3. Which Code is broken.

Fortunately for me Gareth Barnhard provided the guidance to solve my immediate problem. That is, of course, one of the great strengths of the Moodle community. Many knowledgeable folks acting synergistically‎ to produce a fantastic body of knowledge. Gareth directed me into the correct area of the database through his responses in Tracker http://tracker.moodle.org/browse/MDL-31441

To fix, I ended up editing the grade_object.php file that was generating the error message and changed line 161: "if (count($instances) > 1 {" to a 2. Then I went back to my site, tried to enter the quiz again, and it opened! Now I was able to deleted all attempts. Then back to line 161 and changed it back to a 1. Now, all works. But this still doesn't explain why it happened.

However, my solution might point to an area where a fix could be implemented. What if when it came to line 161 with an instance greater than 1, instead of throwing an error it offered a chance to delete the first or the second attempt before going forward?  Or maybe, it would just delete the first attempt?

Anyway, I will follow the bug report to see where it goes. Seems like this is something that should not be able to occur.

Rod Wolford

In reply to Rodney Wolford

Re: Help with Fatal Error More than One Record in Fetch()

by Tim Hunt -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

You persist in your belief that I could have helped you but chose not to. That is not correct, and I don't see what evidence you could have used to reach that conclusion. I still don't know what the cause of the bug you are are seeing is.

In reply to Tim Hunt

Re: Help with Fatal Error More than One Record in Fetch()

by Rodney Wolford -

I actually did not want to respond or carry this issue any further. But I am compelled, probably to the detriment of my own best interest.

First, I did not like your misconstruance of my statement about your choice. Yes, I believe you had the expertise to help. But, no, I do not believe you chose not to. I don't think to help or not was ever your consideration. You were busy with other issues, and that is that. It is not a complaint. Just a fact. You did not say "don't help Rod." I'm really am not that egocentric.

Second, you say you do not know the cause of the bug. I would agree you nor anyone may know the cause. But often triage is available to mitigate effects even when unknown. You correctly identified the issue as grader_object or grader_item, unrelated to quiz. But went no further. Whereas if I were required I could identify at least 15 of your posts where recovery aid was given on database issues with no known cause -- just a solution to get back on the straight and narrow.

Now I am still a newbie, only 1.3 years into Moodle. And ultimately even I could determine that so long as the count on line 161 of the relevant .php script was greater than 1, I was going to get an error that prevented any fix, recovery, or backup. I just find it unimaginable that you, with all of your expertise -- and it is very impressive -- could not have facilitated the recovery, if not the fix. Of course, I don't imagine you have any obligation to do so. But what a disappointment that you didn't even take a whack at it.

Third, you focused on what you presumed I said about you. But you did not comment on the fix I used, saying good, bad, indifferent -- which would have provided useful instruction for me and others. And you did not comment on the proposed solution of taking the error check statement and turning it into a corrective statement to help prevent the error for other users in the future. Even if it is stupid, that would be nice to know.

Maybe, my expectations are out of line with reality. But I'd like to feel that all of us Moodlers, regardless of our knowledge or expertise, are in this together. And, while I tremendously respect your amazing and outstanding talents and contributions -- in my mind you are one of the best -- I just felt let down. Maybe that is what my belief is based on. And maybe it is misplaced.

You will not hear another word  about this from me.

Rod Wolford

In reply to Bob Puffer

Re: Help with Fatal Error More than One Record in Fetch()

by Rodney Wolford -

Bob,

I took your suggestion and posted for someone to solve the problem. What a joke. Most of the responses were from wanna be's -- from my pocket to theirs. I feel cast into the fifth ring of hell. I will respond to each in turn to say "no thank you."

Now, there may be a gem in here somewhere (like the boy at Christmas who was all smiles when he saw piles of horse pucky under the tree, because he reasoned with all this horse sh*t there must be a horse in here somewhere."}  But clearly, this service offers no criteria for making good choices. It is a Bazaar in the bizzare sense of the word.

Anyway, my impression. But thanks for your sincere effort to help.

Rod

In reply to Rodney Wolford

Re: Help with Fatal Error More than One Record in Fetch()

by John Andrewartha -

Clearly Rodney you are not a happy customer.

Tim did attempt to help you, but he like the rest of us. is not mind readers. You failed the first tenant, give all the information, Moodle version, web server and version and which database you are using... .

No matter how eloquent you think your pros are, speaking as you have to a valued and respected member of the community will win you no friends.

Your apology is now due.

John

In reply to Rodney Wolford

Re: Help with Fatal Error More than One Record in Fetch()

by Bob Puffer -

Thanks for the useful feedback on the jobs board. I didn't realize it had deteriorated so badly. Will not recommend again.