Commit 57f7acf8 by Diana Huang

Unbreak grading for capa problems

Clean up some pylint errors
parent a2957cb3
...@@ -16,7 +16,6 @@ This is used by capa_module. ...@@ -16,7 +16,6 @@ This is used by capa_module.
from __future__ import division from __future__ import division
from datetime import datetime from datetime import datetime
import json
import logging import logging
import math import math
import numpy import numpy
...@@ -32,8 +31,6 @@ from xml.sax.saxutils import unescape ...@@ -32,8 +31,6 @@ from xml.sax.saxutils import unescape
from copy import deepcopy from copy import deepcopy
import chem import chem
import chem.chemcalc
import chem.chemtools
import chem.miller import chem.miller
import verifiers import verifiers
import verifiers.draganddrop import verifiers.draganddrop
...@@ -70,9 +67,6 @@ global_context = {'random': random, ...@@ -70,9 +67,6 @@ global_context = {'random': random,
'scipy': scipy, 'scipy': scipy,
'calc': calc, 'calc': calc,
'eia': eia, 'eia': eia,
'chemcalc': chem.chemcalc,
'chemtools': chem.chemtools,
'miller': chem.miller,
'draganddrop': verifiers.draganddrop} 'draganddrop': verifiers.draganddrop}
# These should be removed from HTML output, including all subelements # These should be removed from HTML output, including all subelements
...@@ -371,7 +365,7 @@ class LoncapaProblem(object): ...@@ -371,7 +365,7 @@ class LoncapaProblem(object):
dispatch = get['dispatch'] dispatch = get['dispatch']
return self.inputs[input_id].handle_ajax(dispatch, get) return self.inputs[input_id].handle_ajax(dispatch, get)
else: else:
log.warning("Could not find matching input for id: %s" % problem_id) log.warning("Could not find matching input for id: %s" % input_id)
return {} return {}
......
...@@ -37,7 +37,6 @@ graded status as'status' ...@@ -37,7 +37,6 @@ graded status as'status'
# makes sense, but a bunch of problems have markup that assumes block. Bigger TODO: figure out a # makes sense, but a bunch of problems have markup that assumes block. Bigger TODO: figure out a
# general css and layout strategy for capa, document it, then implement it. # general css and layout strategy for capa, document it, then implement it.
from collections import namedtuple
import json import json
import logging import logging
from lxml import etree from lxml import etree
...@@ -623,6 +622,13 @@ registry.register(CodeInput) ...@@ -623,6 +622,13 @@ registry.register(CodeInput)
class MatlabInput(CodeInput): class MatlabInput(CodeInput):
''' '''
InputType for handling Matlab code input InputType for handling Matlab code input
Example:
<matlabinput rows="10" cols="80" tabsize="4">
<plot_payload>
%api_key=API_KEY
</plot_payload>
</matlabinput>
''' '''
template = "matlabinput.html" template = "matlabinput.html"
tags = ['matlabinput'] tags = ['matlabinput']
......
...@@ -44,7 +44,7 @@ ...@@ -44,7 +44,7 @@
% if linenumbers == 'true': % if linenumbers == 'true':
lineNumbers: true, lineNumbers: true,
% endif % endif
mode: "${mode}", mode: "matlab",
matchBrackets: true, matchBrackets: true,
lineWrapping: true, lineWrapping: true,
indentUnit: "${tabsize}", indentUnit: "${tabsize}",
......
...@@ -446,7 +446,7 @@ class CapaModule(CapaFields, XModule): ...@@ -446,7 +446,7 @@ class CapaModule(CapaFields, XModule):
'problem_save': self.save_problem, 'problem_save': self.save_problem,
'problem_show': self.get_answer, 'problem_show': self.get_answer,
'score_update': self.update_score, 'score_update': self.update_score,
'input_ajax': self.lcp.handle_input_ajax, 'input_ajax': self.handle_input_ajax,
'ungraded_response': self.handle_ungraded_response 'ungraded_response': self.handle_ungraded_response
} }
...@@ -460,7 +460,6 @@ class CapaModule(CapaFields, XModule): ...@@ -460,7 +460,6 @@ class CapaModule(CapaFields, XModule):
'progress_changed': after != before, 'progress_changed': after != before,
'progress_status': Progress.to_js_status_str(after), 'progress_status': Progress.to_js_status_str(after),
}) })
self.set_state_from_lcp()
return json.dumps(d, cls=ComplexEncoder) return json.dumps(d, cls=ComplexEncoder)
def is_past_due(self): def is_past_due(self):
...@@ -544,7 +543,10 @@ class CapaModule(CapaFields, XModule): ...@@ -544,7 +543,10 @@ class CapaModule(CapaFields, XModule):
def handle_ungraded_response(self, get): def handle_ungraded_response(self, get):
''' '''
Get the XQueue response Delivers a response to the capa problem where the expectation where this response does
not have relevant grading information
No ajax return is needed, so an empty dict is returned
''' '''
queuekey = get['queuekey'] queuekey = get['queuekey']
score_msg = get['xqueue_body'] score_msg = get['xqueue_body']
...@@ -553,6 +555,17 @@ class CapaModule(CapaFields, XModule): ...@@ -553,6 +555,17 @@ class CapaModule(CapaFields, XModule):
self.set_state_from_lcp() self.set_state_from_lcp()
return dict() return dict()
def handle_input_ajax(self, get):
'''
Passes information down to the capa problem so that it can handle its own ajax calls
Returns the response from the capa problem
'''
response = self.lcp.handle_input_ajax(get)
# save any state changes that may occur
self.set_state_from_lcp()
return response
def get_answer(self, get): def get_answer(self, get):
''' '''
For the "show answer" button. For the "show answer" button.
......
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