Skip to content

Commit

Permalink
Fix pep8 and pylint errors in modified files
Browse files Browse the repository at this point in the history
- define new variables to shorten line lengths
- remove unused import
- indent arguments
- remove empty lines
- disable too-few-public-methods where pertinent
  • Loading branch information
Giulio Gratta committed Dec 4, 2018
1 parent 23914ae commit 66ecc58
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 10 deletions.
21 changes: 12 additions & 9 deletions freetextresponse/freetextresponse.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
This is the core logic for the Free-text Response XBlock
"""
from enum import Enum
import pkg_resources
from django.db import IntegrityError
from django.template.context import Context
from django.template.loader import get_template
Expand All @@ -27,10 +26,10 @@

@XBlock.needs("i18n")
class FreeTextResponse(
EnforceDueDates,
MissingDataFetcherMixin,
StudioEditableXBlockMixin,
XBlock,
EnforceDueDates,
MissingDataFetcherMixin,
StudioEditableXBlockMixin,
XBlock,
):
# pylint: disable=too-many-ancestors, too-many-instance-attributes
"""
Expand Down Expand Up @@ -279,6 +278,9 @@ def student_view(self, context={}):
(Fragment): The HTML Fragment for this XBlock, which determines the
general frame of the FreeTextResponse Question.
"""

display_other_responses = self.display_other_student_responses

self.runtime.service(self, 'i18n')
context.update(
{
Expand All @@ -292,7 +294,7 @@ def student_view(self, context={}):
'used_attempts_feedback': self._get_used_attempts_feedback(),
'visibility_class': self._get_indicator_visibility_class(),
'word_count_message': self._get_word_count_message(),
'display_other_responses': self.display_other_student_responses,
'display_other_responses': display_other_responses,
'other_responses': self.get_other_answers(),
}
)
Expand Down Expand Up @@ -589,7 +591,8 @@ def submit(self, data, suffix=''):
# even if word count is invalid.
self.count_attempts += 1
self._compute_score()
if self.display_other_student_responses and data.get('can_record_response'):
display_other_responses = self.display_other_student_responses
if display_other_responses and data.get('can_record_response'):
self.store_student_response()
result = {
'status': 'success',
Expand Down Expand Up @@ -651,7 +654,8 @@ def store_student_response(self):

# Want to store extra response so student can still see
# MAX_RESPONSES answers if their answer is in the pool.
self.displayable_answers = self.displayable_answers[-(MAX_RESPONSES+1):]
response_index = -(MAX_RESPONSES+1)
self.displayable_answers = self.displayable_answers[response_index:]

def get_other_answers(self):
"""
Expand All @@ -665,7 +669,6 @@ def get_other_answers(self):
student_answer_incorrect = self._determine_credit() == Credit.zero
if student_answer_incorrect or shouldnt_show_other_responses:
return []

return_list = [
response
for response in self.displayable_answers
Expand Down
3 changes: 2 additions & 1 deletion freetextresponse/mixins.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
"""
Mixins for the Free Text Response XBlock
"""
# pylint: disable=too-few-public-methods
import datetime


class EnforceDueDates(object): # pylint: disable=too-few-public-methods
class EnforceDueDates(object):
"""
xBlock Mixin to allow xblocks to check the due date
(taking the graceperiod into account) of the
Expand Down

0 comments on commit 66ecc58

Please sign in to comment.