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
449ddde1
Commit
449ddde1
authored
Mar 26, 2014
by
Stephen Sanchez
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Changing is_open to is_closed. We're negative like that.
parent
c2509762
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
74 additions
and
75 deletions
+74
-75
apps/openassessment/xblock/openassessmentblock.py
+16
-16
apps/openassessment/xblock/peer_assessment_mixin.py
+9
-8
apps/openassessment/xblock/self_assessment_mixin.py
+4
-4
apps/openassessment/xblock/submission_mixin.py
+2
-4
apps/openassessment/xblock/test/test_openassessment.py
+43
-43
No files found.
apps/openassessment/xblock/openassessmentblock.py
View file @
449ddde1
...
...
@@ -418,12 +418,12 @@ class OpenAssessmentBlock(
template
=
get_template
(
'openassessmentblock/oa_error.html'
)
return
Response
(
template
.
render
(
context
),
content_type
=
'application/html'
,
charset
=
'UTF-8'
)
def
is_
open
(
self
,
step
=
None
):
def
is_
closed
(
self
,
step
=
None
):
"""
Checks if the question is
open
.
Checks if the question is
closed
.
Determines if the start date
has occurred and the end date has not
passed. Optionally limited to a particular step in the workflow.
Determines if the start date
is in the future or the end date has
passed. Optionally limited to a particular step in the workflow.
Kwargs:
step (str): The step in the workflow to check. Options are:
...
...
@@ -433,17 +433,17 @@ class OpenAssessmentBlock(
"self-assessment": check whether the self-assessment section is open.
Returns:
(tuple): True if the question is
open, False if not. If Fals
e,
(tuple): True if the question is
closed, False if not. If Tru
e,
specifies if the "start" date or "due" date is the closing
factor.
Examples:
>>> is_
open
()
Tru
e, None
>>> is_
open
(step="submission")
Fals
e, "due"
>>> is_
open
(step="self-assessment")
Fals
e, "start"
>>> is_
closed
()
Fals
e, None
>>> is_
closed
(step="submission")
Tru
e, "due"
>>> is_
closed
(step="self-assessment")
Tru
e, "start"
"""
submission_range
=
(
self
.
start
,
self
.
submission_due
)
...
...
@@ -470,11 +470,11 @@ class OpenAssessmentBlock(
now
=
dt
.
datetime
.
now
()
.
replace
(
tzinfo
=
pytz
.
utc
)
if
now
<
open_range
[
0
]:
return
Fals
e
,
"start"
return
Tru
e
,
"start"
elif
now
>=
open_range
[
1
]:
return
Fals
e
,
"due"
return
Tru
e
,
"due"
else
:
return
Tru
e
,
None
return
Fals
e
,
None
def
is_released
(
self
,
step
=
None
):
"""
...
...
@@ -492,8 +492,8 @@ class OpenAssessmentBlock(
"""
# By default, assume that we're published, in case the runtime doesn't support publish date.
is_published
=
getattr
(
self
,
'published_date'
,
True
)
is
not
None
is_
open
,
reason
=
self
.
is_open
(
step
=
step
)
return
is_published
and
(
is_open
or
reason
==
'due'
)
is_
closed
,
reason
=
self
.
is_closed
(
step
=
step
)
return
is_published
and
(
not
is_closed
or
reason
==
'due'
)
def
get_assessment_module
(
self
,
mixin_name
):
"""
...
...
apps/openassessment/xblock/peer_assessment_mixin.py
View file @
449ddde1
...
...
@@ -112,14 +112,13 @@ class PeerAssessmentMixin(object):
path
=
'openassessmentblock/peer/oa_peer_unavailable.html'
finished
=
False
problem_
open
,
date
=
self
.
is_open
(
step
=
"peer-assessment"
)
problem_
closed
,
date
=
self
.
is_closed
(
step
=
"peer-assessment"
)
context_dict
=
{
"rubric_criteria"
:
self
.
rubric_criteria
,
"estimated_time"
:
"20 minutes"
# TODO: Need to configure this.
}
submissions_open
,
__
=
self
.
is_open
(
step
=
"submission"
)
over_grading
=
not
submissions_open
submissions_closed
,
__
=
self
.
is_closed
(
step
=
"submission"
)
workflow
=
self
.
get_workflow_info
()
if
workflow
is
None
:
...
...
@@ -127,7 +126,7 @@ class PeerAssessmentMixin(object):
continue_grading
=
(
data
.
params
.
get
(
'continue_grading'
,
False
)
and
workflow
[
"status_details"
][
"peer"
][
"complete"
]
and
over_grading
and
submissions_closed
)
student_item
=
self
.
get_student_item_dict
()
...
...
@@ -157,14 +156,15 @@ class PeerAssessmentMixin(object):
if
assessment
.
get
(
'due'
):
context_dict
[
"peer_due"
]
=
self
.
format_datetime_string
(
assessment
[
"due"
])
if
date
==
'due'
and
not
problem_open
:
if
date
==
"due"
and
problem_closed
:
path
=
'openassessmentblock/peer/oa_peer_closed.html'
elif
date
==
'start'
and
not
problem_open
:
elif
date
==
'start'
and
problem_closed
:
if
assessment
.
get
(
'start'
):
context_dict
[
"peer_start"
]
=
self
.
format_datetime_string
(
assessment
[
"start"
])
path
=
'openassessmentblock/peer/oa_peer_unavailable.html'
elif
workflow
.
get
(
"status"
)
==
"peer"
:
peer_sub
=
self
.
get_peer_submission
(
student_item
,
assessment
,
over_grading
)
peer_sub
=
self
.
get_peer_submission
(
student_item
,
assessment
,
submissions_closed
)
if
peer_sub
:
path
=
'openassessmentblock/peer/oa_peer_assessment.html'
context_dict
[
"peer_submission"
]
=
peer_sub
...
...
@@ -186,8 +186,9 @@ class PeerAssessmentMixin(object):
self
,
student_item_dict
,
assessment
,
over_grading
=
False
over_grading
):
submissions_closed
,
__
=
self
.
is_closed
(
step
=
"submission"
)
peer_submission
=
False
try
:
peer_submission
=
peer_api
.
get_submission_to_assess
(
...
...
apps/openassessment/xblock/self_assessment_mixin.py
View file @
449ddde1
...
...
@@ -28,10 +28,10 @@ class SelfAssessmentMixin(object):
assessment_module
=
self
.
get_assessment_module
(
'self-assessment'
)
path
=
'openassessmentblock/self/oa_self_unavailable.html'
problem_
open
,
date
=
self
.
is_open
(
step
=
"self-assessment"
)
problem_
closed
,
date
=
self
.
is_closed
(
step
=
"self-assessment"
)
due_date
=
assessment_module
.
get
(
'due'
)
if
date
==
'start'
and
not
problem_open
:
if
date
==
'start'
and
problem_closed
:
context
[
"self_start"
]
=
self
.
format_datetime_string
(
assessment_module
[
"start"
])
elif
due_date
:
context
[
"self_due"
]
=
self
.
format_datetime_string
(
assessment_module
[
"due"
])
...
...
@@ -60,7 +60,7 @@ class SelfAssessmentMixin(object):
}
elif
assessment
is
not
None
:
path
=
'openassessmentblock/self/oa_self_complete.html'
elif
date
==
'due'
and
not
problem_open
:
elif
date
==
"due"
and
problem_closed
:
path
=
'openassessmentblock/self/oa_self_closed.html'
return
self
.
render_assessment
(
path
,
context
)
...
...
apps/openassessment/xblock/submission_mixin.py
View file @
449ddde1
import
copy
import
dateutil
import
logging
...
...
@@ -6,7 +5,6 @@ from django.utils.translation import ugettext as _
from
xblock.core
import
XBlock
from
submissions
import
api
from
openassessment.assessment
import
peer_api
from
openassessment.workflow
import
api
as
workflow_api
...
...
@@ -177,7 +175,7 @@ class SubmissionMixin(object):
"""
workflow
=
self
.
get_workflow_info
()
problem_
open
,
date
=
self
.
is_open
(
'submission'
)
problem_
closed
,
date
=
self
.
is_closed
(
'submission'
)
sub_due
=
None
if
self
.
submission_due
is
not
None
:
submission_deadline
=
dateutil
.
parser
.
parse
(
self
.
submission_due
)
...
...
@@ -189,7 +187,7 @@ class SubmissionMixin(object):
"submission_due"
:
sub_due
,
}
if
not
workflow
and
not
problem_open
:
if
not
workflow
and
problem_closed
:
path
=
'openassessmentblock/response/oa_response_closed.html'
elif
not
workflow
:
path
=
"openassessmentblock/response/oa_response.html"
...
...
apps/openassessment/xblock/test/test_openassessment.py
View file @
449ddde1
...
...
@@ -146,31 +146,31 @@ class TestDates(XBlockHandlerTestCase):
xblock
.
start
=
dt
.
datetime
(
2014
,
3
,
1
)
.
replace
(
tzinfo
=
pytz
.
utc
)
.
isoformat
()
xblock
.
due
=
dt
.
datetime
(
2014
,
3
,
5
)
.
replace
(
tzinfo
=
pytz
.
utc
)
.
isoformat
()
self
.
assert_is_
open
(
self
.
assert_is_
closed
(
xblock
,
dt
.
datetime
(
2014
,
2
,
28
,
23
,
59
,
59
),
None
,
Fals
e
,
"start"
,
None
,
Tru
e
,
"start"
,
released
=
False
)
self
.
assert_is_
open
(
self
.
assert_is_
closed
(
xblock
,
dt
.
datetime
(
2014
,
3
,
1
,
1
,
1
,
1
),
None
,
Tru
e
,
None
,
None
,
Fals
e
,
None
,
released
=
True
)
self
.
assert_is_
open
(
self
.
assert_is_
closed
(
xblock
,
dt
.
datetime
(
2014
,
3
,
4
,
23
,
59
,
59
),
None
,
Tru
e
,
None
,
None
,
Fals
e
,
None
,
released
=
True
)
self
.
assert_is_
open
(
self
.
assert_is_
closed
(
xblock
,
dt
.
datetime
(
2014
,
3
,
5
,
1
,
1
,
1
),
None
,
Fals
e
,
"due"
,
None
,
Tru
e
,
"due"
,
released
=
True
)
...
...
@@ -180,31 +180,31 @@ class TestDates(XBlockHandlerTestCase):
xblock
.
start
=
dt
.
datetime
(
2014
,
3
,
1
)
.
replace
(
tzinfo
=
pytz
.
utc
)
.
isoformat
()
xblock
.
due
=
None
self
.
assert_is_
open
(
self
.
assert_is_
closed
(
xblock
,
dt
.
datetime
(
2014
,
2
,
28
,
23
,
59
,
59
)
.
replace
(
tzinfo
=
pytz
.
utc
),
"submission"
,
Fals
e
,
"start"
,
"submission"
,
Tru
e
,
"start"
,
released
=
False
)
self
.
assert_is_
open
(
self
.
assert_is_
closed
(
xblock
,
dt
.
datetime
(
2014
,
3
,
1
,
1
,
1
,
1
)
.
replace
(
tzinfo
=
pytz
.
utc
),
"submission"
,
Tru
e
,
None
,
"submission"
,
Fals
e
,
None
,
released
=
True
)
self
.
assert_is_
open
(
self
.
assert_is_
closed
(
xblock
,
dt
.
datetime
(
2014
,
3
,
31
,
23
,
59
,
59
)
.
replace
(
tzinfo
=
pytz
.
utc
),
"submission"
,
Tru
e
,
None
,
"submission"
,
Fals
e
,
None
,
released
=
True
)
self
.
assert_is_
open
(
self
.
assert_is_
closed
(
xblock
,
dt
.
datetime
(
2014
,
4
,
1
,
1
,
1
,
1
,
1
)
.
replace
(
tzinfo
=
pytz
.
utc
),
"submission"
,
Fals
e
,
"due"
,
"submission"
,
Tru
e
,
"due"
,
released
=
True
)
...
...
@@ -214,31 +214,31 @@ class TestDates(XBlockHandlerTestCase):
xblock
.
start
=
None
xblock
.
due
=
None
self
.
assert_is_
open
(
self
.
assert_is_
closed
(
xblock
,
dt
.
datetime
(
2015
,
1
,
1
,
23
,
59
,
59
)
.
replace
(
tzinfo
=
pytz
.
utc
),
"peer-assessment"
,
Fals
e
,
"start"
,
"peer-assessment"
,
Tru
e
,
"start"
,
released
=
False
)
self
.
assert_is_
open
(
self
.
assert_is_
closed
(
xblock
,
dt
.
datetime
(
2015
,
1
,
2
,
1
,
1
,
1
)
.
replace
(
tzinfo
=
pytz
.
utc
),
"peer-assessment"
,
Tru
e
,
None
,
"peer-assessment"
,
Fals
e
,
None
,
released
=
True
)
self
.
assert_is_
open
(
self
.
assert_is_
closed
(
xblock
,
dt
.
datetime
(
2015
,
3
,
31
,
23
,
59
,
59
)
.
replace
(
tzinfo
=
pytz
.
utc
),
"peer-assessment"
,
Tru
e
,
None
,
"peer-assessment"
,
Fals
e
,
None
,
released
=
True
)
self
.
assert_is_
open
(
self
.
assert_is_
closed
(
xblock
,
dt
.
datetime
(
2015
,
4
,
1
,
1
,
1
,
1
,
1
)
.
replace
(
tzinfo
=
pytz
.
utc
),
"peer-assessment"
,
Fals
e
,
"due"
,
"peer-assessment"
,
Tru
e
,
"due"
,
released
=
True
)
...
...
@@ -248,31 +248,31 @@ class TestDates(XBlockHandlerTestCase):
xblock
.
start
=
None
xblock
.
due
=
None
self
.
assert_is_
open
(
self
.
assert_is_
closed
(
xblock
,
dt
.
datetime
(
2016
,
1
,
1
,
23
,
59
,
59
)
.
replace
(
tzinfo
=
pytz
.
utc
),
"self-assessment"
,
Fals
e
,
"start"
,
"self-assessment"
,
Tru
e
,
"start"
,
released
=
False
)
self
.
assert_is_
open
(
self
.
assert_is_
closed
(
xblock
,
dt
.
datetime
(
2016
,
1
,
2
,
1
,
1
,
1
)
.
replace
(
tzinfo
=
pytz
.
utc
),
"self-assessment"
,
Tru
e
,
None
,
"self-assessment"
,
Fals
e
,
None
,
released
=
True
)
self
.
assert_is_
open
(
self
.
assert_is_
closed
(
xblock
,
dt
.
datetime
(
2016
,
3
,
31
,
23
,
59
,
59
)
.
replace
(
tzinfo
=
pytz
.
utc
),
"self-assessment"
,
Tru
e
,
None
,
"self-assessment"
,
Fals
e
,
None
,
released
=
True
)
self
.
assert_is_
open
(
self
.
assert_is_
closed
(
xblock
,
dt
.
datetime
(
2016
,
4
,
1
,
1
,
1
,
1
,
1
)
.
replace
(
tzinfo
=
pytz
.
utc
),
"self-assessment"
,
Fals
e
,
"due"
,
"self-assessment"
,
Tru
e
,
"due"
,
released
=
True
)
...
...
@@ -284,31 +284,31 @@ class TestDates(XBlockHandlerTestCase):
xblock
.
start
=
dt
.
datetime
(
2014
,
3
,
1
)
.
replace
(
tzinfo
=
pytz
.
utc
)
.
isoformat
()
xblock
.
due
=
None
self
.
assert_is_
open
(
self
.
assert_is_
closed
(
xblock
,
dt
.
datetime
(
2014
,
2
,
28
,
23
,
59
,
59
)
.
replace
(
tzinfo
=
pytz
.
utc
),
"peer-assessment"
,
Fals
e
,
"start"
,
"peer-assessment"
,
Tru
e
,
"start"
,
released
=
False
)
self
.
assert_is_
open
(
self
.
assert_is_
closed
(
xblock
,
dt
.
datetime
(
2014
,
3
,
1
,
1
,
1
,
1
)
.
replace
(
tzinfo
=
pytz
.
utc
),
"peer-assessment"
,
Tru
e
,
None
,
"peer-assessment"
,
Fals
e
,
None
,
released
=
True
)
self
.
assert_is_
open
(
self
.
assert_is_
closed
(
xblock
,
dt
.
datetime
(
2016
,
5
,
1
,
23
,
59
,
59
)
.
replace
(
tzinfo
=
pytz
.
utc
),
"peer-assessment"
,
Tru
e
,
None
,
"peer-assessment"
,
Fals
e
,
None
,
released
=
True
)
self
.
assert_is_
open
(
self
.
assert_is_
closed
(
xblock
,
dt
.
datetime
(
2016
,
5
,
2
,
1
,
1
,
1
)
.
replace
(
tzinfo
=
pytz
.
utc
),
"peer-assessment"
,
Fals
e
,
"due"
,
"peer-assessment"
,
Tru
e
,
"due"
,
released
=
True
)
...
...
@@ -333,7 +333,7 @@ class TestDates(XBlockHandlerTestCase):
# If the runtime doesn't provide a published_date field, assume we've been published
self
.
assertTrue
(
xblock
.
is_released
())
def
assert_is_
open
(
self
,
xblock
,
now
,
step
,
expected_is_open
,
expected_reason
,
released
=
None
):
def
assert_is_
closed
(
self
,
xblock
,
now
,
step
,
expected_is_closed
,
expected_reason
,
released
=
None
):
"""
Assert whether the XBlock step is open/closed.
...
...
@@ -358,8 +358,8 @@ class TestDates(XBlockHandlerTestCase):
self
.
addCleanup
(
datetime_patcher
.
stop
)
mocked_datetime
.
datetime
.
now
.
return_value
=
now
is_
open
,
reason
=
xblock
.
is_open
(
step
=
step
)
self
.
assertEqual
(
is_
open
,
expected_is_open
)
is_
closed
,
reason
=
xblock
.
is_closed
(
step
=
step
)
self
.
assertEqual
(
is_
closed
,
expected_is_closed
)
self
.
assertEqual
(
reason
,
expected_reason
)
if
released
is
not
None
:
...
...
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