def get_marks(course_id): file_name = 'ExcelData/Marks_{0}.xlsx'.format(course_id) book = xlsxwriter.Workbook(file_name) sheet = book.add_worksheet('Успеваемость') h_sheet = book.add_worksheet('Hidden') h_sheet.hide() course = CourseDB.get_course(course_id) centered_format = book.add_format({ 'align': 'center', 'valign': 'vcenter', 'border': 1 }) users = list([UserDB.get_user(u_id) for u_id in course['participants']]) sheet.merge_range(0, 0, 1, 0, 'Студенты', centered_format) sheet.set_column(0, 0, len(max([user['name'] for user in users])) + 4) task_count = len(course['task_numbers']) sheet.merge_range(0, 1, 1, 1 + task_count, 'Задачи', centered_format) sheet.write(2, 1, 'Название') sheet.write(3, 1, 'Макс. балл') sheet.write(4, 1, 'Дедлайн') for i, task in enumerate([ CourseDB.get_task(course_id, t_id) for t_id in course['task_numbers'] ]): sheet.write(2, 2 + i, task['name']) h_sheet.write(2, 2 + i, task['task_id']) sheet.write(3, 2 + i, task['highest_mark']) sheet.write(4, 2 + i, task['deadline']) for i, user in enumerate(users): sheet.write(i + 5, 0, str(i + 1) + '. ' + user['name']) h_sheet.write(i + 5, 0, user['u_id']) for j, mark in enumerate([ CourseDB.get_mark(course_id, t_id, user['u_id']) for t_id in course['task_numbers'] ]): sheet.write(i + 5, j + 2, mark['mark']) book.close() return file_name
def deadline(self): return CourseDB.get_task(self.__course_id, self.__task_number)["deadline"]
def highest_mark(self): return CourseDB.get_task(self.__course_id, self.__task_number)["highest_mark"]
def description(self): return CourseDB.get_task(self.__course_id, self.__task_number)["description"]
def name(self): return CourseDB.get_task(self.__course_id, self.__task_number)["name"]