Skip to content

Commit

Permalink
Applied 2to3 to address compatibility issues while running in Juniper
Browse files Browse the repository at this point in the history
  • Loading branch information
blarghmatey committed Jun 3, 2020
1 parent d0fe786 commit dbc6bfb
Show file tree
Hide file tree
Showing 12 changed files with 19 additions and 28 deletions.
2 changes: 1 addition & 1 deletion rapid_response_xblock/__init__.py
@@ -1,2 +1,2 @@
"""rapid_response_xblock Django app"""
__version__ = '0.0.6'
__version__ = '0.0.7'
2 changes: 1 addition & 1 deletion rapid_response_xblock/apps.py
Expand Up @@ -17,7 +17,7 @@ class RapidResponseAppConfig(AppConfig):
PluginSettings.CONFIG: {
ProjectType.LMS: {
SettingsType.COMMON: {
PluginSettings.RELATIVE_PATH: u'settings'
PluginSettings.RELATIVE_PATH: 'settings'
},
}
}
Expand Down
6 changes: 3 additions & 3 deletions rapid_response_xblock/block.py
Expand Up @@ -62,7 +62,7 @@ def wrapper(aside_instance, *args, **kwargs): # pylint: disable=missing-docstri
return wrapper


BLOCK_PROBLEM_CATEGORY = u'problem'
BLOCK_PROBLEM_CATEGORY = 'problem'
MULTIPLE_CHOICE_TYPE = 'multiplechoiceresponse'


Expand All @@ -82,7 +82,7 @@ def student_view_aside(self, block, context=None): # pylint: disable=unused-arg
"""
Renders the aside contents for the student view
"""
fragment = Fragment(u'')
fragment = Fragment('')
if not self.is_staff() or not self.enabled:
return fragment
fragment.add_content(
Expand All @@ -104,7 +104,7 @@ def studio_view_aside(self, block, context=None): # pylint: disable=unused-argu
"""
Renders the aside contents for the studio view
"""
fragment = Fragment(u'')
fragment = Fragment('')
fragment.add_content(
render_template(
"static/html/rapid_studio.html",
Expand Down
3 changes: 1 addition & 2 deletions rapid_response_xblock/logger.py
@@ -1,7 +1,6 @@
"""
Capture events
"""
from __future__ import absolute_import
import logging
from collections import namedtuple

Expand Down Expand Up @@ -53,7 +52,7 @@ def parse_submission_event(event):
event_submissions = event['event']['submission']
if len(event_submissions) > 1:
return None
submission_key, submission = event_submissions.items()[0]
submission_key, submission = list(event_submissions.items())[0]
# Ignore if the problem being answered has a blank submission or is not multiple choice
if not submission or submission.get('response_type') != MULTIPLE_CHOICE_TYPE:
return None
Expand Down
2 changes: 0 additions & 2 deletions rapid_response_xblock/migrations/0001_initial.py
@@ -1,6 +1,4 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals

from django.db import migrations, models
import jsonfield.fields
from django.conf import settings
Expand Down
2 changes: 0 additions & 2 deletions rapid_response_xblock/migrations/0002_block_status.py
@@ -1,6 +1,4 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals

from django.db import migrations, models
import opaque_keys.edx.django.models

Expand Down
4 changes: 1 addition & 3 deletions rapid_response_xblock/migrations/0003_rename_fields.py
@@ -1,7 +1,5 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals

from django.db import migrations, models
from django.db import migrations


class Migration(migrations.Migration):
Expand Down
2 changes: 0 additions & 2 deletions rapid_response_xblock/migrations/0004_run.py
@@ -1,6 +1,4 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals

from django.db import migrations, models
import django.db.models.deletion
import django.utils.timezone
Expand Down
2 changes: 1 addition & 1 deletion rapid_response_xblock/models.py
@@ -1,7 +1,7 @@
"""
Rapid Response block models
"""
from __future__ import unicode_literals


from django.conf import settings
from django.db import models
Expand Down
2 changes: 1 addition & 1 deletion rapid_response_xblock/utils.py
Expand Up @@ -21,4 +21,4 @@ def get_run_submission_data(run_id):

def get_answer_result(event):
# TODO find better way if we can
return event['event']['submission'].values()[0]['correct']
return list(event['event']['submission'].values())[0]['correct']
12 changes: 6 additions & 6 deletions tests/test_aside.py
Expand Up @@ -271,8 +271,8 @@ def test_responses(self, has_runs):
assert resp.json['choices'] == choices
assert resp.json['runs'] == RapidResponseAside.serialize_runs(run_queryset)
counts_with_str_keys = {
answer_id: {str(run_id): count for run_id, count in runs.items()}
for answer_id, runs in counts.items()
answer_id: {str(run_id): count for run_id, count in list(runs.items())}
for answer_id, runs in list(counts.items())
}
assert resp.json['counts'] == counts_with_str_keys
assert resp.json['total_counts'] == expected_total_counts
Expand Down Expand Up @@ -318,15 +318,15 @@ def test_get_counts_for_problem(self):
{'answer_id': 'choice_2', 'answer_text': 'a different incorrect answer'},
]
choices_lookup = {choice['answer_id']: choice['answer_text'] for choice in choices}
counts = zip(
counts = list(zip(
[choices[i]['answer_id'] for i in range(3)],
range(2, 5),
list(range(2, 5)),
[run1.id for _ in range(3)],
) + zip(
)) + list(zip(
[choices[i]['answer_id'] for i in range(3)],
[3, 0, 7],
[run2.id for _ in range(3)],
)
))

counts_dict = defaultdict(dict)
for answer_id, num_submissions, run_id in counts:
Expand Down
8 changes: 4 additions & 4 deletions tests/test_events.py
Expand Up @@ -72,9 +72,9 @@ def get_problem(self):
request.META['SERVER_PORT'] = 1234
return load_single_xblock(
request=request,
course_id=unicode(self.course_id),
course_id=str(self.course_id),
user_id=self.instructor.id,
usage_key_string=unicode(problem.location)
usage_key_string=str(problem.location)
)

def test_publish(self):
Expand Down Expand Up @@ -209,7 +209,7 @@ def test_extra_submission(self):
If there is more than one submission in the event,
no event should be recorded
"""
submission = self.example_event['event']['submission'].values()[0]
submission = list(self.example_event['event']['submission'].values())[0]
self.example_event['event']['submission']['new_key'] = submission
SubmissionRecorder().send(self.example_event)
self.assert_unsuccessful_event_parsing()
Expand All @@ -220,7 +220,7 @@ def test_no_submission(self, submission_value):
If there is no submission or an empty submission in the event,
no event should be recorded
"""
key = self.example_event['event']['submission'].keys()[0]
key = list(self.example_event['event']['submission'].keys())[0]
self.example_event['event']['submission'][key] = submission_value
SubmissionRecorder().send(self.example_event)
self.assert_unsuccessful_event_parsing()
Expand Down

0 comments on commit dbc6bfb

Please sign in to comment.