def test_enroll_from_csv(self): self.setup_course() template = "{email},{name},{sid},{class_account},{section}" form = BatchEnrollmentForm() form.csv.data = template.format(**self.studentA) + "\n" + template.format(**self.studentB) Enrollment.enroll_from_csv(self.course.id, form) user_a = User.lookup(self.studentA['email']) self.studentA['id'] = user_a.id self.enrollment_matches_info(user_a, self.studentA) user_b = User.lookup(self.studentB['email']) self.studentB['id'] = user_b.id self.enrollment_matches_info(user_b, self.studentB)
def batch_enroll(cid): courses, current_course = get_courses(cid) batch_form = forms.BatchEnrollmentForm() if batch_form.validate_on_submit(): new, updated = Enrollment.enroll_from_csv(cid, batch_form) msg = ("Added {new}, Updated {old} {role} enrollments" .format(new=new, role=batch_form.role.data, old=updated)) flash(msg, "success") return redirect(url_for(".enrollment", cid=cid)) return render_template('staff/course/enrollment/enrollment.batch.html', batch_form=batch_form, courses=courses, current_course=current_course)
def batch_enroll(cid): courses, current_course = get_courses(cid) batch_form = forms.BatchEnrollmentForm() if batch_form.validate_on_submit(): new, updated = Enrollment.enroll_from_csv(cid, batch_form) msg = ("Added {new}, Updated {old} {role} enrollments" .format(new=new, role=batch_form.role.data, old=updated)) flash(msg, "success") return redirect(url_for(".enrollment", cid=cid)) return render_template('staff/course/enrollment.batch.html', batch_form=batch_form, courses=courses, current_course=current_course)