Esempio n. 1
0
    def get_recom(self):
        your_recom = self.__get_gpa(True)
        if isinstance(your_recom, dict):
            maxRank = select_int('select MAX(rank) from credit where class=?',self.Class)

            your_recom['max_rank'] = maxRank
            self.stu_amount = your_recom['max_rank']
            if self.stu_amount:
                percent = self.stu_amount / 5
                result = select_int('select gpa from credit where class=? and rank=?',self.Class, percent)

                your_recom['twenty_per'] = result
        return your_recom
Esempio n. 2
0
def get_read_info(nid, simple=False):
    send_stus = select_one('select stuids from noteindex where nid=?', nid)
    if not send_stus:
        return None
    if(',' in send_stus['stuids']):
        stu_send_list = send_stus['stuids'].split(',')[:-1]
    else:
        stu_send_list = [send_stus['stuids']]
    stu_send_list = list(set(stu_send_list))
    if simple:
        read_number = select_int('select readpop from noteresponse where nid=?', nid)
        if read_number is None:
            read_number=0
        return {'read_list': read_number, 'unread_list': len(stu_send_list)-read_number}

    read_info = select_one('select readTime from noteresponse where nid=?', nid)
    if not read_info:
        return None

    stu_read_list = [i.split(':')[0] for i in read_info['readtime'].split(',')[:-1]]
    stu_read_dicts_with_time = [{'stuid': i.split(":")[0],
                                 'time': __transfer_time(i.split(':')[1]),
                                 'name': get_stu_name(i.split(":")[0])} for i in read_info['readtime'].split(',')[:-1]]

    unread_stu = []
    for i in stu_send_list:
        if i in stu_read_list:
            pass
        else:
            unread_stu.append({'stuid':i, 'name':get_stu_name(i)})
    return {'read_list': stu_read_dicts_with_time, 'unread_list': unread_stu}
Esempio n. 3
0
    def get_recom(self):
        your_recom = self.__get_gpa(True)
        if isinstance(your_recom, dict):
            maxRank = select_int('select MAX(rank) from credit where class=?',
                                 self.Class)

            your_recom['max_rank'] = maxRank
            self.stu_amount = your_recom['max_rank']
            if self.stu_amount:
                percent = self.stu_amount / 5
                result = select_int(
                    'select gpa from credit where class=? and rank=?',
                    self.Class, percent)

                your_recom['twenty_per'] = result
        return your_recom
Esempio n. 4
0
def get_stuid(openid):
    stuid = select_int('select StuID from biding where OpenID =?', openid)

    if stuid:
        return stuid
    else:
        return None
Esempio n. 5
0
def get_stuid(openid):
    stuid = select_int('select StuID from biding where OpenID =?', openid)

    if stuid:
        return stuid
    else:
        return None
Esempio n. 6
0
def verify_password(stuid, passwd):
    result = select_int('select certificationcode from password where stuid =?', stuid)

    if not result:
        log.info("no certificationcode in database for student {stuid}".format(stuid=stuid))
        return -1
    if result == int(passwd):
        return True
    else:
        return False
Esempio n. 7
0
    def get_gpa(self):
        if self.stuid != -1:
            your_gpa = select_one('select *from creditcur where StuID = ?',
                                  self.stuid)

            if not your_gpa:
                return "当前没有您的GPA信息!!"
            if your_gpa.get('gpa'):
                self.gpa = round(your_gpa['gpa'], 4)
                self.Class = your_gpa['class']
                self.gpa_rank = your_gpa['rank']
                self.gpa_rank_next = self.gpa_rank + 1
                self.gpa_rank_prev = self.gpa_rank - 1

                max_rank = select_int(
                    'select max(rank) as max_rank from creditcur where class = ?',
                    self.Class)

                your_gpa['max'] = max_rank
                if self.gpa_rank != max_rank:
                    next_gpa = select_one(
                        'select *from creditcur where Class = ? and rank= ?',
                        self.Class, self.gpa_rank_next)
                    if next_gpa is None:
                        self.gpa_rank_next += 1
                        next_gpa = select_one(
                            'select *from creditcur where Class = ? and rank= ?',
                            self.Class, self.gpa_rank_next)
                    your_gpa['next'] = next_gpa['gpa']
                else:
                    your_gpa['nonnext'] = 1  # 排名是否最后的标志位
                    your_gpa['next'] = '悲剧…后面没有了'

                if self.gpa_rank_prev != 0:
                    prev_gpa = select_one(
                        'select *from creditcur where Class = ? and rank= ?',
                        self.Class, self.gpa_rank_prev)

                    your_gpa['prev'] = prev_gpa['gpa']
                else:
                    your_gpa['nonprev'] = 1
                    your_gpa['prev'] = '很强!前面木有了'

                first_gpa = select_one(
                    'select *from creditcur where Class = ? and rank= ?',
                    self.Class, 1)

                your_gpa['first'] = first_gpa['gpa']

                return your_gpa
            else:
                return '您没有记录在案的GPA数据!'
        else:
            return "您尚未绑定学号!"
Esempio n. 8
0
def verify_password(stuid, passwd):
    result = select_int(
        'select certificationcode from password where stuid =?', stuid)

    if not result:
        log.info("no certificationcode in database for student {stuid}".format(
            stuid=stuid))
        return -1
    if result == int(passwd):
        return True
    else:
        return False
Esempio n. 9
0
    def get_gpa(self):
        if self.stuid != -1:
            your_gpa = select_one('select *from creditcur where StuID = ?', self.stuid)

            if not your_gpa:
                return "当前没有您的GPA信息!!"
            if your_gpa.get('gpa'):
                self.gpa = round(your_gpa['gpa'], 4)
                self.Class = your_gpa['class']
                self.gpa_rank = your_gpa['rank']
                self.gpa_rank_next = self.gpa_rank + 1
                self.gpa_rank_prev = self.gpa_rank - 1

                max_rank = select_int('select max(rank) as max_rank from creditcur where class = ?',self.Class)

                your_gpa['max'] = max_rank
                if self.gpa_rank != max_rank:
                    next_gpa = select_one('select *from creditcur where Class = ? and rank= ?', self.Class, self.gpa_rank_next)
                    if next_gpa is None:
                        self.gpa_rank_next += 1
                        next_gpa = select_one('select *from creditcur where Class = ? and rank= ?', self.Class, self.gpa_rank_next)
                    your_gpa['next'] = next_gpa['gpa']
                else:
                    your_gpa['nonnext'] = 1   # 排名是否最后的标志位
                    your_gpa['next'] = '悲剧…后面没有了'

                if self.gpa_rank_prev != 0:
                    prev_gpa = select_one('select *from creditcur where Class = ? and rank= ?', self.Class, self.gpa_rank_prev)

                    your_gpa['prev'] = prev_gpa['gpa']
                else:
                    your_gpa['nonprev'] = 1
                    your_gpa['prev'] = '很强!前面木有了'

                first_gpa = select_one('select *from creditcur where Class = ? and rank= ?', self.Class, 1)

                your_gpa['first'] = first_gpa['gpa']

                return your_gpa
            else:
                return '您没有记录在案的GPA数据!'
        else:
            return "您尚未绑定学号!"
Esempio n. 10
0
def get_read_info(nid, simple=False):
    send_stus = select_one('select stuids from noteindex where nid=?', nid)
    if not send_stus:
        return None
    if (',' in send_stus['stuids']):
        stu_send_list = send_stus['stuids'].split(',')[:-1]
    else:
        stu_send_list = [send_stus['stuids']]
    stu_send_list = list(set(stu_send_list))
    if simple:
        read_number = select_int(
            'select readpop from noteresponse where nid=?', nid)
        if read_number is None:
            read_number = 0
        return {
            'read_list': read_number,
            'unread_list': len(stu_send_list) - read_number
        }

    read_info = select_one('select readTime from noteresponse where nid=?',
                           nid)
    if not read_info:
        return None

    stu_read_list = [
        i.split(':')[0] for i in read_info['readtime'].split(',')[:-1]
    ]
    stu_read_dicts_with_time = [{
        'stuid': i.split(":")[0],
        'time': __transfer_time(i.split(':')[1]),
        'name': get_stu_name(i.split(":")[0])
    } for i in read_info['readtime'].split(',')[:-1]]

    unread_stu = []
    for i in stu_send_list:
        if i in stu_read_list:
            pass
        else:
            unread_stu.append({'stuid': i, 'name': get_stu_name(i)})
    return {'read_list': stu_read_dicts_with_time, 'unread_list': unread_stu}
Esempio n. 11
0
def get_url(nid):
    return select_int('select url from notecontent where nid=?',nid)
Esempio n. 12
0
def get_url(nid):
    return select_int('select url from notecontent where nid=?', nid)