Beispiel #1
0
def runAssignment(students, assign, args, helpers):
    helpers.printf("Processing assignment '{}' in parellel...\n".format(
        assign.name))

    threshold = args["threshold"]

    # clusters for this assignment
    clusters = []

    # for each specificied file
    files = assign.args["files"]
    for filename in files:
        # get stats from JSON
        (studentDict, array) = getStats(students, assign, filename, helpers)

        # calculate the stats from all students
        stats = {}
        for stat in statTypes:
            mean = getMean(array, stat)
            deviation = getDeviation(array, mean, stat)
            stats[stat] = Stat(mean, deviation)

        # collect the sum of z-scores for each student
        for student in students:
            if student in studentDict:
                data = studentDict[student]
                total = 0.0

                for stat in statTypes:
                    if stats[stat].deviation != 0.0:
                        total += abs(
                            zScore(data[stat], stats[stat].mean,
                                   stats[stat].deviation))

                if total >= threshold:
                    cluster = common.Cluster(False, filename, total)
                    member = common.Member(student, assign.name, helpers)
                    cluster.add(member)
                    clusters.append(cluster)

    # save the clusters
    def sortFun(a, b):
        if a.score < b.score:
            return 1
        return -1

    clusters.sort(sortFun)

    results = []
    for cluster in clusters:
        results.append(cluster.toJSON())
    json = io.getJSONString(results, True)
    helpers.writeToPostprocessed(json, assign.name, "obfuscation_results.json")

    # all done
    helpers.printf("Finished '{}'!\n".format(assign.name))
Beispiel #2
0
def runAssignment(students, assign, args, helpers):
	helpers.printf("Processing assignment '{}' in parellel...\n".format(assign.name))

	threshold = args["threshold"]

	# clusters for this assignment
	clusters = []

	# for each specificied file
	files = assign.args["files"]
	for filename in files:
		# get stats from JSON
		(studentDict, array) = getStats(students, assign, filename, helpers)

		# calculate the stats from all students
		stats = {}
		for stat in statTypes:
			mean = getMean(array, stat)
			deviation = getDeviation(array, mean, stat)
			stats[stat] = Stat(mean, deviation)

		# collect the sum of z-scores for each student
		for student in students:
			if student in studentDict:
				data = studentDict[student]
				total = 0.0

				for stat in statTypes:
					if stats[stat].deviation != 0.0:
						total += abs(zScore(data[stat], stats[stat].mean, stats[stat].deviation))

				if total >= threshold:
					cluster = common.Cluster(False, filename, total)
					member = common.Member(student, assign.name, helpers)
					cluster.add(member)
					clusters.append(cluster)

	# save the clusters
	def sortFun(a, b):
		if a.score < b.score:
			return 1
		return -1

	clusters.sort(sortFun)

	results = []
	for cluster in clusters:
		results.append(cluster.toJSON())
	json = io.getJSONString(results, True)
	helpers.writeToPostprocessed(json, assign.name, "obfuscation_results.json")

	# all done
	helpers.printf("Finished '{}'!\n".format(assign.name))
def filterData(filename, assignment, args, helpers):
	jsonpath = helpers.getPostprocessedPath(assignment.name, filename)
	if jsonpath != None:
		json = io.readJSON(jsonpath)
		if json != None:
			# search the members for students from the given semester
			results = []
			semester = args["semester"]

			for element in json:
				hasSemester = False
				for mem in element['members']:
					if mem['semester'] == semester:
						hasSemester = True

				if hasSemester == True:
					results.append(element)

			# write back to disk
			resultJSON = io.getJSONString(results, True)
			helpers.writeToPostprocessed(resultJSON, assignment.name, semester + "_" + filename)
Beispiel #4
0
def runAssignment(students, assign, helpers):
	helpers.printf("Processing assignment '{}' in parellel...\n".format(assign.name))

	# for each student
	for student in students:
		# for each specificied file
		files = assign.args["files"]
		for filename in files:
			# get the path
			path = helpers.getAssignmentPath(student, assign.name, filename)

			if path != None:
				# get the stats
				stats = genStats(path, helpers)

				# write to a file
				safeFilename = common.makeFilenameSafe(filename) + "stats.json"
				text = io.getJSONString(stats, True)
				helpers.writeToPreprocessed(text, student, assign.name, safeFilename)

	# all done
	helpers.printf("Finished '{}'!\n".format(assign.name))
Beispiel #5
0
def filterData(filename, assignment, args, helpers):
    jsonpath = helpers.getPostprocessedPath(assignment.name, filename)
    if jsonpath != None:
        json = io.readJSON(jsonpath)
        if json != None:
            # search the members for students from the given semester
            results = []
            semester = args["semester"]

            for element in json:
                hasSemester = False
                for mem in element['members']:
                    if mem['semester'] == semester:
                        hasSemester = True

                if hasSemester == True:
                    results.append(element)

            # write back to disk
            resultJSON = io.getJSONString(results, True)
            helpers.writeToPostprocessed(resultJSON, assignment.name,
                                         semester + "_" + filename)
Beispiel #6
0
def runAssignment(students, assign, helpers):
    helpers.printf("Processing assignment '{}' in parellel...\n".format(
        assign.name))

    # for each student
    for student in students:
        # for each specificied file
        files = assign.args["files"]
        for filename in files:
            # get the path
            path = helpers.getAssignmentPath(student, assign.name, filename)

            if path != None:
                # get the stats
                stats = genStats(path, helpers)

                # write to a file
                safeFilename = common.makeFilenameSafe(filename) + "stats.json"
                text = io.getJSONString(stats, True)
                helpers.writeToPreprocessed(text, student, assign.name,
                                            safeFilename)

    # all done
    helpers.printf("Finished '{}'!\n".format(assign.name))