Commit ba7eaa1c by Usman Khalid

Fixed tests.

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