def read_data(lab, class_list): h = Histogram(len(lab.get_anwerlist()) + 1, len(lab.get_anwerlist())) with open(str(lab.get_name()) + ".txt", 'r') as f: content = f.read() content_list = content.split("\n") for line in content_list: id, data = line.split(":") mark = lab.calculate_marks(data) h.append_marks(mark) for s in class_list: if id == s.get_id(): s.append_marks(mark) return h
def read_data(assessment, classlist): questions = len(assessment.get_answer_list()) histogram = Histogram(questions + 1, questions) txt_name = assessment.get_name() + ".txt" txt_file = open(txt_name, "r") txt_content = txt_file.read() txt_content = txt_content.split() txt_file.close() for r in range(len(txt_content)): field = txt_content[r].split(":") x = assessment.calculate_marks(field[1]) histogram.append_marks(x) for y in range(len(classlist)): if r == y: classlist[y].append_marks(x) return histogram