Пример #1
0
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
Пример #2
0
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