Newer
Older
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
markdown = INLINE_MULTI_MARKDOWN_HAS_UNPAIRED_WRAPPER
resp = self.get_page_sandbox_preview_response(markdown)
self.assertEqual(resp.status_code, 200)
self.assertSandboxNotHasValidPage(resp)
self.assertResponseContextContains(
resp, PAGE_ERRORS,
"question has unpaired '[['.")
def test_redundant(self):
markdown = INLINE_MULTI_MARKDOWN_REDUNDANT
resp = self.get_page_sandbox_preview_response(markdown)
self.assertEqual(resp.status_code, 200)
self.assertSandboxHasValidPage(resp)
self.assertSandboxWarningTextContain(
resp,
"redundant answers 'blank_2' provided for non-existing "
"question(s).")
resp = self.get_page_sandbox_submit_answer_response(
markdown,
answer_data={'blank1': 'Bar'})
self.assertEqual(resp.status_code, 200)
self.assertContains(resp, "This is an explanation.")
self.assertResponseContextAnswerFeedbackCorrectnessEquals(resp, 1)
def test_embedded_question_with_markdown(self):
markdown = INLINE_MULTI_EMBEDDED_WITH_MARKDOWN
resp = self.get_page_sandbox_preview_response(markdown)
self.assertEqual(resp.status_code, 200)
self.assertSandboxHasValidPage(resp)
self.assertContains(
resp, '<img src="/course/test-course/media/4124e0c23e369d6709a6'
'70398167cb9c2fe52d35/images/classroom.jpeg">', html=True)
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
class InlineMultiPageUpdateTest(SingleCoursePageTestMixin, TestCase):
flow_id = "quiz-test"
def setUp(self):
super(InlineMultiPageUpdateTest, self).setUp()
self.c.force_login(self.student_participation.user)
def test_quiz_inline_not_show_correctness(self):
page_id = "inlinemulti"
self.start_flow(self.flow_id)
answer_data = {
'blank1': 'Bar', 'blank_2': '0.2', 'blank3': '1',
'blank4': '5', 'blank5': 'Bar', 'choice2': '0',
'choice_a': '0'}
with mock.patch("course.flow.get_page_behavior") as mock_get_bhv:
mock_get_bhv.side_effect = (
get_page_behavior_not_show_correctness_side_effect)
resp = self.post_answer_by_page_id(page_id, answer_data)
self.assertEqual(resp.status_code, 200)
# 7 answer
self.assertContains(resp, 'correctness="1"', count=0)
self.assertContains(resp, 'correctness="0"', count=0)
# {{{ Test bug fix in https://github.com/inducer/relate/pull/262
def test_add_new_question(self):
"""Test bug fix in https://github.com/inducer/relate/pull/262
"""
page_id = "inlinemulti"
with mock.patch("course.content.get_repo_blob") as mock_get_repo_blob:
mock_get_repo_blob.side_effect = get_repo_blob_side_effect
self.post_update_course_content(
commit_sha=b"ec41a2de73a99e6022060518cb5c5c162b88cdf5")
self.start_flow(self.flow_id)
resp = self.c.get(
self.get_page_url_by_page_id(page_id=page_id))
self.assertEqual(resp.status_code, 200)
self.assertContains(resp, "(old version)")
answer_data = {
'blank1': 'Bar', 'blank_2': '0.2', 'blank3': '1',
'blank4': '5', 'choice2': '0', 'choice_a': '0'}
resp = self.post_answer_by_page_id(page_id, answer_data)
self.assertEqual(resp.status_code, 200)
self.end_flow()
self.assertSessionScoreEqual(10)
# 6 correct answer
self.assertContains(resp, 'correctness="1"', count=6)
self.post_update_course_content(
commit_sha=b"4124e0c23e369d6709a670398167cb9c2fe52d35")
resp = self.c.get(
self.get_page_url_by_page_id(page_id=page_id))
self.assertEqual(resp.status_code, 200)
# 7 answer
self.assertContains(resp, 'correctness="1"', count=7)
def test_add_new_question_not_show_correctness(self):
page_id = "inlinemulti"
with mock.patch("course.flow.get_page_behavior") as mock_get_bhv:
mock_get_bhv.side_effect = (
get_page_behavior_not_show_correctness_side_effect)
with mock.patch("course.content.get_repo_blob") as mock_get_repo_blob:
mock_get_repo_blob.side_effect = get_repo_blob_side_effect
self.post_update_course_content(
commit_sha=b"ec41a2de73a99e6022060518cb5c5c162b88cdf5")
self.start_flow(self.flow_id)
resp = self.c.get(
self.get_page_url_by_page_id(page_id=page_id))
self.assertEqual(resp.status_code, 200)
self.assertContains(resp, "(old version)")
answer_data = {
'blank1': 'Bar', 'blank_2': '0.2', 'blank3': '1',
'blank4': '5', 'choice2': '0', 'choice_a': '0'}
resp = self.post_answer_by_page_id(page_id, answer_data)
self.assertEqual(resp.status_code, 200)
# 6 correct answer
self.assertContains(resp, 'correctness="1"', count=0)
self.assertContains(resp, 'correctness="0"', count=0)
self.post_update_course_content(
commit_sha=b"4124e0c23e369d6709a670398167cb9c2fe52d35")
resp = self.c.get(
self.get_page_url_by_page_id(page_id=page_id))
self.assertEqual(resp.status_code, 200)
# 7 answer
self.assertContains(resp, 'correctness="1"', count=0)
self.assertContains(resp, 'correctness="0"', count=0)