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
c89ff2ac
Commit
c89ff2ac
authored
Jan 02, 2013
by
Diana Huang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Basic peer grading view using mocks and some cleanup in
the peer grading service
parent
87370096
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
190 additions
and
44 deletions
+190
-44
lms/djangoapps/open_ended_grading/peer_grading_service.py
+41
-7
lms/djangoapps/open_ended_grading/views.py
+1
-24
lms/static/coffee/src/peer_grading/peer_grading.coffee
+4
-3
lms/static/coffee/src/peer_grading/peer_grading_problem.coffee
+84
-5
lms/templates/peer_grading/peer_grading.html
+1
-1
lms/templates/peer_grading/peer_grading_problem.html
+52
-2
lms/urls.py
+7
-2
No files found.
lms/djangoapps/open_ended_grading/peer_grading_service.py
View file @
c89ff2ac
...
...
@@ -88,18 +88,28 @@ def _err_response(msg):
return
HttpResponse
(
json
.
dumps
({
'success'
:
False
,
'error'
:
msg
}),
mimetype
=
"application/json"
)
def
_check_required
(
request
,
required
):
actual
=
set
(
request
.
POST
.
keys
())
missing
=
required
-
actual
if
len
(
missing
)
>
0
:
return
False
,
"Missing required keys: {0}"
.
format
(
', '
.
join
(
missing
))
else
:
return
True
,
""
def
_check_post
(
request
):
if
request
.
method
!=
'POST'
:
raise
Http404
def
get_next_submission
(
request
,
course_id
):
"""
TODO: fill in this documentation
"""
_check_post
(
request
)
required
=
set
([
'location'
])
if
request
.
method
!=
'POST'
:
raise
Http404
actual
=
set
(
request
.
POST
.
keys
())
missing
=
required
-
actual
if
len
(
missing
)
>
0
:
return
_err_response
(
'Missing required keys {0}'
.
format
(
', '
.
join
(
missing
)))
success
,
message
=
_check_required
(
request
,
required
)
if
not
success
:
return
_err_response
(
message
)
grader_id
=
request
.
user
.
id
p
=
request
.
POST
location
=
p
[
'location'
]
...
...
@@ -119,3 +129,27 @@ def _get_next_submission(course_id, grader_id, location):
return
json
.
dumps
({
'success'
:
False
,
'error'
:
'Could not connect to grading service'
})
def
show_calibration_essay
(
request
,
course_id
):
"""
TODO: fill in this documentation
"""
_check_post
(
request
)
required
=
set
([
'location'
])
success
,
message
=
_check_required
(
request
,
required
)
if
not
success
:
return
_err_response
(
message
)
grader_id
=
request
.
user
.
id
p
=
request
.
POST
location
=
p
[
'location'
]
try
:
response
=
peer_grading_service
()
.
show_calibration_essay
(
location
,
grader_id
)
return
HttpResponse
(
response
,
mimetype
=
"application/json"
)
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'
})
lms/djangoapps/open_ended_grading/views.py
View file @
c89ff2ac
...
...
@@ -106,27 +106,6 @@ def peer_grading_problem(request, course_id, problem_location):
'''
course
=
get_course_with_access
(
request
.
user
,
course_id
,
'load'
)
# TODO: make sure that we show calibration or next submission correctly
# TODO: figure out if we want to make this page pure ajax or not
problem_info_text
=
""
error_text
=
""
# if we are still in calibration
# show a calibration essay
# else, show an actual problem
try
:
problem_info_text
=
peer_gs
.
get_next_submission
(
problem_location
,
request
.
user
.
id
)
log
.
debug
(
problem_info_text
)
problem_info
=
json
.
loads
(
problem_info_text
)
success
=
problem_info
[
'success'
]
if
'error'
in
problem_info
:
error_text
=
problem_info
[
'error'
]
except
GradingServiceError
:
success
=
False
ajax_url
=
reverse
(
'peer_grading'
,
kwargs
=
{
'course_id'
:
course_id
})
if
not
ajax_url
.
endswith
(
'/'
):
ajax_url
+=
'/'
...
...
@@ -134,11 +113,9 @@ def peer_grading_problem(request, course_id, problem_location):
return
render_to_response
(
'peer_grading/peer_grading_problem.html'
,
{
'view_html'
:
''
,
'course'
:
course
,
'problem_location'
:
problem_location
,
'course_id'
:
course_id
,
'success'
:
success
,
'problem_info'
:
problem_info_text
,
'ajax_url'
:
ajax_url
,
'error_text'
:
error_text
,
# Checked above
'staff_access'
:
False
,
})
...
...
lms/static/coffee/src/peer_grading/peer_grading.coffee
View file @
c89ff2ac
class
PeerGrading
constructor
:
(
backend
)
->
@
problem_list
=
$
(
'.problem-list'
)
@
error_container
=
$
(
'.error-container'
)
@
error_container
.
toggle
(
not
@
error_container
.
is
(
':empty'
))
@
message_container
=
$
(
'.message-container'
)
@
message_container
.
toggle
(
not
@
message_container
.
is
(
':empty'
))
backend
=
{}
$
(
document
).
ready
(()
->
new
PeerGrading
(
backend
))
mock_backend
=
false
$
(
document
).
ready
(()
->
new
PeerGrading
(
mock_
backend
))
lms/static/coffee/src/peer_grading/peer_grading_problem.coffee
View file @
c89ff2ac
class
PeerGradingProblemBackend
constructor
:
(
ajax_url
,
mock_backend
)
->
@
mock_backend
=
mock_backend
@
ajax_url
=
ajax_url
post
:
(
cmd
,
data
,
callback
)
->
if
@
mock_backend
callback
(
@
mock
(
cmd
,
data
))
else
# TODO: replace with postWithPrefix when that's loaded
$
.
post
(
@
ajax_url
+
cmd
,
data
,
callback
)
.
error
=>
callback
({
success
:
false
,
error
:
"Error occured while performing this operation"
})
mock
:
(
cmd
,
data
)
->
if
cmd
==
'is_student_calibrated'
# change to test each version
response
=
success
:
true
calibrated
:
false
else
if
cmd
==
'show_calibration_essay'
response
=
success
:
true
submission_id
:
1
submission_key
:
'abcd'
student_response
:
'I am a fake response'
prompt
:
'Answer this question'
rubric
:
'This is a rubric.'
max_score
:
4
return
response
class
PeerGradingProblem
constructor
:
(
backend
)
->
@
prompt_wrapper
=
$
(
'.prompt-wrapper'
)
@
backend
=
backend
# ugly hack to prevent this code from trying to run on the
# general peer grading page
if
(
@
prompt_wrapper
.
length
==
0
)
return
# get the location of the problem
@
location
=
$
(
'.peer-grading'
).
data
(
'location'
)
# get the other elements we want to fill in
@
submission_container
=
$
(
'.submission-container'
)
@
prompt_container
=
$
(
'.prompt-container'
)
@
rubric_container
=
$
(
'.rubric-container'
)
@
error_container
=
$
(
'.error-container'
)
@
render_problem
()
@
is_calibrated_check
()
is_calibrated_check
:
()
=>
@
backend
.
post
(
'is_student_calibrated'
,
{},
@
calibration_check_callback
)
fetch_calibration_essay
:
()
=>
@
backend
.
post
(
'show_calibration_essay'
,
{
location
:
@
location
},
@
render_calibration
)
render_calibration
:
(
response
)
=>
if
response
.
success
#TODO: fill this in
@
submission_container
.
html
(
"<h3>Calibration Essay</h3>"
)
@
submission_container
.
append
(
response
.
student_response
)
@
prompt_container
.
html
(
response
.
prompt
)
@
rubric_container
.
html
(
response
.
rubric
)
else
@
error_container
.
show
()
@
error_container
.
html
(
response
.
error
)
render_submission
:
(
response
)
->
#TODO: fill this in
calibration_check_callback
:
(
response
)
=>
if
response
.
success
# check whether or not we're still calibrating
if
response
.
calibrated
@
fetch_submission
()
@
calibration
=
false
else
@
fetch_calibration_essay
()
@
calibration
=
true
render_problem
:
()
->
# do this when it makes sense
@
error_container
.
toggle
(
not
@
error_container
.
is
(
':empty'
))
backend
=
{}
mock_backend
=
true
ajax_url
=
$
(
'.peer-grading'
).
data
(
'ajax_url'
)
backend
=
new
PeerGradingProblemBackend
(
ajax_url
,
mock_backend
)
$
(
document
).
ready
(()
->
new
PeerGradingProblem
(
backend
))
lms/templates/peer_grading/peer_grading.html
View file @
c89ff2ac
...
...
@@ -19,7 +19,7 @@
<div
class=
"error-container"
>
${error_text}
</div>
<h1>
Peer Grading
</h1>
<h2>
Instructions
</h2>
<p></p>
<p>
Here are a list of problems that need to be peer graded for this course.
</p>
% if success:
<ul
class=
"problem-list"
>
%for problem in problem_list:
...
...
lms/templates/peer_grading/peer_grading_problem.html
View file @
c89ff2ac
...
...
@@ -15,8 +15,58 @@
<
%
static:js
group=
'peer_grading'
/>
</
%
block>
<section
class=
"container"
>
<div
class=
"peer-grading"
data-ajax_url=
"${ajax_url}"
>
<div
class=
"error-container"
>
${error_text}
</div>
<div
class=
"peer-grading"
data-ajax_url=
"${ajax_url}"
location=
"${problem_location}"
>
<div
class=
"error-container"
></div>
<div
class=
"message-container"
></div>
<div
class=
"instructions-panel"
>
<div
class=
"calibration-panel"
>
<h3>
Calibration
</h3>
</div>
<div
class=
"grading-panel"
>
<h3>
Grading
</h3>
</div>
</div>
<section
class=
"prompt-wrapper"
>
<div
class=
"prompt-information-container"
>
<h3>
Question
</h3>
<div
class=
"prompt-container"
>
</div>
</div>
<div
class=
"rubric-wrapper"
>
<h3>
Grading Rubric
</h3>
<div
class=
"rubric-container"
>
</div>
</div>
</section>
<section
class=
"grading-wrapper"
>
<h2>
Grading
</h2>
<div
class=
"grading-container"
>
<div
class=
"submission-wrapper"
>
<h3></h3>
<div
class=
"submission-container"
>
</div>
</div>
<div
class=
"evaluation"
>
<p
class=
"score-selection-container"
>
</p>
<textarea
name=
"feedback"
placeholder=
"Feedback for student (optional)"
class=
"feedback-area"
cols=
"70"
></textarea>
</div>
<div
class=
"submission"
>
<input
type=
"button"
value=
"Submit"
class=
"submit-button"
name=
"show"
/>
</div>
</div>
</div>
</section>
lms/urls.py
View file @
c89ff2ac
...
...
@@ -250,12 +250,17 @@ if settings.COURSEWARE_ENABLED:
'open_ended_grading.staff_grading_service.save_grade'
,
name
=
'staff_grading_save_grade'
),
url
(
r'^courses/(?P<course_id>[^/]+/[^/]+/[^/]+)/staff_grading/get_problem_list$'
,
'open_ended_grading.staff_grading_service.get_problem_list'
,
name
=
'staff_grading_get_problem_list'
),
url
(
r'^courses/(?P<course_id>[^/]+/[^/]+/[^/]+)/peer_grading/get_next_submission$'
,
'open_ended_grading.peer_grading_service.get_next_submission'
,
name
=
'peer_grading_get_next_submission'
),
# Peer Grading
url
(
r'^courses/(?P<course_id>[^/]+/[^/]+/[^/]+)/peer_grading$'
,
'open_ended_grading.views.peer_grading'
,
name
=
'peer_grading'
),
url
(
r'^courses/(?P<course_id>[^/]+/[^/]+/[^/]+)/peer_grading/problem/(?P<problem_location>.*)$'
,
'open_ended_grading.views.peer_grading_problem'
,
name
=
'peer_grading_problem'
),
url
(
r'^courses/(?P<course_id>[^/]+/[^/]+/[^/]+)/peer_grading/get_next_submission$'
,
'open_ended_grading.peer_grading_service.get_next_submission'
,
name
=
'peer_grading_get_next_submission'
),
url
(
r'^courses/(?P<course_id>[^/]+/[^/]+/[^/]+)/peer_grading/show_calibration_essay$'
,
'open_ended_grading.peer_grading_service.show_calibration_essay'
,
name
=
'peer_grading_show_calibration_essay'
),
)
...
...
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