allow capa poroblems access to anonymous_student_id
fix system->capa_system in capa_problem change for anonid
This commit is contained in:
@@ -620,6 +620,7 @@ class LoncapaProblem(object):
|
||||
"""
|
||||
context = {}
|
||||
context['seed'] = self.seed
|
||||
context['anonymous_student_id'] = self.capa_system.anonymous_student_id
|
||||
all_code = ''
|
||||
|
||||
python_path = []
|
||||
|
||||
@@ -73,6 +73,24 @@ class CapaHtmlRenderTest(unittest.TestCase):
|
||||
span_element = rendered_html.find('span')
|
||||
self.assertEqual(span_element.text, 'Test text')
|
||||
|
||||
def test_anonymous_student_id(self):
|
||||
# make sure anonymous_student_id is rendered properly as a context variable
|
||||
xml_str = textwrap.dedent("""
|
||||
<problem>
|
||||
<span>Welcome $anonymous_student_id</span>
|
||||
</problem>
|
||||
""")
|
||||
|
||||
# Create the problem
|
||||
problem = new_loncapa_problem(xml_str)
|
||||
|
||||
# Render the HTML
|
||||
rendered_html = etree.XML(problem.get_html())
|
||||
|
||||
# Expect that the anonymous_student_id was converted to "student"
|
||||
span_element = rendered_html.find('span')
|
||||
self.assertEqual(span_element.text, 'Welcome student')
|
||||
|
||||
def test_render_script(self):
|
||||
# Generate some XML with a <script> tag
|
||||
xml_str = textwrap.dedent("""
|
||||
|
||||
Reference in New Issue
Block a user