From 9c7f2cf6047dde39040739e0ff1c5fe6951192fc Mon Sep 17 00:00:00 2001 From: Victor Shnayder Date: Tue, 15 Jan 2013 14:44:09 -0500 Subject: [PATCH] WIP -- do not merge --- lms/djangoapps/instructor/views.py | 13 ++++++++++--- lms/templates/courseware/instructor_dashboard.html | 6 +++--- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/lms/djangoapps/instructor/views.py b/lms/djangoapps/instructor/views.py index e6aa6c2f2e..9a5a73e4e3 100644 --- a/lms/djangoapps/instructor/views.py +++ b/lms/djangoapps/instructor/views.py @@ -314,14 +314,14 @@ def instructor_dashboard(request, course_id): users = request.POST['betausers'] log.debug("users: {0!r}".format(users)) group = get_beta_group(course) - for username_or_email in users.split(): + for username_or_email in _split_by_comma_and_whitespace(users): msg += "

{0}

".format( add_user_to_group(request, username_or_email, group, 'beta testers', 'beta-tester')) elif action == 'Remove beta testers': users = request.POST['betausers'] group = get_beta_group(course) - for username_or_email in users.split(): + for username_or_email in _split_by_comma_and_whitespace(users): msg += "

{0}

".format( remove_user_from_group(request, username_or_email, group, 'beta testers', 'beta-tester')) @@ -793,11 +793,18 @@ def grade_summary(request, course_id): # enrollment +def _split_by_comma_and_whitespace(s): + """ + Split a string both by on commas and whitespice. + """ + # Note: split() with no args removes empty strings from output + return [x.split() for x in s.split(',')] + def _do_enroll_students(course, course_id, students, overload=False): """Do the actual work of enrolling multiple students, presented as a string of emails separated by commas or returns""" - ns = [x.split('\n') for x in students.split(',')] + ns = _split_by_comma_and_whitespace(students) new_students = [item for sublist in ns for item in sublist] new_students = [str(s.strip()) for s in new_students] new_students_lc = [x.lower() for x in new_students] diff --git a/lms/templates/courseware/instructor_dashboard.html b/lms/templates/courseware/instructor_dashboard.html index 6bff32fc48..84c70226ec 100644 --- a/lms/templates/courseware/instructor_dashboard.html +++ b/lms/templates/courseware/instructor_dashboard.html @@ -61,7 +61,7 @@ function goto( mode) %endif Admin | Forum Admin | - Enrollment + Enrollment | Manage Groups ] @@ -254,7 +254,7 @@ function goto( mode) %endif -

Add students: enter emails, separated by returns or commas;

+

Add students: enter emails, separated by new lines or commas;

@@ -268,7 +268,7 @@ function goto( mode)

- Enter usernames or emails for students who should be beta-testers, one per line. They will get to + Enter usernames or emails for students who should be beta-testers, one per line, or separated by commas. They will get to see course materials early, as configured via the days_early_for_beta option in the course policy.