incr-313 (#20612)
* run python modernize * run isort * move imports together
This commit is contained in:
committed by
Michael Youngstrom
parent
fc80b28bbc
commit
5e20a0b0bb
@@ -8,15 +8,16 @@ from __future__ import absolute_import, division, print_function, unicode_litera
|
||||
import logging
|
||||
from datetime import datetime
|
||||
|
||||
import six
|
||||
from django.core.management.base import BaseCommand, CommandError
|
||||
from pytz import utc
|
||||
from submissions.models import Submission
|
||||
|
||||
from courseware.models import StudentModule
|
||||
from lms.djangoapps.grades.constants import ScoreDatabaseTableEnum
|
||||
from lms.djangoapps.grades.events import PROBLEM_SUBMITTED_EVENT_TYPE
|
||||
from lms.djangoapps.grades.tasks import recalculate_subsection_grade_v3
|
||||
from student.models import user_by_anonymous_id
|
||||
from submissions.models import Submission
|
||||
from track.event_transaction_utils import create_new_event_transaction_id, set_event_transaction_type
|
||||
from util.date_utils import to_timestamp
|
||||
|
||||
@@ -64,12 +65,12 @@ class Command(BaseCommand):
|
||||
for record in StudentModule.objects.filter(**kwargs):
|
||||
task_args = {
|
||||
"user_id": record.student_id,
|
||||
"course_id": unicode(record.course_id),
|
||||
"usage_id": unicode(record.module_state_key),
|
||||
"course_id": six.text_type(record.course_id),
|
||||
"usage_id": six.text_type(record.module_state_key),
|
||||
"only_if_higher": False,
|
||||
"expected_modified_time": to_timestamp(record.modified),
|
||||
"score_deleted": False,
|
||||
"event_transaction_id": unicode(event_transaction_id),
|
||||
"event_transaction_id": six.text_type(event_transaction_id),
|
||||
"event_transaction_type": PROBLEM_SUBMITTED_EVENT_TYPE,
|
||||
"score_db_table": ScoreDatabaseTableEnum.courseware_student_module,
|
||||
}
|
||||
@@ -80,12 +81,12 @@ class Command(BaseCommand):
|
||||
task_args = {
|
||||
"user_id": user_by_anonymous_id(record.student_item.student_id).id,
|
||||
"anonymous_user_id": record.student_item.student_id,
|
||||
"course_id": unicode(record.student_item.course_id),
|
||||
"usage_id": unicode(record.student_item.item_id),
|
||||
"course_id": six.text_type(record.student_item.course_id),
|
||||
"usage_id": six.text_type(record.student_item.item_id),
|
||||
"only_if_higher": False,
|
||||
"expected_modified_time": to_timestamp(record.created_at),
|
||||
"score_deleted": False,
|
||||
"event_transaction_id": unicode(event_transaction_id),
|
||||
"event_transaction_id": six.text_type(event_transaction_id),
|
||||
"event_transaction_type": PROBLEM_SUBMITTED_EVENT_TYPE,
|
||||
"score_db_table": ScoreDatabaseTableEnum.submissions,
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@ from __future__ import absolute_import, division, print_function, unicode_litera
|
||||
|
||||
import ddt
|
||||
import six
|
||||
from six.moves import range
|
||||
from django.contrib.auth import get_user_model
|
||||
from django.core.management import CommandError, call_command
|
||||
from mock import ANY, patch
|
||||
|
||||
@@ -2,15 +2,17 @@
|
||||
Tests for recalculate_learner_grades management command.
|
||||
"""
|
||||
|
||||
from __future__ import absolute_import
|
||||
|
||||
from tempfile import NamedTemporaryFile
|
||||
|
||||
import mock
|
||||
|
||||
from lms.djangoapps.grades.management.commands import recalculate_learner_grades
|
||||
from lms.djangoapps.grades.tests.test_tasks import HasCourseWithProblemsMixin
|
||||
from student.tests.factories import CourseEnrollmentFactory, UserFactory
|
||||
from xmodule.modulestore.tests.django_utils import ModuleStoreTestCase
|
||||
from xmodule.modulestore.tests.factories import CourseFactory
|
||||
from student.tests.factories import UserFactory, CourseEnrollmentFactory
|
||||
|
||||
DATE_FORMAT = u"%Y-%m-%d %H:%M"
|
||||
|
||||
|
||||
@@ -2,9 +2,12 @@
|
||||
Tests for reset_grades management command.
|
||||
"""
|
||||
|
||||
from __future__ import absolute_import
|
||||
|
||||
from datetime import datetime
|
||||
|
||||
import ddt
|
||||
import six
|
||||
from django.conf import settings
|
||||
from mock import MagicMock, patch
|
||||
from pytz import utc
|
||||
@@ -69,7 +72,7 @@ class TestRecalculateSubsectionGrades(HasCourseWithProblemsMixin, ModuleStoreTes
|
||||
"only_if_higher": False,
|
||||
"expected_modified_time": to_timestamp(utc.localize(datetime.strptime('2016-08-23 16:43', DATE_FORMAT))),
|
||||
"score_deleted": False,
|
||||
"event_transaction_id": unicode(get_event_transaction_id()),
|
||||
"event_transaction_id": six.text_type(get_event_transaction_id()),
|
||||
"event_transaction_type": u'edx.grades.problem.submitted',
|
||||
"score_db_table": score_db_table,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user