From 66ecc582d392bd95f4090f40730a7688b314df22 Mon Sep 17 00:00:00 2001 From: Giulio Gratta Date: Tue, 4 Dec 2018 10:19:44 -0800 Subject: [PATCH] Fix pep8 and pylint errors in modified files - define new variables to shorten line lengths - remove unused import - indent arguments - remove empty lines - disable too-few-public-methods where pertinent --- freetextresponse/freetextresponse.py | 21 ++++++++++++--------- freetextresponse/mixins.py | 3 ++- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/freetextresponse/freetextresponse.py b/freetextresponse/freetextresponse.py index 82baf92a..c1f60fa1 100644 --- a/freetextresponse/freetextresponse.py +++ b/freetextresponse/freetextresponse.py @@ -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 @@ -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 """ @@ -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( { @@ -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(), } ) @@ -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', @@ -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): """ @@ -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 diff --git a/freetextresponse/mixins.py b/freetextresponse/mixins.py index 6517bab9..73c1a3dc 100644 --- a/freetextresponse/mixins.py +++ b/freetextresponse/mixins.py @@ -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