Best practice forum (Archived)

Course completion import - duplicate key

 
? ?
Course completion import - duplicate key
بواسطة Monday, 31 March 2014, 10:36 AM - ? ?
 

We are running in to what would appear to be an SQL transactional type of error with importing of course completion records. Totara 2.5.10

With debugging enabled, after attempting to import completion records:

Debug info: Duplicate entry '15-3' for key 'mdl_courcomp_usecou_uix'
INSERT INTO mdl_course_completions (rpl,rplgrade,status,timeenrolled,timestarted,timecompleted,reaggregate,userid,course) VALUES (?,?,?,?,?,?,?,?,?)
[array (
0 => 'Completion history import - imported grade = 92',
1 => '92',
2 => 75,
3 => 1267419600,
4 => 1267419600,
5 => 1267419600,
6 => 0,
7 => '15',
8 => '3',

)]
Error code: dmlwriteexception
Naturally I look at the course_completions mdl_courcomp_usecou_uix index, and verify that there are no existing records in course_completions with a userid of 15 and a course of 3.

I have a suspicion this could possibly be low-level database transaction related. 

With sql logging enabled, we see the transaction followed by a rollback when this error occurs:

SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED

ROLLBACK

 

 

? ?
Re: Course completion import - duplicate key
بواسطة Monday, 31 March 2014, 4:20 PM - ? ?
 

Hi Jamie

First up we are trying to get bug reports moving through the helpdesk system from now on as it is very difficult to keep track of bug reports on forums. The forums should be for general chat, sharing info with other partners, discussion on future features, that sort of thing, but anything that actually needs investigation or action by the Totara Core team should be going through helpdesk.totaralms.com so we can track it to resolution.

The question here as a temporary fix is whether there are multiple records for the same user in the upload file, or alternatively whether there are users in the upload file that have already completed the course. There was a similar issue with certification completion uploads with multiple records for users in the same upload file a few months back, so this may be related.

? ?
Re: Course completion import - duplicate key
بواسطة Tuesday, 1 April 2014, 7:02 AM - ? ?
 

Duly noted Ciaran.

We have analyzed the code and determined the cause of the bug. It is not caused by having the same user in the upload file, and not caused by the user already having completed the course. I will file a bug report in the helpdesk system with details.

Martin Sandberg
Re: Course completion import - duplicate key
بواسطة Tuesday, 1 April 2014, 7:46 AM - Martin Sandberg
مجموعة Partners

We have found the same issue and have filed a bugreport on it yesterday.

It only happens when there are actual courses in the system and not if imported as evidence.

However, it is not easy to import as evidence as even if the courseid is not correct but the shortname is the import will take it as a course. You would think that the ID would have to be correct wouldn't you?

BR

Martin

 

 

 

? ?
Re: Course completion import - duplicate key
بواسطة Tuesday, 1 April 2014, 8:38 AM - ? ?
 

Yes that is one peculiarity I came across too Martin.

? ?
Re: Course completion import - duplicate key
بواسطة Tuesday, 1 April 2014, 2:12 PM - ? ?
 

Thanks for the additional info Jamie, yeah it looks like it's the "completion begins on enrolment" setting. A developer has been assigned so hopefully we'll have a fix shortly. In the meantime I suppose a workaround would be to turn off completion begins on enrolment, import the historical records, then turn that setting back on again?

Martin Sandberg
Re: Course completion import - duplicate key
بواسطة Tuesday, 1 April 2014, 10:53 PM - Martin Sandberg
مجموعة Partners

Thanks for the info Ciaran.....

By changing the "completion begins on enrollment" setting on all courses in the database I could import my data and then change the setting back to on afterwards.

Best regards,

Martin