Coding error detected, it must be fixed by a programmer: loop of categories detected.

Coding error detected, it must be fixed by a programmer: loop of categories detected.

by Moshtaq Khan -
Number of replies: 5
My site has 11 category and in first category there are 4 courses with courseid=2 - 2, 3, 4, 5. Problem is happening only with courseid=2.

When i enter into "Question bank" from "course administration" of courseid=2, i got this error message - "Coding error detected, it must be fixed by a programmer: Category id=2 is already on the list - loop of categories detected." Even when i want to add question from question bank, i can't get any list of question, only "loading icon". I am using Moodle version 3.3 (Build: 20170515)


I just can't understand what should i do. Appreciate any help and thanks is advance.

Regards

Attachment question add error.PNG.png
Attachment question bank error1.PNG
Average of ratings: -
In reply to Moshtaq Khan

Re: Coding error detected, it must be fixed by a programmer: loop of categories detected.

by Howard Miller -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

Moving to Quiz forum...

In reply to Moshtaq Khan

Re: Coding error detected, it must be fixed by a programmer: loop of categories detected.

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

The categories being referred to are the question categories. It is saying that you have categories in your database like category 2 has parent category 3, and category 3 has parent category 2. This should never happen.

The only way I can think of to fix this is to look directly in the database, in the mdl_question_categories table. Start with the row with id = 2, and follow the chain of parent links to see what is going on. Probably, if you change the parent of one of them to 0 (meaning top) it will start working again. (However, directly editing things in the database is potentially dangerous.)

The real question is: how did this course get into this broken state in the first place?

Average of ratings: Useful (2)
In reply to Tim Hunt

Re: Coding error detected, it must be fixed by a programmer: loop of categories detected.

by Moshtaq Khan -

Thanks Tim.

I go through the way you showed. I go to database and searched with my course name ('foundation') string in question_categories table. what i found is in screenshot. Please show me the next way.

Regards

Attachment question_categories table.PNG
In reply to Moshtaq Khan

Re: Coding error detected, it must be fixed by a programmer: loop of categories detected.

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

So that is the shortest possible look. Category 2 is claiming to be its own parent.

It should be safe to edit that row (the one with id = 2) and change the parent value to 0 there. As SQL that would be

UPDATE question_categories SET parent = 0 WHERE id = 2

You could also try the search

SELECT * FROM question_categories WHERE parent = id

to see if there are any more of these.


Average of ratings: Useful (2)
In reply to Tim Hunt

Re: Coding error detected, it must be fixed by a programmer: loop of categories detected.

by Moshtaq Khan -

wow...many many thanks Tim.

problem is perfectly solved. Just run sql update to set parent = 0 and everything is working perfectly now.

Run also sql search for parent = id, found only that one. 

Thanks and gratitude again.