Пример #1
0
def absence(wechat_id):
    subprocess.call("clear")
    while True:
        obj = ManCheckin(wechat_id)
        if obj.tea_id == 0:
            print PrtInfo.failedMessage(4)
            prompt = raw_input('maybe try again?(y/n)')
            if prompt == 'n':
                break
        else:
            c = BaseCheckin.find_checkin_obj_for_tea(wechat_id)
            if c != None:
                temp = []
                for stu in c.init_student_records():
                    auto_rec = c.get_latest_record(stu['StuID'], 'Auto')
                    if auto_rec == {} or auto_rec['IsSuc'] == 'False':
                        auto_rec = {
                            'StuID': stu['StuID'],
                            'checkinTime': '?????????????????????',
                            'ProofPath': 'none',
                            'checkinType': 'Auto',
                            'IsSuc': 'False',
                            'checkinResult': '???'
                        }
                        temp.append(auto_rec)
                print detail_format(temp)
                break
            else:
                break
Пример #2
0
def sum_history(wechat_id):
    subprocess.call("clear")
    while True:
        obj = ManCheckin(wechat_id)
        if obj.tea_id == 0:
            print PrtInfo.failedMessage(4)
            prompt = raw_input('maybe try again?(y/n)')
            if prompt == 'n':
                break
        else:
            BaseCheckin.update_sum(obj)
            sum_records = SumFile.read_file(
                BaseCheckin.init_sum_name(obj.tea_id, obj.crs_id))
            r = range(1, obj.init_seq_id(obj.tea_id, obj.crs_id))
            r.append('exit')
            q = Form(['seq id'], ['once', 'all', 'back'])
            ch = q.init_form()

            if ch == len(q.items) or ch == -1:
                break
            elif ch == 1:
                c = Form(['seq id'], r)
                seq_id = c.init_form()
                if seq_id == len(r) or seq_id == -1:
                    break
                sum_format(sum_records, seq_id=seq_id)
                break
            sum_format(sum_records)
            break
Пример #3
0
def attendence(wechat_id):
    subprocess.call("clear")
    while True:
        obj = ManCheckin(wechat_id)
        if obj.tea_id == 0:
            print PrtInfo.failedMessage(4)
            prompt = raw_input('maybe try again?(y/n)')
            if prompt == 'n':
                break
        else:
            c = BaseCheckin.find_checkin_obj_for_tea(wechat_id)
            if c != None:
                detail_records = BaseFile.read_file(
                    c.init_detail_name(str(c.tea_id), str(c.crs_id),
                                       str(c.seq_id)))
                detail_records = BaseCheckin.filter_invalid_detail_records(
                    detail_records)
                temp = []
                for i in detail_records:
                    if i['IsSuc'] == 'True':
                        temp.append(i)
                print detail_format(temp)
                break
            else:
                break
Пример #4
0
 def find_checkin_obj_for_tea(wechat_id):
     if BaseCheckin.checkin_list == []:
         print PrtInfo.failedMessage(6)
         return None
     else:
         tea_id = BaseCheckin.init_teacher_id_by_wechatid(wechat_id)
         for i in BaseCheckin.checkin_list:
             if i.tea_id == tea_id:
                 return i
         else:
             print PrtInfo.failedMessage(6)
             return None
Пример #5
0
def start_manual_menu(wechat_id):
    subprocess.call("clear")
    while True:
        obj = ManCheckin(wechat_id)
        if obj.tea_id == 0:
            print PrtInfo.failedMessage(4)
            prompt = raw_input('maybe try again?(y/n)')
            if prompt == 'n':
                break
        else:
            obj.add_seq_id(obj.seq_id)
            obj.write_detail_file(obj.init_detail_records())
            obj.update_sum_by_certain_seq_id(obj.seq_id)
            break
Пример #6
0
def start_checkin_menu(wechat_id):
    subprocess.call("clear")
    while True:
        obj = BaseCheckin.find_checkin_obj_for_tea(wechat_id)
        if obj != None:
            print PrtInfo.failedMessage(7)
            break
        obj = AutoCheckin(wechat_id)
        if obj == None:
            print PrtInfo.failedMessage(4)
            prompt = raw_input('maybe try again?(y/n)')
            if prompt == 'n':
                break
        else:
            obj.start_checkin()
            break
Пример #7
0
def start_random_menu(wechat_id):
    subprocess.call("clear")
    while True:
        obj = BaseCheckin.find_checkin_obj_for_tea(wechat_id)
        if obj == None:
            print PrtInfo.failedMessage(4)
            prompt = raw_input('maybe try again?(y/n)')
            if prompt == 'n':
                subprocess.call("clear")
                break
        else:
            try:
                i = int(raw_input('Please input random number:'))
                obj.start_random_checkin(i)
                break
            except ValueError, e:
                print 'invalid input ,try again'
Пример #8
0
def detail_now(wechat_id):
    subprocess.call("clear")
    while True:
        obj = ManCheckin(wechat_id)
        if obj.tea_id == 0:
            print PrtInfo.failedMessage(4)
            prompt = raw_input('maybe try again?(y/n)')
            if prompt == 'n':
                break
        else:
            c = BaseCheckin.find_checkin_obj_for_tea(wechat_id)
            if c != None:
                detail_records = BaseFile.read_file(
                    c.init_detail_name(str(c.tea_id), str(c.crs_id),
                                       str(c.seq_id)))
                detail_format(detail_records)
                break
            else:
                break
Пример #9
0
def detail_history(wechat_id):
    subprocess.call("clear")
    while True:
        obj = ManCheckin(wechat_id)
        if obj.tea_id == 0:
            print PrtInfo.failedMessage(4)
            prompt = raw_input('maybe try again?(y/n)')
            if prompt == 'n':
                break
        else:
            r = range(1, obj.init_seq_id(obj.tea_id, obj.crs_id))
            r.append('exit')
            c = Form(['seq id'], r)
            seq_id = c.init_form()
            if seq_id == len(r) or seq_id == -1:
                break
            detail_records = DetailFile.read_file(
                BaseCheckin.init_detail_name(obj.tea_id, obj.crs_id, seq_id))
            detail_format(detail_records)
            break
Пример #10
0
 def find_checkin_obj_with_wechat_id(wechat_id):
     if BaseCheckin.checkin_list == []:
         print PrtInfo.failedMessage(0)
         return None
     else:
         print PrtInfo.promptMessage(10)
         tea_ids = []
         for i in BaseCheckin.checkin_list:
             tea_ids.append(i.tea_id)
         choice = Form(['teacher id'], tea_ids).init_form()
         if choice == -1:
             return None
         tea_id = tea_ids[choice - 1]
         for i in BaseCheckin.checkin_list:
             if i.tea_id == tea_id:
                 if i.get_stu_id_in_class_list(wechat_id) != None:
                     return i
                 else:
                     print PrtInfo.notFoundMessage(4)
                     return None
         else:
             print PrtInfo.failedMessage(0)
             return None
Пример #11
0
 def join_checkin(self, wechat_id):
     if self in BaseCheckin.checkin_list:
         checkin_type = raw_input(PrtInfo.promptMessage(6))
         if checkin_type == 'Auto':
             self.init_new_detail_record(wechat_id, 'Auto')
             PrtInfo.successMessage(8)
             return True
         elif checkin_type == 'Random':
             random_list = self.get_random_list()
             if random_list == []:
                 print 'No random check in now'
                 return False
             if self.get_stu_id_in_class_list(wechat_id) not in random_list:
                 print PrtInfo.notFoundMessage(4)
                 return False
             else:
                 self.init_new_detail_record(wechat_id, 'Random')
                 PrtInfo.successMessage(8)
         else:
             print PrtInfo.failedMessage(1)
     else:
         print PrtInfo.failedMessage(0)
         return False