本文整理匯總了Python中xmodule.open_ended_grading_classes.openendedchild.OpenEndedChild類的典型用法代碼示例。如果您正苦於以下問題:Python OpenEndedChild類的具體用法?Python OpenEndedChild怎麽用?Python OpenEndedChild使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了OpenEndedChild類的12個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: test_combined
def test_combined(self):
"""
tests a combination of inputs
"""
test_input = u"{}\n{}\n{}\n\n{}{}\n{}".format(self.link_text,
self.text,
self.script_dirty,
self.embed_dirty,
self.text_lessthan_noencd,
self.img_dirty)
test_output = u"{}<br/>{}<br/>{}<br/><br/>{}{}<br/>{}".format(self.link_atag,
self.text,
self.script_clean,
self.embed_clean,
self.text_lessthan_encode,
self.img_clean)
self.assertEqual(OpenEndedChild.sanitize_html(test_input), test_output)
示例2: setUp
def setUp(self):
self.test_system = get_test_system()
self.test_system.open_ended_grading_interface = None
self.openendedchild = OpenEndedChild(self.test_system, self.location,
self.definition, self.descriptor, self.static_data, self.metadata)
示例3: OpenEndedChildTest
class OpenEndedChildTest(unittest.TestCase):
"""
Test the open ended child class
"""
location = Location(["i4x", "edX", "sa_test", "selfassessment",
"SampleQuestion"])
metadata = json.dumps({'attempts': '10'})
prompt = etree.XML("<prompt>This is a question prompt</prompt>")
rubric = '''<rubric><rubric>
<category>
<description>Response Quality</description>
<option>The response is not a satisfactory answer to the question. It either fails to address the question or does so in a limited way, with no evidence of higher-order thinking.</option>
<option>Second option</option>
</category>
</rubric></rubric>'''
max_score = 1
static_data = {
'max_attempts': 20,
'prompt': prompt,
'rubric': rubric,
'max_score': max_score,
'display_name': 'Name',
'accept_file_upload': False,
'close_date': None,
's3_interface': "",
'open_ended_grading_interface': {},
'skip_basic_checks': False,
'control': {
'required_peer_grading': 1,
'peer_grader_count': 1,
'min_to_calibrate': 3,
'max_to_calibrate': 6,
'peer_grade_finished_submissions_when_none_pending': False,
}
}
definition = Mock()
descriptor = Mock()
def setUp(self):
self.test_system = get_test_system()
self.test_system.open_ended_grading_interface = None
self.openendedchild = OpenEndedChild(self.test_system, self.location,
self.definition, self.descriptor, self.static_data, self.metadata)
def test_latest_answer_empty(self):
answer = self.openendedchild.latest_answer()
self.assertEqual(answer, "")
def test_latest_score_empty(self):
answer = self.openendedchild.latest_score()
self.assertEqual(answer, None)
def test_latest_post_assessment_empty(self):
answer = self.openendedchild.latest_post_assessment(self.test_system)
self.assertEqual(answer, "")
def test_new_history_entry(self):
new_answer = "New Answer"
self.openendedchild.new_history_entry(new_answer)
answer = self.openendedchild.latest_answer()
self.assertEqual(answer, new_answer)
new_answer = "Newer Answer"
self.openendedchild.new_history_entry(new_answer)
answer = self.openendedchild.latest_answer()
self.assertEqual(new_answer, answer)
def test_record_latest_score(self):
new_answer = "New Answer"
self.openendedchild.new_history_entry(new_answer)
new_score = 3
self.openendedchild.record_latest_score(new_score)
score = self.openendedchild.latest_score()
self.assertEqual(score, 3)
new_score = 4
self.openendedchild.new_history_entry(new_answer)
self.openendedchild.record_latest_score(new_score)
score = self.openendedchild.latest_score()
self.assertEqual(score, 4)
def test_record_latest_post_assessment(self):
new_answer = "New Answer"
self.openendedchild.new_history_entry(new_answer)
post_assessment = "Post assessment"
self.openendedchild.record_latest_post_assessment(post_assessment)
self.assertEqual(post_assessment,
self.openendedchild.latest_post_assessment(self.test_system))
def test_get_score(self):
new_answer = "New Answer"
self.openendedchild.new_history_entry(new_answer)
score = self.openendedchild.get_score()
self.assertEqual(score['score'], 0)
self.assertEqual(score['total'], self.static_data['max_score'])
#.........這裏部分代碼省略.........
示例4: test_linebreaks
def test_linebreaks(self):
"""
tests the replace_newlines function
"""
self.assertEqual(OpenEndedChild.replace_newlines(self.text_linebreaks), self.text_brs)
示例5: test_linkify
def test_linkify(self):
"""
tests the replace_newlines function
"""
self.assertEqual(OpenEndedChild.sanitize_html(self.link_text), self.link_atag)
示例6: test_text
def test_text(self):
"""
Test for passing through text unchanged, including unicode
"""
self.assertEqual(OpenEndedChild.sanitize_html(self.text), self.text)
示例7: test_lessthan
def test_lessthan(self):
"""
Tests that `<` in text context is handled properly
"""
self.assertEqual(OpenEndedChild.sanitize_html(self.text_lessthan_noencd), self.text_lessthan_encode)
示例8: test_iframe
def test_iframe(self):
"""
Basic test for passing through iframe, but stripping bad attr
"""
self.assertEqual(OpenEndedChild.sanitize_html(self.iframe_dirty), self.iframe_clean)
示例9: test_embed
def test_embed(self):
"""
Basic test for passing through embed, but stripping bad attr
"""
self.assertEqual(OpenEndedChild.sanitize_html(self.embed_dirty), self.embed_clean)
示例10: test_script
def test_script(self):
"""
Basic test for stripping <script>
"""
self.assertEqual(OpenEndedChild.sanitize_html(self.script_dirty), self.script_clean)
示例11: setUp
def setUp(self):
self.test_system = get_test_system()
self.openendedchild = OpenEndedChild(self.test_system, self.location,
self.definition, self.descriptor, self.static_data, self.metadata)
示例12: OpenEndedChildTest
class OpenEndedChildTest(unittest.TestCase):
"""
Test the open ended child class
"""
location = Location(["i4x", "edX", "sa_test", "selfassessment", "SampleQuestion"])
metadata = json.dumps({"attempts": "10"})
prompt = etree.XML("<prompt>This is a question prompt</prompt>")
rubric = """<rubric><rubric>
<category>
<description>Response Quality</description>
<option>The response is not a satisfactory answer to the question. It either fails to address the question or does so in a limited way, with no evidence of higher-order thinking.</option>
<option>Second option</option>
</category>
</rubric></rubric>"""
max_score = 1
static_data = {
"max_attempts": 20,
"prompt": prompt,
"rubric": rubric,
"max_score": max_score,
"display_name": "Name",
"accept_file_upload": False,
"close_date": None,
"s3_interface": "",
"open_ended_grading_interface": {},
"skip_basic_checks": False,
"control": {
"required_peer_grading": 1,
"peer_grader_count": 1,
"min_to_calibrate": 3,
"max_to_calibrate": 6,
"peer_grade_finished_submissions_when_none_pending": False,
},
}
definition = Mock()
descriptor = Mock()
def setUp(self):
self.test_system = get_test_system()
self.test_system.open_ended_grading_interface = None
self.openendedchild = OpenEndedChild(
self.test_system, self.location, self.definition, self.descriptor, self.static_data, self.metadata
)
def test_latest_answer_empty(self):
answer = self.openendedchild.latest_answer()
self.assertEqual(answer, "")
def test_latest_score_empty(self):
answer = self.openendedchild.latest_score()
self.assertEqual(answer, None)
def test_latest_post_assessment_empty(self):
answer = self.openendedchild.latest_post_assessment(self.test_system)
self.assertEqual(answer, "")
def test_new_history_entry(self):
new_answer = "New Answer"
self.openendedchild.new_history_entry(new_answer)
answer = self.openendedchild.latest_answer()
self.assertEqual(answer, new_answer)
new_answer = "Newer Answer"
self.openendedchild.new_history_entry(new_answer)
answer = self.openendedchild.latest_answer()
self.assertEqual(new_answer, answer)
def test_record_latest_score(self):
new_answer = "New Answer"
self.openendedchild.new_history_entry(new_answer)
new_score = 3
self.openendedchild.record_latest_score(new_score)
score = self.openendedchild.latest_score()
self.assertEqual(score, 3)
new_score = 4
self.openendedchild.new_history_entry(new_answer)
self.openendedchild.record_latest_score(new_score)
score = self.openendedchild.latest_score()
self.assertEqual(score, 4)
def test_record_latest_post_assessment(self):
new_answer = "New Answer"
self.openendedchild.new_history_entry(new_answer)
post_assessment = "Post assessment"
self.openendedchild.record_latest_post_assessment(post_assessment)
self.assertEqual(post_assessment, self.openendedchild.latest_post_assessment(self.test_system))
def test_get_score(self):
new_answer = "New Answer"
self.openendedchild.new_history_entry(new_answer)
score = self.openendedchild.get_score()
self.assertEqual(score["score"], 0)
self.assertEqual(score["total"], self.static_data["max_score"])
#.........這裏部分代碼省略.........