Skip to content

Commit

Permalink
Merge pull request #30 from edx/andytr1/rename-bulk-management-columns
Browse files Browse the repository at this point in the history
EDUCATOR-4611 rename columns
  • Loading branch information
Andytr1 authored Sep 9, 2019
2 parents 86bf985 + 02c289d commit f961862
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 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.5.10'
__version__ = '0.5.11'

default_app_config = 'bulk_grades.apps.BulkGradesConfig' # pylint: disable=invalid-name
16 changes: 8 additions & 8 deletions bulk_grades/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ def _get_graded_subsections(self, course_id, filter_subsection=None, filter_assi
continue
short_block_id = block_id[:8]
if short_block_id not in subsections:
for key in ('name', 'grade', 'previous', 'new_grade'):
for key in ('name', 'original_grade', 'previous_override', 'new_override'):
self.columns.append('{}-{}'.format(key, short_block_id))
subsections[short_block_id] = (subsection, subsection.display_name)
return subsections
Expand Down Expand Up @@ -269,7 +269,7 @@ def preprocess_row(self, row):
if row['user_id'] in self._users_seen:
return operation
for key in row:
if key.startswith('new_grade-'):
if key.startswith('new_override-'):
value = row[key].strip()
if value:
short_id = key.split('-', 1)[1]
Expand All @@ -278,10 +278,10 @@ def preprocess_row(self, row):
operation['course_id'] = self.course_id
operation['block_id'] = text_type(subsection.location)
try:
operation['new_grade'] = float(value)
operation['new_override'] = float(value)
except ValueError:
raise ValidationError(_('Grade must be a number'))
if operation['new_grade'] < 0:
if operation['new_override'] < 0:
raise ValidationError(_('Grade must be positive'))
self._users_seen.add(row['user_id'])
return operation
Expand All @@ -295,7 +295,7 @@ def process_row(self, row):
row['course_id'],
row['block_id'],
overrider=self._user,
earned_graded=row['new_grade'],
earned_graded=row['new_override'],
feature='grade-import'
)
return True, None
Expand Down Expand Up @@ -345,11 +345,11 @@ def get_rows_to_export(self):
row['name-{}'.format(block_id)] = display_name
grade = grades.get(subsection.location, None)
if grade:
row['grade-{}'.format(block_id)] = grade.earned_graded
row['original_grade-{}'.format(block_id)] = grade.earned_graded
try:
row['previous-{}'.format(block_id)] = grade.override.earned_graded_override
row['previous_override-{}'.format(block_id)] = grade.override.earned_graded_override
except AttributeError:
row['previous-{}'.format(block_id)] = None
row['previous_override-{}'.format(block_id)] = None
yield row


Expand Down
2 changes: 1 addition & 1 deletion tests/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ def test_less_than_zero(self, course_grade_factory_mock):

row = {
'block_id': self.block_id,
'new_grade-block-v1': '-1',
'new_override-block-v1': '-1',
'user_id': self.learner.id,
'csum': '07ec',
'Previous Points': '',
Expand Down

0 comments on commit f961862

Please sign in to comment.