'Creates course schedules as per specified parametes'

def schedule_course(self):

    course_schedules = []
    course_schedules_errors = []
    rescheduled = []
    reschedule_errors = []
    self.validate_mandatory()
    self.validate_date()
    self.instructor_name = frappe.db.get_value(u'Instructor', self.instructor, u'instructor_name')
    (group_based_on, course) = frappe.db.get_value(u'Student    Group', self.student_group, [u'group_based_on', u'course'])
    if (group_based_on == u'Course'):
        self.course = course
    if self.rechedule:
        (rescheduled, reschedule_errors) = self.delete_course_schedule(rescheduled, reschedule_errors)
    date = self.course_start_date
    while (date < self.course_end_date):
        if (self.day == calendar.day_name[getdate(date).weekday()]):
            course_schedule = self.make_course_schedule(date)
            try:
                course_schedule.save()
            except OverlapError:
                course_schedules_errors.append(date)
            else:
                course_schedules.append(((course_schedule.name + u'    on    ') + date))
            date = add_days(date, 7)
        else:
            date = add_days(date, 1)
    frappe.local.message_log = []
    if course_schedules:
        frappe.msgprint(((_(u'Course    Schedules    created:') + u'\n') + u'\n'.join(course_schedules)))
    if course_schedules_errors:
        frappe.msgprint(((_(u'There    were    errors    while    scheduling    course    on    :') + u'\n') + u'\n'.join(course_schedules_errors)))
    if rescheduled:
        frappe.msgprint(((_(u'Course    Schedules    deleted:') + u'\n') + u'\n'.join(rescheduled)))
    if reschedule_errors:
        frappe.msgprint(((_(u'There    were    errors    while    deleting    following    schedules:') + u'\n') + u'\n'.join(reschedule_errors)))
