Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,35 +1,27 @@
<div class="problem">
<div>
<span>
<section id="textbox_test_matlab_plot1_2_1" class="capa_inputtype cminput">
<textarea rows="10" cols="80" name="input_i4x-MITx-2_01x-problem-test_matlab_plot1_2_1" aria-describedby="answer_i4x-MITx-2_01x-problem-test_matlab_plot1_2_1" id="input_i4x-MITx-2_01x-problem-test_matlab_plot1_2_1" data-tabsize="4" data-mode="octave" data-linenums="true" style="display: none;">This is the MATLAB input, whatever that may be.
<section id="textbox_test_code1_2_1" class="capa_inputtype cminput">
<textarea rows="10" cols="80" name="input_i4x-MITx-2_01x-problem-test_code1_2_1" aria-describedby="answer_i4x-MITx-2_01x-problem-test_code1_2_1" id="input_i4x-MITx-2_01x-problem-test_code1_2_1" data-tabsize="4" data-mode="python" data-linenums="true" style="display: none;">print('hello world')
</textarea>
<div class="grader-status" tabindex="-1">
<span id="status_test_matlab_plot1_2_1"
<span id="status_test_code1_2_1"
class="processing"
aria-describedby="input_test_matlab_plot1_2_1">
aria-describedby="input_test_code1_2_1">
<span class="status sr">processing</span>
</span>
<span style="display:none;" class="xqueue" id="test_matlab_plot1_2_1">1</span>
<span style="display:none;" class="xqueue" id="test_code1_2_1">1</span>
<p class="debug">processing</p>
</div>
<span id="answer_test_matlab_plot1_2_1"></span>
<span id="answer_test_code1_2_1"></span>
<div class="external-grader-message" aria-live="polite">
Submitted. As soon as a response is returned, this message will be replaced by that feedback.
</div>
<div class="ungraded-matlab-result" aria-live="polite"></div>
<div class="plot-button">
<input type="button"
class="save"
name="plot-button"
id="plot_test_matlab_plot1_2_1"
value="Run Code">
</div>
</section>
</span>
</div>
<div class="action">
<input type="hidden" name="problem_id" value="Plot a straight line">
<input type="hidden" name="problem_id" value="Print hello world">
<button class="reset" data-value="Reset">
Reset<span class="sr">your answer</span>
</button>
Expand Down
8 changes: 4 additions & 4 deletions src/xblock_problem/assets/spec/display_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -1141,15 +1141,15 @@ data-url='/problem/quiz/'> \
});
});

describe("Submitting an xqueue-graded problem", function () {
const matlabinput_html = readFixtures("matlabinput_problem.html");
describe("Submitting an externally graded problem", function () {
const queued_problem_html = readFixtures("queued_codeinput_problem.html");

beforeEach(function () {
spyOn($, "postWithPrefix").and.callFake((url, callback) => callback({ html: matlabinput_html }));
spyOn($, "postWithPrefix").and.callFake((url, callback) => callback({ html: queued_problem_html }));
jasmine.clock().install();
this.problem = new Problem(mockRuntime, $(".xblock-student_view"));
spyOn(this.problem, "poll").and.callThrough();
this.problem.render(matlabinput_html);
this.problem.render(queued_problem_html);
});

afterEach(() => jasmine.clock().uninstall());
Expand Down
44 changes: 1 addition & 43 deletions src/xblock_problem/block.py
Original file line number Diff line number Diff line change
Expand Up @@ -387,17 +387,6 @@ class ProblemBlock(ScorableXBlockMixin, LegacyXmlMixin, XBlock):
help=_("Source code for LaTeX and Word problems. This feature is not well-supported."), scope=Scope.settings
)
use_latex_compiler = Boolean(help=_("Enable LaTeX templates?"), default=False, scope=Scope.settings)
matlab_api_key = String(
display_name=_("Matlab API key"),
help=_(
"Enter the API key provided by MathWorks for accessing the MATLAB Hosted Service. "
"This key is granted for exclusive use by this course for the specified duration. "
"Please do not share the API key with other courses and notify MathWorks immediately "
"if you believe the key is exposed or compromised. To obtain a key for your course, "
"or to report an issue, please contact moocsupport@mathworks.com"
),
scope=Scope.settings,
)
markdown_edited = Boolean(
help=_("Indicates if the problem was edited using the Markdown editor in the Authoring MFE."),
scope=Scope.settings,
Expand Down Expand Up @@ -492,7 +481,6 @@ def handle_ajax(self, dispatch, data): # pylint: disable=too-many-locals
"problem_show": self.get_answer,
"score_update": self.update_score,
"input_ajax": self.handle_input_ajax,
"ungraded_response": self.handle_ungraded_response,
}

_ = self.runtime.service(self, "i18n").gettext
Expand Down Expand Up @@ -619,10 +607,6 @@ def non_editable_metadata_fields(self):
ProblemBlock.markdown,
ProblemBlock.use_latex_compiler,
ProblemBlock.show_correctness,
# Temporarily remove the ability to see MATLAB API key in Studio, as
# a pre-cursor to removing it altogether.
# https://github.com/openedx/public-engineering/issues/192
ProblemBlock.matlab_api_key,
]
)
return non_editable_fields
Expand Down Expand Up @@ -716,7 +700,6 @@ def max_score(self):
resources_fs=self.runtime.resources_fs,
seed=None,
xqueue=None,
matlab_api_key=None,
)
try:
lcp = LoncapaProblem(
Expand Down Expand Up @@ -764,7 +747,7 @@ def generate_report_data(self, user_state_iterator, limit_responses=None):
capa_system = LoncapaSystem(
ajax_url=None,
# TODO set anonymous_student_id to the anonymous ID of the user which answered each problem
# Anonymous ID is required for Matlab, CodeResponse, and some custom problems that include
# Anonymous ID is required for CodeResponse and some custom problems that include
# '$anonymous_student_id' in their XML.
# For the purposes of this report, we don't need to support those use cases.
anonymous_student_id=None,
Expand All @@ -777,7 +760,6 @@ def generate_report_data(self, user_state_iterator, limit_responses=None):
resources_fs=self.runtime.resources_fs,
seed=1,
xqueue=None,
matlab_api_key=None,
)
_ = capa_system.i18n.gettext

Expand Down Expand Up @@ -940,7 +922,6 @@ def new_lcp(self, state, text=None):
resources_fs=self.runtime.resources_fs,
seed=seed, # Why do we do this if we have self.seed?
xqueue=None if is_studio else xqueue_service,
matlab_api_key=self.matlab_api_key,
)

return LoncapaProblem(
Expand Down Expand Up @@ -1624,29 +1605,6 @@ def update_score(self, data):

return {} # No AJAX return is needed

def handle_ungraded_response(self, data):
"""
Delivers a response from the XQueue to the capa problem

The score of the problem will not be updated

Args:
- data (dict) must contain keys:
queuekey - a key specific to this response
xqueue_body - the body of the response
Returns:
empty dictionary

No ajax return is needed, so an empty dict is returned
"""
queuekey = data["queuekey"]
score_msg = data["xqueue_body"]

# pass along the xqueue message to the problem
self.lcp.ungraded_response(score_msg, queuekey)
self.set_state_from_lcp()
return {}

def handle_input_ajax(self, data):
"""
Handle ajax calls meant for a particular input in the problem
Expand Down
15 changes: 0 additions & 15 deletions src/xblock_problem/capa/capa_problem.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,6 @@ def __init__( # pylint: disable=too-many-positional-arguments,too-many-argument
resources_fs,
seed, # Why do we do this if we have self.seed?
xqueue,
matlab_api_key=None,
):
self.ajax_url = ajax_url
self.anonymous_student_id = anonymous_student_id
Expand All @@ -119,7 +118,6 @@ def __init__( # pylint: disable=too-many-positional-arguments,too-many-argument
self.seed = seed # Why do we do this if we have self.seed?
self.STATIC_URL = settings.STATIC_URL # pylint: disable=invalid-name
self.xqueue = xqueue
self.matlab_api_key = matlab_api_key


class LoncapaProblem:
Expand Down Expand Up @@ -409,19 +407,6 @@ def update_score(self, score_msg, queuekey):
self.correct_map.set_dict(cmap.get_dict())
return cmap

def ungraded_response(self, xqueue_msg, queuekey):
"""
Handle any responses from the xqueue that do not contain grades
Will try to pass the queue message to all inputtypes that can handle ungraded responses

Does not return any value
"""
# check against each inputtype
for the_input in self.inputs.values():
# if the input type has an ungraded function, pass in the values
if hasattr(the_input, "ungraded_response"):
the_input.ungraded_response(xqueue_msg, queuekey)

def is_queued(self):
"""
Returns True if any part of the problem has been submitted to an external queue
Expand Down
Loading