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_problem_list(request): """ Get the list of problems that need grading in course_id request.GET['course_id']. Returns: list of dicts with keys 'location' 'problem_name' 'num_graded' -- number graded 'num_pending' -- number pending in the queue """ if request.method != "GET": error_message = "Request needs to be GET." log.error(error_message) return util._error_response(error_message, _INTERFACE_VERSION) course_id = request.GET.get("course_id") student_id = request.GET.get("student_id") if not course_id or not student_id: error_message = "Missing needed tag course_id or student_id" log.error(error_message) return util._error_response(error_message, _INTERFACE_VERSION) locations_for_course = [ x["location"] for x in list(Submission.objects.filter(course_id=course_id).values("location").distinct()) ] location_info = [] for location in locations_for_course: student_sub_count = peer_grading_util.get_required_peer_grading_for_location( {"student_id": student_id, "location": location, "preferred_grader_type": "PE"} ) if student_sub_count > 0: problem_name = Submission.objects.filter(location=location)[0].problem_id submissions_pending = peer_grading_util.peer_grading_submissions_pending_for_location( location, student_id ).count() submissions_graded = peer_grading_util.peer_grading_submissions_graded_for_location( location, student_id ).count() submissions_required = max( [0, (settings.REQUIRED_PEER_GRADING_PER_STUDENT * student_sub_count) - submissions_graded] ) problem_name_from_location = location.split("://")[1] if submissions_graded > 0 or submissions_pending > 0: location_dict = { "location": location, "problem_name": problem_name, "num_graded": submissions_graded, "num_required": submissions_required, "num_pending": submissions_pending, } location_info.append(location_dict) util.log_connection_data() return util._success_response({"problem_list": location_info}, _INTERFACE_VERSION)
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_problem_list(request): """ Get the list of problems that need grading in course_id request.GET['course_id']. Returns: list of dicts with keys 'location' 'problem_name' 'num_graded' -- number graded 'num_pending' -- number pending in the queue """ if request.method != "GET": error_message = "Request needs to be GET." log.error(error_message) return util._error_response(error_message, _INTERFACE_VERSION) course_id = request.GET.get("course_id") student_id = request.GET.get("student_id") if not course_id or not student_id: error_message = "Missing needed tag course_id or student_id" log.error(error_message) return util._error_response(error_message, _INTERFACE_VERSION) locations_for_course = [ x['location'] for x in list( Submission.objects.filter( course_id=course_id).values('location').distinct()) ] location_info = [] for location in locations_for_course: student_sub_count = peer_grading_util.get_required_peer_grading_for_location( { 'student_id': student_id, 'location': location, 'preferred_grader_type': "PE" }) if student_sub_count > 0: problem_name = Submission.objects.filter( location=location)[0].problem_id submissions_pending = peer_grading_util.peer_grading_submissions_pending_for_location( location, student_id).count() submissions_graded = peer_grading_util.peer_grading_submissions_graded_for_location( location, student_id).count() submissions_required = max([ 0, (settings.REQUIRED_PEER_GRADING_PER_STUDENT * student_sub_count) - submissions_graded ]) problem_name_from_location = location.split("://")[1] if submissions_graded > 0 or submissions_pending > 0: location_dict = { 'location': location, 'problem_name': problem_name, 'num_graded': submissions_graded, 'num_required': submissions_required, 'num_pending': submissions_pending, } location_info.append(location_dict) util.log_connection_data() return util._success_response({'problem_list': location_info}, _INTERFACE_VERSION)