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
9f9f5e4c
Commit
9f9f5e4c
authored
Oct 17, 2013
by
Vik Paruchuri
Committed by
Brian Wilson
Oct 28, 2013
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Ensure that peer grading modules whose linked problem is removed change over to panel mode
parent
2673049c
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
136 additions
and
67 deletions
+136
-67
common/lib/xmodule/xmodule/peer_grading_module.py
+39
-27
common/lib/xmodule/xmodule/tests/test_peer_grading.py
+97
-40
No files found.
common/lib/xmodule/xmodule/peer_grading_module.py
View file @
9f9f5e4c
...
...
@@ -104,30 +104,28 @@ class PeerGradingModule(PeerGradingFields, XModule):
def
__init__
(
self
,
*
args
,
**
kwargs
):
super
(
PeerGradingModule
,
self
)
.
__init__
(
*
args
,
**
kwargs
)
#We need to set the location here so the child modules can use it
# Copy this to a new variable so that we can edit it if needed.
# We need to edit it if the linked module cannot be found, so
# we can revert to panel model.
self
.
use_for_single_location_local
=
self
.
use_for_single_location
# We need to set the location here so the child modules can use it.
self
.
runtime
.
set
(
'location'
,
self
.
location
)
if
(
self
.
runtime
.
open_ended_grading_interface
):
self
.
peer_gs
=
PeerGradingService
(
self
.
system
.
open_ended_grading_interface
,
self
.
system
)
else
:
self
.
peer_gs
=
MockPeerGradingService
()
if
self
.
use_for_single_location
:
try
:
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
)
if
self
.
use_for_single_location_local
:
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
)
# Change module over to panel mode from single problem mode.
self
.
use_for_single_location_local
=
False
else
:
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
))
raise
except
NoPathToItem
:
log
.
error
(
"Linked location {0} for peer grading module {1} cannot be linked to."
.
format
(
self
.
link_to_location
,
self
.
location
))
raise
try
:
self
.
timeinfo
=
TimeInfo
(
self
.
due
,
self
.
graceperiod
)
...
...
@@ -175,7 +173,7 @@ class PeerGradingModule(PeerGradingFields, XModule):
"""
if
self
.
closed
():
return
self
.
peer_grading_closed
()
if
not
self
.
use_for_single_location
:
if
not
self
.
use_for_single_location
_local
:
return
self
.
peer_grading
()
else
:
return
self
.
peer_grading_problem
({
'location'
:
self
.
link_to_location
})[
'html'
]
...
...
@@ -236,7 +234,7 @@ class PeerGradingModule(PeerGradingFields, XModule):
'score'
:
score
,
'total'
:
max_score
,
}
if
not
self
.
use_for_single_location
or
not
self
.
graded
:
if
not
self
.
use_for_single_location
_local
or
not
self
.
graded
:
return
score_dict
try
:
...
...
@@ -270,7 +268,7 @@ class PeerGradingModule(PeerGradingFields, XModule):
randomization, and 5/7 on another
'''
max_grade
=
None
if
self
.
use_for_single_location
and
self
.
graded
:
if
self
.
use_for_single_location
_local
and
self
.
graded
:
max_grade
=
self
.
weight
return
max_grade
...
...
@@ -492,7 +490,7 @@ class PeerGradingModule(PeerGradingFields, XModule):
Show the Peer grading closed template
'''
html
=
self
.
system
.
render_template
(
'peer_grading/peer_grading_closed.html'
,
{
'use_for_single_location'
:
self
.
use_for_single_location
'use_for_single_location'
:
self
.
use_for_single_location
_local
})
return
html
...
...
@@ -578,7 +576,7 @@ class PeerGradingModule(PeerGradingFields, XModule):
'error_text'
:
error_text
,
# Checked above
'staff_access'
:
False
,
'use_single_location'
:
self
.
use_for_single_location
,
'use_single_location'
:
self
.
use_for_single_location
_local
,
})
return
html
...
...
@@ -588,7 +586,7 @@ class PeerGradingModule(PeerGradingFields, XModule):
Show individual problem interface
'''
if
data
is
None
or
data
.
get
(
'location'
)
is
None
:
if
not
self
.
use_for_single_location
:
if
not
self
.
use_for_single_location
_local
:
# This is an error case, because it must be set to use a single location to be called without get parameters
# This is a dev_facing_error
log
.
error
(
...
...
@@ -610,7 +608,7 @@ class PeerGradingModule(PeerGradingFields, XModule):
# Checked above
'staff_access'
:
False
,
'track_changes'
:
getattr
(
module
,
'track_changes'
,
False
),
'use_single_location'
:
self
.
use_for_single_location
,
'use_single_location'
:
self
.
use_for_single_location
_local
,
})
return
{
'html'
:
html
,
'success'
:
True
}
...
...
@@ -656,10 +654,24 @@ class PeerGradingDescriptor(PeerGradingFields, RawDescriptor):
return
non_editable_fields
def
get_required_module_descriptors
(
self
):
"""Returns a list of XModuleDescritpor instances upon which this module depends, but are
not children of this module"""
"""
Returns a list of XModuleDescriptor instances upon which this module depends, but are
not children of this module.
"""
# If use_for_single_location is True, this is linked to an open ended problem.
if
self
.
use_for_single_location
:
return
[
self
.
system
.
load_item
(
self
.
link_to_location
)]
# Try to load the linked module.
# If we can't load it, return empty list to avoid exceptions on progress page.
try
:
linked_module
=
self
.
system
.
load_item
(
self
.
link_to_location
)
return
[
linked_module
]
except
(
NoPathToItem
,
ItemNotFoundError
):
error_message
=
(
"Cannot find the combined open ended module "
"at location {0} being linked to from peer "
"grading module {1}"
)
.
format
(
self
.
link_to_location
,
self
.
location
)
log
.
error
(
error_message
)
return
[]
else
:
return
[]
...
...
common/lib/xmodule/xmodule/tests/test_peer_grading.py
View file @
9f9f5e4c
This diff is collapsed.
Click to expand it.
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