Found more than one record in fetch() ! Error

Re: Found more than one record in fetch() ! Error

by Terus E-learning -
Number of replies: 2
Picture of Plugin developers
Incredibly useful comment, thanks. 


Just a quick note, the duplicate entry with the higher ID will be created time and time again when viewing grader reports, but deleting the duplicates with the lower ID's seems to do the trick. 


Average of ratings: Useful (1)
In reply to Terus E-learning

Re: Found more than one record in fetch() ! Error

by Michael Haskell -
This query was useful to find the course that had duplicate entries and to see what the entries were.

select from_unixtime(gi.timecreated), from_unixtime(gi.timemodified), gi.* from mdl_grade_items gi where
gi.courseid in (
select courseid
from mdl_grade_items
where itemtype = 'course'
group by courseid
having count(*) > 1
)
and gi.itemtype = 'course'
order by gi.courseid;

In one case we also had unused mdl_grade_items of type 'category' that needed to be deleted.

select * from mdl_grade_items 
where courseid = my_courseid
and itemtype = 'category';

As well as very old duplicate mdl_grade_categories that needed to be deleted.

select from_unixtime(gc.timecreated), from_unixtime(gc.timemodified),  gc.* from mdl_grade_categories gc
where gc.courseid = my_courseid;


Thanks!
Average of ratings: Useful (5)