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
3d2ae66c
Commit
3d2ae66c
authored
Jan 15, 2013
by
Diana Huang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactor out rubric rendering and pass along
the right information for peer grading
parent
48be0b15
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
57 additions
and
50 deletions
+57
-50
lms/djangoapps/open_ended_grading/grading_service.py
+28
-0
lms/djangoapps/open_ended_grading/peer_grading_service.py
+22
-23
lms/djangoapps/open_ended_grading/staff_grading_service.py
+3
-22
lms/static/coffee/src/peer_grading/peer_grading_problem.coffee
+3
-3
lms/static/coffee/src/staff_grading/staff_grading.coffee
+0
-1
lms/templates/peer_grading/peer_grading_problem.html
+1
-1
No files found.
lms/djangoapps/open_ended_grading/grading_service.py
View file @
3d2ae66c
...
...
@@ -11,6 +11,8 @@ from django.http import HttpResponse, Http404
from
courseware.access
import
has_access
from
util.json_request
import
expect_json
from
xmodule.course_module
import
CourseDescriptor
from
xmodule.combined_open_ended_rubric
import
CombinedOpenEndedRubric
from
lxml
import
etree
log
=
logging
.
getLogger
(
__name__
)
...
...
@@ -98,3 +100,29 @@ class GradingService(object):
return
response
def
_render_rubric
(
self
,
response
,
view_only
=
False
):
"""
Given an HTTP Response with the key 'rubric', render out the html
required to display the rubric
"""
try
:
response_json
=
json
.
loads
(
response
)
if
response_json
.
has_key
(
'rubric'
):
rubric
=
response_json
[
'rubric'
]
rubric_renderer
=
CombinedOpenEndedRubric
(
False
)
success
,
rubric_html
=
rubric_renderer
.
render_rubric
(
rubric
)
if
not
success
:
error_message
=
"Could not render rubric: {0}"
.
format
(
rubric
)
log
.
exception
(
error_message
)
return
json
.
dumps
({
'success'
:
False
,
'error'
:
error_message
})
response_json
[
'rubric'
]
=
rubric_html
return
json
.
dumps
(
response_json
)
# if we can't parse the rubric into HTML,
except
etree
.
XMLSyntaxError
:
log
.
exception
(
"Cannot parse rubric string. Raw string: {0}"
.
format
(
rubric
))
return
json
.
dumps
({
'success'
:
False
,
'error'
:
'Error displaying submission'
})
lms/djangoapps/open_ended_grading/peer_grading_service.py
View file @
3d2ae66c
...
...
@@ -20,7 +20,9 @@ from grading_service import GradingServiceError
from
courseware.access
import
has_access
from
util.json_request
import
expect_json
from
xmodule.course_module
import
CourseDescriptor
from
xmodule.combined_open_ended_rubric
import
CombinedOpenEndedRubric
from
student.models
import
unique_id_for_user
from
lxml
import
etree
log
=
logging
.
getLogger
(
__name__
)
...
...
@@ -83,15 +85,17 @@ class PeerGradingService(GradingService):
def
get_next_submission
(
self
,
problem_location
,
grader_id
):
response
=
self
.
get
(
self
.
get_next_submission_url
,
{
'location'
:
problem_location
,
'grader_id'
:
grader_id
})
return
response
return
self
.
_render_rubric
(
response
)
def
save_grade
(
self
,
location
,
grader_id
,
submission_id
,
score
,
feedback
,
submission_key
):
def
save_grade
(
self
,
location
,
grader_id
,
submission_id
,
score
,
feedback
,
submission_key
,
rubric_scores
):
data
=
{
'grader_id'
:
grader_id
,
'submission_id'
:
submission_id
,
'score'
:
score
,
'feedback'
:
feedback
,
'submission_key'
:
submission_key
,
'location'
:
location
}
'location'
:
location
,
'rubric_scores'
:
rubric_scores
,
'rubric_scores_complete'
:
True
}
return
self
.
post
(
self
.
save_grade_url
,
data
)
def
is_student_calibrated
(
self
,
problem_location
,
grader_id
):
...
...
@@ -100,15 +104,19 @@ class PeerGradingService(GradingService):
def
show_calibration_essay
(
self
,
problem_location
,
grader_id
):
params
=
{
'problem_id'
:
problem_location
,
'student_id'
:
grader_id
}
return
self
.
get
(
self
.
show_calibration_essay_url
,
params
)
response
=
self
.
get
(
self
.
show_calibration_essay_url
,
params
)
return
self
.
_render_rubric
(
response
)
def
save_calibration_essay
(
self
,
problem_location
,
grader_id
,
calibration_essay_id
,
submission_key
,
score
,
feedback
):
def
save_calibration_essay
(
self
,
problem_location
,
grader_id
,
calibration_essay_id
,
submission_key
,
score
,
feedback
,
rubric_scores
):
data
=
{
'location'
:
problem_location
,
'student_id'
:
grader_id
,
'calibration_essay_id'
:
calibration_essay_id
,
'submission_key'
:
submission_key
,
'score'
:
score
,
'feedback'
:
feedback
}
'feedback'
:
feedback
,
'rubric_scores[]'
:
rubric_scores
,
'rubric_scores_complete'
:
True
}
return
self
.
post
(
self
.
save_calibration_essay_url
,
data
)
def
get_problem_list
(
self
,
course_id
,
grader_id
):
...
...
@@ -210,7 +218,7 @@ def save_grade(request, course_id):
error: if there was an error in the submission, this is the error message
"""
_check_post
(
request
)
required
=
set
([
'location'
,
'submission_id'
,
'submission_key'
,
'score'
,
'feedback'
])
required
=
set
([
'location'
,
'submission_id'
,
'submission_key'
,
'score'
,
'feedback'
,
'rubric_scores[]'
])
success
,
message
=
_check_required
(
request
,
required
)
if
not
success
:
return
_err_response
(
message
)
...
...
@@ -221,9 +229,10 @@ def save_grade(request, course_id):
score
=
p
[
'score'
]
feedback
=
p
[
'feedback'
]
submission_key
=
p
[
'submission_key'
]
rubric_scores
=
p
.
getlist
(
'rubric_scores[]'
)
try
:
response
=
peer_grading_service
()
.
save_grade
(
location
,
grader_id
,
submission_id
,
score
,
feedback
,
submission_key
)
score
,
feedback
,
submission_key
,
rubric_scores
)
return
HttpResponse
(
response
,
mimetype
=
"application/json"
)
except
GradingServiceError
:
log
.
exception
(
"""Error saving grade. server url: {0}, location: {1}, submission_id:{2},
...
...
@@ -308,19 +317,7 @@ def show_calibration_essay(request, course_id):
location
=
p
[
'location'
]
try
:
response
=
peer_grading_service
()
.
show_calibration_essay
(
location
,
grader_id
)
response_json
=
json
.
loads
(
response
)
# if we can't handle the rubric
if
response_json
.
has_key
(
'rubric'
):
rubric
=
response_json
[
'rubric'
]
rubric_renderer
=
CombinedOpenEndedRubric
(
False
)
success
,
rubric_html
=
rubric_renderer
.
render_rubric
(
rubric
)
if
not
success
:
error_message
=
"Could not render rubric: {0}"
.
format
(
rubric
)
log
.
exception
(
error_message
)
return
json
.
dumps
({
'success'
:
False
,
'error'
:
error_message
})
response_json
[
'rubric'
]
=
rubric_html
return
json
.
dumps
(
response_json
)
return
HttpResponse
(
response
,
mimetype
=
"application/json"
)
except
GradingServiceError
:
log
.
exception
(
"Error from grading service. server url: {0}, location: {0}"
.
format
(
peer_grading_service
()
.
url
,
location
))
...
...
@@ -353,7 +350,7 @@ def save_calibration_essay(request, course_id):
"""
_check_post
(
request
)
required
=
set
([
'location'
,
'submission_id'
,
'submission_key'
,
'score'
,
'feedback'
])
required
=
set
([
'location'
,
'submission_id'
,
'submission_key'
,
'score'
,
'feedback'
,
'rubric_scores[]'
])
success
,
message
=
_check_required
(
request
,
required
)
if
not
success
:
return
_err_response
(
message
)
...
...
@@ -364,9 +361,11 @@ def save_calibration_essay(request, course_id):
submission_key
=
p
[
'submission_key'
]
score
=
p
[
'score'
]
feedback
=
p
[
'feedback'
]
rubric_scores
=
p
.
getlist
(
'rubric_scores[]'
)
try
:
response
=
peer_grading_service
()
.
save_calibration_essay
(
location
,
grader_id
,
calibration_essay_id
,
submission_key
,
score
,
feedback
)
response
=
peer_grading_service
()
.
save_calibration_essay
(
location
,
grader_id
,
calibration_essay_id
,
submission_key
,
score
,
feedback
,
rubric_scores
)
return
HttpResponse
(
response
,
mimetype
=
"application/json"
)
except
GradingServiceError
:
log
.
exception
(
"Error saving calibration grade, location: {0}, submission_id: {1}, submission_key: {2}, grader_id: {3}"
.
format
(
location
,
submission_id
,
submission_key
,
grader_id
))
...
...
lms/djangoapps/open_ended_grading/staff_grading_service.py
View file @
3d2ae66c
...
...
@@ -19,8 +19,6 @@ from xmodule.course_module import CourseDescriptor
from
student.models
import
unique_id_for_user
from
xmodule.x_module
import
ModuleSystem
from
mitxmako.shortcuts
import
render_to_string
from
xmodule.combined_open_ended_rubric
import
CombinedOpenEndedRubric
from
lxml
import
etree
log
=
logging
.
getLogger
(
__name__
)
...
...
@@ -110,9 +108,10 @@ class StaffGradingService(GradingService):
Raises:
GradingServiceError: something went wrong with the connection.
"""
re
turn
self
.
get
(
self
.
get_next_url
,
re
sponse
=
self
.
get
(
self
.
get_next_url
,
params
=
{
'location'
:
location
,
'grader_id'
:
grader_id
})
return
self
.
_render_rubric
(
response
)
def
save_grade
(
self
,
course_id
,
grader_id
,
submission_id
,
score
,
feedback
,
skipped
,
rubric_scores
):
...
...
@@ -260,30 +259,12 @@ def _get_next(course_id, grader_id, location):
Implementation of get_next (also called from save_grade) -- returns a json string
"""
try
:
response
=
staff_grading_service
()
.
get_next
(
course_id
,
location
,
grader_id
)
response_json
=
json
.
loads
(
response
)
if
response_json
.
has_key
(
'rubric'
):
rubric
=
response_json
[
'rubric'
]
rubric_renderer
=
CombinedOpenEndedRubric
(
False
)
success
,
rubric_html
=
rubric_renderer
.
render_rubric
(
rubric
)
if
not
success
:
error_message
=
"Could not render rubric: {0}"
.
format
(
rubric
)
log
.
exception
(
error_message
)
return
json
.
dumps
({
'success'
:
False
,
'error'
:
error_message
})
response_json
[
'rubric'
]
=
rubric_html
return
json
.
dumps
(
response_json
)
return
staff_grading_service
()
.
get_next
(
course_id
,
location
,
grader_id
)
except
GradingServiceError
:
log
.
exception
(
"Error from grading service. server url: {0}"
.
format
(
staff_grading_service
()
.
url
))
return
json
.
dumps
({
'success'
:
False
,
'error'
:
'Could not connect to grading service'
})
# if we can't parse the rubric into HTML,
except
etree
.
XMLSyntaxError
:
log
.
exception
(
"Cannot parse rubric string. Raw string: {0}"
.
format
(
rubric
))
return
json
.
dumps
({
'success'
:
False
,
'error'
:
'Error displaying submission'
})
@expect_json
...
...
lms/static/coffee/src/peer_grading/peer_grading_problem.coffee
View file @
3d2ae66c
...
...
@@ -194,7 +194,7 @@ class PeerGradingProblem
@
score_selection_container
=
$
(
'.score-selection-container'
)
@
rubric_selection_container
=
$
(
'.rubric-selection-container'
)
@
scor
e
=
null
@
grad
e
=
null
@
calibration
=
null
@
submit_button
=
$
(
'.submit-button'
)
...
...
@@ -415,10 +415,10 @@ class PeerGradingProblem
# display correct grade
@
calibration_feedback_panel
.
slideDown
()
calibration_wrapper
=
$
(
'.calibration-feedback-wrapper'
)
calibration_wrapper
.
html
(
"<p>The score you gave was:
#{
@
scor
e
}
. The actual score is:
#{
response
.
actual_score
}
</p>"
)
calibration_wrapper
.
html
(
"<p>The score you gave was:
#{
@
grad
e
}
. The actual score is:
#{
response
.
actual_score
}
</p>"
)
score
=
parseInt
(
@
scor
e
)
score
=
parseInt
(
@
grad
e
)
actual_score
=
parseInt
(
response
.
actual_score
)
if
score
==
actual_score
...
...
lms/static/coffee/src/staff_grading/staff_grading.coffee
View file @
3d2ae66c
...
...
@@ -357,7 +357,6 @@ class StaffGrading
@
state
==
state_no_data
)
@
prompt_wrapper
.
toggle
(
show_grading_elements
)
@
submission_wrapper
.
toggle
(
show_grading_elements
)
@
rubric_wrapper
.
toggle
(
show_grading_elements
)
@
grading_wrapper
.
toggle
(
show_grading_elements
)
@
meta_info_wrapper
.
toggle
(
show_grading_elements
)
@
action_button
.
hide
()
...
...
lms/templates/peer_grading/peer_grading_problem.html
View file @
3d2ae66c
...
...
@@ -44,8 +44,8 @@
</div>
<div
class=
"prompt-wrapper"
>
<h2>
Question
</h2>
<div
class=
"prompt-information-container"
>
<header>
Question
</header>
<section>
<div
class=
"prompt-container"
>
</div>
...
...
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