def add_test(task, test, answer): path = own_dir + FW.make_path(task) + tests_dir num = len(FW.getdirs(path)) name = str(num) FW.create_file(path, FW.make_path(name + ".txt")) FW.write_text(path, FW.make_path(name + ".txt"), test) FW.create_file(path, FW.make_path(name + ".ans")) FW.write_text(path, FW.make_path(name + ".ans"), answer)
def new_submit(user, task, text): global submits, own_dir new_task(user, task) path = own_dir + FW.make_path(user) + FW.make_path(task) num = len(FW.getdirs(path)) name = FW.make_path(str(num)) FW.create_file(path, name) FW.write_text(path, name, text)
def read(): global submits, own_dir submits = dict() #list of str ls = FW.getdirs(own_dir) for user in ls: submits[user] = dict() for user in ls: now = own_dir + FW.make_path(user) tasks = FW.getdirs(now) for task in tasks: submits[user][task] = [] now2 = now + FW.make_path(task) for sub in FW.getdirs(now2): submits[user][task].append(sub)
def new_task(user, task): global submits, own_dir new_user(user) if task not in submits[user]: submits[user][task] = [] FW.create_folder(own_dir + FW.make_path(user) + FW.make_path(task))
def new_user(user): global submits, own_dir if user not in submits: submits[user] = dict() FW.create_folder(own_dir + FW.make_path(user))
def add_lesson(name): name = FW.make_path(name) FW.create_file(own_folder, name)
def add_task(lesson_name, task_name): lesson_name = make_path(lesson_name) if folder_exists(own_path + lesson_name) and folder_exists("/.tasks" + FW.make_path(task_name)): FW.write_text(own_dir, lesson_name, [task_name + "\n"])
def add_task(task): FW.create_folder(own_dir + FW.make_path(task)) tests = own_dir + FW.make_path(task) + tests_dir FW.create_folder(tests)
def get_test_output(task, num): path = own_dir + FW.make_path(task) + tests_dir + "/" + str(num) + ".ans" return "".join(FW.to_string(path))
def get_statements(task): path = own_dir + FW.make_path(task) + "/statements.txt" answer = "".join(FW.to_string(path)) return answer
def add_statements(task, text): path = own_dir + FW.make_path(task) FW.create_file(path, "/statements.txt") FW.write_text(path, "/statements.txt", text)