Commit 8d9b242e by Calen Pennington

Get rid of unused code

parent eec80426
...@@ -11,15 +11,12 @@ Used by capa_problem.py ...@@ -11,15 +11,12 @@ Used by capa_problem.py
import inspect import inspect
import json import json
import logging import logging
import math
import numbers import numbers
import numpy import numpy
import random import random
import re import re
import requests import requests
import scipy
import traceback import traceback
import copy
import abc import abc
# specific library imports # specific library imports
...@@ -27,15 +24,8 @@ from calc import evaluator, UndefinedVariable ...@@ -27,15 +24,8 @@ from calc import evaluator, UndefinedVariable
from django.conf import settings from django.conf import settings
from util import contextualize_text from util import contextualize_text
from lxml import etree from lxml import etree
from lxml.etree import Element
from lxml.html.soupparser import fromstring as fromstring_bs # uses Beautiful Soup!!! FIXME? from lxml.html.soupparser import fromstring as fromstring_bs # uses Beautiful Soup!!! FIXME?
# local imports
import calc
import eia
from util import contextualize_text
log = logging.getLogger("mitx.courseware") log = logging.getLogger("mitx.courseware")
def compare_with_tolerance(v1, v2, tol): def compare_with_tolerance(v1, v2, tol):
...@@ -186,12 +176,12 @@ class NumericalResponse(GenericResponse): ...@@ -186,12 +176,12 @@ class NumericalResponse(GenericResponse):
self.tolerance_xml = xml.xpath('//*[@id=$id]//responseparam[@type="tolerance"]/@default', self.tolerance_xml = xml.xpath('//*[@id=$id]//responseparam[@type="tolerance"]/@default',
id=xml.get('id'))[0] id=xml.get('id'))[0]
self.tolerance = contextualize_text(self.tolerance_xml, context) self.tolerance = contextualize_text(self.tolerance_xml, context)
except Exception,err: except Exception:
self.tolerance = 0 self.tolerance = 0
try: try:
self.answer_id = xml.xpath('//*[@id=$id]//textline/@id', self.answer_id = xml.xpath('//*[@id=$id]//textline/@id',
id=xml.get('id'))[0] id=xml.get('id'))[0]
except Exception, err: except Exception:
self.answer_id = None self.answer_id = None
def get_score(self, student_answers): def get_score(self, student_answers):
...@@ -277,7 +267,7 @@ def sympy_check2(): ...@@ -277,7 +267,7 @@ def sympy_check2():
answer = None answer = None
try: try:
answer = xml.xpath('//*[@id=$id]//answer',id=xml.get('id'))[0] answer = xml.xpath('//*[@id=$id]//answer',id=xml.get('id'))[0]
except IndexError,err: except IndexError:
# print "xml = ",etree.tostring(xml,pretty_print=True) # print "xml = ",etree.tostring(xml,pretty_print=True)
# if we have a "cfn" attribute then look for the function specified by cfn, in the problem context # if we have a "cfn" attribute then look for the function specified by cfn, in the problem context
...@@ -308,12 +298,6 @@ def sympy_check2(): ...@@ -308,12 +298,6 @@ def sympy_check2():
of each key removed (the string before the first "_"). of each key removed (the string before the first "_").
''' '''
def getkey2(dict,key,default):
"""utilify function: get dict[key] if key exists, or return default"""
if dict.has_key(key):
return dict[key]
return default
idset = sorted(self.answer_ids) # ordered list of answer id's idset = sorted(self.answer_ids) # ordered list of answer id's
try: try:
submission = [student_answers[k] for k in idset] # ordered list of answers submission = [student_answers[k] for k in idset] # ordered list of answers
...@@ -330,8 +314,6 @@ def sympy_check2(): ...@@ -330,8 +314,6 @@ def sympy_check2():
if len(idset)==1 and not submission[0]: if len(idset)==1 and not submission[0]:
return {idset[0]:'no_answer_entered'} return {idset[0]:'no_answer_entered'}
gctxt = self.context['global_context']
correct = ['unknown'] * len(idset) correct = ['unknown'] * len(idset)
messages = [''] * len(idset) messages = [''] * len(idset)
...@@ -649,13 +631,13 @@ class FormulaResponse(GenericResponse): ...@@ -649,13 +631,13 @@ class FormulaResponse(GenericResponse):
self.tolerance_xml = xml.xpath('//*[@id=$id]//responseparam[@type="tolerance"]/@default', self.tolerance_xml = xml.xpath('//*[@id=$id]//responseparam[@type="tolerance"]/@default',
id=xml.get('id'))[0] id=xml.get('id'))[0]
self.tolerance = contextualize_text(self.tolerance_xml, context) self.tolerance = contextualize_text(self.tolerance_xml, context)
except Exception,err: except Exception:
self.tolerance = 0 self.tolerance = 0
try: try:
self.answer_id = xml.xpath('//*[@id=$id]//textline/@id', self.answer_id = xml.xpath('//*[@id=$id]//textline/@id',
id=xml.get('id'))[0] id=xml.get('id'))[0]
except Exception, err: except Exception:
self.answer_id = None self.answer_id = None
raise Exception, "[courseware.capa.responsetypes.FormulaResponse] Error: missing answer_id!!" raise Exception, "[courseware.capa.responsetypes.FormulaResponse] Error: missing answer_id!!"
...@@ -680,7 +662,6 @@ class FormulaResponse(GenericResponse): ...@@ -680,7 +662,6 @@ class FormulaResponse(GenericResponse):
self.samples.split('@')[1].split('#')[0].split(':'))) self.samples.split('@')[1].split('#')[0].split(':')))
ranges=dict(zip(variables, sranges)) ranges=dict(zip(variables, sranges))
correct = True
for i in range(numsamples): for i in range(numsamples):
instructor_variables = self.strip_dict(dict(self.context)) instructor_variables = self.strip_dict(dict(self.context))
student_variables = dict() student_variables = dict()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment