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
c6e5e674
Commit
c6e5e674
authored
Sep 13, 2013
by
Vik Paruchuri
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix linking problem for peer grading, add in a test
Conflicts: common/lib/xmodule/xmodule/tests/test_peer_grading.py
parent
00050a08
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
71 additions
and
3 deletions
+71
-3
common/lib/xmodule/xmodule/peer_grading_module.py
+13
-1
common/lib/xmodule/xmodule/tests/test_peer_grading.py
+55
-2
common/test/data/open_ended/course/2012_Fall.xml
+1
-0
common/test/data/open_ended/peergrading/PeerGradingLinked.xml
+2
-0
No files found.
common/lib/xmodule/xmodule/peer_grading_module.py
View file @
c6e5e674
...
...
@@ -72,6 +72,12 @@ class PeerGradingFields(object):
scope
=
Scope
.
content
)
class
InvalidLinkLocation
(
Exception
):
"""
Exception for the case in which a peer grading module tries to link to an invalid location.
"""
pass
class
PeerGradingModule
(
PeerGradingFields
,
XModule
):
"""
...
...
@@ -103,7 +109,13 @@ class PeerGradingModule(PeerGradingFields, XModule):
if
self
.
use_for_single_location
:
try
:
self
.
linked_problem
=
self
.
system
.
get_module
(
self
.
link_to_location
)
linked_descriptors
=
self
.
descriptor
.
get_required_module_descriptors
()
if
len
(
linked_descriptors
)
==
0
:
error_msg
=
"Peer grading module {0} is trying to use single problem mode without "
"a location specified."
.
format
(
self
.
location
)
log
.
error
(
error_msg
)
raise
InvalidLinkLocation
(
error_msg
)
self
.
linked_problem
=
self
.
system
.
get_module
(
linked_descriptors
[
0
])
except
ItemNotFoundError
:
log
.
error
(
"Linked location {0} for peer grading module {1} does not exist"
.
format
(
self
.
link_to_location
,
self
.
location
))
...
...
common/lib/xmodule/xmodule/tests/test_peer_grading.py
View file @
c6e5e674
...
...
@@ -4,6 +4,10 @@ from .import get_test_system
from
test_util_open_ended
import
MockQueryDict
,
DummyModulestore
from
xmodule.open_ended_grading_classes.peer_grading_service
import
MockPeerGradingService
import
json
from
mock
import
Mock
from
xmodule.peer_grading_module
import
PeerGradingModule
from
xblock.field_data
import
DictFieldData
from
xblock.fields
import
ScopeIds
import
logging
...
...
@@ -180,4 +184,54 @@ class PeerGradingModuleScoredTest(unittest.TestCase, DummyModulestore):
# Swap for our mock class, which will find peer grading.
peer_grading
.
peer_gs
=
MockPeerGradingServiceProblemList
()
html
=
peer_grading
.
peer_grading
()
self
.
assertIn
(
"Peer-Graded"
,
html
)
\ No newline at end of file
self
.
assertIn
(
"Peer-Graded"
,
html
)
class
PeerGradingModuleLinkedTest
(
unittest
.
TestCase
,
DummyModulestore
):
"""
Test peer grading that is linked to an open ended module.
"""
problem_location
=
Location
([
"i4x"
,
"edX"
,
"open_ended"
,
"peergrading"
,
"PeerGradingLinked"
])
coe_location
=
Location
([
"i4x"
,
"edX"
,
"open_ended"
,
"combinedopenended"
,
"SampleQuestion"
])
def
setUp
(
self
):
"""
Create a peer grading module from a test system.
"""
self
.
test_system
=
get_test_system
()
self
.
test_system
.
open_ended_grading_interface
=
None
self
.
setup_modulestore
(
COURSE
)
def
test_linked_problem
(
self
):
"""
Check to see if a peer grading module with a linked problem loads properly.
"""
# Mock the linked problem descriptor.
linked_descriptor
=
Mock
()
linked_descriptor
.
location
=
self
.
coe_location
# Mock the peer grading descriptor.
pg_descriptor
=
Mock
()
pg_descriptor
.
location
=
self
.
problem_location
pg_descriptor
.
get_required_module_descriptors
=
lambda
:
[
linked_descriptor
,
]
# Setup the proper field data for the peer grading module.
field_data
=
DictFieldData
({
'data'
:
'<peergrading/>'
,
'location'
:
self
.
problem_location
,
'use_for_single_location'
:
True
,
'link_to_location'
:
self
.
coe_location
,
})
# Initialize the peer grading module.
peer_grading
=
PeerGradingModule
(
pg_descriptor
,
self
.
test_system
,
field_data
,
ScopeIds
(
None
,
None
,
self
.
problem_location
,
self
.
problem_location
)
)
# Ensure that it is properly setup.
self
.
assertTrue
(
peer_grading
.
use_for_single_location
)
common/test/data/open_ended/course/2012_Fall.xml
View file @
c6e5e674
...
...
@@ -4,5 +4,6 @@
<combinedopenended
url_name=
"SampleQuestion1Attempt"
/>
<peergrading
url_name=
"PeerGradingSample"
/>
<peergrading
url_name=
"PeerGradingScored"
/>
<peergrading
url_name=
"PeerGradingLinked"
/>
</chapter>
</course>
common/test/data/open_ended/peergrading/PeerGradingLinked.xml
0 → 100644
View file @
c6e5e674
<peergrading
is_graded=
"True"
max_grade=
"1"
use_for_single_location=
"True"
link_to_location=
"i4x://edX/open_ended/combinedopenended/SampleQuestion"
/>
\ No newline at end of file
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