Example #1
0
class StuJoinCheckInControl(object):
    def __init__(self):
        self.detail = DetailInfo()
        self.ini = IniInfo()

    # 获取当前系统时间
    def get_time(self):
        """
        获取系统当前的时间
        :return: 
        """
        return time.strftime("%Y-%m-%d %X", time.localtime())

    # 学生签到(stu_id, proof)
    # 查找该学生所属的考勤对象
    def get_checkininfo(self, stu_id, cii_list):
        for acia in cii_list:
            if stu_id in acia.stuids:
                return acia
        return

    # 构造detail_line信息
    def set_new_detail_line(self, stuid, acii, type, result="wait"):
        newdetail_line = \
            self.detail.set_detail_line(stuid, self.get_time(),
                                        self.detail.set_proofpath(stuid, acii.courseid, acii.seqid,
                                                                  self.get_time()),
                                        type, "null", result)
        return newdetail_line

    # 提交/请假(result="wait"/"qj")
    def stu_send_checkininfo(self, stuid, type, result, cii_list, default_path):
        now_cii = self.get_checkininfo(stuid, cii_list)  # 这里应当做考勤对象是否存在的判断
        if now_cii:
            new_detail_line = self.set_new_detail_line(stuid, now_cii, type, result)
            # 构建detail文件名
            teacher_id = now_cii.tecid
            course_id = now_cii.courseid
            seq_id = now_cii.seqid
            new_detail_filename = default_path + self.detail.set_detail_filename(teacher_id, course_id, seq_id)
            all_detail_info = self.detail.get_all_detail_info(new_detail_filename)
            all_detail_info.append(new_detail_line)
            self.detail.write_detail(all_detail_info, new_detail_filename)
        else:
            print "您不能参与"

    # 签到
    def sign_in(self, stu_id):
        DEFAULTPATH = "../outputdemo/"
        self.stu_send_checkininfo(stu_id, "auto", "null", IniInfo.List, DEFAULTPATH)

    # 抽到
    def sample_in(self, stu_id):
        DEFAULTPATH = "../outputdemo/"
        self.stu_send_checkininfo(stu_id, "sample", "抽到", self.ini.List, DEFAULTPATH)

    # 请假
    def leave_in(self, stu_id):
        DEFAULTPATH = "../outputdemo/"
        self.stu_send_checkininfo(stu_id, "man", "请假", self.ini.List, DEFAULTPATH)
Example #2
0
class TecSampleCheckInControl(object):
    def __init__(self):
        self.detail = DetailInfo()

    # 通过tecid查询考勤学生集合
    def get_checkin_stuids(self, tec_id, checkerin_arry):
        for acii in checkerin_arry:
            if acii.tecid == tec_id:
                # 记录抽点时间
                acii.sampletime = self.get_time()
                return acii.stuids
        return

    # 抽取部分学生
    def get_part_stuids(self, all_stuids, percent=5):
        return random.sample(all_stuids, percent)

    # 为抽点学生初始化状态
    # 获取当前系统时间
    def get_time(self):
        """
        获取系统当前的时间
        :return: 
        """
        return time.strftime("%Y-%m-%d %X", time.localtime())

    # 构造detail_line信息
    def set_new_detail_line(self, stuid, acii, result="zaotui"):
        newdetail_line = \
            self.detail.set_detail_line(stuid, self.get_time(),
                                        self.detail.set_proofpath(stuid, acii.courseid, acii.seqid,
                                                                  self.get_time()),
                                        "auto", "null", result)
        return newdetail_line

    # 加入detail文件
    def add_to_detail(self, new_details, now_cii, default_path):
        # 构建detail文件名
        teacher_id = now_cii.tecid
        course_id = now_cii.courseid
        seq_id = now_cii.seqid
        new_detail_filename = default_path + self.detail.set_detail_filename(
            teacher_id, course_id, seq_id)
        all_detail_info = self.detail.get_all_detail_info(new_detail_filename)
        all_detail_info = self.detail.detail_update(new_details,
                                                    all_detail_info)
        self.detail.write_detail(all_detail_info, new_detail_filename)
Example #3
0
class StuJoinCheckInControl(object):
    def __init__(self):
        self.detail = DetailInfo()

    # 获取当前系统时间
    def get_time(self):
        """
        获取系统当前的时间
        :return: 
        """
        return time.strftime("%Y-%m-%d %X", time.localtime())

    # 学生签到(stu_id, proof)
    # 查找该学生所属的考勤对象
    def get_checkininfo(self, stu_id, cii_list):
        for acia in cii_list:
            if stu_id in acia.stuids:
                return acia
        return

    # 构造detail_line信息
    def set_new_detail_line(self, stuid, acii, result="wait"):
        newdetail_line = \
            self.detail.set_detail_line(stuid, self.get_time(),
                                        self.detail.set_proofpath(stuid, acii.courseid, acii.seqid,
                                                                  self.get_time()),
                                        "auto", "null", result)
        return newdetail_line

    # 提交/请假(result="wait"/"qj")
    def stu_send_checkininfo(self, stuid, result, cii_list, default_path):
        now_cii = self.get_checkininfo(stuid, cii_list)  # 这里应当做考勤对象是否存在的判断
        if now_cii:
            new_detail_line = self.set_new_detail_line(stuid, now_cii, result)
            # 构建detail文件名
            teacher_id = now_cii.tecid
            course_id = now_cii.courseid
            seq_id = now_cii.seqid
            new_detail_filename = default_path + self.detail.set_detail_filename(
                teacher_id, course_id, seq_id)
            all_detail_info = self.detail.get_all_detail_info(
                new_detail_filename)
            all_detail_info.append(new_detail_line)
            self.detail.write_detail(all_detail_info, new_detail_filename)
        else:
            print "error"
Example #4
0
class TecSampleCheckInControl(object):
    def __init__(self):
        self.detail = DetailInfo()

    # 通过tecid查询考勤学生集合
    def get_checkin_stuids(self, tec_id, course_id, checkerin_arry):
        for acii in checkerin_arry:
            if acii.tecid == tec_id and acii.courseid == course_id:
                # 记录抽点时间
                acii.sampletime = self.get_time()
                return acii.stuids
        return

    # 通过tecid查询考勤队列中的该考勤对象
    def get_checker(self, tec_id, course_id, checkerin_arry):
        for acii in checkerin_arry:
            if acii.tecid == tec_id and acii.courseid == course_id:
                return acii
        return

    # 抽取部分学生
    def get_part_stuids(self, all_stuids, percent=5):
        return random.sample(all_stuids, percent)

    # 为抽点学生初始化状态
    # 获取当前系统时间
    def get_time(self):
        """
        获取系统当前的时间
        :return: 
        """
        return time.strftime("%Y-%m-%d %X", time.localtime())

    # 构造detail_line信息
    def set_new_detail_line(self, stuid, acii, result="早退"):
        newdetail_line = \
            self.detail.set_detail_line(stuid, self.get_time(),
                                        self.detail.set_proofpath(stuid, acii.courseid, acii.seqid,
                                                                  self.get_time()),
                                        "man", "null", result)
        return newdetail_line

    # 加入detail文件
    def add_to_detail(self, new_details, now_cii, default_path):
        # 构建detail文件名
        teacher_id = now_cii.tecid
        course_id = now_cii.courseid
        seq_id = now_cii.seqid
        new_detail_filename = default_path + self.detail.set_detail_filename(
            teacher_id, course_id, seq_id)
        all_detail_info = self.detail.get_all_detail_info(new_detail_filename)
        all_detail_info = self.detail.detail_update(new_details,
                                                    all_detail_info)
        self.detail.write_detail(all_detail_info, new_detail_filename)

    # 抽点考勤
    def tec_sample_checkin(self, tec_id, course_id, people_num, a_arry):
        # 在考勤队列中到到考勤对象的学生集合,
        check_stuids = self.get_checkin_stuids(tec_id, course_id, a_arry)
        checker = self.get_checker(tec_id, course_id, a_arry)
        if check_stuids and checker:
            print check_stuids
            # 抽取部分学生
            part_stuids = self.get_part_stuids(check_stuids, int(people_num))
            print part_stuids
            # 初始化抽点信息
            part_stus_detail = []
            for a_stuid in part_stuids:
                part_stus_detail.append(
                    self.set_new_detail_line(a_stuid, checker, "早退"))
            # print part_stus_detail
            # 写入detail文件
            self.add_to_detail(part_stus_detail, checker, "../outputdemo/")
        else:
            print "请先开启自助考勤"
Example #5
0
class UpdateSum(object):
    def __init__(self):
        self.seq = SeqInfo()
        self.course = CourseInfo()
        self.stu = StuInfo()
        self.sum = SumInfo()
        self.detail = DetailInfo()

    # 传入参数 tec_id, course_id, seq_id
    # 从seq表中获取本次的starttime, 需要附加文件名,seq_filename
    # 获取所有学生的名单,需要附加文件名,course_filename,stu_filename
    # 通过detail类的两个方法获得所有学生的考勤结果
    # 获取sum表的文件名
    # 若seq_id==1,需要初始化sum表
    # 按学生考勤结果更新入sum表
    def update_sum(self, tec_id, course_id, seq_id, course_filename,
                   stu_filename, seq_filename):
        starttime = self.get_tec_start_time(tec_id, course_id, seq_id,
                                            seq_filename)
        stuids = self.get_all_stuids(tec_id, course_id, course_filename,
                                     stu_filename)
        sumfilename = self.sum.set_sum_filename(tec_id, course_id)
        if starttime and stuids and sumfilename:
            # 获得所有学生的考勤结果
            detail_filename = self.detail.set_detail_filename(
                tec_id, course_id, seq_id)
            all_detail_info = self.detail.get_all_detail_info(detail_filename)
            for detail_line in all_detail_info:
                self.detail.set_detail_result(detail_line, starttime)
            new_sum_line = self.detail.detail_sum(all_detail_info, stuids,
                                                  seq_id)

            # 更新sum
            if os.path.exists(sumfilename):
                pass
            else:
                # 初始化sum表
                new_sum_info = self.sum.sum_creat(stuids)
                self.sum.write_file(new_sum_info, sumfilename)
            all_sum_info = self.sum.get_all_sum_info(sumfilename)
            new_sum_info = self.sum.sum_update(new_sum_line, all_sum_info,
                                               seq_id)
            self.sum.write_file(new_sum_info, sumfilename)
        else:
            print "您输入的内容有误,请检查后重新操作"

    # 获取教师发起考勤时间
    def get_tec_start_time(self, tec_id, course_id, seq_id, seq_filename):
        all_seq_info = self.seq.get_all_seq_info(seq_filename)
        if self.seq.check_seq_id(tec_id, course_id, seq_id, all_seq_info):
            start_time = self.seq.get_start_time(tec_id, course_id, seq_id,
                                                 all_seq_info)
            if start_time:
                return start_time
            else:
                return None
        else:
            print "您输入的考勤次序号错误"
            return None

    # 获取所有学生的名单
    def get_all_stuids(self, tec_id, course_id, course_filename, stu_filename):
        all_course_info = self.course.get_all_course_info(course_filename)
        classnums = self.course.get_classnames(tec_id, course_id,
                                               all_course_info)
        all_stu_info = self.stu.get_all_stu_info(stu_filename)
        stu_ids = self.stu.get_stuids(
            self.stu.get_wait_checkin_stu_info(classnums, all_stu_info))
        if stu_ids:
            return stu_ids
        else:
            return None

    # 遍历seq表,获取所有detail表,更新sum表
    def update_all_sum(self, COURSEFILENAME, STUFILENAME, SEQFILENAME):
        all_seq_info = self.seq.get_all_seq_info(SEQFILENAME)
        for seq_line in all_seq_info:
            tec_id = seq_line["TeacherID"]
            course_id = seq_line["CourseID"]
            seq_id = seq_line["SeqID"]
            self.update_sum(tec_id, course_id, seq_id, COURSEFILENAME,
                            STUFILENAME, SEQFILENAME)
Example #6
0
class TecStartCheckInControl(object):
    # 实例考勤队列
    cia = CheckInArray()

    def __init__(self):
        self.seq = SeqInfo()
        self.detail = DetailInfo()
        self.course = CourseInfo()
        self.stu = StuInfo()
        self.sum = SumInfo()

    # 获取当前系统时间
    def get_time(self):
        """
        获取系统当前的时间
        :return: 
        """
        return time.strftime("%Y-%m-%d %X", time.localtime())

    # 初始化seq表
    def creat_seq(self, seq_filename):
        creat_seq_line = [{
            "TeacherID": None,
            "CourseID": None,
            "SeqID": None,
            "StartTime": None
        }]
        self.seq.write_file(creat_seq_line, seq_filename)

    # 更新seq表
    def update_seq(self, now_cii, seq_filename):
        # 获取seq表已有信息
        all_seq_info = self.seq.get_all_seq_info(seq_filename)
        # 分配新的考勤次序号
        seq_id = int(
            self.seq.get_seqid(now_cii.tecid, now_cii.courseid,
                               all_seq_info)) + 1
        now_cii.seqid = str(seq_id)
        # 构建新的考勤次序记录
        new_sql_line = self.seq.set_seq_line(now_cii.tecid, now_cii.courseid,
                                             now_cii.seqid, now_cii.starttime)
        # 将新的考勤记录加入seq表
        all_seq_info = self.seq.seq_update(new_sql_line, all_seq_info)
        # 更新seq表
        self.seq.write_file(all_seq_info, seq_filename)
        return

    # 初始化detail表
    def creat_detail(self, now_cii, default_path):
        # 构建detail文件名
        teacher_id = now_cii.tecid
        course_id = now_cii.courseid
        seq_id = now_cii.seqid
        new_detail_filename = default_path + self.detail.set_detail_filename(
            teacher_id, course_id, seq_id)
        # 待考勤学生id集合
        stuids = now_cii.stuids
        # 初始化detail表
        newdetail_info = []
        for stuid in stuids:
            newdetail_line = \
                self.detail.set_detail_line(stuid, self.get_time(),
                                            self.detail.set_proofpath(stuid, course_id, seq_id, self.get_time()),
                                            "man", "null", "in")
            newdetail_info.append(newdetail_line)
        self.detail.write_file(newdetail_info, new_detail_filename, "wb")

    # 初始化sum表本
    # 导入考勤结果

    # 教师发起自助考勤
    def tec_start_checkin(self, now_cii, seq_filename):
        # 考勤对象家加入考勤队列
        if self.__class__.cia.update_arry(now_cii):
            print "开启成功"
            # 初始化seq表
            # self.creat_seq(seq_filename)  # 有一次即可
            # 在seq表添加记录 !!!只有一行
            self.update_seq(now_cii, seq_filename)
            # 初始化detail表
            default_path = seq_filename[:-7]
            self.creat_detail(now_cii, default_path)
            # 初始化sum表 不应放在这里
        else:
            print "开启失败"

    # 学生签到(stu_id, proof)
    # 查找该学生所属的考勤对象
    def get_checkininfo(self, stu_id, stu_filename):
        # all_stu_info = self.stu.get_all_stu_info(stu_filename)
        # classname = self.stu.get_classid(stu_id, all_stu_info)
        for acia in self.__class__.cia.List:
            if stu_id in acia.stuids:
                return acia
        return

    # 构造detail_line信息
    def set_new_detail_line(self, stuid, acii, result="wait"):
        newdetail_line = \
            self.detail.set_detail_line(stuid, self.get_time(),
                                        self.detail.set_proofpath(stuid, acii.courseid, acii.seqid, self.get_time()),
                                        "auto", "null", result)
        return newdetail_line

    # 提交/请假(result="wait"/"qj")
    def stu_send_checkininfo(self, stuid, result, stu_filename, default_path):
        now_cii = self.get_checkininfo(stuid, stu_filename)  # 这里应当做考勤对象是否存在的判断
        new_detail_line = self.set_new_detail_line(stuid, now_cii, result)
        # 构建detail文件名
        teacher_id = now_cii.tecid
        course_id = now_cii.courseid
        seq_id = now_cii.seqid
        new_detail_filename = default_path + self.detail.set_detail_filename(
            teacher_id, course_id, seq_id)
        all_detail_info = self.detail.get_all_detail_info(new_detail_filename)
        all_detail_info.append(new_detail_line)
        self.detail.write_detail(all_detail_info, new_detail_filename)
Example #7
0
class TecApproveNote(object):
    def __init__(self):
        self.course = CourseInfo()
        self.stu = StuInfo()
        self.seq = SeqInfo()
        self.detail = DetailInfo()

    # 审批假条
    def approve_note(self, tec_id, course_id, seq_id, stu_ids, seq_filename,
                     default_path):
        if self.check_seqid(tec_id, course_id, seq_id, seq_filename):
            if self.check_stuids(tec_id, course_id, seq_id, stu_ids,
                                 default_path):
                new_detail_info = self.build_detail(stu_ids)
                detail_filename = self.detail.set_detail_filename(
                    tec_id, course_id, str(seq_id))
                detail_filename = default_path + detail_filename
                self.update_detail(new_detail_info, detail_filename)
            else:
                print "有学生非本班学生,请检查后重新操作"
        else:
            print "没有您选择的考勤序号,请检查后重新输入"

    # 获取当前系统时间
    def get_time(self):
        """
        获取系统当前的时间
        :return: 
        """
        return time.strftime("%Y-%m-%d %X", time.localtime())

    # 1.检查seqid有效性
    def check_seqid(self, tec_id, course_id, seq_id, seq_filename):
        # 通过获取最大seqid值验证当前输入的seqid值是否有效
        all_seq_info = self.seq.get_all_seq_info(seq_filename)
        max_seqid = self.seq.get_seqid(tec_id, course_id, all_seq_info)
        if int(seq_id) > 0 and int(seq_id) <= int(max_seqid):
            return True
        else:
            return False

    # 检查输入的学生的有效性
    def check_stuids(self, tec_id, course_id, seq_id, stu_ids, default_path):
        # 通过获取该考勤对象的学生集合,判断输入的学号是否有效
        detail_filename = self.detail.set_detail_filename(
            tec_id, course_id, seq_id)
        detail_filename = default_path + detail_filename
        all_stuids = self.note_stu_ids(detail_filename)
        for a_stuid in stu_ids:
            if a_stuid in all_stuids:
                pass
            else:
                return False
        return True

    # 2.打印请假学生
    def show_note_stuids(self, tec_id, course_id, seq_id, seq_filename,
                         default_path):
        all_seq_info = self.seq.get_all_seq_info(seq_filename)
        max_seqid = self.seq.get_seqid(tec_id, course_id, all_seq_info)
        if int(seq_id) > 0 and int(seq_id) <= int(max_seqid):
            detail_filename = self.detail.set_detail_filename(
                tec_id, course_id, seq_id)
            detail_filename = default_path + detail_filename
            note_stuids = self.note_stu_ids(detail_filename)
            return note_stuids
        else:
            print "您输入选择的seqid错误,请检查后重新操作"

    # 请假学生
    def note_stu_ids(self, detail_filename):
        stuids = []
        all_detail_info = self.detail.get_all_detail_info(detail_filename)
        for a_detail_line in all_detail_info:
            if a_detail_line["CheckinResult"] == "请假":
                stuids.append(a_detail_line["StuID"])
            else:
                pass
        return stuids

    # 3.将审批通过的记录计入detail表
    def update_detail(self, new_detail_info, detail_filename):
        self.detail.write_file(new_detail_info, detail_filename, 'ab')

    # 构造detail数据
    def build_detail(self, stu_ids):
        new_detail_info = []
        for a_person in stu_ids:
            new_detail_info.append(
                self.detail.set_detail_line(a_person, self.get_time(), "null",
                                            "man", "null", "请假通过"))
        return new_detail_info