コード例 #1
0
def student_rank(request):
    id = request.session.get('student_id', -1)
    if id == -1:
        return HttpResponse('Access denied')
    student_dic = stu.getStudentAllDictByAccount(stu.idToAccountStudent(str(id)))
    account = stu.idToAccountStudent(str(id))
    student = stu.getStudentAll(account)
    name_list = []
    score_list = []
    rank_list = []
    score = getStudentEstimateScore(student)
    rank, sum_rank = stu.getStudentEstimateRank(student)

    name_list.append(u'总成绩(审核通过)')
    score_list.append(score)
    rank_list.append(rank + '/' + sum_rank)

    estimate_dic = eval(getattr(student, 'estimateScore', '{}'))
    listall = [{'name':u'总成绩(审核通过)', 'score':score, 'rank':rank + '/' + sum_rank}]
    for item in estimate_dic.keys():
        if 'shenhe' not in estimate_dic[item].keys():
            continue
        item_score = stu.getStudentEstimateScore_Every(student, item)
        item_rank, item_sum = stu.getStudentEstimateRank_Every(student, item)
        listall.append({'name':item, 'score':item_score, 'rank':item_rank + '/' + item_sum})

    '''
    namelist是试题名称的列表,例如[2016_北京_理综]
    scorelist是试题得分的列表,例如[90]
    ranklist是试题的排名的列表, 例如[1/34]
    '''

    return render(request, 'student/rank.html', {'dict': listall, 'id': id})
コード例 #2
0
def get_message_info(request):
    """
        后端应在此处返回某个消息的详细信息,需要的信息见下面的样例
    """
    # print request.POST
    # print 'message id',request.POST.get('message_id')
    message_id = int(request.POST.get('message_id', -1))
    id = request.session.get('student_id', -1)
    if id == -1:
        return HttpResponse('Access denied')
    id = int(id)

    stu_readed_list = eval(stu.getStudent(stu.idToAccountStudent(id), Student.READED))
    if message_id not in stu_readed_list:
        stu_readed_list.append(message_id)

    stu.setStudent(stu.idToAccountStudent(id), Student.READED, stu_readed_list)



    dic = []
    notice = back.getNoticebyDict({Notice.ID: message_id})[0]
    info_dic = back.getNoticeAllDictByObject(notice)
    send_tch_account = tch.idToAccountTeacher(int(info_dic[Notice.TEACHER_ID]))
    send_tch_name = tch.getTeacher(send_tch_account, Teacher.REAL_NAME)
    dic = {'sender': send_tch_name,
           'title': info_dic[Notice.TITLE],
           # 'time': info_dic[Notice.SEND_DATE].strftime("%Y-%m-%d %H:%I:%S"),
           'time': info_dic[Notice.SEND_DATE].replace(tzinfo=pytz.utc).astimezone(pytz.timezone('Asia/Shanghai')).strftime("%Y-%m-%d %H:%M:%S"),
           'text': info_dic[Notice.TEXT]}
    # print dic
    return JsonResponse(dic)
コード例 #3
0
def submit_test_result(request):
    """
        后端应在此处保存这次答题的结果
        学生id从request.session获取
        时间数据、分数数据、试题名称见下面样例
        返回空Json即可
    """
    id = request.session.get('student_id', -1)
    if id == -1:
        return HttpResponse('Access denied')
    print id
    print request.POST
    time_list = [int(item) for item in request.POST.get('time_list').split(",")]
    score_list = [int(item) for item in request.POST.get('score_list').split(",")]
    test_name = request.POST.get('test_name')
    account = stu.idToAccountStudent(str(id))
    tmp = (stu.getStudentAllDictByAccount(account))[Student.ESTIMATE_SCORE]
    if tmp.strip() == '':
        tmp = '{}'
    try:
        stu_dic = eval(tmp)
    except:
        stu_dic = {}
    stu_dic[test_name] = {'time': sum(time_list), 'score': sum(score_list), 'every_time':time_list, 'every_score':score_list}
    stu.setStudent(account, Student.ESTIMATE_SCORE, str(stu_dic))
    return JsonResponse({})
コード例 #4
0
def get_all_tests(request):
    """
        后端应在此处返回该学生全部可以做的题目名称。名称无重复
        学生id由request.session中获取,同其他函数里的写法
        然后放到下面样例写好的dic的'tests'键对应的列表值中
    """
    id = request.session.get('student_id', -1)
    if id == -1:
        return HttpResponse('Access denied')
    print id
    account = stu.idToAccountStudent(str(id))
    student = stu.getStudentAll(account)
    stu_dic = stu.getStudentAllDictByAccount(account)
    year = datetime.datetime.now().strftime("%Y")

    year = int(year) - YEAR_LIST[1] + 1
    province = int(stu_dic[Student.PROVINCE]['province'])
    print 'pro ', province
    dic = {
        Picture.YEAR: year,
        Picture.PROVINCE: province,
        Picture.IS_TITLE: 0,
        Picture.IS_DELEVERED: 1,
    }
    global rec_dict
    rec_dict = dic

    ret_list = []
    subject_list = []
    pic_list = pic.getPicturebyDict(dic)
    for item in pic_list:
        pic_dic = pic.getPictureAllDictByObject(item)
        if pic_dic[Picture.SUBJECT] in subject_list:
            continue
        subject_list.append(pic_dic[Picture.SUBJECT])
        tao = u'%s_%s_%s' % (str(YEAR_LIST[pic_dic[Picture.YEAR]]),
                            str(PROVINCE_LIST[pic_dic[Picture.PROVINCE]]),
                            str(SUBJECT_LIST[pic_dic[Picture.SUBJECT]]))
        ret_list.append(tao)

    done_list = []
    for item in ret_list:
        shenhe_fen = int(stu.getStudentEstimateScore_Every(student, item))
        no_shenhe_fen = int(stu.getStudentEstimateScore_Every_no_shenhe(student, item))
        print shenhe_fen, no_shenhe_fen
        if no_shenhe_fen == 0:
            done_list.append(u'未测试')
        else:
            if shenhe_fen != no_shenhe_fen:
                done_list.append(u'测试未审核, 得分:%s'%(str(no_shenhe_fen)))
            else:
                done_list.append(u'已审核, 得分:%s'%(str(shenhe_fen)))

    print 'done ', done_list
    dic = {'tests' : ret_list,
           'done_list' : done_list}
    # 后端需要增加一个键值对,done_list存储是否估分,长度和ret_list一样

    return JsonResponse(dic)
コード例 #5
0
def check_should_log_out(request, id):
    total_seconds = 600 # 10min
    account = stu.idToAccountStudent(id)
    try:
        new_time = stu.getStudent(account, Student.LAST_LOGIN_TIME)
        this_time = time.strptime(request.session.get['login_time'], "%Y-%m-%d %H:%M:%S")
        time_delta = (new_time - this_time).total_seconds()
        if time_delta > total_seconds or time_delta < -total_seconds:
            return redirect('/login/')
        else:
            return False
    except:
        return False
コード例 #6
0
def get_last_estimate_score(stu_id, test_id):
    if type(stu_id) == str:
        stu_id = int(stu_id)
    stu_account = stu.idToAccountStudent(stu_id)
    try:
        estimate_info = stu.getStudent(stu_account, Student.ESTIMATE_SCORE)
    except:
        estimate_info = '{}'
    estimate_info = eval(estimate_info)
    try:
        last_score = estimate_info[test_id]['score']
    except:
        last_score = 0
    return last_score
コード例 #7
0
def volunteer_search_student_by_name(request):
    if 'volunteer_id' not in request.session.keys():
        return redirect('/login/')
    '''
        后端需要在这里改代码,根据姓名搜索学生
        姓名可以通过request.POST.get('name')获取
    '''
    if request.is_ajax() and request.method == 'POST':
        name = request.POST.get('name')
        t = []

        vol_id = request.session.get('volunteer_id')
        vol_student_id_list = vol.get_can_see_students(vol_id)
        vol_student_account_list = []
        for item in vol_student_id_list:
            vol_student_account_list.append(stu.idToAccountStudent(item))
        # print 'sadfasdf--------------------------', vol_student_account_list
        if request.is_ajax() and request.method == 'POST':
            t = []
            record_id = []
            for account in vol_student_account_list:
                item = stu.getStudentAll(account)
                stu_dic = stu.getStudentAllDictByAccount(account)
                if name.strip() != '' and name != stu_dic[Student.REAL_NAME]:
                    continue
                if stu_dic[Student.ID] in record_id:
                    continue
                record_id.append(stu_dic[Student.ID])
                dic = {
                    'id':
                    stu_dic[Student.ID],
                    'name':
                    stu_dic[Student.REAL_NAME],
                    'gender':
                    stu_dic[Student.SEX]['sexlist'][stu_dic[Student.SEX]
                                                    ['sex']],
                    'source':
                    stu_dic[Student.PROVINCE]['provincelist'][stu_dic[
                        Student.PROVINCE]['province']],
                    'school':
                    stu_dic[Student.SCHOOL],
                    'id_card':
                    stu_dic[Student.ID_NUMBER]
                }
                t.append(dic)

        return JsonResponse(t, safe=False)  # must use 'safe=False'
    else:
        return HttpResponse('Access denied.')
コード例 #8
0
def back_to_profile(request, id):
    account = stu.idToAccountStudent(id)
    stu_dic = stu.getStudentAllDictByAccount(account)
    student = stu.getStudentAll(account)
    (rank, tmp) = stu.getStudentEstimateRank(student)
    dic = {
        'name': stu_dic[Student.REAL_NAME],
        'identification': stu_dic[Student.ID_NUMBER],
        'sex': stu_dic[Student.SEX],
        'nation': stu_dic[Student.NATION],
        'birth': stu_dic[Student.BIRTH].strftime("%m/%d/%Y"),
        'province': stu_dic[Student.PROVINCE],
        'phone': stu_dic[Student.PHONE],
        'email': stu_dic[Student.EMAIL],
        'wenli': stu_dic[Student.TYPE],
        'address': stu_dic[Student.ADDRESS],
        'dadName': stu_dic[Student.DAD_NAME],
        'dadPhone': stu_dic[Student.DAD_PHONE],
        'momName': stu_dic[Student.MOM_NAME],
        'momPhone': stu_dic[Student.MOM_PHONE],
        'school': stu_dic[Student.SCHOOL],
        'stu_class': stu_dic[Student.CLASSROOM],
        'tutorName': stu_dic[Student.TUTOR_NAME],
        'tutorPhone': stu_dic[Student.TUTOR_PHONE],
        Student.MAJOR: stu_dic[Student.MAJOR],
        Student.TEST_SCORE_LIST: stu_dic[Student.TEST_SCORE_LIST],
        Student.RANK_LIST: stu_dic[Student.RANK_LIST],
        Student.SUM_NUMBER_LIST: stu_dic[Student.SUM_NUMBER_LIST],
        'realScore': stu_dic[Student.REAL_SCORE],
        'relTeacher': stu_dic[Student.DUIYING_TEACHER],
        'comment': stu_dic[Student.COMMENT],
        'estimateScore': getStudentEstimateScore(stu.getStudentAll(account)),
        'estimateRank': str(rank) + '/' + str(tmp)
    }
    group_list = stu.getStudentGroupIDListString(student).split(' ')
    for i in range(1, 6):
        if i < len(group_list):
            dic['group' + str(i)] = group_list[i]
        else:
            dic['group' + str(i)] = '0'
    dic['grouplist'] = [' ']
    all_group = back.getGroupbyDict({})
    for item in all_group:
        dic['grouplist'].append(back.getGroupAllDictByObject(item)['id'])
    print '----------------*****--------'
    return redirect('/student/profile/?auth=0')
コード例 #9
0
def student_info_save(request):
    t = get_template('teacher/student_info.html')
    print '------------------------'
    print 'lihaoyang : ' + str(request.POST)
    if id == -1:
        return HttpResponse('Access denied')
    account = stu.idToAccountStudent(str(id))
    stu_dic = stu.getStudentAllDictByAccount(account)
    dic = {
        Student.ID: stu_dic[Student.ID],
        Student.ACCOUNT: stu_dic[Student.ACCOUNT],
        Student.REAL_NAME: stu_dic[Student.REAL_NAME],
        Student.BIRTH: stu_dic[Student.BIRTH].strftime("%Y-%m-%d"),
        Student.ID_NUMBER: stu_dic[Student.ID_NUMBER],
        Student.TYPE: stu_dic[Student.TYPE],
        Student.SEX: stu_dic[Student.SEX],
        Student.NATION: stu_dic[Student.NATION],
        Student.SCHOOL: stu_dic[Student.SCHOOL],
        Student.CLASSROOM: stu_dic[Student.CLASSROOM],
        Student.ADDRESS: stu_dic[Student.ADDRESS],
        Student.PHONE: stu_dic[Student.PHONE],
        Student.EMAIL: stu_dic[Student.EMAIL],
        Student.DAD_PHONE: stu_dic[Student.DAD_PHONE],
        Student.MOM_PHONE: stu_dic[Student.MOM_PHONE],
        Student.TUTOR_NAME: stu_dic[Student.TUTOR_NAME],
        Student.TUTOR_PHONE: stu_dic[Student.TUTOR_PHONE],
        Student.PROVINCE: stu_dic[Student.PROVINCE],
        Student.MAJOR: stu_dic[Student.MAJOR],
        Student.TEST_SCORE_LIST: stu_dic[Student.TEST_SCORE_LIST],
        Student.RANK_LIST: stu_dic[Student.RANK_LIST],
        Student.SUM_NUMBER_LIST: stu_dic[Student.SUM_NUMBER_LIST],
        Student.ESTIMATE_SCORE:
        getStudentEstimateScore(stu.getStudentAll(account)),
        Student.REAL_SCORE: stu_dic[Student.REAL_SCORE],
        Student.REGISTER_CODE: stu_dic[Student.REGISTER_CODE],
        Student.ADMISSION_STATUS: stu_dic[Student.ADMISSION_STATUS],
        Student.TEACHER_LIST: stu_dic[Student.TEACHER_LIST],
        Student.VOLUNTEER_ACCOUNT_LIST:
        stu_dic[Student.VOLUNTEER_ACCOUNT_LIST],
        Student.COMMENT: stu_dic[Student.COMMENT],
        Student.MOM_NAME: stu_dic[Student.MOM_NAME],
        Student.DAD_NAME: stu_dic[Student.DAD_NAME],
    }

    id_ = request.session.get('teacher_id', -1)
    return HttpResponse(t.render({'student': dic, 'id': id_}))
コード例 #10
0
def student_admit(request):
    '''

    后端需要获取录取信息传给前端
    '''
    id = request.session.get('student_id', -1)
    if id == -1:
        return HttpResponse('Access denied')


    student_dic = stu.getStudentAllDictByAccount(stu.idToAccountStudent(str(id)))
    info = student_dic[Student.ADMISSION_STATUS]
    if info.strip() == '' or info.strip() == "0":
        info = u'暂时还没有您的录取信息,请耐心等待老师添加'
    admition = info
    return render(request,
                  'student/admit.html', {'admition': admition, 'id':id})
コード例 #11
0
def checkscoredetail(request):
    '''
     'name':name,
     'testname':testname,
     'stu_id':stu_id,
     后端会从GET中得到上面的参数,然后完成下面的字典
    '''
    # timelist = [{"label": "1", "value": "100s"}, {"label": "2", "value": "810s"}, {"label": "3", "value": "40s"},
    #         {"label": "4", "value": "140s"}, {"label": "5", "value": "40s"}, {"label": "6", "value": "420s"},
    #         {"label": "7", "value": "405s"}, {"label": "8", "value": "420s"}, {"label": "9", "value": "140s"},
    #         {"label": "1", "value": "100s"}, {"label": "2", "value": "810s"}, {"label": "3", "value": "40s"},
    #         {"label": "4", "value": "140s"}, {"label": "5", "value": "40s"}, {"label": "6", "value": "420s"},
    #         {"label": "7", "value": "405s"}, {"label": "8", "value": "420s"}, {"label": "9", "value": "140s"},
    #         {"label": "1", "value": "100s"}, {"label": "2", "value": "810s"}, {"label": "3", "value": "40s"},
    #         {"label": "4", "value": "140s"}, {"label": "5", "value": "40s"}, {"label": "6", "value": "420s"},
    #         {"label": "7", "value": "405s"}, {"label": "8", "value": "420s"}, {"label": "9", "value": "140s"},] ;
    #
    # dict = {
    #     'timelist': timelist,
    #     'subject': '语文',
    # }

    timelist = []
    dict = {}

    stu_id = int(request.GET.get('stu_id'))
    test_id = request.GET.get('testname')

    info_dic = stu.getStudentAllDictByAccount(stu.idToAccountStudent(stu_id))

    every_time_list = eval(
        info_dic[Student.ESTIMATE_SCORE])[test_id]['every_time']
    for i in range(0, len(every_time_list)):
        dic = {}
        dic['label'] = str(i + 1)
        dic['value'] = '%ss' % (str(every_time_list[i]))
        timelist.append(dic)

    dict = {
        'timelist': timelist,
        'subject': test_id,
    }

    return JsonResponse(dict)
コード例 #12
0
def get_all_message(request):
    """
        后端应在此处返回某个学生可以看见的所有消息的列表,需要的信息见下面的样例
    """
    id = request.session.get('student_id', -1)
    if id == -1:
        return HttpResponse('Access denied')
    id = int(id)
    dic = []
    notice_list = back.getNoticebyDict({})
    # print 'notice_list', len(notice_list)
    for notice in notice_list:
        info_dic = back.getNoticeAllDictByObject(notice)
        print info_dic
        try:
            rece_stu_list = eval(info_dic[Notice.RECEIVE_STU])
        except:
            print 'bug'
            rece_stu_list = []

        if id in rece_stu_list or str(id) in rece_stu_list:
            send_tch_account = tch.idToAccountTeacher(int(info_dic[Notice.TEACHER_ID]))
            send_tch_name = tch.getTeacher(send_tch_account, Teacher.REAL_NAME)
            read_state = u'未读'
            try:
                stu_readed_list = eval(stu.getStudent(stu.idToAccountStudent(id), Student.READED))
            except:
                stu_readed_list = []
            if info_dic[Notice.ID] in stu_readed_list:
                read_state = u'已读'


            tmp_dic = {'sender': send_tch_name,
                       'title': info_dic[Notice.TITLE],
                       'state': read_state,
                       'message_id':info_dic[Notice.ID]}
            dic.append(tmp_dic)
    ret = list(reversed(dic))
    return JsonResponse(ret, safe=False)
コード例 #13
0
def distribute_student(request):
    '''
       GET newteam 新建组
    '''
    if 'newteam' in request.GET:
        back.createGroupbyDict({Group.NAME: 'new name'})
        num = len(back.getGroupbyDict({}))
        return JsonResponse({'teamnum': num})
    '''
    GET id teamid 删除
    '''
    if ('id' in request.GET) and ('teamid'
                                  in request.GET) and ('class' in request.GET):

        print 'cao ', request.GET
        group_id = int(request.GET['teamid'])
        isDelStudent = int(request.GET['class'])
        if isDelStudent == 1:
            stu_id = str(request.GET['id'])
            group = back.getGroupbyDict({Group.ID: group_id})[0]
            group_dic = back.getGroupAllDictByObject(group)
            # print 'group_dic', group_dic
            stu_id_list = group_dic[Group.STU_LIST].split('_')
            if stu_id in stu_id_list:
                stu_id_list.remove(stu_id)
            str_list = '_'.join(stu_id_list)
            print 'haha', str_list
            back.setGroup(group, Group.STU_LIST, str_list)
        else:
            vol_id = str(request.GET['id'])
            group = back.getGroupbyDict({Group.ID: group_id})[0]
            group_dic = back.getGroupAllDictByObject(group)
            vol_id_list = group_dic[Group.VOL_LIST].split('_')
            if vol_id in vol_id_list:
                vol_id_list.remove(vol_id)
            str_list = '_'.join(vol_id_list)
            back.setGroup(group, Group.VOL_LIST, str_list)

        return JsonResponse({'success': 1})
    else:
        team_list = []

        group_list = back.getGroupbyDict({})
        for group in group_list:
            group_dic = back.getGroupAllDictByObject(group)
            team = {}
            team['teamleader'] = str(group_dic[Group.ID])
            team['teamname'] = str(group_dic[Group.NAME])
            team['volunteer'] = {}
            team['student'] = {}

            print 'adf', group_dic
            if len(group_dic[Group.VOL_LIST].strip()) > 0:
                vol_id_list = group_dic[Group.VOL_LIST].split('_')
                for i in range(0, len(vol_id_list)):
                    if vol_id_list[i].strip() == '':
                        continue
                    vol_account = vol.idToAccountVolunteer(str(vol_id_list[i]))
                    vol_dic = vol.getVolunteerAllDictByAccount(vol_account)
                    dic = {
                        'user_name': vol_dic[Volunteer.ACCOUNT],
                        'name': vol_dic[Volunteer.REAL_NAME],
                        'id': vol_dic[Volunteer.ID],
                    }
                    team['volunteer'][('volunteer' + str(i))] = dic

            if len(group_dic[Group.STU_LIST].strip()) > 0:
                stu_id_list = group_dic[Group.STU_LIST].split('_')
                for i in range(0, len(stu_id_list)):
                    if stu_id_list[i].strip() == '':
                        continue
                    stu_account = stu.idToAccountStudent(str(stu_id_list[i]))
                    stu_dic = stu.getStudentAllDictByAccount(stu_account)
                    dic = {
                        'user_name': stu_dic[Student.ACCOUNT],
                        'name': stu_dic[Student.REAL_NAME],
                        'id': stu_dic[Student.ID],
                    }
                    team['student'][('student' + str(i))] = dic

            team_list.append(team)
        team_list.reverse()

        id_ = request.session.get('teacher_id', -1)
        return render(request, 'teacher/distribute_student.html', {
            'dict': team_list,
            'id': id_
        })
コード例 #14
0
def student_info_show(request):
    t = get_template('teacher/student_info.html')
    id = request.GET.get('id', -1)
    if id == -1:
        return HttpResponse('Access denied')
    account = stu.idToAccountStudent(str(id))
    student = stu.getStudentAll(account)
    stu_dic = stu.getStudentAllDictByAccount(account)
    dic = {
        Student.ID: stu_dic[Student.ID],
        Student.ACCOUNT: stu_dic[Student.ACCOUNT],
        Student.REAL_NAME: stu_dic[Student.REAL_NAME],
        Student.BIRTH: stu_dic[Student.BIRTH].strftime("%Y-%m-%d"),
        Student.ID_NUMBER: stu_dic[Student.ID_NUMBER],
        Student.TYPE: stu_dic[Student.TYPE],
        Student.SEX: stu_dic[Student.SEX],
        Student.NATION: stu_dic[Student.NATION],
        Student.SCHOOL: stu_dic[Student.SCHOOL],
        Student.CLASSROOM: stu_dic[Student.CLASSROOM],
        Student.ADDRESS: stu_dic[Student.ADDRESS],
        Student.PHONE: stu_dic[Student.PHONE],
        Student.EMAIL: stu_dic[Student.EMAIL],
        Student.DAD_PHONE: stu_dic[Student.DAD_PHONE],
        Student.MOM_PHONE: stu_dic[Student.MOM_PHONE],
        Student.TUTOR_NAME: stu_dic[Student.TUTOR_NAME],
        Student.TUTOR_PHONE: stu_dic[Student.TUTOR_PHONE],
        Student.PROVINCE: stu_dic[Student.PROVINCE],
        Student.MAJOR: stu_dic[Student.MAJOR],
        Student.TEST_SCORE_LIST: stu_dic[Student.TEST_SCORE_LIST],
        Student.RANK_LIST: stu_dic[Student.RANK_LIST],
        Student.SUM_NUMBER_LIST: stu_dic[Student.SUM_NUMBER_LIST],
        Student.ESTIMATE_SCORE:
        getStudentEstimateScore(stu.getStudentAll(account)),
        Student.REAL_SCORE: stu_dic[Student.REAL_SCORE],
        Student.REGISTER_CODE: stu_dic[Student.REGISTER_CODE],
        Student.ADMISSION_STATUS: stu_dic[Student.ADMISSION_STATUS],
        Student.TEACHER_LIST: stu_dic[Student.TEACHER_LIST],
        Student.VOLUNTEER_ACCOUNT_LIST:
        stu_dic[Student.VOLUNTEER_ACCOUNT_LIST],
        Student.COMMENT: stu_dic[Student.COMMENT],
        Student.MOM_NAME: stu_dic[Student.MOM_NAME],
        Student.DAD_NAME: stu_dic[Student.DAD_NAME],
        Student.DUIYING_TEACHER: stu_dic[Student.DUIYING_TEACHER],
    }

    group_list = stu.getStudentGroupIDListString(student).split(' ')
    if '' in group_list:
        group_list.remove('')
    for i in range(0, 5):
        if i < len(group_list) and group_list[i] != '':
            dic['group' + str(i + 1)] = int(group_list[i])
        else:
            dic['group' + str(i + 1)] = 0

    dic['grouplist'] = [' ']
    all_group = back.getGroupbyDict({})
    for item in all_group:
        dic['grouplist'].append(back.getGroupAllDictByObject(item)['id'])
    print dic['grouplist']
    dic['forbid'] = int(stu_dic[Student.QUANXIAN])
    dic['forbidlist'] = PERMISSION_LIST
    print 'byr pinwei ', dic['forbid'], dic['forbidlist']
    id_ = request.session.get('teacher_id', -1)
    return HttpResponse(t.render({'student': dic, 'id': id_}))
コード例 #15
0
def student_info_edit(request):
    if request.method == 'POST':
        '''
            后端需要在这里改代码,保存传进来的数据到数据库,并返回正确的dict
        '''
        id = request.GET.get('id')
        account = stu.idToAccountStudent(str(id))
        info_dict = request.POST.copy()
        for i in range(1, 7):
            if info_dict['majorSelect' + str(i)].strip() == '':
                info_dict['majorSelect' + str(i)] = '0'
        for i in range(1, 4):
            if info_dict['testScore' + str(i)].strip() == '':
                info_dict['testScore' + str(i)] = '0'
        for i in range(1, 4):
            if info_dict['rank' + str(i)].strip() == '':
                info_dict['rank' + str(i)] = '0'
        for i in range(1, 4):
            if info_dict['rank' + str(i)].strip() == '':
                info_dict['rank' + str(i)] = '0'
        for i in range(1, 4):
            if info_dict['rank' + str(i) + str(i)].strip() == '':
                info_dict['rank' + str(i) + str(i)] = '0'
        if info_dict['estimateScore'].strip() == '':
            info_dict['estimateScore'] = '0'
        if info_dict['realScore'].strip() == '':
            info_dict['realScore'] = '0'
        if info_dict['admissionStatus'].strip() == '':
            info_dict['admissionStatus'] = '0'

        print info_dict
        dic = {
            'type':
            int(info_dict.get('type', '110')),
            'province':
            int(info_dict.get('province', '110')),
            'phone':
            info_dict.get('phone', '110'),
            'email':
            info_dict.get('email', '110'),
            'address':
            info_dict.get('address', '110'),
            'dadName':
            info_dict.get('dadName', '110'),
            'dadPhone':
            info_dict.get('dadPhone', '110'),
            'momName':
            info_dict.get('momName', '110'),
            'momPhone':
            info_dict.get('momPhone', '110'),
            'school':
            info_dict.get('school', '110'),
            'stu_class':
            info_dict.get('stu_class', '110'),
            'tutorName':
            info_dict.get('tutorName', '110'),
            'tutorPhone':
            info_dict.get('tutorPhone', '110'),
            'majorSelect1':
            int(info_dict.get('majorSelect1', '110')),
            'majorSelect2':
            int(info_dict.get('majorSelect2', '110')),
            'majorSelect3':
            int(info_dict.get('majorSelect3', '110')),
            'majorSelect4':
            int(info_dict.get('majorSelect4', '110')),
            'majorSelect5':
            int(info_dict.get('majorSelect5', '110')),
            'majorSelect6':
            int(info_dict.get('majorSelect6', '110')),
            'testScore1':
            int(info_dict.get('testScore1', '110')),
            'testScore2':
            int(info_dict.get('testScore2', '110')),
            'testScore3':
            int(info_dict.get('testScore3', '110')),
            'rank1':
            int(info_dict.get('rank1', '110')),
            'rank11':
            int(info_dict.get('rank11', '110')),
            'rank2':
            int(info_dict.get('rank2', '110')),
            'rank22':
            int(info_dict.get('rank22', '110')),
            'rank3':
            int(info_dict.get('rank3', '110')),
            'rank33':
            int(info_dict.get('rank33', '110')),
            'estimateScore':
            getStudentEstimateScore(stu.getStudentAll(account)),
            'realScore':
            int(info_dict.get('realScore', '110')),
            'admissionStatus':
            info_dict.get('admissionStatus', '110'),
            'relTeacher':
            info_dict.get('relTeacher', '110'),
            'relVolunteer':
            info_dict.get('relVolunteer', '110'),
            'comment':
            info_dict.get('comment', '110') +
            info_dict.get('newcomment', '110') + '\n',
            'team1':
            info_dict.get('team1', '1'),
            'team2':
            info_dict.get('team2', '1'),
            'team3':
            info_dict.get('team3', '1'),
            'team4':
            info_dict.get('team4', '1'),
            'team5':
            info_dict.get('team5', '1'),
            'forbid':
            int(info_dict.get('forbid', '1')),
            'name':
            info_dict.get('realName'),
            'id_card':
            info_dict.get('idNumber'),
            'sex':
            int(info_dict.get('sex')),
            'nation':
            int(info_dict.get('nation')),
            'birth':
            info_dict.get('birth'),
        }

        if info_dict.get('newcomment', '110').strip() == '':
            dic['comment'] = info_dict.get('comment', '110')

        stu.setStudent(account, Student.REAL_NAME, dic['name'])
        stu.setStudent(account, Student.ID_NUMBER, dic['id_card'])
        stu.setStudent(account, Student.SEX, dic['sex'])
        stu.setStudent(account, Student.NATION, dic['nation'])
        try:
            tmp = dic['birth'].split('-')
            stu.setStudent(
                account, Student.BIRTH,
                datetime.date(int(tmp[0]), int(tmp[1]), int(tmp[2])))
        except:
            pass
        print 'asdfasdfasdf-----'
        stu.setStudent(account, Student.TYPE, dic['type'])
        stu.setStudent(account, Student.PROVINCE, dic['province'])
        stu.setStudent(account, Student.PHONE, dic['phone'])
        stu.setStudent(account, Student.EMAIL, dic['email'])
        stu.setStudent(account, Student.ADDRESS, dic['address'])
        stu.setStudent(account, Student.TYPE, dic['type'])
        stu.setStudent(account, Student.DAD_PHONE, dic['dadPhone'])
        stu.setStudent(account, Student.MOM_PHONE, dic['momPhone'])
        stu.setStudent(account, Student.SCHOOL, dic['school'])
        stu.setStudent(account, Student.CLASSROOM, dic['stu_class'])
        stu.setStudent(account, Student.TUTOR_NAME, dic['tutorName'])
        stu.setStudent(account, Student.TUTOR_PHONE, dic['tutorPhone'])
        stu.setStudent(account, Student.MAJOR, [
            dic['majorSelect1'], dic['majorSelect2'], dic['majorSelect3'],
            dic['majorSelect4'], dic['majorSelect5'], dic['majorSelect6']
        ])
        stu.setStudent(
            account, Student.TEST_SCORE_LIST,
            [dic['testScore1'], dic['testScore2'], dic['testScore3']])
        stu.setStudent(account, Student.RANK_LIST,
                       [dic['rank1'], dic['rank2'], dic['rank3']])
        stu.setStudent(account, Student.SUM_NUMBER_LIST,
                       [dic['rank11'], dic['rank22'], dic['rank33']])
        stu.setStudent(account, Student.REAL_SCORE, dic['realScore'])
        stu.setStudent(account, Student.ADMISSION_STATUS,
                       dic['admissionStatus'])
        # stu.setStudent(account, Student.TYPE, dic['relTeacher'])
        # stu.setStudent(account, Student.TYPE, dic['relVolunteer'])
        stu.setStudent(account, Student.COMMENT, dic['comment'])

        stu.setStudent(account, Student.DAD_NAME, dic['dadName'])
        stu.setStudent(account, Student.MOM_NAME, dic['momName'])

        stu.setStudentGroupbyList(stu.getStudentAll(account), [
            dic['team1'], dic['team2'], dic['team3'], dic['team4'],
            dic['team5']
        ])

        stu.setStudent(account, Student.DUIYING_TEACHER, dic['relTeacher'])
        stu.setStudent(account, Student.QUANXIAN, dic['forbid'])

        ret_dic = {}
        for key in request.POST.copy().keys():
            ret_dic[key] = request.POST.copy().get(key)
        ret_dic['comment'] = dic['comment']

        return JsonResponse(ret_dic)
    else:
        '''
            后端需要在这里改代码,从数据库读取正确的dict,并返回
        '''
        if 'teacher_id' not in request.session.keys():
            return redirect('/login/')
        print request.GET
        id = request.GET.get('id')
        account = stu.idToAccountStudent(str(id))
        student = stu.getStudentAll(account)
        stu_dic = stu.getStudentAllDictByAccount(account)

        dic = {
            Student.ID:
            stu_dic[Student.ID],
            Student.ACCOUNT:
            stu_dic[Student.ACCOUNT],
            Student.REAL_NAME:
            stu_dic[Student.REAL_NAME],
            Student.BIRTH:
            stu_dic[Student.BIRTH].strftime("%Y-%m-%d"),
            Student.ID_NUMBER:
            stu_dic[Student.ID_NUMBER],
            Student.TYPE:
            stu_dic[Student.TYPE],
            Student.SEX:
            stu_dic[Student.SEX],
            Student.NATION:
            stu_dic[Student.NATION],
            Student.SCHOOL:
            stu_dic[Student.SCHOOL],
            Student.CLASSROOM:
            stu_dic[Student.CLASSROOM],
            Student.ADDRESS:
            stu_dic[Student.ADDRESS],
            Student.PHONE:
            stu_dic[Student.PHONE],
            Student.EMAIL:
            stu_dic[Student.EMAIL],
            Student.DAD_PHONE:
            stu_dic[Student.DAD_PHONE],
            Student.MOM_PHONE:
            stu_dic[Student.MOM_PHONE],
            Student.TUTOR_NAME:
            stu_dic[Student.TUTOR_NAME],
            Student.TUTOR_PHONE:
            stu_dic[Student.TUTOR_PHONE],
            Student.PROVINCE:
            stu_dic[Student.PROVINCE],
            Student.MAJOR:
            stu_dic[Student.MAJOR],
            Student.TEST_SCORE_LIST:
            stu_dic[Student.TEST_SCORE_LIST],
            Student.RANK_LIST:
            stu_dic[Student.RANK_LIST],
            Student.SUM_NUMBER_LIST:
            stu_dic[Student.SUM_NUMBER_LIST],
            Student.ESTIMATE_SCORE:
            getStudentEstimateScore(stu.getStudentAll(account)),
            Student.REAL_SCORE:
            stu_dic[Student.REAL_SCORE],
            Student.REGISTER_CODE:
            stu_dic[Student.REGISTER_CODE],
            Student.ADMISSION_STATUS:
            stu_dic[Student.ADMISSION_STATUS],
            Student.TEACHER_LIST:
            stu_dic[Student.TEACHER_LIST],
            Student.VOLUNTEER_ACCOUNT_LIST:
            stu_dic[Student.VOLUNTEER_ACCOUNT_LIST],
            Student.COMMENT:
            stu_dic[Student.COMMENT],
            Student.MOM_NAME:
            stu_dic[Student.MOM_NAME],
            Student.DAD_NAME:
            stu_dic[Student.DAD_NAME],
            Student.DUIYING_TEACHER:
            stu_dic[Student.DUIYING_TEACHER],
        }

        group_list = stu.getStudentGroupIDListString(student).split(' ')
        if '' in group_list:
            group_list.remove('')
        for i in range(0, 5):
            if i < len(group_list) and group_list[i] != '':
                dic['group' + str(i + 1)] = int(group_list[i])
            else:
                dic['group' + str(i + 1)] = 0
        dic['grouplist'] = [' ']
        all_group = back.getGroupbyDict({})
        for item in all_group:
            dic['grouplist'].append(back.getGroupAllDictByObject(item)['id'])
        id_ = request.session.get('teacher_id', -1)
        # print 'byr ', dic['group1'], dic['group2'], dic['group3'], dic['group4'], dic['group5']

        dic['forbid'] = int(stu_dic[Student.QUANXIAN])
        dic['forbidlist'] = PERMISSION_LIST
        print 'wo ca lei', dic['forbid'], dic['forbidlist']
        return render(request, 'teacher/student_info_edit.html', {
            'student': dic,
            'id': id_
        })
コード例 #16
0
def profile(request):
    weichatopenid(request)
    id = request.session.get('student_id', -1)
    if id == -1:
        return HttpResponse('Access denied')
    account = stu.idToAccountStudent(str(id))
    student = stu.getStudentAll(account)

    if request.method == 'POST':
        '''
        保存信息并返回json
        '''
        print "wp",request.POST

        info_dict = request.POST.copy()
        print info_dict
        for i in range(1, 7):
            if info_dict['majorSelect' + str(i)].strip() == '':
                info_dict['majorSelect' + str(i)] = '0'
        for i in range(1, 4):
            if info_dict['testScore' + str(i)].strip() == '':
                info_dict['testScore' + str(i)] = '0'
        for i in range(1, 4):
            if info_dict['rank' + str(i)].strip() == '':
                info_dict['rank' + str(i)] = '0'
        for i in range(1, 4):
            if info_dict['rank' + str(i)].strip() == '':
                info_dict['rank' + str(i)] = '0'
        for i in range(1, 4):
            if info_dict['rank' + str(i) + str(i)].strip() == '':
                info_dict['rank' + str(i) + str(i)] = '0'
        if info_dict['realScore'].strip() == '':
            info_dict['realScore'] = '0'

        dic = {
            'name': info_dict.get('name'),
            'identification': info_dict.get('identification'),
            'sex': info_dict.get('sex'),
            'nation': info_dict.get('nation'),
            'birth': info_dict.get('birth'),

            'type': int(info_dict.get('wenli')),
            'province': int(info_dict.get('province')),
            'phone': info_dict.get('phone'),
            'email': info_dict.get('email'),
            'address': info_dict.get('address'),

            'dadName': info_dict.get('dadName'),
            'dadPhone': info_dict.get('dadPhone'),
            'momName': info_dict.get('momName'),
            'momPhone': info_dict.get('momPhone'),
            'school': info_dict.get('school'),

            'stu_class': info_dict.get('stu_class'),
            'tutorName': info_dict.get('tutorName'),
            'tutorPhone': info_dict.get('tutorPhone'),

            'majorSelect1': int(info_dict.get('majorSelect1')),
            'majorSelect2': int(info_dict.get('majorSelect2')),
            'majorSelect3': int(info_dict.get('majorSelect3')),
            'majorSelect4': int(info_dict.get('majorSelect4')),
            'majorSelect5': int(info_dict.get('majorSelect5')),
            'majorSelect6': int(info_dict.get('majorSelect6')),

            'testScore1': int(info_dict.get('testScore1')),
            'testScore2': int(info_dict.get('testScore2')),
            'testScore3': int(info_dict.get('testScore3')),

            'rank1': int(info_dict.get('rank1')),
            'rank11': int(info_dict.get('rank11')),
            'rank2': int(info_dict.get('rank2')),
            'rank22': int(info_dict.get('rank22')),
            'rank3': int(info_dict.get('rank3')),
            'rank33': int(info_dict.get('rank33')),

            'realScore': int(info_dict.get('realScore')),
            # 'relTeacher': info_dict.get('relTeacher'),
            'comment': info_dict.get('comment'),

            'password': info_dict.get('comment'),
        }
        # print 'wocao ni mei', dic
        try:
            birth_list = info_dict['birth'].split('/')
            dic['birth'] = datetime.date(int(birth_list[2]), int(birth_list[0]), int(birth_list[1]))
        except:
            dic['success'] = 'N'
            dic['message'] = u'日期设置不正确,请重新输入'
            return JsonResponse(dic)

        stu.setStudent(account, Student.REAL_NAME, dic['name'])
        stu.setStudent(account, Student.ID_NUMBER, dic['identification'])
        stu.setStudent(account, Student.SEX, dic['sex'])
        stu.setStudent(account, Student.NATION, dic['nation'])
        stu.setStudent(account, Student.BIRTH, dic['birth'])

        stu.setStudent(account, Student.TYPE, dic['type'])
        stu.setStudent(account, Student.PROVINCE, dic['province'])
        stu.setStudent(account, Student.PHONE, dic['phone'])
        stu.setStudent(account, Student.EMAIL, dic['email'])
        stu.setStudent(account, Student.ADDRESS, dic['address'])

        stu.setStudent(account, Student.MOM_NAME, dic['momName'])
        stu.setStudent(account, Student.DAD_NAME, dic['dadName'])
        stu.setStudent(account, Student.DAD_PHONE, dic['dadPhone'])
        stu.setStudent(account, Student.MOM_PHONE, dic['momPhone'])
        stu.setStudent(account, Student.SCHOOL, dic['school'])

        stu.setStudent(account, Student.CLASSROOM, dic['stu_class'])
        stu.setStudent(account, Student.TUTOR_NAME, dic['tutorName'])
        stu.setStudent(account, Student.TUTOR_PHONE, dic['tutorPhone'])

        stu.setStudent(account,
                       Student.MAJOR,
                       [dic['majorSelect1'],
                        dic['majorSelect2'],
                        dic['majorSelect3'],
                        dic['majorSelect4'],
                        dic['majorSelect5'],
                        dic['majorSelect6']])

        stu.setStudent(
            account, Student.TEST_SCORE_LIST, [
                dic['testScore1'], dic['testScore2'], dic['testScore3']])

        stu.setStudent(
            account, Student.RANK_LIST, [
                dic['rank1'], dic['rank2'], dic['rank3']])

        stu.setStudent(
            account, Student.SUM_NUMBER_LIST, [
                dic['rank11'], dic['rank22'], dic['rank33']])

        stu.setStudent(account, Student.REAL_SCORE, dic['realScore'])
        stu.setStudent(account, Student.COMMENT, dic['comment'])


        return JsonResponse(dic)
    else:
        '''
        获取信息并返回
        '''
        stu_dic = stu.getStudentAllDictByAccount(account)
        (rank, tmp) = stu.getStudentEstimateRank(student)
        dic = {
            'name': stu_dic[Student.REAL_NAME],
            'identification': stu_dic[Student.ID_NUMBER],
            'sex': stu_dic[Student.SEX],
            'nation': stu_dic[Student.NATION],
            'birth': stu_dic[Student.BIRTH].strftime("%m/%d/%Y"),
            'province': stu_dic[Student.PROVINCE],
            'phone': stu_dic[Student.PHONE],
            'email': stu_dic[Student.EMAIL],
            'wenli': stu_dic[Student.TYPE],
            'address': stu_dic[Student.ADDRESS],
            'dadName': stu_dic[Student.DAD_NAME],
            'dadPhone': stu_dic[Student.DAD_PHONE],
            'momName': stu_dic[Student.MOM_NAME],
            'momPhone': stu_dic[Student.MOM_PHONE],
            'school': stu_dic[Student.SCHOOL],
            'stu_class': stu_dic[Student.CLASSROOM],
            'tutorName': stu_dic[Student.TUTOR_NAME],
            'tutorPhone': stu_dic[Student.TUTOR_PHONE],
             Student.MAJOR: stu_dic[Student.MAJOR],
             Student.TEST_SCORE_LIST: stu_dic[Student.TEST_SCORE_LIST],
             Student.RANK_LIST: stu_dic[Student.RANK_LIST],
             Student.SUM_NUMBER_LIST: stu_dic[Student.SUM_NUMBER_LIST],
            'realScore': stu_dic[Student.REAL_SCORE],
            'relTeacher': stu_dic[Student.DUIYING_TEACHER],
            'comment': stu_dic[Student.COMMENT],
            'estimateScore': getStudentEstimateScore(stu.getStudentAll(account)),
            'estimateRank': str(rank)+'/'+str(tmp)
        }
        group_list = stu.getStudentGroupIDListString(student).split(' ')
        for i in range(1, 6):
            if i < len(group_list):
                dic['group' + str(i)] = group_list[i]
            else:
                dic['group' + str(i)] = '0'
        dic['grouplist'] = [' ']
        all_group = back.getGroupbyDict({})
        for item in all_group:
            dic['grouplist'].append(back.getGroupAllDictByObject(item)['id'])
        print 'jiao baba', dic
        if 'auth' in request.GET:
            dic['auth'] = '0'
        return render(request, 'student/userinfo.html', {'dict': dic, 'id':id})
コード例 #17
0
def checkscore(request):
    '''

    后端需要从数据库获取数据补全代码
    '''
    if ('name' in request.GET) and ('stu_id' in request.GET):
        # print request.GET
        student_id = request.GET.get('stu_id')
        testname = request.GET.get('testname')
        code = int(request.GET.get('code'))
        # print '****************************', student_id, testname, code
        # try:
        info_dic = stu.getStudentAllDictByAccount(
            stu.idToAccountStudent(int(student_id)))
        estimate_dic = eval(info_dic[Student.ESTIMATE_SCORE])
        if code == 1:
            if testname in estimate_dic.keys():
                estimate_dic[testname]['shenhe'] = 1
        else:
            tmp_dic = {}
            for key in estimate_dic.keys():
                if key != testname:
                    tmp_dic[key] = estimate_dic[key]
            estimate_dic = tmp_dic
        stu.setStudent(stu.idToAccountStudent(int(student_id)),
                       Student.ESTIMATE_SCORE, str(estimate_dic))
        # except:
        #     print '-------------------'
        #     return render(request,
        #                   'teacher/checkscore.html')
        print 'sdf', estimate_dic
        return render(request, 'teacher/checkscore.html')
    else:
        list = []
        student_list = stu.getAllInStudent()
        for student in student_list:
            info_dic = stu.getStudentAllDictByAccount(
                getattr(student, Student.ACCOUNT))
            name = info_dic[Student.REAL_NAME]
            sex = SEX_LIST[int(info_dic[Student.SEX]['sex'])]
            province = PROVINCE_LIST[int(
                info_dic[Student.PROVINCE]['province'])]
            school = info_dic[Student.SCHOOL]
            ident = info_dic[Student.ID_NUMBER]
            estimate_score = info_dic[Student.ESTIMATE_SCORE]
            try:
                estimate_score = eval(estimate_score)
            except:
                estimate_score = eval('{}')
            for key in estimate_score.keys():
                testname = key
                time = str(estimate_score[key]['time']) + ' s'
                score = str(estimate_score[key]['score']) + ' points'
                if 'shenhe' in estimate_score[key].keys():
                    continue
                else:
                    dict = {
                        'name': name,
                        'sex': sex,
                        'province': province,
                        'school': school,
                        'ident': ident,
                        'testname': testname,
                        'time': time,
                        'score': score,
                        'stu_id': info_dic[Student.ID]
                    }
                    list.append(dict)

        id_ = request.session.get('teacher_id', -1)
        return render(request, 'teacher/checkscore.html', {
            'dict': list,
            'id': id_
        })
コード例 #18
0
def student_info_show(request):
    if 'volunteer_id' not in request.session.keys():
        return redirect('/login/')
    t = get_template('volunteer/student_info.html')
    id = request.GET.get('stu_id', -1)
    if id == -1:
        # 后端需要在这里加上一类条件,即另一种情况下的Access denied
        # 根据request.session.get('volunteer_id')获取志愿者ID,前面代码中的id变量为学生id
        # 要据此排除学生不是该志愿者权限范围内的情况
        return HttpResponse('Access denied')

    # 检查这个id是否应该让这个志愿者看到
    vol_id = request.session.get('volunteer_id')
    vol_account = vol.idToAccountVolunteer(vol_id)
    account = stu.idToAccountStudent(str(id))
    student = stu.getStudentAll(account)
    stu_dic = stu.getStudentAllDictByAccount(account)
    dic = {
        Student.ID:
        stu_dic[Student.ID],
        Student.ACCOUNT:
        stu_dic[Student.ACCOUNT],
        Student.REAL_NAME:
        stu_dic[Student.REAL_NAME],
        Student.BIRTH:
        stu_dic[Student.BIRTH].strftime("%Y-%m-%d"),
        Student.ID_NUMBER:
        stu_dic[Student.ID_NUMBER],
        Student.TYPE:
        stu_dic[Student.TYPE]['typelist'][stu_dic[Student.TYPE]['type']],
        Student.SEX:
        stu_dic[Student.SEX]['sexlist'][stu_dic[Student.SEX]['sex']],
        Student.NATION:
        stu_dic[Student.NATION]['nationlist'][stu_dic[Student.NATION]
                                              ['nation']],
        Student.SCHOOL:
        stu_dic[Student.SCHOOL],
        Student.CLASSROOM:
        stu_dic[Student.CLASSROOM],
        Student.ADDRESS:
        stu_dic[Student.ADDRESS],
        Student.PHONE:
        stu_dic[Student.PHONE],
        Student.EMAIL:
        stu_dic[Student.EMAIL],
        Student.DAD_PHONE:
        stu_dic[Student.DAD_PHONE],
        Student.MOM_PHONE:
        stu_dic[Student.MOM_PHONE],
        Student.DAD_NAME:
        stu_dic[Student.DAD_NAME],
        Student.MOM_NAME:
        stu_dic[Student.MOM_NAME],
        Student.TUTOR_NAME:
        stu_dic[Student.TUTOR_NAME],
        Student.TUTOR_PHONE:
        stu_dic[Student.TUTOR_PHONE],
        Student.PROVINCE:
        stu_dic[Student.PROVINCE]['provincelist'][stu_dic[Student.PROVINCE]
                                                  ['province']],
        Student.MAJOR:
        stu_dic[Student.MAJOR],
        Student.TEST_SCORE_LIST:
        stu_dic[Student.TEST_SCORE_LIST],
        Student.RANK_LIST:
        stu_dic[Student.RANK_LIST],
        Student.SUM_NUMBER_LIST:
        stu_dic[Student.SUM_NUMBER_LIST],
        Student.ESTIMATE_SCORE:
        stu_dic[Student.ESTIMATE_SCORE],
        Student.REAL_SCORE:
        stu_dic[Student.REAL_SCORE],
        Student.REGISTER_CODE:
        stu_dic[Student.REGISTER_CODE],
        Student.ADMISSION_STATUS:
        stu_dic[Student.ADMISSION_STATUS],
        Student.TEACHER_LIST:
        stu_dic[Student.TEACHER_LIST],
        Student.VOLUNTEER_ACCOUNT_LIST:
        stu_dic[Student.VOLUNTEER_ACCOUNT_LIST],
        Student.COMMENT:
        stu_dic[Student.COMMENT],
    }

    tmp_dic = stu_dic[Student.ESTIMATE_SCORE]
    try:
        tmp_dic = eval(tmp_dic)
    except:
        tmp_dic = eval('{}')
    sum_score = 0
    for key in tmp_dic.keys():
        sum_score += tmp_dic[key]['score']
    dic[Student.ESTIMATE_SCORE] = str(sum_score)
    return HttpResponse(t.render({'student': dic}))
def logincheck(request):
    errors = []
    if request.method == 'POST':
        if not request.POST.get('login_username', ''):
            errors.append('enter login username')
        if not request.POST.get('login_password', ''):
            errors.append('enter login password')
        if not request.POST.get('login_yzm', ''):
            errors.append('enter login yzm')
        if not errors:
            if 'student' in request.POST:
                username = request.POST.get('login_username')
                password = request.POST.get('login_password')
                yzmString = request.POST.get('login_yzm').upper()
                if (yzmString == request.session['yzmString']):
                    print ' student login'
                    (login, id) = student_backend.checkStudentPassword(username, password)
                    if login:
                        if 'open_id' in request.session:
                            stu_id = id
                            account = student_backend.idToAccountStudent(stu_id)
                            student_backend.setStudent(account, 'openid', request.session['open_id'])
                            print "#############"
                        request.session['student_id'] = int(id)
                        print 'student_id', id
                        request.session['user_name'] = username
                        #request.session['password'] = password
                        return redirect('/student/')
                    else:
                        return HttpResponse(u"<a href='/login'>学生界面登录失败啦</a>")
                else:
                    return HttpResponse(u"<a href='/login'>学生界面登录失败</a>")
            elif 'teacher' in request.POST:
                username = request.POST.get('login_username')
                password = request.POST.get('login_password')
                yzmString = request.POST.get('login_yzm').upper()
                if (yzmString == request.session['yzmString']):
                    print ' teacher login'
                    (login,id) = teacher_backend.checkTeacherPassword(username, password)
                    if login:
                        request.session['teacher_id'] = int(id)
                        request.session['user_name'] = username
                        #request.session['password'] = password
                        return redirect('/teacher/')
                    else:
                        return HttpResponse(u"a href='/login'>教师界面登录失败<</a>")
                else:
                    return HttpResponse(u"<a href='/login'>教师界面登录失败</a>")
            elif 'volunteer' in request.POST:
                username = request.POST.get('login_username')
                password = request.POST.get('login_password')
                yzmString = request.POST.get('login_yzm').upper()
                if (yzmString == request.session['yzmString']):
                    (login,id) = volunteer_backend.checkVolunteerPassword(username, password)
                    if login:
                        request.session['volunteer_id'] = id
                        request.session['user_name'] = username
                        #request.session['password'] = password
                        # return render_to_response('/student')
                        return redirect('/volunteer')
                        #return HttpResponse(u"志愿者界面")
                    else:
                        return HttpResponse(u"<a href='/login'>志愿者界面登录失败</a>")
                else:
                    return HttpResponse(u"<a href='/login'>验证码不正确</a>")
            else:
                return HttpResponse(u"<a href='/login'>请检查用户名是否存在,请检查用户名、密码、验证码是否未填</a>")
        else:
            return HttpResponse(u"<a href='/login'>请检查用户名是否存在,请检查用户名、密码、验证码是否未填</a>")
    else:
        return HttpResponse(u"<a href='/login'>请检查用户名是否存在,请检查用户名、密码、验证码是否未填</a>")