示例#1
0
文件: Course.py 项目: rtix/course_bot
 def __init__(self, course_id, cw_number, user_id):
     self.__course_id = course_id
     self.__cw_number = cw_number
     self.__user_id = user_id
     if not (CourseDB.get_attendance(self.__course_id, self.__cw_number,
                                     self.__user_id)):
         CourseDB.create_attendance(self.__course_id, self.__cw_number,
                                    self.__user_id, False)
示例#2
0
def get_attendance(course_id):
    file_name = 'ExcelData/Attendance_{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)

    cw_count = len(course['cw_numbers'])
    sheet.merge_range(0, 1, 1, cw_count, 'Посещаемость', centered_format)
    for i, class_work in enumerate([
            CourseDB.get_classwork(course_id, c_id)
            for c_id in course['cw_numbers']
    ]):
        sheet.write(2, i + 1, class_work['date'])
        h_sheet.write(2, i + 1, class_work['classwork_id'])

    for i, user in enumerate(users):
        sheet.write(i + 3, 0, str(i + 1) + '. ' + user['name'])
        h_sheet.write(i + 3, 0, user['u_id'])

        for j, attendance in enumerate([
                CourseDB.get_attendance(course_id, c_id, user['u_id'])
                for c_id in course['cw_numbers']
        ]):
            sheet.write(i + 3, j + 1, attendance['value'])

    book.close()
    return file_name
示例#3
0
文件: Course.py 项目: rtix/course_bot
 def value(self):
     return CourseDB.get_attendance(self.__course_id, self.__cw_number,
                                    self.__user_id)["value"]