Merge pull request #20908 from edx/INCR-472/python-modernize-369-of-380
Python-modernize on edx-platform (369 of 380)
This commit is contained in:
@@ -5,6 +5,8 @@ This will mostly involve searching by course_id or task_id and manually failing
|
||||
a task.
|
||||
|
||||
"""
|
||||
from __future__ import absolute_import
|
||||
|
||||
from config_models.admin import ConfigurationModelAdmin
|
||||
from django.contrib import admin
|
||||
|
||||
|
||||
@@ -6,16 +6,19 @@ already been submitted, filtered either by running state or input
|
||||
arguments.
|
||||
|
||||
"""
|
||||
from __future__ import absolute_import
|
||||
|
||||
import hashlib
|
||||
from collections import Counter
|
||||
|
||||
import six
|
||||
from celery.states import READY_STATES
|
||||
|
||||
from bulk_email.models import CourseEmail
|
||||
from lms.djangoapps.certificates.models import CertificateGenerationHistory
|
||||
from lms.djangoapps.instructor_task.api_helper import (
|
||||
check_arguments_for_rescoring,
|
||||
check_arguments_for_overriding,
|
||||
check_arguments_for_rescoring,
|
||||
check_entrance_exam_problems_for_rescoring,
|
||||
encode_entrance_exam_and_student_input,
|
||||
encode_problem_and_student_input,
|
||||
@@ -23,7 +26,6 @@ from lms.djangoapps.instructor_task.api_helper import (
|
||||
)
|
||||
from lms.djangoapps.instructor_task.models import InstructorTask
|
||||
from lms.djangoapps.instructor_task.tasks import (
|
||||
override_problem_score,
|
||||
calculate_grades_csv,
|
||||
calculate_may_enroll_csv,
|
||||
calculate_problem_grade_report,
|
||||
@@ -36,6 +38,7 @@ from lms.djangoapps.instructor_task.tasks import (
|
||||
exec_summary_report_csv,
|
||||
export_ora2_data,
|
||||
generate_certificates,
|
||||
override_problem_score,
|
||||
proctored_exam_results_csv,
|
||||
rescore_problem,
|
||||
reset_problem_attempts,
|
||||
@@ -309,7 +312,7 @@ def submit_bulk_course_email(request, course_key, email_id):
|
||||
targets = [
|
||||
target if count <= 1 else
|
||||
u"{} {}".format(count, target)
|
||||
for target, count in targets.iteritems()
|
||||
for target, count in six.iteritems(targets)
|
||||
]
|
||||
|
||||
task_type = 'bulk_course_email'
|
||||
|
||||
@@ -4,6 +4,8 @@ Helper lib for instructor_tasks API.
|
||||
Includes methods to check args for rescoring task, encoding student input,
|
||||
and task submission logic, including handling the Celery backend.
|
||||
"""
|
||||
from __future__ import absolute_import
|
||||
|
||||
import hashlib
|
||||
import json
|
||||
import logging
|
||||
@@ -364,7 +366,7 @@ def check_entrance_exam_problems_for_rescoring(exam_key): # pylint: disable=inv
|
||||
descriptor doesn't exist for exam_key. NotImplementedError is raised if
|
||||
any of the problem in entrance exam doesn't support re-scoring calls.
|
||||
"""
|
||||
problems = get_problems_in_section(exam_key).values()
|
||||
problems = list(get_problems_in_section(exam_key).values())
|
||||
if any(not _supports_rescore(problem) for problem in problems):
|
||||
msg = _("Not all problems in entrance exam support re-scoring.")
|
||||
raise NotImplementedError(msg)
|
||||
|
||||
@@ -12,6 +12,8 @@ file and check it in at the same time as your model changes. To do that,
|
||||
ASSUMPTIONS: modules have unique IDs, even across different module_types
|
||||
|
||||
"""
|
||||
from __future__ import absolute_import
|
||||
|
||||
import codecs
|
||||
import csv
|
||||
import hashlib
|
||||
@@ -20,6 +22,7 @@ import logging
|
||||
import os.path
|
||||
from uuid import uuid4
|
||||
|
||||
import six
|
||||
from boto.exception import BotoServerError
|
||||
from django.conf import settings
|
||||
from django.contrib.auth.models import User
|
||||
@@ -87,7 +90,7 @@ class InstructorTask(models.Model):
|
||||
},)
|
||||
|
||||
def __unicode__(self):
|
||||
return unicode(repr(self))
|
||||
return six.text_type(repr(self))
|
||||
|
||||
@classmethod
|
||||
def create(cls, course_id, task_type, task_key, task_input, requester):
|
||||
@@ -226,7 +229,7 @@ class ReportStore(object):
|
||||
compatibility.
|
||||
"""
|
||||
for row in rows:
|
||||
yield [unicode(item).encode('utf-8') for item in row]
|
||||
yield [six.text_type(item).encode('utf-8') for item in row]
|
||||
|
||||
|
||||
class DjangoStorageReportStore(ReportStore):
|
||||
|
||||
@@ -19,6 +19,8 @@ a problem URL and optionally a student. These are used to set up the initial va
|
||||
of the query for traversing StudentModule objects.
|
||||
|
||||
"""
|
||||
from __future__ import absolute_import
|
||||
|
||||
import logging
|
||||
from functools import partial
|
||||
|
||||
@@ -44,8 +46,8 @@ from lms.djangoapps.instructor_task.tasks_helper.misc import (
|
||||
)
|
||||
from lms.djangoapps.instructor_task.tasks_helper.module_state import (
|
||||
delete_problem_module_state,
|
||||
perform_module_state_update,
|
||||
override_score_module_state,
|
||||
perform_module_state_update,
|
||||
rescore_problem_module_state,
|
||||
reset_attempts_module_state
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user