Fix SQL error when backuping course with empty thematic plan - refs #6827