fix: Restructuring to send course_id and score to edx submission fix: Refactoring of sending information to sent_to_submission fix: Elimination of unnecessary functions fix: Added usage comment to ProblemBlock in XqueueInterface constructor fix: update doc ADR fix: setting for Quality Others test (ubuntu-24.04, 3.11, 20) fix: Deprecation for django-trans-escape-filter-parse-error test: Add @pytest.mark.django_db decorator to test functions test: Fix for pylint being disabled fix: updated changes for pylint disable fix: update error from docs ADR-0005 update: xmodule/docs/decisions/0005-send-data-to-edx-submission.rst Co-authored-by: Sarina Canelake <sarina@axim.org> update: xmodule/docs/decisions/0005-send-data-to-edx-submission.rst Co-authored-by: Sarina Canelake <sarina@axim.org> fix: Adjusted correction fix: update date for docs ADR Revert "fix: update date for docs ADR" This reverts commit 0b4229c51c4937f95cb407872645dd448df45418. fix: replace call created_submission to create_external_grader_detail fix: update test xqueue_submission fix: add docstring in test_xqueue_submission fix: update date doc ADR fix: update version edx-submission 3.8.6 fix: add @pytest.mark.xfail fix: add 20 chances in test_capa_block: fix: increase retry attempts for seed generation in ProblemBlockTest fix: change version to edx-submission lib fix: new version edx-submission in testings fix: replace parameter file to files fix: update variable grader_file_name and points_possible fix: Adjustment in the is_flag_active function to always take the last record edited in the waffle fix: wrap large line of code fix: update function is_flag_active fix: code style adjustment fix: changes for 60 retry feat: use CourseWaffleFlag to determine xqueue callback path fix: Code style adjustment fix: remove deprecated xqueue callback route and simplify callback type logic fix: Deleting a comment in the ADR document fix: add log in self.block is None fix: Code style adjustment in log
82 lines
2.4 KiB
Python
82 lines
2.4 KiB
Python
# lint-amnesty, pylint: disable=missing-module-docstring
|
|
|
|
import unittest
|
|
import xml.sax.saxutils as saxutils
|
|
|
|
from lxml import etree
|
|
|
|
from xmodule.capa import customrender
|
|
from xmodule.capa.tests.helpers import test_capa_system
|
|
|
|
# just a handy shortcut
|
|
lookup_tag = customrender.registry.get_class_for_tag
|
|
|
|
|
|
def extract_context(xml):
|
|
"""
|
|
Given an xml element corresponding to the output of test_capa_system.render_template, get back the
|
|
original context
|
|
"""
|
|
return eval(xml.text) # lint-amnesty, pylint: disable=eval-used
|
|
|
|
|
|
def quote_attr(s):
|
|
return saxutils.quoteattr(s)[1:-1] # don't want the outer quotes
|
|
|
|
|
|
class HelperTest(unittest.TestCase):
|
|
'''
|
|
Make sure that our helper function works!
|
|
'''
|
|
|
|
def check(self, d):
|
|
xml = etree.XML(test_capa_system().render_template('blah', d))
|
|
assert d == extract_context(xml)
|
|
|
|
def test_extract_context(self):
|
|
self.check({})
|
|
self.check({1, 2})
|
|
self.check({'id', 'an id'})
|
|
self.check({'with"quote', 'also"quote'})
|
|
|
|
|
|
class SolutionRenderTest(unittest.TestCase):
|
|
'''
|
|
Make sure solutions render properly.
|
|
'''
|
|
|
|
def test_rendering(self):
|
|
solution = 'To compute unicorns, count them.'
|
|
xml_str = """<solution id="solution_12">{s}</solution>""".format(s=solution)
|
|
element = etree.fromstring(xml_str)
|
|
|
|
renderer = lookup_tag('solution')(test_capa_system(), element)
|
|
|
|
assert renderer.id == 'solution_12'
|
|
|
|
# Our test_capa_system "renders" templates to a div with the repr of the context.
|
|
xml = renderer.get_html()
|
|
context = extract_context(xml)
|
|
assert context == {'id': 'solution_12'}
|
|
|
|
|
|
class MathRenderTest(unittest.TestCase):
|
|
'''
|
|
Make sure math renders properly.
|
|
'''
|
|
|
|
def check_parse(self, latex_in, mathjax_out): # lint-amnesty, pylint: disable=missing-function-docstring
|
|
xml_str = """<math>{tex}</math>""".format(tex=latex_in)
|
|
element = etree.fromstring(xml_str)
|
|
|
|
renderer = lookup_tag('math')(test_capa_system(), element)
|
|
|
|
assert renderer.mathstr == mathjax_out
|
|
|
|
def test_parsing(self):
|
|
self.check_parse('$abc$', '[mathjaxinline]abc[/mathjaxinline]')
|
|
self.check_parse('$abc', '$abc')
|
|
self.check_parse(r'$\displaystyle 2+2$', '[mathjax] 2+2[/mathjax]')
|
|
|
|
# NOTE: not testing get_html yet because I don't understand why it's doing what it's doing.
|