27 lines
761 B
XML
27 lines
761 B
XML
<problem display_name="String response" markdown="null" showanswer="attempted">
|
|
<p>
|
|
A custom python-evaluated input problem accepts one or more lines of text input from the
|
|
student, and evaluates the inputs for correctness based on evaluation using a
|
|
python script embedded within the problem.
|
|
</p>
|
|
<script type="loncapa/python">
|
|
import re
|
|
def test_contains_stan(expect, ans):
|
|
response = re.search('^[sS]tan', ans)
|
|
if response:
|
|
return 1
|
|
else:
|
|
return 0
|
|
</script>
|
|
<p>Nice university, whose name begins with "s"...</p>
|
|
<customresponse cfn="test_contains_stan">
|
|
<textline size="40"/>
|
|
</customresponse>
|
|
<solution>
|
|
<div class="detailed-solution">
|
|
<p>Explanation</p>
|
|
<p>Stanford</p>
|
|
</div>
|
|
</solution>
|
|
</problem>
|