Commit 0aba4f7e by stv

Wrap JSInput Python code in CDATA section

Python code can commonly contain characters that are invalid XML, such
as '<' and '>'. This has proven to be a pain point for instructors
implementing custom Python grading functions for their JSInput problems
(see sample code below).

This change creates a more robust template from which to make
modifications.

```python
    # This is an XML syntax error, when not inside a CDATA section.
    if i < 0:
        print('negative')
```
parent fced72e4
...@@ -5,6 +5,7 @@ metadata: ...@@ -5,6 +5,7 @@ metadata:
data: | data: |
<problem display_name="webGLDemo"> <problem display_name="webGLDemo">
<script type="loncapa/python"> <script type="loncapa/python">
<![CDATA[
import json import json
def vglcfn(e, ans): def vglcfn(e, ans):
''' '''
...@@ -22,6 +23,7 @@ data: | ...@@ -22,6 +23,7 @@ data: |
selectedObjects = state["selectedObjects"] selectedObjects = state["selectedObjects"]
return selectedObjects["cylinder"] and not selectedObjects["cube"] return selectedObjects["cylinder"] and not selectedObjects["cube"]
''' '''
]]>
</script> </script>
<p> <p>
The shapes below can be selected (yellow) or unselected (cyan). The shapes below can be selected (yellow) or unselected (cyan).
......
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