コード例 #1
0
ファイル: test_main.py プロジェクト: emilearthur/code4all
from grader import Grader
from lessons import IntroToPython, Statistics

grader = Grader()
itp_id = grader.register(IntroToPython)
stat_id = grader.register(Statistics)

grader.start_assignment("Tammy", itp_id)
print("Tammy's Lesson:", grader.get_lesson("Tammy"))
print(
    "Tammy's check:",
    grader.check_assignment("Tammy", "a = 1 ; b = 'hello'"),
)
print(
    "Tammmy's other check:",
    grader.check_assignment("Tammy", "a = 1\nb = 'hello'"),
)
print(grader.assignment_summary("Tammy"))

grader.start_assignment("Tammy", stat_id)
print("Tammy's Lessons:", grader.get_lesson("Tammy"))
print("Tammy's check:", grader.check_assignment("Tammy", "avg=5.25"))
print(
    "Tammy's other check:",
    grader.check_assignment("Tammy", "avg = statistics.mean([1, 5, 18, -3])"),
)
print(grader.assignment_summary("Tammy"))
コード例 #2
0
		if results:
			self.correct_attempts += 1

		return results 

	def lesson(self):
		return self.assignment.lesson()

import uuid
class Grader:
	def __init__(self):
		self.student_graders = {}
		self.assignment_classes = {}

	def register(self, assignment_classes):
		if not issubclass(assignment_class, Assignment):
			raise RuntimeError(
				"Your class does not have the right method"
				)
		id = uuid.uuid4() 
		self.assignment_classes[id] = assignment_class
		return id 


# main file 
from grader import Grader 
from lessons import IntroToPython, Statistics

grader = Grader()
itp_id = grader.register(IntroToPython)