<commit_before>module CourseSummariesHelper
    ###
    #  Get JSON data for the table in the form of
    #  { id: student_id, user_name: student.user_name,
    #    first_name: student.first_name, last_name: student.last_name
    #    marks: [ // an array of marks for each assignment, null if no grade ] }
    ###
    def get_table_json_data
		all_students = Student.where(type: 'Student');
		all_assignments = Assignment.all;

		studentList = all_students.map do |student|
			{
				:id => student.id,
				:user_name => student.user_name,
				:first_name => student.first_name,
				:last_name => student.last_name,
				:marks => get_mark_for_all_assignments_for_student(student, all_assignments)
			}
		end

		studentList.to_json
	end

	# Get marks for all assignments for a student 
	def get_mark_for_all_assignments_for_student(student, all_assignments)
		marks = []
		all_assignments.each do |assignment|
			marks[assignment.id - 1] = \
			    get_mark_for_assignment_and_student(assignment, student)
		end
		marks
	end

	# Get mark for a perticular assignment for a student
	def get_mark_for_assignment_and_student(assignment, student)
		grouping = get_grouping_for_user_for_assignment(student, assignment)
		if (grouping)
			submission = Submission.where(grouping_id: grouping.id).first
			if (submission)
				result = Result.where(submission_id: submission.id).first
				if (result)
					return result.total_mark
				end
			end
		end
		return nil
	end

	def get_grouping_for_user_for_assignment(student, assignment)
		memberships = Membership.where(user_id: student.id)
		if (memberships.count == 0)
			return nil
		end
		grouping = get_grouping_for_assignment_for_membership(memberships, assignment)
		return grouping
	end

	def get_grouping_for_assignment_for_membership(memberships, assignment)
		memberships.each do |membership|
			grouping = Grouping.where(id: membership.grouping_id).first
			if (grouping.assignment_id == assignment.id)
				return grouping
			end
		end
		return nil
	end
end<commit_msg>converting tabs to spaced<commit_after>module CourseSummariesHelper
    ###
    #  Get JSON data for the table in the form of
    #  { id: student_id, user_name: student.user_name,
    #    first_name: student.first_name, last_name: student.last_name
    #    marks: [ // an array of marks for each assignment, null if no grade ] }
    ###
    def get_table_json_data
        all_students = Student.where(type: 'Student');
        all_assignments = Assignment.all;

        studentList = all_students.map do |student|
            {
                :id => student.id,
                :user_name => student.user_name,
                :first_name => student.first_name,
                :last_name => student.last_name,
                :marks => get_mark_for_all_assignments_for_student(student, all_assignments)
            }
        end

        studentList.to_json
    end

    # Get marks for all assignments for a student 
    def get_mark_for_all_assignments_for_student(student, all_assignments)
        marks = []
        all_assignments.each do |assignment|
            marks[assignment.id - 1] = \
                get_mark_for_assignment_and_student(assignment, student)
        end
        marks
    end

    # Get mark for a perticular assignment for a student
    def get_mark_for_assignment_and_student(assignment, student)
        grouping = get_grouping_for_user_for_assignment(student, assignment)
        if (grouping)
            submission = Submission.where(grouping_id: grouping.id).first
            if (submission)
                result = Result.where(submission_id: submission.id).first
                if (result)
                    return result.total_mark
                end
            end
        end
        return nil
    end

    def get_grouping_for_user_for_assignment(student, assignment)
        memberships = Membership.where(user_id: student.id)
        if (memberships.count == 0)
            return nil
        end
        grouping = get_grouping_for_assignment_for_membership(memberships, assignment)
        return grouping
    end

    def get_grouping_for_assignment_for_membership(memberships, assignment)
        memberships.each do |membership|
            grouping = Grouping.where(id: membership.grouping_id).first
            if (grouping.assignment_id == assignment.id)
                return grouping
            end
        end
        return nil
    end
end
{'fraction_non_alphanumeric': 0.07225107247685708, 'fraction_numerical': 0.0009031384059607134, 'mean_word_length': 2.7766410912190964, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4213382', 'n_tokens_mistral': 1447, 'n_tokens_neox': 1328, 'n_words': 306}