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
6c4e7445
Commit
6c4e7445
authored
Jan 27, 2014
by
Stephen Sanchez
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Adding some quick doc to the functions
parent
516df4f1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
25 additions
and
6 deletions
+25
-6
apps/submissions/api.py
+23
-4
apps/submissions/tests/test_api.py
+1
-2
apps/submissions/views.py
+1
-0
No files found.
apps/submissions/api.py
View file @
6c4e7445
...
...
@@ -18,6 +18,10 @@ class SubmissionInternalError(Exception):
pass
class
SubmissionNotFoundError
(
Exception
):
pass
class
SubmissionRequestError
(
Exception
):
def
__init__
(
self
,
field_errors
):
self
.
field_errors
=
copy
.
deepcopy
(
field_errors
)
...
...
@@ -30,10 +34,6 @@ class SubmissionRequestError(Exception):
return
"SubmissionRequestError({!r})"
.
format
(
self
.
field_errors
)
class
SubmissionNotFoundError
(
Exception
):
pass
def
create_submission
(
student_item_dict
,
answer
,
submitted_at
=
None
,
attempt_number
=
None
):
"""Creates a submission for evaluation.
...
...
@@ -151,6 +151,25 @@ def set_score(student_item):
def
_get_or_create_student_item
(
student_item_dict
):
"""Gets or creates a Student Item that matches the values specified.
Attempts to get the specified Student Item. If it does not exist, the
specified parameters are validated, and a new Student Item is created.
Args:
student_item_dict (dict): The dict containing the student_id, item_id,
course_id, and item_type that uniquely defines a student item.
Returns:
StudentItem: The student item that was retrieved or created.
Raises:
SubmissionInternalError: Thrown if there was an internal error while
attempting to create or retrieve the specified student item.
SubmissionRequestError: Thrown if the given student item parameters fail
validation.
"""
try
:
try
:
student_item_model
=
StudentItem
.
objects
.
get
(
**
student_item_dict
)
...
...
apps/submissions/tests/test_api.py
View file @
6c4e7445
import
datetime
from
django.db
import
DatabaseError
from
django.db
import
DatabaseError
from
django.test
import
TestCase
from
nose.tools
import
raises
from
mock
import
patch
...
...
@@ -72,7 +72,6 @@ class TestApi(TestCase):
mock_create
.
side_effect
=
DatabaseError
(
"Bad things happened"
)
create_submission
(
STUDENT_ITEM
,
ANSWER_ONE
)
def
_assert_submission
(
self
,
submission
,
expected_answer
,
expected_item
,
expected_attempt
):
self
.
assertIsNotNone
(
submission
)
...
...
apps/submissions/views.py
0 → 100644
View file @
6c4e7445
__author__
=
'stephensanchez'
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