Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
edx-platform
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
edx
edx-platform
Commits
bb521a20
Commit
bb521a20
authored
Jan 25, 2013
by
Diana Huang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix a bug caught with testing and update some tests
(the last couple are still broken, though)
parent
bb60dde4
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
72 additions
and
3 deletions
+72
-3
common/lib/xmodule/xmodule/open_ended_module.py
+5
-1
common/lib/xmodule/xmodule/tests/test_combined_open_ended.py
+67
-2
No files found.
common/lib/xmodule/xmodule/open_ended_module.py
View file @
bb521a20
...
...
@@ -257,7 +257,7 @@ class OpenEndedModule(openendedchild.OpenEndedChild):
"""
new_score_msg
=
self
.
_parse_score_msg
(
score_msg
,
system
)
if
not
new_score_msg
[
'valid'
]:
score_msg
[
'feedback'
]
=
'Invalid grader reply. Please contact the course staff.'
new_
score_msg
[
'feedback'
]
=
'Invalid grader reply. Please contact the course staff.'
self
.
record_latest_score
(
new_score_msg
[
'score'
])
self
.
record_latest_post_assessment
(
score_msg
)
...
...
@@ -404,6 +404,10 @@ class OpenEndedModule(openendedchild.OpenEndedChild):
'score': Numeric value (floating point is okay) to assign to answer
'msg': grader_msg
'feedback' : feedback from grader
'grader_type': what type of grader resulted in this score
'grader_id': id of the grader
'submission_id' : id of the submission
'success': whether or not this submission was successful
}
Returns (valid_score_msg, correct, score, msg):
...
...
common/lib/xmodule/xmodule/tests/test_combined_open_ended.py
View file @
bb521a20
import
json
from
mock
import
Mock
,
MagicMock
from
mock
import
Mock
,
MagicMock
,
ANY
import
unittest
from
xmodule.openendedchild
import
OpenEndedChild
from
xmodule.open_ended_module
import
OpenEndedModule
from
xmodule.modulestore
import
Location
from
lxml
import
etree
import
capa.xqueue_interface
as
xqueue_interface
from
datetime
import
datetime
from
.
import
test_system
...
...
@@ -165,15 +167,78 @@ class OpenEndedModuleTest(unittest.TestCase):
'submission_id'
:
'1'
,
'grader_id'
:
'1'
,
'score'
:
3
}
qtime
=
datetime
.
strftime
(
datetime
.
now
(),
xqueue_interface
.
dateformat
)
student_info
=
{
'anonymous_student_id'
:
test_system
.
anonymous_student_id
,
'submission_time'
:
qtime
}
contents
=
{
'feedback'
:
get
[
'feedback'
],
'submission_id'
:
int
(
get
[
'submission_id'
]),
'grader_id'
:
int
(
get
[
'grader_id'
]),
'score'
:
get
[
'score'
],
'student_info'
:
json
.
dumps
(
student_info
)
}
result
=
self
.
openendedmodule
.
message_post
(
get
,
test_system
)
self
.
assertTrue
(
result
[
'success'
])
# make sure it's actually sending something to the queue
self
.
mock_xqueue
.
send_to_queue
.
assert_called_with
(
body
=
json
.
dumps
(
contents
),
header
=
ANY
)
state
=
json
.
loads
(
self
.
openendedmodule
.
get_instance_state
())
self
.
assertIsNotNone
(
state
[
'state'
],
OpenEndedModule
.
DONE
)
def
test_send_to_grader
(
self
):
result
=
self
.
openendedmodule
.
send_to_grader
(
"This is a student submission"
,
test_system
)
submission
=
"This is a student submission"
qtime
=
datetime
.
strftime
(
datetime
.
now
(),
xqueue_interface
.
dateformat
)
student_info
=
{
'anonymous_student_id'
:
test_system
.
anonymous_student_id
,
'submission_time'
:
qtime
}
contents
=
self
.
openendedmodule
.
payload
.
copy
()
contents
.
update
({
'student_info'
:
json
.
dumps
(
student_info
),
'student_response'
:
submission
,
'max_score'
:
self
.
max_score
})
result
=
self
.
openendedmodule
.
send_to_grader
(
submission
,
test_system
)
self
.
assertTrue
(
result
)
self
.
mock_xqueue
.
send_to_queue
.
assert_called_with
(
body
=
json
.
dumps
(
contents
),
header
=
ANY
)
def
update_score_single
(
self
):
self
.
openendedmodule
.
new_history_entry
(
"New Entry"
)
score_msg
=
{
'correct'
:
True
,
'score'
:
4
,
'msg'
:
'Grader Message'
,
'feedback'
:
"Grader Feedback"
}
get
=
{
'queuekey'
:
"abcd"
,
'xqueue_body'
:
score_msg
}
self
.
openendedmodule
.
update_score
(
get
,
test_system
)
def
update_score_single
(
self
):
self
.
openendedmodule
.
new_history_entry
(
"New Entry"
)
feedback
=
{
"success"
:
True
,
"feedback"
:
"Grader Feedback"
}
score_msg
=
{
'correct'
:
True
,
'score'
:
4
,
'msg'
:
'Grader Message'
,
'feedback'
:
feedback
,
'grader_type'
:
'IN'
,
'grader_id'
:
'1'
,
'submission_id'
:
'1'
,
'success'
:
True
}
get
=
{
'queuekey'
:
"abcd"
,
'xqueue_body'
:
json
.
dumps
(
score_msg
)}
self
.
openendedmodule
.
update_score
(
get
,
test_system
)
def
test_update_score
(
self
):
self
.
update_score_single
()
score
=
self
.
openendedmodule
.
latest_score
()
self
.
assertEqual
(
score
,
4
)
def
test_latest_post_assessment
(
self
):
self
.
update_score_single
()
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment