本文整理汇总了Python中submissions.api.get_submissions函数的典型用法代码示例。如果您正苦于以下问题:Python get_submissions函数的具体用法?Python get_submissions怎么用?Python get_submissions使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_submissions函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_two_students
def test_two_students(self):
api.create_submission(STUDENT_ITEM, ANSWER_ONE)
api.create_submission(SECOND_STUDENT_ITEM, ANSWER_TWO)
submissions = api.get_submissions(STUDENT_ITEM)
self.assertEqual(1, len(submissions))
self._assert_submission(submissions[0], ANSWER_ONE, 1, 1)
submissions = api.get_submissions(SECOND_STUDENT_ITEM)
self.assertEqual(1, len(submissions))
self._assert_submission(submissions[0], ANSWER_TWO, 2, 1)
示例2: get_submissions_for_student_item
def get_submissions_for_student_item(request, course_id, student_id, item_id):
"""Retrieve all submissions associated with the given student item.
Developer utility for accessing all the submissions associated with a
student item. The student item is specified by the unique combination of
course, student, and item.
Args:
request (dict): The request.
course_id (str): The course id for this student item.
student_id (str): The student id for this student item.
item_id (str): The item id for this student item.
Returns:
HttpResponse: The response object for this request. Renders a simple
development page with all the submissions related to the specified
student item.
"""
student_item_dict = dict(
course_id=course_id,
student_id=student_id,
item_id=item_id,
)
context = dict(**student_item_dict)
try:
submissions = get_submissions(student_item_dict)
context["submissions"] = submissions
except SubmissionRequestError:
context["error"] = "The specified student item was not found."
return render_to_response('submissions.html', context)
示例3: clear_student_state
def clear_student_state(self, user_id, course_id, item_id):
"""
This xblock method is called (from our LMS runtime, which defines this method signature) to clear student state
for a given problem. It will cancel the workflow using traditional methods to remove it from the grading pools,
and pass through to the submissions API to orphan the submission so that the user can create a new one.
"""
# Note that student_item cannot be constructed using get_student_item_dict, since we're in a staff context
student_item = {
'course_id': course_id,
'student_id': user_id,
'item_id': item_id,
'item_type': 'openassessment',
}
# There *should* only be one submission, but the logic is easy to extend for multiples so we may as well do it
submissions = submission_api.get_submissions(student_item)
for sub in submissions:
# Remove the submission from grading pools
self._cancel_workflow(sub['uuid'], "Student state cleared")
# Tell the submissions API to orphan the submission to prevent it from being accessed
submission_api.reset_score(
user_id,
course_id,
item_id,
clear_state=True # pylint: disable=unexpected-keyword-arg
)
示例4: test_create_submissions
def test_create_submissions(self):
# Create some submissions
cmd = create_oa_submissions.Command(**{'self_assessment_required': True})
cmd.handle("test_course", "test_item", "5", 100)
self.assertEqual(len(cmd.student_items), 5)
for student_item in cmd.student_items:
# Check that the student item was created for the right course / item
self.assertEqual(student_item['course_id'], 'test_course')
self.assertEqual(student_item['item_id'], 'test_item')
# Check that a submission was created
submissions = sub_api.get_submissions(student_item)
self.assertEqual(len(submissions), 1)
answer_dict = submissions[0]['answer']
self.assertIsInstance(answer_dict['text'], basestring)
self.assertGreater(len(answer_dict['text']), 0)
# Check that peer and self assessments were created
assessments = peer_api.get_assessments(submissions[0]['uuid'])
# Verify that the assessments exist and have content
self.assertEqual(len(assessments), cmd.NUM_PEER_ASSESSMENTS)
for assessment in assessments:
self.assertGreater(assessment['points_possible'], 0)
# Check that a self-assessment was created
assessment = self_api.get_assessment(submissions[0]['uuid'])
# Verify that the assessment exists and has content
self.assertIsNot(assessment, None)
self.assertGreater(assessment['points_possible'], 0)
示例5: test_get_submissions
def test_get_submissions(self):
api.create_submission(STUDENT_ITEM, ANSWER_ONE)
api.create_submission(STUDENT_ITEM, ANSWER_TWO)
submissions = api.get_submissions(STUDENT_ITEM)
self._assert_submission(submissions[1], ANSWER_ONE, 1, 1)
self._assert_submission(submissions[0], ANSWER_TWO, 1, 2)
示例6: test_get_submissions
def test_get_submissions(self):
api.create_submission(STUDENT_ITEM, ANSWER_ONE)
api.create_submission(STUDENT_ITEM, ANSWER_TWO)
submissions = api.get_submissions(STUDENT_ITEM)
student_item = self._get_student_item(STUDENT_ITEM)
self._assert_submission(submissions[1], ANSWER_ONE, student_item.pk, 1)
self._assert_submission(submissions[0], ANSWER_TWO, student_item.pk, 2)
示例7: get_submission
def get_submission(self, submission_id=None):
"""
Get student's most recent submission.
"""
submissions = submissions_api.get_submissions(
self.student_submission_id(submission_id))
if submissions:
# If I understand docs correctly, most recent submission should
# be first
return submissions[0]
示例8: get_student_info_path_and_context
def get_student_info_path_and_context(self, data):
"""
Get the proper path and context for rendering the the student info
section of the staff debug panel.
"""
student_id = data.params.get('student_id', '')
submission_uuid = None
submission = None
assessment_steps = self.assessment_steps
if student_id:
student_item = self.get_student_item_dict()
student_item['student_id'] = student_id
# If there is a submission available for the requested student, present
# it. If not, there will be no other information to collect.
submissions = submission_api.get_submissions(student_item, 1)
if submissions:
submission = submissions[0]
submission_uuid = submissions[0]['uuid']
example_based_assessment = None
self_assessment = None
peer_assessments = []
submitted_assessments = []
if "peer-assessment" in assessment_steps:
peer_assessments = peer_api.get_assessments(submission_uuid)
submitted_assessments = peer_api.get_submitted_assessments(submission_uuid, scored_only=False)
if "self-assessment" in assessment_steps:
self_assessment = self_api.get_assessment(submission_uuid)
if "example-based-assessment" in assessment_steps:
example_based_assessment = ai_api.get_latest_assessment(submission_uuid)
context = {
'submission': submission,
'peer_assessments': peer_assessments,
'submitted_assessments': submitted_assessments,
'self_assessment': self_assessment,
'example_based_assessment': example_based_assessment,
'rubric_criteria': copy.deepcopy(self.rubric_criteria),
}
if peer_assessments or self_assessment or example_based_assessment:
max_scores = peer_api.get_rubric_max_scores(submission_uuid)
for criterion in context["rubric_criteria"]:
criterion["total_value"] = max_scores[criterion["name"]]
path = 'openassessmentblock/staff_debug/student_info.html'
return path, context
示例9: test_get_latest_submission
def test_get_latest_submission(self):
past_date = datetime.datetime(2007, 9, 12, 0, 0, 0, 0, pytz.UTC)
more_recent_date = datetime.datetime(2007, 9, 13, 0, 0, 0, 0, pytz.UTC)
api.create_submission(STUDENT_ITEM, ANSWER_ONE, more_recent_date)
api.create_submission(STUDENT_ITEM, ANSWER_TWO, past_date)
# Test a limit on the submissions
submissions = api.get_submissions(STUDENT_ITEM, 1)
self.assertEqual(1, len(submissions))
self.assertEqual(ANSWER_ONE, submissions[0]["answer"])
self.assertEqual(more_recent_date.year,
submissions[0]["submitted_at"].year)
示例10: get_student_info_path_and_context
def get_student_info_path_and_context(self, data):
"""
Get the proper path and context for rendering the the student info
section of the staff debug panel.
"""
student_id = data.params.get("student_id", "")
submission_uuid = None
submission = None
assessment_steps = self.assessment_steps
if student_id:
student_item = self.get_student_item_dict()
student_item["student_id"] = student_id
# If there is a submission available for the requested student, present
# it. If not, there will be no other information to collect.
submissions = submission_api.get_submissions(student_item, 1)
if submissions:
submission = submissions[0]
submission_uuid = submissions[0]["uuid"]
if "peer-assessment" in assessment_steps:
peer_assessments = peer_api.get_assessments(submission_uuid)
submitted_assessments = peer_api.get_submitted_assessments(submission_uuid, scored_only=False)
else:
peer_assessments = []
submitted_assessments = []
if "self-assessment" in assessment_steps:
self_assessment = self_api.get_assessment(submission_uuid)
else:
self_assessment = None
context = {
"submission": submission,
"peer_assessments": peer_assessments,
"submitted_assessments": submitted_assessments,
"self_assessment": self_assessment,
"rubric_criteria": copy.deepcopy(self.rubric_criteria),
}
if peer_assessments or self_assessment:
max_scores = peer_api.get_rubric_max_scores(submission_uuid)
for criterion in context["rubric_criteria"]:
criterion["total_value"] = max_scores[criterion["name"]]
path = "openassessmentblock/staff_debug/student_info.html"
return path, context
示例11: test_clear_state
def test_clear_state(self):
# Create a submission, give it a score, and verify that score exists
submission = api.create_submission(STUDENT_ITEM, ANSWER_ONE)
api.set_score(submission["uuid"], 11, 12)
score = api.get_score(STUDENT_ITEM)
self._assert_score(score, 11, 12)
self.assertEqual(score['submission_uuid'], submission['uuid'])
# Reset the score with clear_state=True
# This should set the submission's score to None, and make it unavailable to get_submissions
api.reset_score(
STUDENT_ITEM["student_id"],
STUDENT_ITEM["course_id"],
STUDENT_ITEM["item_id"],
clear_state=True,
)
score = api.get_score(STUDENT_ITEM)
self.assertIsNone(score)
subs = api.get_submissions(STUDENT_ITEM)
self.assertEqual(subs, [])
示例12: get_student_info_path_and_context
def get_student_info_path_and_context(self, student_username):
"""
Get the proper path and context for rendering the student info
section of the staff area.
Args:
student_username (unicode): The username of the student to report.
"""
# Import is placed here to avoid model import at project startup.
from submissions import api as submission_api
anonymous_user_id = None
student_item = None
submissions = None
submission = None
submission_uuid = None
if student_username:
anonymous_user_id = self.get_anonymous_user_id(student_username, self.course_id)
student_item = self.get_student_item_dict(anonymous_user_id=anonymous_user_id)
if anonymous_user_id:
# If there is a submission available for the requested student, present
# it. If not, there will be no other information to collect.
submissions = submission_api.get_submissions(student_item, 1)
if submissions:
submission = submissions[0]
submission_uuid = submission['uuid']
# This will add submission (which may be None) and username to the context.
context = self.get_student_submission_context(student_username, submission)
# Only add the rest of the details to the context if a submission exists.
if submission_uuid:
self.add_submission_context(submission_uuid, context)
path = 'openassessmentblock/staff_area/oa_student_info.html'
return path, context
示例13: clear_student_state
def clear_student_state(self, *args, **kwargs):
# pylint: disable=unused-argument
"""
For a given user, clears submissions and uploaded files for this XBlock.
Staff users are able to delete a learner's state for a block in LMS. When that capability is
used, the block's "clear_student_state" function is called if it exists.
"""
student_id = kwargs['user_id']
for submission in submissions_api.get_submissions(
self.get_student_item_dict(student_id)
):
submission_file_sha1 = submission['answer'].get('sha1')
submission_filename = submission['answer'].get('filename')
submission_file_path = self.file_storage_path(submission_file_sha1, submission_filename)
if default_storage.exists(submission_file_path):
default_storage.delete(submission_file_path)
submissions_api.reset_score(
student_id,
self.block_course_id,
self.block_id,
clear_state=True
)
示例14: test_set_attempt_number
def test_set_attempt_number(self):
api.create_submission(STUDENT_ITEM, ANSWER_ONE, None, 2)
submissions = api.get_submissions(STUDENT_ITEM)
student_item = self._get_student_item(STUDENT_ITEM)
self._assert_submission(submissions[0], ANSWER_ONE, student_item.pk, 2)
示例15: test_unicode_enforcement
def test_unicode_enforcement(self):
api.create_submission(STUDENT_ITEM, "Testing unicode answers.")
submissions = api.get_submissions(STUDENT_ITEM, 1)
self.assertEqual(u"Testing unicode answers.", submissions[0]["answer"])