MDL-40924 badges: added a print_error call to prevent PHP notices when no badges are found