Merge pull request #20677 from edx/dcs/track-cohort-sgp

Added track and cohort filter for CSV score export
This commit is contained in:
Dave St.Germain
2019-05-28 11:14:36 -04:00
committed by GitHub
8 changed files with 7 additions and 220 deletions

View File

@@ -320,7 +320,7 @@ def migrate_cohort_settings(course):
return cohort_settings
def get_course_cohorts(course, assignment_type=None):
def get_course_cohorts(course=None, course_id=None, assignment_type=None):
"""
Get a list of all the cohorts in the given course. This will include auto cohorts,
regardless of whether or not the auto cohorts include any users.
@@ -333,11 +333,14 @@ def get_course_cohorts(course, assignment_type=None):
A list of CourseUserGroup objects. Empty if there are no cohorts. Does
not check whether the course is cohorted.
"""
assert bool(course) ^ bool(course_id), "course or course_id required"
# Migrate cohort settings for this course
migrate_cohort_settings(course)
if course:
migrate_cohort_settings(course)
course_id = course.location.course_key
query_set = CourseUserGroup.objects.filter(
course_id=course.location.course_key,
course_id=course_id,
group_type=CourseUserGroup.COHORT
)
query_set = query_set.filter(cohort__assignment_type=assignment_type) if assignment_type else query_set

View File

@@ -45,7 +45,7 @@ def move_to_verified_cohort(sender, instance, **kwargs): # pylint: disable=unus
log.error(u"Automatic verified cohorting enabled for course '%s', but course is not cohorted.", course_key)
else:
course = get_course_by_id(course_key)
existing_manual_cohorts = get_course_cohorts(course, CourseCohort.MANUAL)
existing_manual_cohorts = get_course_cohorts(course, assignment_type=CourseCohort.MANUAL)
if any(cohort.name == verified_cohort_name for cohort in existing_manual_cohorts):
# Get a random cohort to use as the default cohort (for audit learners).
# Note that calling this method will create a "Default Group" random cohort if no random