fix errors 'undefined variable ' and 'Duplicate entry for key 'mdl_coursect_cousec_uix'' when downloading quizzes