From 1cba122dc0d437ab39f048b0781f45ca7bfbb6cf Mon Sep 17 00:00:00 2001 From: Will Daly Date: Mon, 1 Apr 2013 13:47:59 -0400 Subject: [PATCH] Undid accidental commit of pylint fixes to responsetypes --- common/lib/capa/capa/responsetypes.py | 70 +++++++++------------------ 1 file changed, 24 insertions(+), 46 deletions(-) diff --git a/common/lib/capa/capa/responsetypes.py b/common/lib/capa/capa/responsetypes.py index ec1d5ffe1b..5b1b46d858 100644 --- a/common/lib/capa/capa/responsetypes.py +++ b/common/lib/capa/capa/responsetypes.py @@ -2,8 +2,7 @@ # File: courseware/capa/responsetypes.py # ''' -Problem response evaluation. Handles checking of -student responses, of a variety of types. +Problem response evaluation. Handles checking of student responses, of a variety of types. Used by capa_problem.py ''' @@ -11,6 +10,7 @@ Used by capa_problem.py # standard library imports import abc import cgi +import hashlib import inspect import json import logging @@ -34,10 +34,7 @@ from .correctmap import CorrectMap from datetime import datetime from .util import * from lxml import etree - -# uses Beautiful Soup!!! FIXME? -from lxml.html.soupparser import fromstring as fromstring_bs - +from lxml.html.soupparser import fromstring as fromstring_bs # uses Beautiful Soup!!! FIXME? import xqueue_interface log = logging.getLogger(__name__) @@ -246,17 +243,13 @@ class LoncapaResponse(object): # hint specified by function? hintfn = hintgroup.get('hintfn') if hintfn: - # Hint is determined by a function defined - # in the stanza instead cfn = xml.get('cfn') @@ -986,8 +973,8 @@ def sympy_check2(): else: msg = "%s: can't find cfn %s in context" % ( unicode(self), cfn) - msg += ("\nSee XML source line %s" % - getattr(self.xml, 'sourceline', '')) + msg += "\nSee XML source line %s" % getattr(self.xml, 'sourceline', + '') raise LoncapaProblemError(msg) if not self.code: @@ -1023,17 +1010,14 @@ def sympy_check2(): log.error(msg) raise Exception(msg) - # global variable in context which holds the - # Presentation MathML from dynamic math input + # global variable in context which holds the Presentation MathML from dynamic math input # ordered list of dynamath responses dynamath = [student_answers.get(k + '_dynamath', None) for k in idset] # if there is only one box, and it's empty, then don't evaluate if len(idset) == 1 and not submission[0]: - # default to no error message on empty answer - # (to be consistent with other - # responsetypes) but allow author to still - # have the old behavior by setting + # default to no error message on empty answer (to be consistent with other + # responsetypes) but allow author to still have the old behavior by setting # empty_answer_err attribute msg = ('No answer entered!' if self.xml.get('empty_answer_err') else '') @@ -1108,8 +1092,7 @@ def sympy_check2(): try: answer_given = submission[0] if ( len(idset) == 1) else submission - # handle variable number of arguments in check function, - # for backwards compatibility + # handle variable number of arguments in check function, for backwards compatibility # with various Tutor2 check functions args = [self.expect, answer_given, student_answers, self.answer_ids[0]] @@ -1141,8 +1124,7 @@ def sympy_check2(): msg = ret.get('msg', None) msg = self.clean_message_html(msg) - # If there is only one input, apply the message to - # that input + # If there is only one input, apply the message to that input # Otherwise, apply the message to the whole problem if len(idset) > 1: overall_message = msg @@ -1155,8 +1137,7 @@ def sympy_check2(): # 'input_list': [{ 'ok': BOOLEAN, 'msg': STRING }, ...] } # # This allows the function to return an 'overall message' - # that applies to the entire problem, as well as - # correct/incorrect + # that applies to the entire problem, as well as correct/incorrect # status and messages for individual inputs elif 'input_list' in ret: overall_message = ret.get('overall_message', '') @@ -1389,8 +1370,7 @@ class CodeResponse(LoncapaResponse): tests = self.xml.get('tests') - # Extract 'answer' and 'initial_display' from XML. - # Note that the code to be exec'ed here is: + # Extract 'answer' and 'initial_display' from XML. Note that the code to be exec'ed here is: # (1) Internal edX code, i.e. NOT student submissions, and # (2) The code should only define the strings 'initial_display', 'answer', # 'preamble', 'test_program' @@ -1411,8 +1391,7 @@ class CodeResponse(LoncapaResponse): " 'answer' and/or 'initial_display' in ..." % err) raise Exception(err) - # Finally, make the ExternalResponse input XML format - # conform to the generic + # Finally, make the ExternalResponse input XML format conform to the generic # exteral grader interface # The XML tagging of grader_payload is pyxserver-specific grader_payload = '' @@ -1521,8 +1500,7 @@ class CodeResponse(LoncapaResponse): # TODO: Find out how this is used elsewhere, if any self.context['correct'] = correctness - # Replace 'oldcmap' with new grading results if queuekey matches. - # If queuekey + # Replace 'oldcmap' with new grading results if queuekey matches. If queuekey # does not match, we keep waiting for the score_msg whose key actually # matches if oldcmap.is_right_queuekey(self.answer_id, queuekey):