Commit ba7eaa1c by Usman Khalid

Fixed tests.

TNL-708.
parent 4cd55f53
<openassessment>
<title>Open Assessment Test</title>
<prompt>Example-based assessment</prompt>
<prompts>
<prompt>
<description>Given the state of the world today, what do you think should be done to combat poverty?</description>
</prompt>
<prompt>
<description>Given the state of the world today, what do you think should be done to combat pollution?</description>
</prompt>
</prompts>
<rubric>
<prompt>Read for conciseness, clarity of thought, and form.</prompt>
<criterion>
<name>Ideas</name>
<prompt>How good are the ideas?</prompt>
......
<openassessment>
<title>Open Assessment Test</title>
<prompt>Example-based assessment</prompt>
<prompts>
<prompt>
<description>Given the state of the world today, what do you think should be done to combat poverty?</description>
</prompt>
<prompt>
<description>Given the state of the world today, what do you think should be done to combat pollution?</description>
</prompt>
</prompts>
<rubric>
<prompt>Read for conciseness, clarity of thought, and form.</prompt>
<criterion>
<name>Ideas</name>
<prompt>How good are the ideas?</prompt>
......
<openassessment>
<title>Feedback only criterion</title>
<prompt>Test prompt</prompt>
<prompts>
<prompt>
<description>Given the state of the world today, what do you think should be done to combat poverty?</description>
</prompt>
<prompt>
<description>Given the state of the world today, what do you think should be done to combat pollution?</description>
</prompt>
</prompts>
<rubric>
<prompt>Test rubric prompt</prompt>
<criterion>
<name>vocabulary</name>
<prompt>How good is the vocabulary?</prompt>
......
<openassessment>
<title>Feedback only criterion</title>
<prompt>Test prompt</prompt>
<prompts>
<prompt>
<description>Given the state of the world today, what do you think should be done to combat poverty?</description>
</prompt>
<prompt>
<description>Given the state of the world today, what do you think should be done to combat pollution?</description>
</prompt>
</prompts>
<rubric>
<prompt>Test rubric prompt</prompt>
<criterion>
<name>𝓒𝓸𝓷𝓬𝓲𝓼𝓮</name>
<prompt>How concise is it?</prompt>
......
<openassessment>
<title>Feedback only criterion</title>
<prompt>Test prompt</prompt>
<prompts>
<prompt>
<description>Given the state of the world today, what do you think should be done to combat poverty?</description>
</prompt>
<prompt>
<description>Given the state of the world today, what do you think should be done to combat pollution?</description>
</prompt>
</prompts>
<rubric>
<prompt>Test rubric prompt</prompt>
<criterion>
<name>vocabulary</name>
<prompt>How good is the vocabulary?</prompt>
......
<openassessment>
<title>Feedback only criterion</title>
<prompt>Test prompt</prompt>
<prompts>
<prompt>
<description>Given the state of the world today, what do you think should be done to combat poverty?</description>
</prompt>
<prompt>
<description>Given the state of the world today, what do you think should be done to combat pollution?</description>
</prompt>
</prompts>
<rubric>
<prompt>Test rubric prompt</prompt>
<criterion>
<name>vocabulary</name>
<prompt>How good is the vocabulary?</prompt>
......
<openassessment>
<title>Feedback only criterion</title>
<prompt>Test prompt</prompt>
<prompts>
<prompt>
<description>Given the state of the world today, what do you think should be done to combat poverty?</description>
</prompt>
<prompt>
<description>Given the state of the world today, what do you think should be done to combat pollution?</description>
</prompt>
</prompts>
<rubric>
<prompt>Test rubric prompt</prompt>
<criterion>
<name>vocabulary</name>
<prompt>How good is the vocabulary?</prompt>
......
<openassessment>
<title>Open Assessment Test</title>
<prompt>
Given the state of the world today, what do you think should be done to
combat poverty? Please answer in a short essay of 200-300 words.
</prompt>
<prompts>
<prompt>
<description>Given the state of the world today, what do you think should be done to combat poverty?</description>
</prompt>
<prompt>
<description>Given the state of the world today, what do you think should be done to combat pollution?</description>
</prompt>
</prompts>
<rubric>
<prompt>Read for conciseness, clarity of thought, and form.</prompt>
<criterion feedback="optional">
<name>𝓒𝓸𝓷𝓬𝓲𝓼𝓮</name>
<prompt>How concise is it?</prompt>
......
<openassessment>
<title>Open Assessment Test</title>
<prompt>
Given the state of the world today, what do you think should be done to
combat poverty? Please answer in a short essay of 200-300 words.
</prompt>
<prompts>
<prompt>
<description>Given the state of the world today, what do you think should be done to combat poverty?</description>
</prompt>
<prompt>
<description>Given the state of the world today, what do you think should be done to combat pollution?</description>
</prompt>
</prompts>
<rubric>
<prompt>Read for conciseness, clarity of thought, and form.</prompt>
<criterion>
......
<openassessment>
<title>Open Assessment Test</title>
<prompt>
Given the state of the world today, what do you think should be done to
combat poverty? Please answer in a short essay of 200-300 words.
</prompt>
<prompts>
<prompt>
<description>Given the state of the world today, what do you think should be done to combat poverty?</description>
</prompt>
<prompt>
<description>Given the state of the world today, what do you think should be done to combat pollution?</description>
</prompt>
</prompts>
<rubric>
<prompt>Read for conciseness, clarity of thought, and form.</prompt>
<criterion>
<name>𝓒𝓸𝓷𝓬𝓲𝓼𝓮</name>
<prompt>How concise is it?</prompt>
......
<openassessment>
<title>Open Assessment Test</title>
<prompt>
Given the state of the world today, what do you think should be done to
combat poverty? Please answer in a short essay of 200-300 words.
</prompt>
<prompts>
<prompt>
<description>Given the state of the world today, what do you think should be done to combat poverty?</description>
</prompt>
<prompt>
<description>Given the state of the world today, what do you think should be done to combat pollution?</description>
</prompt>
</prompts>
<rubric>
<prompt>Read for conciseness, clarity of thought, and form.</prompt>
<criterion>
<name>𝓒𝓸𝓷𝓬𝓲𝓼𝓮</name>
<prompt>How concise is it?</prompt>
......
<openassessment>
<title>Open Assessment Test</title>
<prompt>
Given the state of the world today, what do you think should be done to
combat poverty? Please answer in a short essay of 200-300 words.
</prompt>
<prompts>
<prompt>
<description>Given the state of the world today, what do you think should be done to combat poverty?</description>
</prompt>
<prompt>
<description>Given the state of the world today, what do you think should be done to combat pollution?</description>
</prompt>
</prompts>
<rubric>
<prompt>Read for conciseness, clarity of thought, and form.</prompt>
<criterion>
<name>𝓒𝓸𝓷𝓬𝓲𝓼𝓮</name>
<prompt>How concise is it?</prompt>
......
<openassessment>
<title>Open Assessment Test</title>
<prompt>
Given the state of the world today, what do you think should be done to
combat poverty? Please answer in a short essay of 200-300 words.
</prompt>
<prompts>
<prompt>
<description>Given the state of the world today, what do you think should be done to combat poverty?</description>
</prompt>
<prompt>
<description>Given the state of the world today, what do you think should be done to combat pollution?</description>
</prompt>
</prompts>
<rubric>
<prompt>Read for conciseness, clarity of thought, and form.</prompt>
<criterion>
<name>𝓒𝓸𝓷𝓬𝓲𝓼𝓮</name>
<prompt>How concise is it?</prompt>
......
{
"empty": [""],
"unicode": ["Ѕраѓтаиѕ! ГоиіБЂт, Щэ ↁіиэ іи Нэll!"],
"empty": [[""], [""]],
"unicode": [["Ѕраѓтаиѕ! ГоиіБЂт, Щэ ↁіиэ іи Нэll!"], ["Ѕраѓтаиѕ! ГоиіБЂт, Щэ ↁіиэ іи Нэll!"]],
"long": [
"Lorem ipsum dolor sit amet,",
[ "Lorem ipsum dolor sit amet,"],
[
"consectetur adipiscing elit. Etiam luctus dapibus ante, vel luctus nibh bibendum et.",
"Praesent in commodo quam. Morbi lobortis at felis ac mollis.",
"Maecenas placerat nisl sed imperdiet posuere.",
......@@ -50,5 +51,6 @@
"nascetur ridiculus mus. Mauris at dapibus mauris, sed pharetra tortor.",
"Pellentesque purus sem, congue sed elementum non, pretium in mi. Cras cursus gravida commodo.",
"Aenean eu massa rhoncus, faucibus tortor id, sollicitudin tortor."
]
]
}
\ No newline at end of file
<openassessment>
<title>Open Assessment Test</title>
<prompt>
Given the state of the world today, what do you think should be done to
combat poverty? Please answer in a short essay of 200-300 words.
</prompt>
<prompts>
<prompt>
<description>Given the state of the world today, what do you think should be done to combat poverty?</description>
</prompt>
<prompt>
<description>Given the state of the world today, what do you think should be done to combat pollution?</description>
</prompt>
</prompts>
<rubric>
<prompt>Read for conciseness, clarity of thought, and form.</prompt>
<criterion>
......
......@@ -13,7 +13,7 @@ class AIAssessmentIntegrationTest(XBlockHandlerTestCase):
"""
Integration test for example-based assessment (AI).
"""
SUBMISSION = json.dumps({'submission': 'This is a submission!'})
SUBMISSION = json.dumps({'submission': ('This is submission part 1!', 'This is submission part 2!')})
AI_ALGORITHMS = {
'fake': 'openassessment.assessment.worker.algorithm.FakeAIAlgorithm'
}
......
......@@ -41,7 +41,7 @@ class TestGrade(XBlockHandlerTestCase):
},
]
SUBMISSION = u'ՇﻉรՇ รપ๒๓ٱรรٱѻก'
SUBMISSION = (u'ՇﻉรՇ', u'รપ๒๓ٱรรٱѻก')
STEPS = ['peer', 'self']
......@@ -148,10 +148,9 @@ class TestGrade(XBlockHandlerTestCase):
xblock, self.SUBMISSION, [], [], None, waiting_for_peer=True
)
resp = self.request(xblock, 'render_grade', json.dumps(dict()))
# Verify that feedback from each scorer appears in the view
self.assertNotIn(u'єאςєɭɭєภՇ', resp.decode('utf-8'))
self.assertIn(u'Poor', resp.decode('utf-8'))
self.assertIn(u'Good', resp.decode('utf-8'))
# Verify that the submission and peer steps show that we're graded
# This isn't strictly speaking part of the grade step rendering,
......
......@@ -48,13 +48,6 @@ class TestOpenAssessment(XBlockHandlerTestCase):
self.assertIsNotNone(grade_response)
self.assertTrue(grade_response.body.find("openassessment__grade"))
@scenario('data/line_breaks.xml')
def test_prompt_line_breaks(self, xblock):
# Verify that prompts with multiple lines retain line breaks.
xblock_fragment = self.runtime.render(xblock, "student_view")
expected_prompt = u"<p><br />Line 1</p><p>Line 2</p><p>Line 3<br /></p>"
self.assertIn(expected_prompt, xblock_fragment.body_html())
@scenario('data/empty_prompt.xml')
def test_prompt_intentionally_empty(self, xblock):
# Verify that prompts intentionally left empty don't create DOM elements
......@@ -177,6 +170,10 @@ class TestOpenAssessment(XBlockHandlerTestCase):
{
'description': (u'Given the state of the world today, what do you think should be done to '
u'combat poverty? Please answer in a short essay of 200-300 words.')
},
{
'description': (u'Given the state of the world today, what do you think should be done to '
u'combat pollution?')
}
])
......
......@@ -4,6 +4,8 @@ Test that the student can save a response.
"""
import json
import ddt
from openassessment.xblock.data_conversion import prepare_submission_for_serialization
from .base import XBlockHandlerTestCase, scenario
......@@ -19,35 +21,35 @@ class SaveResponseTest(XBlockHandlerTestCase):
@scenario('data/save_scenario.xml', user_id="Perleman")
def test_save_response(self, xblock, data):
# Save the response
submission_text = " ".join(data)
payload = json.dumps({'submission': submission_text })
submission = [" ".join(data[0]), " ".join(data[1])]
payload = json.dumps({'submission': submission })
resp = self.request(xblock, 'save_submission', payload, response_format="json")
self.assertTrue(resp['success'])
self.assertEqual(resp['msg'], u'')
# Reload the submission UI
resp = self.request(xblock, 'render_submission', json.dumps({}))
self.assertIn(submission_text, resp.decode('utf-8'))
self.assertIn(submission[0], resp.decode('utf-8'))
self.assertIn(submission[1], resp.decode('utf-8'))
self.assertIn('saved but not submitted', resp.lower())
@scenario('data/save_scenario.xml', user_id="Valchek")
def test_overwrite_saved_response(self, xblock):
# XBlock has a saved response already
xblock.saved_response = (
u"THAT'ꙅ likɘ A 40-bɘgᴙɘɘ bAY."
xblock.saved_response = prepare_submission_for_serialization([
u"THAT'ꙅ likɘ A 40-bɘgᴙɘɘ bAY.",
u"Aiᴎ'T ᴎodobY goT ᴎoTHiᴎg To ꙅAY AdoUT A 40-bɘgᴙɘɘ bAY."
u"ꟻiꟻTY. dᴙiᴎg A ꙅmilɘ To YoUᴙ ꟻAↄɘ."
)
])
# Save another response
submission_text = u"ГЂіи lіиэ ъэтшээи Ђэаvэи аиↁ Ђэѓэ."
payload = json.dumps({'submission': submission_text })
submission = [u"ГЂіи lіиэ ъэтшээи", u"Ђэаvэи аиↁ Ђэѓэ."]
payload = json.dumps({'submission': submission })
resp = self.request(xblock, 'save_submission', payload, response_format="json")
self.assertTrue(resp['success'])
# Verify that the saved response was overwritten
self.assertEqual(xblock.saved_response, submission_text)
self.assertEqual(xblock.saved_response, json.dumps(prepare_submission_for_serialization(submission)))
@scenario('data/save_scenario.xml', user_id="Bubbles")
def test_missing_submission_key(self, xblock):
......
......@@ -90,6 +90,13 @@ class SubmissionTest(XBlockHandlerTestCase):
resp = self.request(xblock, 'render_submission', json.dumps(dict()))
self.assertIn("Incomplete", resp)
@scenario('data/line_breaks.xml')
def test_prompt_line_breaks(self, xblock):
# Verify that prompts with multiple lines retain line breaks
resp = self.request(xblock, 'render_submission', json.dumps(dict()))
expected_prompt = u"<p><br />Line 1</p><p>Line 2</p><p>Line 3<br /></p>"
self.assertIn(expected_prompt, resp)
class SubmissionRenderTest(XBlockHandlerTestCase):
"""
......
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