Beispiel #1
0
    def _determine_next_submission_to_grade(self, submissions_to_grade,
                                            course_id):
        """
        Helper function that
        #Ensure that student hasn't graded this submission before!
        #Also ensures that all submissions are searched through if student has graded the minimum one
        @param submissions_to_grade:
        @param course_id:
        @return:
        """
        found = False
        sub_id = 0

        submission_grader_counts = [
            p['num_graders'] for p in submissions_to_grade
        ]

        submission_ids = [p['id'] for p in submissions_to_grade]

        student_profile_success, profile_dict = utilize_student_metrics.get_student_profile(
            self.student_id, course_id)
        fallback_sub_id = None
        for i in xrange(len(submission_ids)):
            minimum_index = submission_grader_counts.index(
                min(submission_grader_counts))
            grade_item = Submission.objects.get(
                id=int(submission_ids[minimum_index]))
            previous_graders = [
                p.grader_id for p in grade_item.get_successful_peer_graders()
            ]
            if self.student_id not in previous_graders:
                found = True
                sub_id = grade_item.id

                if fallback_sub_id is None:
                    fallback_sub_id = grade_item.id

                if not student_profile_success:
                    grade_item.state = SubmissionState.being_graded
                    grade_item.save()
                    return found, sub_id
                else:
                    success, similarity_score = utilize_student_metrics.get_similarity_score(
                        profile_dict, grade_item.student_id, course_id)
                    if similarity_score <= settings.PEER_GRADER_MIN_SIMILARITY_FOR_MATCHING:
                        grade_item.state = SubmissionState.being_graded
                        grade_item.save()
                        return found, sub_id
            else:
                if len(submission_ids) > 1:
                    submission_ids.pop(minimum_index)
                    submission_grader_counts.pop(minimum_index)
        if found:
            grade_item = Submission.objects.get(id=fallback_sub_id)
            grade_item.state = SubmissionState.being_graded
            grade_item.save()
            return found, fallback_sub_id

        return found, sub_id
Beispiel #2
0
    def _determine_next_submission_to_grade(self, submissions_to_grade, course_id):
        """
        Helper function that
        #Ensure that student hasn't graded this submission before!
        #Also ensures that all submissions are searched through if student has graded the minimum one
        @param submissions_to_grade:
        @param course_id:
        @return:
        """
        found = False
        sub_id = 0

        submission_grader_counts = [p['num_graders'] for p in submissions_to_grade]

        submission_ids = [p['id'] for p in submissions_to_grade]

        student_profile_success, profile_dict = utilize_student_metrics.get_student_profile(self.student_id, course_id)
        fallback_sub_id = None
        for i in xrange(len(submission_ids)):
            minimum_index = submission_grader_counts.index(min(submission_grader_counts))
            grade_item = Submission.objects.get(id=int(submission_ids[minimum_index]))
            previous_graders = [p.grader_id for p in grade_item.get_successful_peer_graders()]
            if self.student_id not in previous_graders:
                found = True
                sub_id = grade_item.id

                if fallback_sub_id is None:
                    fallback_sub_id = grade_item.id

                if not student_profile_success:
                    grade_item.state = SubmissionState.being_graded
                    grade_item.save()
                    return found, sub_id
                else:
                    success, similarity_score = utilize_student_metrics.get_similarity_score(profile_dict, grade_item.student_id, course_id)
                    if similarity_score <= settings.PEER_GRADER_MIN_SIMILARITY_FOR_MATCHING:
                        grade_item.state = SubmissionState.being_graded
                        grade_item.save()
                        return found, sub_id
            else:
                if len(submission_ids) > 1:
                    submission_ids.pop(minimum_index)
                    submission_grader_counts.pop(minimum_index)
        if found:
            grade_item = Submission.objects.get(id=fallback_sub_id)
            grade_item.state = SubmissionState.being_graded
            grade_item.save()
            return found, fallback_sub_id

        return found, sub_id
Beispiel #3
0
def get_single_peer_grading_item(location, grader_id):
    """
    Gets peer grading for a given location and grader.
    Returns one submission id corresponding to the location and the grader.
    Input:
        location - problem location.
        grader_id - student id of the peer grader
    Returns:
        found - Boolean indicating whether or not something to grade was found
        sub_id - If found, the id of a submission to grade
    """
    found = False
    sub_id = 0
    to_be_graded = peer_grading_submissions_pending_for_location(
        location, grader_id)
    #Do some checks to ensure that there are actually items to grade
    if to_be_graded is not None:
        to_be_graded_length = to_be_graded.count()
        if to_be_graded_length > 0:
            course_id = to_be_graded[0].course_id
            submissions_to_grade = (to_be_graded.filter(
                grader__status_code=GraderStatus.success,
                grader__grader_type__in=[
                    "PE", "BC"
                ]).exclude(grader__grader_id=grader_id).annotate(
                    num_graders=Count('grader')).values(
                        "num_graders", "id").order_by("num_graders")[:50])

            if submissions_to_grade is not None:
                submission_grader_counts = [
                    p['num_graders'] for p in submissions_to_grade
                ]
                #log.debug("Submissions to grade with graders: {0} {1}".format(submission_grader_counts, submissions_to_grade))

                submission_ids = [p['id'] for p in submissions_to_grade]

                student_profile_success, profile_dict = utilize_student_metrics.get_student_profile(
                    grader_id, course_id)
                #Ensure that student hasn't graded this submission before!
                #Also ensures that all submissions are searched through if student has graded the minimum one
                fallback_sub_id = None
                for i in xrange(0, len(submission_ids)):
                    #log.debug("Looping through graders, on {0}".format(i))
                    minimum_index = submission_grader_counts.index(
                        min(submission_grader_counts))
                    grade_item = Submission.objects.get(
                        id=int(submission_ids[minimum_index]))
                    previous_graders = [
                        p.grader_id
                        for p in grade_item.get_successful_peer_graders()
                    ]
                    if grader_id not in previous_graders:
                        found = True
                        sub_id = grade_item.id

                        #Insert timing initialization code
                        if fallback_sub_id is None:
                            fallback_sub_id = grade_item.id

                        if not student_profile_success:
                            initialize_timing(sub_id)
                            grade_item.state = SubmissionState.being_graded
                            grade_item.save()
                            return found, sub_id
                        else:
                            success, similarity_score = utilize_student_metrics.get_similarity_score(
                                profile_dict, grade_item.student_id, course_id)
                            log.debug(similarity_score)
                            if similarity_score <= settings.PEER_GRADER_MIN_SIMILARITY_FOR_MATCHING:
                                initialize_timing(sub_id)
                                grade_item.state = SubmissionState.being_graded
                                grade_item.save()
                                return found, sub_id
                    else:
                        if len(submission_ids) > 1:
                            submission_ids.pop(minimum_index)
                            submission_grader_counts.pop(minimum_index)
                if found:
                    initialize_timing(fallback_sub_id)
                    grade_item = Submission.objects.get(id=fallback_sub_id)
                    grade_item.state = SubmissionState.being_graded
                    grade_item.save()
                    return found, fallback_sub_id

    return found, sub_id
Beispiel #4
0
def get_single_peer_grading_item(location, grader_id):
    """
    Gets peer grading for a given location and grader.
    Returns one submission id corresponding to the location and the grader.
    Input:
        location - problem location.
        grader_id - student id of the peer grader
    Returns:
        found - Boolean indicating whether or not something to grade was found
        sub_id - If found, the id of a submission to grade
    """
    found = False
    sub_id = 0
    to_be_graded = peer_grading_submissions_pending_for_location(location, grader_id) 
    #Do some checks to ensure that there are actually items to grade
    if to_be_graded is not None:
        to_be_graded_length = to_be_graded.count()
        if to_be_graded_length > 0:
            course_id = to_be_graded[0].course_id
            submissions_to_grade = (to_be_graded
                                    .filter(grader__status_code=GraderStatus.success, grader__grader_type__in=["PE","BC"])
                                    .exclude(grader__grader_id=grader_id)
                                    .annotate(num_graders=Count('grader'))
                                    .values("num_graders", "id")
                                    .order_by("num_graders")[:50])

            if submissions_to_grade is not None:
                submission_grader_counts = [p['num_graders'] for p in submissions_to_grade]
                #log.debug("Submissions to grade with graders: {0} {1}".format(submission_grader_counts, submissions_to_grade))

                submission_ids = [p['id'] for p in submissions_to_grade]

                student_profile_success, profile_dict = utilize_student_metrics.get_student_profile(grader_id, course_id)
                #Ensure that student hasn't graded this submission before!
                #Also ensures that all submissions are searched through if student has graded the minimum one
                fallback_sub_id = None
                for i in xrange(0, len(submission_ids)):
                    #log.debug("Looping through graders, on {0}".format(i))
                    minimum_index = submission_grader_counts.index(min(submission_grader_counts))
                    grade_item = Submission.objects.get(id=int(submission_ids[minimum_index]))
                    previous_graders = [p.grader_id for p in grade_item.get_successful_peer_graders()]
                    if grader_id not in previous_graders:
                        found = True
                        sub_id = grade_item.id

                        #Insert timing initialization code
                        if fallback_sub_id is None:
                            fallback_sub_id = grade_item.id

                        if not student_profile_success:
                            initialize_timing(sub_id)
                            grade_item.state = SubmissionState.being_graded
                            grade_item.save()
                            return found, sub_id
                        else:
                            success, similarity_score = utilize_student_metrics.get_similarity_score(profile_dict, grade_item.student_id, course_id)
                            log.debug(similarity_score)
                            if similarity_score <= settings.PEER_GRADER_MIN_SIMILARITY_FOR_MATCHING:
                                initialize_timing(sub_id)
                                grade_item.state = SubmissionState.being_graded
                                grade_item.save()
                                return found, sub_id
                    else:
                        if len(submission_ids) > 1:
                            submission_ids.pop(minimum_index)
                            submission_grader_counts.pop(minimum_index)
                if found:
                    initialize_timing(fallback_sub_id)
                    grade_item = Submission.objects.get(id=fallback_sub_id)
                    grade_item.state = SubmissionState.being_graded
                    grade_item.save()
                    return found, fallback_sub_id

    return found, sub_id
Beispiel #5
0
    def next_item(self):
        """
        Gets peer grading for a given location and grader.
        Returns one submission id corresponding to the location and the grader.
        Input:
            location - problem location.
            grader_id - student id of the peer grader
        Returns:
            found - Boolean indicating whether or not something to grade was found
            sub_id - If found, the id of a submission to grade
        """
        found = False
        sub_id = 0
        to_be_graded = self.pending()
        #Do some checks to ensure that there are actually items to grade
        if to_be_graded.count()>0:
            course_id = to_be_graded[0].course_id
            submissions_to_grade = (to_be_graded
                                    .annotate(num_graders=Count('grader'))
                                    .values("num_graders", "id")
                                    .order_by("date_created")[:50])

            submission_grader_counts = [p['num_graders'] for p in submissions_to_grade]

            submission_ids = [p['id'] for p in submissions_to_grade]

            student_profile_success, profile_dict = utilize_student_metrics.get_student_profile(self.student_id, course_id)
            #Ensure that student hasn't graded this submission before!
            #Also ensures that all submissions are searched through if student has graded the minimum one
            fallback_sub_id = None
            for i in xrange(len(submission_ids)):
                minimum_index = submission_grader_counts.index(min(submission_grader_counts))
                grade_item = Submission.objects.get(id=int(submission_ids[minimum_index]))
                previous_graders = [p.grader_id for p in grade_item.get_successful_peer_graders()]
                if self.student_id not in previous_graders:
                    found = True
                    sub_id = grade_item.id

                    if fallback_sub_id is None:
                        fallback_sub_id = grade_item.id

                    if not student_profile_success:
                        grade_item.state = SubmissionState.being_graded
                        grade_item.save()
                        return found, sub_id
                    else:
                        success, similarity_score = utilize_student_metrics.get_similarity_score(profile_dict, grade_item.student_id, course_id)
                        if similarity_score <= settings.PEER_GRADER_MIN_SIMILARITY_FOR_MATCHING:
                            grade_item.state = SubmissionState.being_graded
                            grade_item.save()
                            return found, sub_id
                else:
                    if len(submission_ids) > 1:
                        submission_ids.pop(minimum_index)
                        submission_grader_counts.pop(minimum_index)
            if found:
                grade_item = Submission.objects.get(id=fallback_sub_id)
                grade_item.state = SubmissionState.being_graded
                grade_item.save()
                return found, fallback_sub_id

        return found, sub_id
Beispiel #6
0
    def next_item(self):
        """
        Gets peer grading for a given location and grader.
        Returns one submission id corresponding to the location and the grader.
        Input:
            location - problem location.
            grader_id - student id of the peer grader
        Returns:
            found - Boolean indicating whether or not something to grade was found
            sub_id - If found, the id of a submission to grade
        """
        found = False
        sub_id = 0
        to_be_graded = self.pending()
        #Do some checks to ensure that there are actually items to grade
        if to_be_graded.count() > 0:
            course_id = to_be_graded[0].course_id
            submissions_to_grade = (to_be_graded.annotate(
                num_graders=Count('grader')).values(
                    "num_graders", "id").order_by("date_created")[:50])

            submission_grader_counts = [
                p['num_graders'] for p in submissions_to_grade
            ]

            submission_ids = [p['id'] for p in submissions_to_grade]

            student_profile_success, profile_dict = utilize_student_metrics.get_student_profile(
                self.student_id, course_id)
            #Ensure that student hasn't graded this submission before!
            #Also ensures that all submissions are searched through if student has graded the minimum one
            fallback_sub_id = None
            for i in xrange(len(submission_ids)):
                minimum_index = submission_grader_counts.index(
                    min(submission_grader_counts))
                grade_item = Submission.objects.get(
                    id=int(submission_ids[minimum_index]))
                previous_graders = [
                    p.grader_id
                    for p in grade_item.get_successful_peer_graders()
                ]
                if self.student_id not in previous_graders:
                    found = True
                    sub_id = grade_item.id

                    if fallback_sub_id is None:
                        fallback_sub_id = grade_item.id

                    if not student_profile_success:
                        grade_item.state = SubmissionState.being_graded
                        grade_item.save()
                        return found, sub_id
                    else:
                        success, similarity_score = utilize_student_metrics.get_similarity_score(
                            profile_dict, grade_item.student_id, course_id)
                        if similarity_score <= settings.PEER_GRADER_MIN_SIMILARITY_FOR_MATCHING:
                            grade_item.state = SubmissionState.being_graded
                            grade_item.save()
                            return found, sub_id
                else:
                    if len(submission_ids) > 1:
                        submission_ids.pop(minimum_index)
                        submission_grader_counts.pop(minimum_index)
            if found:
                grade_item = Submission.objects.get(id=fallback_sub_id)
                grade_item.state = SubmissionState.being_graded
                grade_item.save()
                return found, fallback_sub_id

        return found, sub_id