def get_peer_grading_notifications(course_id, student_id): student_needs_to_peer_grade = False success = True student_responses_for_course = Submission.objects.filter(student_id = student_id, course_id=course_id, preferred_grader_type="PE") unique_student_locations = [x['location'] for x in student_responses_for_course.values('location').distinct()] for location in unique_student_locations: location_response_count = get_required_peer_grading_for_location({'student_id' : student_id, 'preferred_grader_type' : "PE", 'location' : location}) required_peer_grading_for_location = location_response_count * settings.REQUIRED_PEER_GRADING_PER_STUDENT completed_peer_grading_for_location = Grader.objects.filter(grader_id = student_id, submission__location = location).count() submissions_pending = peer_grading_submissions_pending_for_location(location, student_id).count() if completed_peer_grading_for_location<required_peer_grading_for_location and submissions_pending>0: student_needs_to_peer_grade = True notification_created_recently = NotificationsSeen.check_for_recent_notifications( student_id = student_id, location = location, notification_type=NotificationTypes.peer_grading, recent_notification_interval=settings.RECENT_NOTIFICATION_CHECK_INTERVAL ) if not notification_created_recently: notification_seen = NotificationsSeen( student_id = student_id, course_id = course_id, location = location, notification_type = NotificationTypes.peer_grading ) notification_seen.save() return success, student_needs_to_peer_grade
def get_peer_grading_data_for_location(request): if request.method != 'GET': return util._error_response("Request type must be GET", _INTERFACE_VERSION) for tag in ['student_id', 'location']: if tag not in request.GET: return util._error_response("Missing required key {0}".format(tag), _INTERFACE_VERSION) location = request.GET.get('location') student_id = request.GET.get('student_id') student_sub_count= peer_grading_util.get_required_peer_grading_for_location({'student_id' : student_id, 'location' : location, 'preferred_grader_type' : "PE"}) submissions_graded = peer_grading_util.peer_grading_submissions_graded_for_location(location,student_id).count() submissions_required = settings.REQUIRED_PEER_GRADING_PER_STUDENT*student_sub_count ##Check to see if submissions were available to grade in the past week notification_seen_recently = NotificationsSeen.check_for_recent_notifications( student_id = student_id, location = location, notification_type=NotificationTypes.peer_grading, recent_notification_interval=settings.PEER_GRADING_TIMEOUT_INTERVAL ) if not notification_seen_recently: submissions_required = submissions_graded peer_data = { 'count_graded' : submissions_graded, 'count_required' : submissions_required, 'student_sub_count' : student_sub_count, } util.log_connection_data() return util._success_response(peer_data, _INTERFACE_VERSION)
def get_peer_grading_notifications(course_id, student_id): student_needs_to_peer_grade = False success = True student_responses_for_course = Submission.objects.filter( student_id=student_id, course_id=course_id, preferred_grader_type="PE") unique_student_locations = [ x['location'] for x in student_responses_for_course.values('location').distinct() ] for location in unique_student_locations: location_response_count = get_required_peer_grading_for_location({ 'student_id': student_id, 'preferred_grader_type': "PE", 'location': location }) required_peer_grading_for_location = location_response_count * settings.REQUIRED_PEER_GRADING_PER_STUDENT completed_peer_grading_for_location = Grader.objects.filter( grader_id=student_id, submission__location=location).count() submissions_pending = peer_grading_submissions_pending_for_location( location, student_id).count() if completed_peer_grading_for_location < required_peer_grading_for_location and submissions_pending > 0: student_needs_to_peer_grade = True notification_created_recently = NotificationsSeen.check_for_recent_notifications( student_id=student_id, location=location, notification_type=NotificationTypes.peer_grading, recent_notification_interval=settings. RECENT_NOTIFICATION_CHECK_INTERVAL) if not notification_created_recently: notification_seen = NotificationsSeen( student_id=student_id, course_id=course_id, location=location, notification_type=NotificationTypes.peer_grading) notification_seen.save() return success, student_needs_to_peer_grade
def get_peer_grading_data_for_location(request): if request.method != 'GET': return util._error_response("Request type must be GET", _INTERFACE_VERSION) for tag in ['student_id', 'location']: if tag not in request.GET: return util._error_response("Missing required key {0}".format(tag), _INTERFACE_VERSION) location = request.GET.get('location') student_id = request.GET.get('student_id') student_sub_count = peer_grading_util.get_required_peer_grading_for_location( { 'student_id': student_id, 'location': location, 'preferred_grader_type': "PE" }) submissions_graded = peer_grading_util.peer_grading_submissions_graded_for_location( location, student_id).count() submissions_required = settings.REQUIRED_PEER_GRADING_PER_STUDENT * student_sub_count ##Check to see if submissions were available to grade in the past week notification_seen_recently = NotificationsSeen.check_for_recent_notifications( student_id=student_id, location=location, notification_type=NotificationTypes.peer_grading, recent_notification_interval=settings.PEER_GRADING_TIMEOUT_INTERVAL) if not notification_seen_recently: submissions_required = submissions_graded peer_data = { 'count_graded': submissions_graded, 'count_required': submissions_required, 'student_sub_count': student_sub_count, } util.log_connection_data() return util._success_response(peer_data, _INTERFACE_VERSION)