def _validate_course(self):
<EOL>course_details = self.cleaned_data.get(self.Fields.COURSE)<EOL>if course_details:<EOL><INDENT>course_mode = self.cleaned_data.get(self.Fields.COURSE_MODE)<EOL>if not course_mode:<EOL><INDENT>raise ValidationError(ValidationMessages.COURSE_WITHOUT_COURSE_MODE)<EOL><DEDENT>valid_course_modes = course_details["<STR_LIT>"]<EOL>if all(course_mode != mode["<STR_LIT>"] for mode in valid_course_modes):<EOL><INDENT>error = ValidationError(ValidationMessages.COURSE_MODE_INVALID_FOR_COURSE.format(<EOL>course_mode=course_mode,<EOL>course_id=course_details["<STR_LIT>"],<EOL>))<EOL>raise ValidationError({self.Fields.COURSE_MODE: error})<EOL><DEDENT><DEDENT>
Verify that the selected mode is valid for the given course .