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
764ae02e
Commit
764ae02e
authored
Feb 26, 2014
by
Stephen Sanchez
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Changing the start due date logic to be its own function
parent
a70972d6
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
59 additions
and
9 deletions
+59
-9
apps/openassessment/peer/api.py
+1
-1
apps/openassessment/peer/models.py
+2
-2
apps/openassessment/xblock/openassessmentblock.py
+27
-0
apps/openassessment/xblock/submission_mixin.py
+2
-4
apps/openassessment/xblock/test/test_openassessment.py
+27
-2
No files found.
apps/openassessment/peer/api.py
View file @
764ae02e
...
@@ -245,7 +245,7 @@ def get_assessment_median_scores(submission_id, must_be_graded_by):
...
@@ -245,7 +245,7 @@ def get_assessment_median_scores(submission_id, must_be_graded_by):
# found in an assessment.
# found in an assessment.
try
:
try
:
submission
=
Submission
.
objects
.
get
(
uuid
=
submission_id
)
submission
=
Submission
.
objects
.
get
(
uuid
=
submission_id
)
scores
=
Assessment
.
get_assessment_
scores_by_criterion
(
submission
,
must_be_graded_by
)
scores
=
Assessment
.
scores_by_criterion
(
submission
,
must_be_graded_by
)
return
Assessment
.
get_median_score_dict
(
scores
)
return
Assessment
.
get_median_score_dict
(
scores
)
except
DatabaseError
:
except
DatabaseError
:
error_message
=
(
error_message
=
(
...
...
apps/openassessment/peer/models.py
View file @
764ae02e
...
@@ -273,7 +273,7 @@ class Assessment(models.Model):
...
@@ -273,7 +273,7 @@ class Assessment(models.Model):
return
median_score
return
median_score
@classmethod
@classmethod
def
get_assessment_
scores_by_criterion
(
cls
,
submission
,
must_be_graded_by
):
def
scores_by_criterion
(
cls
,
submission
,
must_be_graded_by
):
"""Create a dictionary of lists for scores associated with criterion
"""Create a dictionary of lists for scores associated with criterion
Create a key value in a dict with a list of values, for every criterion
Create a key value in a dict with a list of values, for every criterion
...
@@ -290,7 +290,7 @@ class Assessment(models.Model):
...
@@ -290,7 +290,7 @@ class Assessment(models.Model):
this score analysis.
this score analysis.
Examples:
Examples:
>>> A
ttribute.get_assessment_
scores_by_criterion(submission, 3)
>>> A
ssessment.
scores_by_criterion(submission, 3)
{
{
"foo": [1, 2, 3],
"foo": [1, 2, 3],
"bar": [6, 7, 8]
"bar": [6, 7, 8]
...
...
apps/openassessment/xblock/openassessmentblock.py
View file @
764ae02e
...
@@ -395,3 +395,30 @@ class OpenAssessmentBlock(XBlock, SubmissionMixin, PeerAssessmentMixin, SelfAsse
...
@@ -395,3 +395,30 @@ class OpenAssessmentBlock(XBlock, SubmissionMixin, PeerAssessmentMixin, SelfAsse
template
=
get_template
(
path
)
template
=
get_template
(
path
)
context
=
Context
(
context_dict
)
context
=
Context
(
context_dict
)
return
Response
(
template
.
render
(
context
),
content_type
=
'application/html'
,
charset
=
'UTF-8'
)
return
Response
(
template
.
render
(
context
),
content_type
=
'application/html'
,
charset
=
'UTF-8'
)
def
is_open
(
self
):
"""Checks if the question is open.
Determines if the start date has occurred and the end date has not
passed.
Returns:
(tuple): True if the question is open, False if not. If False,
specifies if the "start" date or "due" date is the closing
factor.
Examples:
>>> is_open()
False, "due"
"""
# Is the question closed?
if
self
.
start_datetime
:
start
=
datetime
.
datetime
.
strptime
(
self
.
start_datetime
,
TIME_PARSE_FORMAT
)
if
start
>
datetime
.
datetime
.
utcnow
():
return
False
,
"start"
if
self
.
due_datetime
:
due
=
datetime
.
datetime
.
strptime
(
self
.
due_datetime
,
TIME_PARSE_FORMAT
)
if
due
<
datetime
.
datetime
.
utcnow
():
return
False
,
"due"
return
True
,
None
apps/openassessment/xblock/submission_mixin.py
View file @
764ae02e
...
@@ -136,14 +136,12 @@ class SubmissionMixin(object):
...
@@ -136,14 +136,12 @@ class SubmissionMixin(object):
student_item
=
self
.
get_student_item_dict
()
student_item
=
self
.
get_student_item_dict
()
# Has the student submitted?
# Has the student submitted?
student_submission
=
self
.
_get_user_submission
(
student_item
)
student_submission
=
self
.
_get_user_submission
(
student_item
)
# Is the question closed?
due
=
datetime
.
datetime
.
strptime
(
self
.
due_datetime
,
"
%
Y-
%
m-
%
dT
%
H:
%
M:
%
S"
)
# Has it been graded yet?
# Has it been graded yet?
student_score
=
self
.
_get_submission_score
(
student_item
)
student_score
=
self
.
_get_submission_score
(
student_item
)
step_status
=
"Graded"
if
student_score
else
"Submitted"
step_status
=
"Graded"
if
student_score
else
"Submitted"
step_status
=
step_status
if
student_submission
else
"Incomplete"
step_status
=
step_status
if
student_submission
else
"Incomplete"
assessment_ui_model
=
self
.
get_assessment_module
(
'peer-assessment'
)
assessment_ui_model
=
self
.
get_assessment_module
(
'peer-assessment'
)
problem_open
,
date
=
self
.
is_open
()
context
=
{
context
=
{
"student_submission"
:
student_submission
,
"student_submission"
:
student_submission
,
"student_score"
:
student_score
,
"student_score"
:
student_score
,
...
@@ -166,7 +164,7 @@ class SubmissionMixin(object):
...
@@ -166,7 +164,7 @@ class SubmissionMixin(object):
path
=
'openassessmentblock/oa_response_graded.html'
path
=
'openassessmentblock/oa_response_graded.html'
elif
student_submission
:
elif
student_submission
:
path
=
'openassessmentblock/oa_response_submitted.html'
path
=
'openassessmentblock/oa_response_submitted.html'
elif
due
<
datetime
.
datetime
.
now
()
and
not
student_submission
:
elif
not
problem_open
and
date
==
"due"
and
not
student_submission
:
path
=
'openassessmentblock/oa_response_closed.html'
path
=
'openassessmentblock/oa_response_closed.html'
return
self
.
render_assessment
(
path
,
context_dict
=
context
)
return
self
.
render_assessment
(
path
,
context_dict
=
context
)
apps/openassessment/xblock/test/test_openassessment.py
View file @
764ae02e
...
@@ -2,11 +2,13 @@
...
@@ -2,11 +2,13 @@
Tests the Open Assessment XBlock functionality.
Tests the Open Assessment XBlock functionality.
"""
"""
import
json
import
json
import
datetime
from
django.test
import
TestCase
from
django.test
import
TestCase
from
mock
import
patch
from
mock
import
patch
from
workbench.runtime
import
WorkbenchRuntime
from
workbench.runtime
import
WorkbenchRuntime
import
webob
import
webob
from
openassessment.xblock.openassessmentblock
import
TIME_PARSE_FORMAT
from
openassessment.xblock.submission_mixin
import
SubmissionMixin
from
openassessment.xblock.submission_mixin
import
SubmissionMixin
from
submissions
import
api
as
sub_api
from
submissions
import
api
as
sub_api
...
@@ -144,5 +146,28 @@ class TestOpenAssessment(TestCase):
...
@@ -144,5 +146,28 @@ class TestOpenAssessment(TestCase):
self
.
assertIsNotNone
(
submission_response
)
self
.
assertIsNotNone
(
submission_response
)
self
.
assertTrue
(
submission_response
.
body
.
find
(
"openassessment__response"
))
self
.
assertTrue
(
submission_response
.
body
.
find
(
"openassessment__response"
))
def
test_start_end_date_checks
(
self
):
"""
Check if the start and end date checks work appropriately.
"""
now
=
datetime
.
datetime
.
utcnow
()
past
=
now
-
datetime
.
timedelta
(
minutes
=
10
)
future
=
now
+
datetime
.
timedelta
(
minutes
=
10
)
way_future
=
now
+
datetime
.
timedelta
(
minutes
=
20
)
self
.
assessment
.
start_datetime
=
past
.
strftime
(
TIME_PARSE_FORMAT
)
self
.
assessment
.
due_datetime
=
past
.
strftime
(
TIME_PARSE_FORMAT
)
problem_open
,
reason
=
self
.
assessment
.
is_open
()
self
.
assertFalse
(
problem_open
)
self
.
assertEqual
(
"due"
,
reason
)
self
.
assessment
.
start_datetime
=
past
.
strftime
(
TIME_PARSE_FORMAT
)
self
.
assessment
.
due_datetime
=
future
.
strftime
(
TIME_PARSE_FORMAT
)
problem_open
,
reason
=
self
.
assessment
.
is_open
()
self
.
assertTrue
(
problem_open
)
self
.
assertEqual
(
None
,
reason
)
self
.
assessment
.
start_datetime
=
future
.
strftime
(
TIME_PARSE_FORMAT
)
self
.
assessment
.
due_datetime
=
way_future
.
strftime
(
TIME_PARSE_FORMAT
)
problem_open
,
reason
=
self
.
assessment
.
is_open
()
self
.
assertFalse
(
problem_open
)
self
.
assertEqual
(
"start"
,
reason
)
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