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
ecb6f0f9
Commit
ecb6f0f9
authored
Sep 19, 2013
by
Vik Paruchuri
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add in peer grading tests to cover linking behavior
parent
29710661
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
73 additions
and
7 deletions
+73
-7
common/lib/xmodule/xmodule/tests/test_peer_grading.py
+73
-7
No files found.
common/lib/xmodule/xmodule/tests/test_peer_grading.py
View file @
ecb6f0f9
...
@@ -4,10 +4,11 @@ from .import get_test_system
...
@@ -4,10 +4,11 @@ from .import get_test_system
from
test_util_open_ended
import
MockQueryDict
,
DummyModulestore
from
test_util_open_ended
import
MockQueryDict
,
DummyModulestore
from
xmodule.open_ended_grading_classes.peer_grading_service
import
MockPeerGradingService
from
xmodule.open_ended_grading_classes.peer_grading_service
import
MockPeerGradingService
from
mock
import
Mock
from
mock
import
Mock
from
xmodule.peer_grading_module
import
PeerGradingModule
from
xmodule.peer_grading_module
import
PeerGradingModule
,
InvalidLinkLocation
from
xblock.field_data
import
DictFieldData
from
xblock.field_data
import
DictFieldData
from
xblock.fields
import
ScopeIds
from
xblock.fields
import
ScopeIds
from
xmodule.modulestore.exceptions
import
ItemNotFoundError
from
xmodule.modulestore.exceptions
import
ItemNotFoundError
,
NoPathToItem
import
json
import
logging
import
logging
...
@@ -215,26 +216,31 @@ class PeerGradingModuleLinkedTest(unittest.TestCase, DummyModulestore):
...
@@ -215,26 +216,31 @@ class PeerGradingModuleLinkedTest(unittest.TestCase, DummyModulestore):
self
.
test_system
.
open_ended_grading_interface
=
None
self
.
test_system
.
open_ended_grading_interface
=
None
self
.
setup_modulestore
(
COURSE
)
self
.
setup_modulestore
(
COURSE
)
def
test_linked_problem
(
self
):
def
_create_peer_grading_with_linked_problem
(
self
,
location
,
valid_linked_descriptor
=
True
):
"""
"""
C
heck to see if a peer grading module with a linked problem loads properly
.
C
reate a peer grading problem with a linked location
.
"""
"""
# Mock the linked problem descriptor.
# Mock the linked problem descriptor.
linked_descriptor
=
Mock
()
linked_descriptor
=
Mock
()
linked_descriptor
.
location
=
self
.
coe_
location
linked_descriptor
.
location
=
location
# Mock the peer grading descriptor.
# Mock the peer grading descriptor.
pg_descriptor
=
Mock
()
pg_descriptor
=
Mock
()
pg_descriptor
.
location
=
self
.
problem_location
pg_descriptor
.
location
=
self
.
problem_location
pg_descriptor
.
get_required_module_descriptors
=
lambda
:
[
linked_descriptor
,
]
if
valid_linked_descriptor
:
pg_descriptor
.
get_required_module_descriptors
=
lambda
:
[
linked_descriptor
,
]
else
:
pg_descriptor
.
get_required_module_descriptors
=
lambda
:
[]
# Setup the proper field data for the peer grading module.
# Setup the proper field data for the peer grading module.
field_data
=
DictFieldData
({
field_data
=
DictFieldData
({
'data'
:
'<peergrading/>'
,
'data'
:
'<peergrading/>'
,
'location'
:
self
.
problem_location
,
'location'
:
self
.
problem_location
,
'use_for_single_location'
:
True
,
'use_for_single_location'
:
True
,
'link_to_location'
:
self
.
coe_location
,
'link_to_location'
:
self
.
coe_location
.
url
(),
'graded'
:
True
,
})
})
# Initialize the peer grading module.
# Initialize the peer grading module.
...
@@ -245,9 +251,69 @@ class PeerGradingModuleLinkedTest(unittest.TestCase, DummyModulestore):
...
@@ -245,9 +251,69 @@ class PeerGradingModuleLinkedTest(unittest.TestCase, DummyModulestore):
ScopeIds
(
None
,
None
,
self
.
problem_location
,
self
.
problem_location
)
ScopeIds
(
None
,
None
,
self
.
problem_location
,
self
.
problem_location
)
)
)
return
peer_grading
def
test_invalid_link
(
self
):
"""
Ensure that a peer grading problem with no linked locations raises an error.
"""
# Setup the peer grading module with no linked locations.
with
self
.
assertRaises
(
InvalidLinkLocation
):
self
.
_create_peer_grading_with_linked_problem
(
self
.
coe_location
,
valid_linked_descriptor
=
False
)
def
test_linked_problem
(
self
):
"""
Ensure that a peer grading problem with a linked location loads properly.
"""
# Setup the peer grading module with the proper linked location.
peer_grading
=
self
.
_create_peer_grading_with_linked_problem
(
self
.
coe_location
)
# Ensure that it is properly setup.
# Ensure that it is properly setup.
self
.
assertTrue
(
peer_grading
.
use_for_single_location
)
self
.
assertTrue
(
peer_grading
.
use_for_single_location
)
def
test_linked_ajax
(
self
):
"""
Ensure that a peer grading problem with a linked location responds to ajax calls.
"""
# Setup the peer grading module with the proper linked location.
peer_grading
=
self
.
_create_peer_grading_with_linked_problem
(
self
.
coe_location
)
# If we specify a location, it will render the problem for that location.
data
=
peer_grading
.
handle_ajax
(
'problem'
,
{
'location'
:
self
.
coe_location
})
self
.
assertTrue
(
json
.
loads
(
data
)[
'success'
])
# If we don't specify a location, it should use the linked location.
data
=
peer_grading
.
handle_ajax
(
'problem'
,
{})
self
.
assertTrue
(
json
.
loads
(
data
)[
'success'
])
def
test_linked_score
(
self
):
"""
Ensure that a peer grading problem with a linked location is properly scored.
"""
# Setup the peer grading module with the proper linked location.
peer_grading
=
self
.
_create_peer_grading_with_linked_problem
(
self
.
coe_location
)
score_dict
=
peer_grading
.
get_score
()
self
.
assertEqual
(
score_dict
[
'score'
],
1
)
self
.
assertEqual
(
score_dict
[
'total'
],
1
)
def
test_get_next_submission
(
self
):
"""
Ensure that a peer grading problem with a linked location can get a submission to score.
"""
# Setup the peer grading module with the proper linked location.
peer_grading
=
self
.
_create_peer_grading_with_linked_problem
(
self
.
coe_location
)
data
=
peer_grading
.
handle_ajax
(
'get_next_submission'
,
{
'location'
:
self
.
coe_location
})
self
.
assertEqual
(
json
.
loads
(
data
)[
'submission_id'
],
1
)
class
PeerGradingModuleTrackChangesTest
(
unittest
.
TestCase
,
DummyModulestore
):
class
PeerGradingModuleTrackChangesTest
(
unittest
.
TestCase
,
DummyModulestore
):
"""
"""
...
...
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