Skip to content

Commit

Permalink
Merge pull request #41 from edx/ahtisham/PROD-1352
Browse files Browse the repository at this point in the history
Updated query according to model update in platform
  • Loading branch information
AhtishamShahid authored Mar 20, 2020
2 parents c0813b6 + 969b8f7 commit 82b0546
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 16 deletions.
2 changes: 1 addition & 1 deletion bulk_grades/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@

from __future__ import absolute_import, unicode_literals

__version__ = '0.6.7'
__version__ = '0.6.8'

default_app_config = 'bulk_grades.apps.BulkGradesConfig' # pylint: disable=invalid-name
29 changes: 15 additions & 14 deletions bulk_grades/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,8 @@ def _get_enrollments(course_id, track=None, cohort=None):
'student_uid': institution user id from program enrollment
}
"""
enrollments = apps.get_model('student', 'CourseEnrollment').objects.filter(
course_id=course_id).select_related('user', 'programcourseenrollment')

enrollments = apps.get_model('student', 'CourseEnrollment').objects.filter(course_id=course_id).select_related(
'user').prefetch_related('programcourseenrollment_set')
if track:
enrollments = enrollments.filter(mode=track)
if cohort:
Expand All @@ -61,10 +60,11 @@ def _get_enrollments(course_id, track=None, cohort=None):
'enrolled': enrollment.is_active,
'track': enrollment.mode,
}
try:
pce = enrollment.programcourseenrollment.program_enrollment
enrollment_dict['student_uid'] = pce.external_user_key
except ObjectDoesNotExist:
program_course_enrollment = enrollment.programcourseenrollment_set.all()
if program_course_enrollment.exists():
program_course_enrollment = program_course_enrollment.first().program_enrollment
enrollment_dict['student_uid'] = program_course_enrollment.external_user_key
else:
enrollment_dict['student_uid'] = None
yield enrollment_dict

Expand Down Expand Up @@ -206,6 +206,7 @@ class GradedSubsectionMixin(object):
Mixin to help generated lists of graded subsections
and appropriate column names for each.
"""

def append_columns(self, new_column_names):
"""
Appends items from ``new_column_names`` to ``self.columns``
Expand Down Expand Up @@ -365,13 +366,13 @@ def process_row(self, row):
Save a row to the persistent subsection override table.
"""
grades_api.override_subsection_grade(
row['user_id'],
row['course_id'],
row['block_id'],
overrider=self._user,
earned_graded=row['new_override'],
feature='grade-import',
comment='Bulk Grade Import',
row['user_id'],
row['course_id'],
row['block_id'],
overrider=self._user,
earned_graded=row['new_override'],
feature='grade-import',
comment='Bulk Grade Import',
)
return True, None

Expand Down
2 changes: 1 addition & 1 deletion mock_apps/student/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ class ProgramEnrollment(object):


class ProgramCourseEnrollment(models.Model):
course_enrollment = models.OneToOneField(CourseEnrollment, on_delete=models.CASCADE)
course_enrollment = models.ForeignKey(CourseEnrollment, on_delete=models.CASCADE)

@property
def program_enrollment(self):
Expand Down

0 comments on commit 82b0546

Please sign in to comment.