Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
edx-ora2
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-ora2
Commits
867d9373
Commit
867d9373
authored
Feb 20, 2014
by
Stephen Sanchez
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Renaming everything with an appended _block, and some cleanup
parent
f693bc1f
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
102 additions
and
86 deletions
+102
-86
apps/openassessment/xblock/assessment_block.py
+5
-2
apps/openassessment/xblock/grade_block.py
+0
-0
apps/openassessment/xblock/openassessmentblock.py
+14
-64
apps/openassessment/xblock/peer_assessment_block.py
+20
-4
apps/openassessment/xblock/scenario_parser.py
+4
-4
apps/openassessment/xblock/self_assessment_block.py
+5
-4
apps/openassessment/xblock/static/html/oa_base.html
+1
-6
apps/openassessment/xblock/static/js/src/oa_base.js
+0
-0
apps/openassessment/xblock/submission.py
+0
-1
apps/openassessment/xblock/submission_block.py
+43
-0
apps/openassessment/xblock/test/test_openassessment.py
+2
-1
apps/openassessment/xblock/utils.py
+8
-0
No files found.
apps/openassessment/xblock/assessment.py
→
apps/openassessment/xblock/assessment
_block
.py
View file @
867d9373
class
Assessment
(
object
):
class
Assessment
Block
(
object
):
assessment_type
=
None
assessment_type
=
None
name
=
''
name
=
''
start_datetime
=
None
start_datetime
=
None
...
@@ -7,6 +7,7 @@ class Assessment(object):
...
@@ -7,6 +7,7 @@ class Assessment(object):
must_be_graded_by
=
0
must_be_graded_by
=
0
navigation_text
=
""
navigation_text
=
""
path
=
""
path
=
""
title
=
""
def
create_ui_model
(
self
):
def
create_ui_model
(
self
):
return
{
return
{
...
@@ -17,5 +18,6 @@ class Assessment(object):
...
@@ -17,5 +18,6 @@ class Assessment(object):
"must_grade"
:
self
.
must_grade
,
"must_grade"
:
self
.
must_grade
,
"must_be_graded_by"
:
self
.
must_be_graded_by
,
"must_be_graded_by"
:
self
.
must_be_graded_by
,
"navigation_text"
:
self
.
navigation_text
,
"navigation_text"
:
self
.
navigation_text
,
"path"
:
self
.
path
"path"
:
self
.
path
,
"title"
:
self
.
title
}
}
\ No newline at end of file
apps/openassessment/xblock/grade.py
→
apps/openassessment/xblock/grade
_block
.py
View file @
867d9373
File moved
apps/openassessment/xblock/openassessmentblock.py
View file @
867d9373
"""An XBlock where students can read a question and compose their response"""
"""An XBlock where students can read a question and compose their response"""
from
django.template.context
import
Context
import
datetime
import
pkg_resources
from
django.template.context
import
Context
from
django.template.loader
import
get_template
from
django.template.loader
import
get_template
import
datetime
from
xblock.core
import
XBlock
from
xblock.core
import
XBlock
from
xblock.fields
import
List
,
Scope
,
String
from
xblock.fields
import
List
,
Scope
,
String
from
xblock.fragment
import
Fragment
from
xblock.fragment
import
Fragment
from
openassessment.xblock.peer_assessment
import
PeerAssessment
from
openassessment.xblock.peer_assessment
_block
import
PeerAssessmentBlock
from
submissions.api
import
SubmissionRequestError
from
openassessment.xblock.submission_block
import
SubmissionBlock
from
submissions
import
api
from
openassessment.xblock.utils
import
load
from
scenario_parser
import
ScenarioParser
from
scenario_parser
import
ScenarioParser
...
@@ -112,7 +110,7 @@ DEFAULT_RUBRIC_CRITERIA = [
...
@@ -112,7 +110,7 @@ DEFAULT_RUBRIC_CRITERIA = [
}
}
]
]
DEFAULT_PEER_ASSESSMENT
=
PeerAssessment
()
DEFAULT_PEER_ASSESSMENT
=
PeerAssessment
Block
()
DEFAULT_PEER_ASSESSMENT
.
name
=
"peer-assessment"
DEFAULT_PEER_ASSESSMENT
.
name
=
"peer-assessment"
DEFAULT_PEER_ASSESSMENT
.
start_datetime
=
datetime
.
datetime
.
now
()
.
isoformat
()
DEFAULT_PEER_ASSESSMENT
.
start_datetime
=
datetime
.
datetime
.
now
()
.
isoformat
()
DEFAULT_PEER_ASSESSMENT
.
must_grade
=
5
DEFAULT_PEER_ASSESSMENT
.
must_grade
=
5
...
@@ -123,12 +121,6 @@ DEFAULT_ASSESSMENT_MODULES = [
...
@@ -123,12 +121,6 @@ DEFAULT_ASSESSMENT_MODULES = [
]
]
def
load
(
path
):
"""Handy helper for getting resources from our kit."""
data
=
pkg_resources
.
resource_string
(
__name__
,
path
)
return
data
.
decode
(
"utf8"
)
class
OpenAssessmentBlock
(
XBlock
):
class
OpenAssessmentBlock
(
XBlock
):
"""Displays a question and gives an area where students can compose a response."""
"""Displays a question and gives an area where students can compose a response."""
...
@@ -179,13 +171,6 @@ class OpenAssessmentBlock(XBlock):
...
@@ -179,13 +171,6 @@ class OpenAssessmentBlock(XBlock):
help
=
"The course_id associated with this prompt (until we can get it from runtime)."
,
help
=
"The course_id associated with this prompt (until we can get it from runtime)."
,
)
)
submit_errors
=
{
# Reported to user sometimes, and useful in tests
'ENOSUB'
:
'API submission is unrequested'
,
'ENODATA'
:
'API returned an empty response'
,
'EBADFORM'
:
'API Submission Request Error'
,
'EUNKNOWN'
:
'API returned unclassified exception'
,
}
def
_get_xblock_trace
(
self
):
def
_get_xblock_trace
(
self
):
"""Uniquely identify this xblock by context.
"""Uniquely identify this xblock by context.
...
@@ -231,29 +216,12 @@ class OpenAssessmentBlock(XBlock):
...
@@ -231,29 +216,12 @@ class OpenAssessmentBlock(XBlock):
"grade_state"
:
grade_state
,
"grade_state"
:
grade_state
,
}
}
try
:
template
=
get_template
(
"static/html/oa_base.html"
)
previous_submissions
=
api
.
get_submissions
(
student_item_dict
)
context
=
Context
(
context_dict
)
except
SubmissionRequestError
:
frag
=
Fragment
(
template
.
render
(
context
))
previous_submissions
=
[]
frag
.
add_css
(
load
(
"static/css/openassessment.css"
))
frag
.
add_javascript
(
load
(
"static/js/src/oa_base.js"
))
peer_module
=
self
.
_get_assessment_module
(
'peer-assessment'
)
frag
.
initialize_js
(
'OpenAssessmentBlock'
)
peer_assessment
=
peer_module
.
get_peer_submission
(
student_item_dict
)
if
previous_submissions
and
peer_assessment
:
# XXX: until workflow better, move on w/ prev submit
template
=
get_template
(
"static/html/oa_base.html"
)
context
=
Context
(
context_dict
)
frag
=
Fragment
(
template
.
render
(
context
))
frag
.
add_css
(
load
(
"static/css/openassessment.css"
))
frag
.
add_javascript
(
load
(
"static/js/src/oa_assessment.js"
))
frag
.
initialize_js
(
'OpenAssessmentBlock'
)
elif
previous_submissions
:
return
Fragment
(
u"<div>There are no submissions to review.</div>"
)
else
:
# XXX: until workflow better, submit until submitted
template
=
get_template
(
"static/html/oa_base.html"
)
context
=
Context
(
context_dict
)
frag
=
Fragment
(
template
.
render
(
context
))
frag
.
add_css
(
load
(
"static/css/openassessment.css"
))
frag
.
add_javascript
(
load
(
"static/js/src/oa_submission.js"
))
frag
.
initialize_js
(
'OpenAssessmentBlock'
)
return
frag
return
frag
@XBlock.json_handler
@XBlock.json_handler
...
@@ -279,26 +247,7 @@ class OpenAssessmentBlock(XBlock):
...
@@ -279,26 +247,7 @@ class OpenAssessmentBlock(XBlock):
"""
"""
Place the submission text into Openassessment system
Place the submission text into Openassessment system
"""
"""
status
=
False
return
SubmissionBlock
()
.
submit
(
self
.
_get_student_item_dict
(),
data
)
status_tag
=
'ENOSUB'
status_text
=
None
student_sub
=
data
[
'submission'
]
student_item_dict
=
self
.
_get_student_item_dict
()
try
:
status_tag
=
'ENODATA'
response
=
api
.
create_submission
(
student_item_dict
,
student_sub
)
if
response
:
status
=
True
status_tag
=
response
.
get
(
'student_item'
)
status_text
=
response
.
get
(
'attempt_number'
)
except
api
.
SubmissionRequestError
,
e
:
status_tag
=
'EBADFORM'
status_text
=
unicode
(
e
.
field_errors
)
except
api
.
SubmissionError
:
status_tag
=
'EUNKNOWN'
# relies on success being orthogonal to errors
status_text
=
status_text
if
status_text
else
self
.
submit_errors
[
status_tag
]
return
status
,
status_tag
,
status_text
@staticmethod
@staticmethod
def
workbench_scenarios
():
def
workbench_scenarios
():
...
@@ -328,6 +277,7 @@ class OpenAssessmentBlock(XBlock):
...
@@ -328,6 +277,7 @@ class OpenAssessmentBlock(XBlock):
sparser
=
ScenarioParser
(
block
,
node
,
unknown_handler
)
sparser
=
ScenarioParser
(
block
,
node
,
unknown_handler
)
block
=
sparser
.
parse
()
block
=
sparser
.
parse
()
block
.
rubric_assessments
.
insert
(
0
,
SubmissionBlock
())
return
block
return
block
def
_get_grade_state
(
self
):
def
_get_grade_state
(
self
):
...
...
apps/openassessment/xblock/peer_assessment.py
→
apps/openassessment/xblock/peer_assessment
_block
.py
View file @
867d9373
from
django.template
import
Context
from
django.template.loader
import
get_template
from
xblock.fragment
import
Fragment
from
openassessment.peer
import
api
as
peer_api
from
openassessment.peer
import
api
as
peer_api
from
openassessment.peer.api
import
PeerAssessmentWorkflowError
from
openassessment.peer.api
import
PeerAssessmentWorkflowError
from
openassessment.xblock.assessment
import
Assessment
from
openassessment.xblock.assessment_block
import
AssessmentBlock
from
openassessment.xblock.utils
import
load
class
PeerAssessment
(
Assessment
):
class
PeerAssessment
Block
(
AssessmentBlock
):
assessment_type
=
"peer-assessment"
assessment_type
=
"peer-assessment"
title
=
"Assess Peers' Responses"
navigation_text
=
"Your assessment(s) of peer responses"
navigation_text
=
"Your assessment(s) of peer responses"
path
=
"static/html/oa_peer_assessment.html"
path
=
"static/html/oa_peer_assessment.html"
...
@@ -48,4 +55,13 @@ class PeerAssessment(Assessment):
...
@@ -48,4 +55,13 @@ class PeerAssessment(Assessment):
except
PeerAssessmentWorkflowError
:
except
PeerAssessmentWorkflowError
:
# TODO: Log?
# TODO: Log?
pass
pass
return
peer_submission
return
peer_submission
\ No newline at end of file
def
render
(
self
,
context_dict
):
template
=
get_template
(
"static/html/oa_peer_assessment.html"
)
context
=
Context
(
context_dict
)
frag
=
Fragment
(
template
.
render
(
context
))
frag
.
add_css
(
load
(
"static/css/openassessment.css"
))
frag
.
add_javascript
(
load
(
"static/js/src/oa_assessment.js"
))
frag
.
initialize_js
(
'PeerAssessment'
)
return
frag
\ No newline at end of file
apps/openassessment/xblock/scenario_parser.py
View file @
867d9373
# -*- coding: utf-8 -*-
# -*- coding: utf-8 -*-
"""XBlock scenario parsing routines"""
"""XBlock scenario parsing routines"""
from
openassessment.xblock.peer_assessment
import
PeerAssessment
from
openassessment.xblock.peer_assessment
_block
import
PeerAssessmentBlock
from
openassessment.xblock.self_assessment
import
SelfAssessment
from
openassessment.xblock.self_assessment
_block
import
SelfAssessmentBlock
class
ScenarioParser
(
object
):
class
ScenarioParser
(
object
):
...
@@ -81,11 +81,11 @@ class ScenarioParser(object):
...
@@ -81,11 +81,11 @@ class ScenarioParser(object):
assessment
=
None
assessment
=
None
assessment_type
=
asmnt
.
tag
assessment_type
=
asmnt
.
tag
if
'peer-assessment'
==
assessment_type
:
if
'peer-assessment'
==
assessment_type
:
assessment
=
PeerAssessment
()
assessment
=
PeerAssessment
Block
()
assessment
.
must_grade
=
int
(
asmnt
.
attrib
.
get
(
'must_grade'
,
1
))
assessment
.
must_grade
=
int
(
asmnt
.
attrib
.
get
(
'must_grade'
,
1
))
assessment
.
must_be_graded_by
=
int
(
asmnt
.
attrib
.
get
(
'must_be_graded_by'
,
0
))
assessment
.
must_be_graded_by
=
int
(
asmnt
.
attrib
.
get
(
'must_be_graded_by'
,
0
))
elif
'self-assessment'
==
assessment_type
:
elif
'self-assessment'
==
assessment_type
:
assessment
=
SelfAssessment
()
assessment
=
SelfAssessment
Block
()
if
assessment
:
if
assessment
:
assessment
.
name
=
asmnt
.
attrib
.
get
(
'name'
,
''
)
assessment
.
name
=
asmnt
.
attrib
.
get
(
'name'
,
''
)
...
...
apps/openassessment/xblock/self_assessment.py
→
apps/openassessment/xblock/self_assessment
_block
.py
View file @
867d9373
from
openassessment.xblock.assessment
import
Assessment
from
openassessment.xblock.assessment
_block
import
AssessmentBlock
class
SelfAssessment
(
Assessment
):
class
SelfAssessment
Block
(
AssessmentBlock
):
assessment_type
=
"self-assessment"
assessment_type
=
"self-assessment"
navigation_text
=
"Your assessment of your response"
navigation_text
=
"Your assessment of your response"
path
=
"static/html/oa_self_assessment.html"
path
=
"static/html/oa_self_assessment.html"
\ No newline at end of file
title
=
"Assess Your Response"
\ No newline at end of file
apps/openassessment/xblock/static/html/oa_base.html
View file @
867d9373
...
@@ -32,9 +32,6 @@
...
@@ -32,9 +32,6 @@
<h2
class=
"title"
>
Skip to a part of this problem:
</h2>
<h2
class=
"title"
>
Skip to a part of this problem:
</h2>
<ol
class=
"list list--nav"
>
<ol
class=
"list list--nav"
>
<li
class=
"list--nav__item"
>
<a
class=
"action"
href=
"#openassessment__response"
>
Your response to this problem
</a>
</li>
{% for assessment in rubric_assessments %}
{% for assessment in rubric_assessments %}
<li
class=
"list--nav__item"
>
<li
class=
"list--nav__item"
>
<a
class=
"action"
href=
"#openassessment__{{ assessment.type }}"
>
{{ assessment.navigation_text }}
</a>
<a
class=
"action"
href=
"#openassessment__{{ assessment.type }}"
>
{{ assessment.navigation_text }}
</a>
...
@@ -71,10 +68,8 @@
...
@@ -71,10 +68,8 @@
<ol
class=
"openassessment__steps"
id=
"openassessment__steps"
>
<ol
class=
"openassessment__steps"
id=
"openassessment__steps"
>
<!-- STEP: response -->
<!-- STEP: response -->
{% include "static/html/oa_response.html" %}
{% for assessment in rubric_assessments %}
{% for assessment in rubric_assessments %}
{% include assessment.path %}
<li
id=
"{{ assessment.name }}"
>
{{ assessment.title }}
</li>
{% endfor %}
{% endfor %}
</ol>
</ol>
...
...
apps/openassessment/xblock/static/js/src/oa_
submission
.js
→
apps/openassessment/xblock/static/js/src/oa_
base
.js
View file @
867d9373
File moved
apps/openassessment/xblock/submission.py
deleted
100644 → 0
View file @
f693bc1f
__author__
=
'stephensanchez'
apps/openassessment/xblock/submission_block.py
0 → 100644
View file @
867d9373
from
openassessment.xblock.assessment_block
import
AssessmentBlock
from
submissions
import
api
class
SubmissionBlock
(
AssessmentBlock
):
assessment_type
=
"submission"
name
=
"submission"
navigation_text
=
"Your response to this problem"
path
=
"static/html/oa_response.html"
title
=
"Your Response"
submit_errors
=
{
# Reported to user sometimes, and useful in tests
'ENOSUB'
:
'API submission is unrequested'
,
'ENODATA'
:
'API returned an empty response'
,
'EBADFORM'
:
'API Submission Request Error'
,
'EUNKNOWN'
:
'API returned unclassified exception'
,
}
def
submit
(
self
,
student_item_dict
,
data
):
"""
Place the submission text into Openassessment system
"""
status
=
False
status_text
=
None
student_sub
=
data
[
'submission'
]
try
:
status_tag
=
'ENODATA'
response
=
api
.
create_submission
(
student_item_dict
,
student_sub
)
if
response
:
status
=
True
status_tag
=
response
.
get
(
'student_item'
)
status_text
=
response
.
get
(
'attempt_number'
)
except
api
.
SubmissionRequestError
,
e
:
status_tag
=
'EBADFORM'
status_text
=
unicode
(
e
.
field_errors
)
except
api
.
SubmissionError
:
status_tag
=
'EUNKNOWN'
# relies on success being orthogonal to errors
status_text
=
status_text
if
status_text
else
self
.
submit_errors
[
status_tag
]
return
status
,
status_tag
,
status_text
\ No newline at end of file
apps/openassessment/xblock/test/test_openassessment.py
View file @
867d9373
...
@@ -7,6 +7,7 @@ import webob
...
@@ -7,6 +7,7 @@ import webob
from
django.test
import
TestCase
from
django.test
import
TestCase
from
mock
import
patch
from
mock
import
patch
from
openassessment.xblock.submission_block
import
SubmissionBlock
from
submissions
import
api
from
submissions
import
api
from
submissions.api
import
SubmissionRequestError
,
SubmissionInternalError
from
submissions.api
import
SubmissionRequestError
,
SubmissionInternalError
...
@@ -97,7 +98,7 @@ class TestOpenAssessment(TestCase):
...
@@ -97,7 +98,7 @@ class TestOpenAssessment(TestCase):
result
=
json
.
loads
(
resp
.
body
)
result
=
json
.
loads
(
resp
.
body
)
self
.
assertFalse
(
result
[
0
])
self
.
assertFalse
(
result
[
0
])
self
.
assertEqual
(
result
[
1
],
"EUNKNOWN"
)
self
.
assertEqual
(
result
[
1
],
"EUNKNOWN"
)
self
.
assertEqual
(
result
[
2
],
self
.
assessment
.
submit_errors
[
"EUNKNOWN"
])
self
.
assertEqual
(
result
[
2
],
SubmissionBlock
()
.
submit_errors
[
"EUNKNOWN"
])
@patch.object
(
api
,
'create_submission'
)
@patch.object
(
api
,
'create_submission'
)
def
test_submission_API_failure
(
self
,
mock_submit
):
def
test_submission_API_failure
(
self
,
mock_submit
):
...
...
apps/openassessment/xblock/utils.py
0 → 100644
View file @
867d9373
import
pkg_resources
def
load
(
path
):
"""Handy helper for getting resources from our kit."""
data
=
pkg_resources
.
resource_string
(
__name__
,
path
)
return
data
.
decode
(
"utf8"
)
\ 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