예제 #1
0
def main(stuId):
    url = 'https://zjyapp.icve.com.cn/newmobileapi/onlineExam/saveExamTimeInfo?data='
    allcourse = get_all_course(stuId)
    openClassId = allcourse['openClassId']
    courseOpenId = allcourse['courseOpenId']
    exams = exam_list(openClassId, courseOpenId, stuId)
    index = 1
    for i in exams:
        print(f'【{index}】{i["title"]}\t{i["startDate"]}')
        index += 1
    target = exams[int(input("请输入序号:")) - 1]
    examId = target['examId']
    examTermTimeId = target['examTermTimeId']
    starttime = input("请输入开始时间(2020-03-20 00:00:00):")
    endtime = input("请输入结束时间(2020-03-20 00:00:00):")
    teaid = getteaid(openClassId, courseOpenId)
    xdata = f'{{"Id":"{examTermTimeId}","CreatorId":"{teaid}","OpenClassId":"{openClassId}","ExamId":"{examId}","StuStartDate":"{starttime}","StuEndDate":"{endtime}"}}'
    result_url = url + xdata
    result = requests.post(url=result_url).json()
    print(result['msg'])
    sele = input("【1】返回首页\n【2】返回上级\n请选择:")
    if sele == 2:
        main(stuId)
    else:
        from Main import main as menu
        menu()
예제 #2
0
def main(stuId):
    allcourse = get_all_course(stuId)
    openClassId = allcourse['openClassId']
    courseOpenId = allcourse['courseOpenId']
    homeworklist = get_homework_list(stuId, openClassId, courseOpenId)
    if homeworklist == 0:
        print("获取失败")
    else:
        homeworkTermTimeId = homeworklist['homeworkTermTimeId']
        homeworkId = homeworklist['homeworkId']
        grades = get_homework_grade(openClassId, homeworkId, stuId,
                                    homeworkTermTimeId)
        if grades != 0:
            index = 1
            for i in grades:
                print(f"【{index}】时间:{i['dateCreated']}\t分数{i['getScore']}")
                index += 1
            target = int(input("请输入要修改的序号:")) - 1
            homeworkStuId = grades[target]['homeworkStuId']
        else:
            input("回车键后退出")
    teaId = input("请输入教师ID")
    url = 'https://zjyapp.icve.com.cn/newmobileapi/homework/rejectHomework'
    data = {
        'homeworkStuId': homeworkStuId,
        'teaId': teaId,
    }
    result = requests.post(url=url, data=data).json()
    print(result['msg'])
    sele = input("【1】返回首页\n【2】返回上级\n请选择:")
    if sele == 2:
        main(stuId)
    else:
        from Main import main as menu
        menu()
예제 #3
0
def examlist(stuid):
    courses = get_all_course(stuid)
    openClassId = courses['openClassId']
    courseOpenId = courses['courseOpenId']
    exam_list = exams(openClassId, courseOpenId, stuid)
    index = 1
    for i in exam_list:
        print(f"【{index}】{i['title']}")
    target = int(input("请选择需要退回的考试:")) - 1
    examId = exam_list[target]['examId']
    examTermTimeId = exam_list[target]['examTermTimeId']
    url = 'https://zjyapp.icve.com.cn/newmobileapi/onlineExam/getReadStuList'
    data = {
        'courseOpenId': courseOpenId,
        'openClassId': openClassId,
        'examId': examId,
        'examTermTimeId': examTermTimeId,
    }
    html = requests.post(url=url, data=data).json()
    print(html['msg'])
    num = 0
    for i in html['examStuList']:
        if i['stuId'] == stuid:
            examStuId = i['examStuId']
            num = 1
    if num == 0:
        print("未发现你的试卷,请先提交")
        from Main import main as menu
        menu()
    reurl = 'https://zjyapp.icve.com.cn/newmobileapi/onlineExam/rejectExam'
    data = {'examStuId': examStuId}
    html = requests.post(url=reurl, data=data).json()
    input(html['msg'])
    from Main import main as menu
    menu()
예제 #4
0
def Main(stuId):
    print("注意:改分只可以改非题库作业,需要老师批阅的")
    allcourse = get_all_course(stuId)
    openClassId = allcourse['openClassId']
    courseOpenId = allcourse['courseOpenId']
    homeworklist = get_homework_list(stuId, openClassId, courseOpenId)
    if homeworklist == 0:
        print("获取失败")
    else:
        homeworkTermTimeId = homeworklist['homeworkTermTimeId']
        homeworkId = homeworklist['homeworkId']
        grades = get_homework_grade(openClassId, homeworkId, stuId,
                                    homeworkTermTimeId)
        if grades != 0:
            index = 1
            for i in grades:
                print(f"【{index}】时间:{i['dateCreated']}\t分数{i['getScore']}")
                index += 1
            target = int(input("请输入要修改的序号:")) - 1
            if target > len(grades):
                print("请输入正确的序号")
                target = int(input("请输入要修改的序号:")) - 1
            homeworkStuId = grades[target]['homeworkStuId']
            getScore = int(input("请输入目标分数(整数):"))
            result = re_grade(homeworkStuId, getScore)
            print(result)
            input("回车后返回首页!")
            from Main import main as menu
            menu()
        else:
            Main(stuId)
            input("回车后返回首页!")
            from Main import main as menu
            menu()
예제 #5
0
def retime(time, teaid, HomeWorkId, CourseOpenId, OpenClassId):
    url = 'https://zjyapp.icve.com.cn/newmobileapi/coursehomework/saveHkTimeByOpenClass'
    data = {
        'data':
        f'{{"CreatorId":"{teaid}","CourseOpenId":"{CourseOpenId}","HomeWorkId":"{HomeWorkId}","StuEndDate":"{time}","OpenClassId":"{OpenClassId}"}}'
    }
    html = requests.post(url=url, data=data).json()
    input(html['msg'])
    from Main import main as menu
    menu()
예제 #6
0
def main(stuid):
    print("【欢迎使用职教云补签助手】")
    print("                  By:Lan")
    date = input("请输入需要补签的日期如(2020-5-20):")
    courses = get_course(stuid, date)
    if courses == 'no':
        print("你今天没有课,好好休息")
    else:
        print("Lan职教云助手提示您:\n您今天课表如下:")
        for i in range(len(courses['courseNmae'])):
            print(
                f'【{i + 1}】:{courses["classSection"][i]}{courses["courseNmae"][i]}'
            )
        index = int(input("请输入你要改签的课程:")) - 1
        activities = get_activity(stuid, courses["courseId"][index],
                                  courses["openClassId"][index])
        buqianname = []
        buqianid = []
        for j in range(len(activities)):
            datatype = activities[j]['DataType']
            if datatype == "签到":
                buqianname.append(activities[j]['Title'])
                buqianid.append(activities[j]['Id'])
        for i in range(len(buqianid)):
            print(f'【{i}】{buqianname[i]}')
        target = int(input("请输入要逆天改命的序号:"))
        datas = f'{{"OpenClassId":"{courses["openClassId"]}","Id":"{stuid}","SignId":"{buqianid[target]}","StuId":"{stuid}","SignResultType":1,"SourceType":2,"schoolId":"3-3sabgooohfboflpnx6bq"}}'
        xdata = {'data': f'{datas}'}
        bqurl = 'https://zjyapp.icve.com.cn/newmobileapi/faceteach/changeSignType'
        html = requests.post(url=bqurl, data=xdata).json()
        if html['code'] == 1:
            print(html['msg'])
            print("逆天改命成功,Lan's Blog:https://www.lanol.cn")
            sele = input("【1】]返回首页\n【2】返回上级")
            if sele == 2:
                main(stuid)
            else:
                from Main import main as menu
                menu()
        else:
            print(html['msg'])
            print("逆天改命失败,请联系Lan")
            sele = input("【1】返回首页\n【2】返回上级\n请选择:")
            if sele == 2:
                main(stuid)
            else:
                from Main import main as menu
                menu()
def get_activity(stuid, stuname):
    print("【欢迎使用课堂活动改分功能】")
    print("                  By:Lan")
    date = input("请输入需要改活动的日期如(2020-5-20):")
    courses = get_course(stuid, date)
    if courses == 'no':
        print("你今天没有课,好好休息")
    else:
        print("Lan职教云助手提示您:\n您今天课表如下:")
        for i in range(len(courses['courseNmae'])):
            print(
                f'【{i + 1}】:{courses["classSection"][i]}{courses["courseNmae"][i]}'
            )
        index = int(input("请输入你要改签的课程:")) - 1
        activityId = courses["courseId"][index]
        courseOpenId = courses['courseOpenId'][index]
    url = 'https://zjyapp.icve.com.cn/newmobileapi/faceteachbytea/getOpenClassFaceTeachList'
    data = {
        'courseOpenId': courseOpenId,
        'activityId': activityId,
        'type': '2',
    }
    html = requests.post(url=url, data=data).json()
    if html['code'] == 1:
        activity_list = html['list']
        index = 1
        for i in activity_list:
            print(f'【{index}】{i["title"]}')
            index += 1
        target = int(input("请输入你要修改的序号:")) - 1
        grade = input("请输入分数:")
        type = activity_list[target]['activityType']
        if type == '提问':
            Question(activity_list[target]['Id'], stuid, grade, stuname)
        elif type == '头脑风暴':
            BrainStorm(activity_list[target]['Id'], stuid, grade)
        elif type == '讨论':
            discuss(activity_list[target]['Id'], stuid, grade)
        else:
            input("暂不支持改类型!")
        from Main import main as menu
        menu()
    else:
        input("获取失败")
예제 #8
0
def Main(stuId):
    allcourse = get_all_course(stuId)
    openClassId = allcourse['openClassId']
    courseOpenId = allcourse['courseOpenId']
    homeworklist = get_homework_list(stuId, openClassId, courseOpenId)
    if homeworklist == 0:
        print("获取失败")
    else:
        homeworkTermTimeId = homeworklist['homeworkTermTimeId']
        homeworkId = homeworklist['homeworkId']
        grades = get_homework_grade(openClassId, homeworkId, stuId,
                                    homeworkTermTimeId)
        if grades != 0:
            index = 1
            for i in grades:
                print(f"【{index}】时间:{i['dateCreated']}\t分数{i['getScore']}")
                index += 1
            target = int(input("请输入要修改的序号:")) - 1
            homeworkStuId = grades[target]['homeworkStuId']
            getScore = int(input("请输入目标分数(整数):"))
            result = re_grade(homeworkStuId, getScore)
            print(result)
            sele = input("【1】返回首页\n【2】返回上级")
            if sele == 2:
                Main(stuId)
            else:
                from Main import main as menu
                menu()
        else:
            Main(stuId)
            sele = input("【1】返回首页\n【2】返回上级\n请选择:")
            if sele == 2:
                Main(stuId)
            else:
                from Main import main as menu
                menu()
예제 #9
0
def main(stuid, schoolid):
    print("【欢迎使用职教云补签助手】")
    print("注意事项:修改之后课堂表现可看到结果,老师那边会显示已参与")
    print("                  By:Lan")
    date = input("请输入需要补签的日期如(2020-5-20):")
    courses = get_course(stuid, date)
    if courses == 'no':
        print("你今天没有课,好好休息")
    else:
        print("Lan职教云助手提示您:\n您今天课表如下:")
        for i in range(len(courses['courseNmae'])):
            print(
                f'【{i + 1}】:{courses["classSection"][i]}{courses["courseNmae"][i]}'
            )
        index = int(input("请输入你要改签的课程:")) - 1
        activities = get_activity(stuid, courses["courseId"][index],
                                  courses["openClassId"][index])
        buqianname = []
        buqianid = []
        for j in range(len(activities)):
            datatype = activities[j]['DataType']
            if datatype == "签到":
                buqianname.append(activities[j]['Title'])
                buqianid.append(activities[j]['Id'])
        for i in range(len(buqianid)):
            print(f'【{i}】{buqianname[i]}')
        target = int(input("请输入要逆天改命的序号:"))
        datas = f'{{"OpenClassId":"{courses["openClassId"]}","Id":"{stuid}","SignId":"{buqianid[target]}","StuId":"{stuid}","SignResultType":1,"SourceType":2,"schoolId":"{schoolid}"}}'
        xdata = {'data': f'{datas}'}
        bqurl = 'https://zjyapp.icve.com.cn/newmobileapi/faceteach/changeSignType'
        html = requests.post(url=bqurl, data=xdata).json()
        if html['code'] == 1:
            print(html['msg'])
            print("逆天改命成功,Lan's Blog:https://www.lanol.cn")
            re_grade = input("是否需要修改签到分数:是 或 否")
            if re_grade == "是":
                SignId = buqianid[target]
                activityid = activities[target]['Id']
                url = 'https://zjyapp.icve.com.cn/newmobileapi/faceTeach/getCheckStuInfo'
                data = {
                    'signId': SignId,
                    'activityId': activityid,
                }
                html = requests.post(url=url, data=data).json()
                for i in html['signedList']:
                    if i['StuId'] == stuid:
                        SignStuId = i['SignStuId']
                get_grade = input("请输入要改的分数(1-5):")
                if int(get_grade) < 6:
                    grade_url = 'https://zjyapp.icve.com.cn/newmobileapi/faceTeach/saveSignStuScore'
                    data = {
                        'signId': SignId,
                        'signStuIds': SignStuId,
                        'score': get_grade
                    }
                    result = requests.post(url=grade_url,
                                           data=data).json()['msg']
                    print(result)
                    print("返回首页菜单")
                    from Main import main as menu
                    menu()
                else:
                    print("再见")
                    from Main import main as menu
                    menu()
        else:
            print(html['msg'])
            print("逆天改命失败,请联系Lan")
            from Main import main as menu
            menu()
예제 #10
0
def main(window):
    pygame.init()

    #create window
    window = pygame.display.set_mode((window_width, window_height))

    #create grid
    grid = create_grid()

    positions = {}

    #define game state
    game_state = State.play

    new_shape = False

    #create current shape
    current_shape = create_new_shape()

    #create next shape
    next_shape = create_new_shape()

    score = 0

    #determinate fall speed
    fall_speed = 0.25

    fall_time = 0

    level_time = 0

    clock = pygame.time.Clock()

    while True:

        if game_state == State.play:

            #create grid with filled blocks
            grid = create_grid(positions)

            #get time since last update
            update_time = clock.tick(60)

            fall_time += update_time

            level_time += update_time

            #increase speed
            if level_time / 1000 > 5:
                level_time = 0
                if fall_speed > 0.15:
                    fall_speed -= 0.005

            #move shape down
            if fall_time / 1000 > fall_speed:
                current_shape.y += 1
                fall_time = 0

                #if shape collide border or another shape
                if not check_free_space(current_shape, grid):
                    current_shape.y -= 1
                    new_shape = True

            #get pressed keys
            keys = pygame.key.get_pressed()

            #handling input
            for event in pygame.event.get():
                if event.type == pygame.QUIT:
                    pygame.display.quit()
                    quit()

                if event.type == pygame.KEYDOWN:

                    #move left
                    if event.key == pygame.K_LEFT:
                        current_shape.x -= 1
                        if not check_free_space(current_shape, grid):
                            current_shape.x += 1

                    #move right
                    if event.key == pygame.K_RIGHT:
                        current_shape.x += 1
                        if not check_free_space(current_shape, grid):
                            current_shape.x -= 1

                    #rotate
                    if event.key == pygame.K_UP:
                        current_shape.rotation += 1
                        if not check_free_space(current_shape, grid):
                            current_shape.rotation -= 1

                    #fall shape
                    if event.key == pygame.K_SPACE:
                        current_shape.y = fall(current_shape, grid)

                    #pause
                    if event.key == pygame.K_p:
                        game_state = State.pause

            #speed up
            if keys[pygame.K_DOWN]:
                current_shape.y += 1
                if not check_free_space(current_shape, grid):
                    current_shape.y -= 1

            #get position of current shape
            current_shape_position = convert_shape_to_position(current_shape)

            #add current shape to grid
            for i in range(len(current_shape_position)):
                x, y = current_shape_position[i]

                if y >= 0:
                    grid[y][x] = current_shape.color
            ''' create new shape , check if rows are filled , update score , define next shape '''
            if new_shape:
                for pos in current_shape_position:
                    p = (pos[0], pos[1])
                    positions[p] = current_shape.color

                new_shape = False
                current_shape = next_shape
                next_shape = create_new_shape()
                score += 10
                score += clear_rows(grid, positions)
            ''' if there are blocks at first row finish the game '''
            if check_game_over(positions):
                game_state = State.game_over

            #draw window
            draw_window(window, grid, game_state, next_shape, score)

        elif game_state == State.pause:

            for event in pygame.event.get():

                if event.type == pygame.QUIT:
                    pygame.display.quit()
                    quit()

                if event.type == pygame.KEYDOWN:

                    #continue play
                    if event.key == pygame.K_p:
                        game_state = State.play

        elif game_state == State.game_over:

            for event in pygame.event.get():

                if event.type == pygame.QUIT:
                    pygame.display.quit()
                    quit()

                #return to menu
                if event.type == pygame.KEYDOWN:
                    menu(window)
예제 #11
0
def main(stuid, schoolid):
    allcourse = get_all_course(stuid)
    print(allcourse)
    courseOpenId = allcourse['courseOpenId']
    url = 'https://zjyapp.icve.com.cn/newmobileapi/coursequestion/getCourseQuestionList'
    data = {
        'schoolId': schoolid,
        'courseOpenId': courseOpenId,
        'limit': '1000',
    }
    tihuana = {
        '0': 'A',
        '1': 'B',
        '2': 'C',
        '3': 'D',
        '4': 'E',
        '5': 'F',
        '6': 'G',
        '7': 'H',
        '8': 'I',
    }
    # PreviewList = requests.post(url=url, data=data).json()
    # 先转为文本删除无效内容再转回去json处理
    PreviewListReq = requests.post(url=url, data=data).text
    PreviewListReq = PreviewListReq.replace('&nbsp;', '').replace(
        '</span>', '').replace('</p>', '').replace('</font>', '').replace(
            '<strong>',
            '').replace('</strong>',
                        '').replace('<b>', '').replace('</b>', '').replace(
                            '<div>',
                            '').replace('</div>',
                                        '').replace('<br>',
                                                    '').replace('<br/>', '')
    PreviewListReq = re.sub('<p.*?>', "", PreviewListReq)
    PreviewListReq = re.sub('<span.*?>', "", PreviewListReq)
    PreviewListReq = re.sub('<font.*?>', "", PreviewListReq)
    PreviewList = json.loads(PreviewListReq)
    if PreviewListReq.find('<img') > 0:
        hhf = '<br />'
        kzm = '.html'
    else:
        hhf = '\n'
        kzm = '.txt'

    if PreviewList['code'] == 1:
        questions = PreviewList['questionList']
        index = 1
        filename = time.strftime("%Y-%m-%d-%H-%M", time.localtime())
        for item in questions:
            Title = item['title']
            try:
                with open(f"{filename}" + kzm, "a", encoding="utf-8") as file:
                    if item['queTypeName'] == "单选题":
                        dataJsons = json.loads(item['dataJson'])
                        Contents = ''
                        for SortOrder_i in range(len(dataJsons)):
                            tihao = tihuana[str(
                                dataJsons[SortOrder_i]['SortOrder'])]
                            Content = dataJsons[SortOrder_i]['Content']
                            if dataJsons[SortOrder_i]['IsAnswer'] == True:
                                key = '单选题答案:' + tihao + '.' + Content
                            Contents = Contents + tihao + '.' + Content + hhf
                        Contents = Contents + key
                        file.write('题目' + str(index) + ':' + Title + hhf +
                                   Contents + hhf + hhf)
                    if item['queTypeName'] == "多选题":
                        dataJsons = json.loads(item['dataJson'])
                        Contents = ''
                        key = '多选题答案:'
                        for SortOrder_i in range(len(dataJsons)):
                            tihao = tihuana[str(
                                dataJsons[SortOrder_i]['SortOrder'])]
                            Content = dataJsons[SortOrder_i]['Content']
                            if dataJsons[SortOrder_i]['IsAnswer'] == True:
                                key = key + tihao + '.' + Content + ','
                            Contents = Contents + tihao + '.' + Content + hhf
                        if key[-1] == ',':
                            key = key[0:-1]
                        Contents = Contents + key
                        file.write('题目' + str(index) + ':' + Title + hhf +
                                   Contents + '\n\n')
                    if item['queTypeName'] == "判断题":
                        x = item['answer'].replace('0', '错').replace(
                            '1', '对').replace('2',
                                              '').replace('3',
                                                          '').replace('4', '')
                        file.write('题目' + str(index) + ':' + Title + hhf +
                                   hhf + "判断题答案:" + x + hhf + hhf)
                    if item['queTypeName'] == "问答题":
                        y = item['answer']
                        file.write('题目' + str(index) + ':' + Title + hhf +
                                   hhf + '问答题答案:' + y + hhf + hhf)
                    if item['queTypeName'] == "填空题(客观)":
                        y = item['answer']
                        file.write('题目' + str(index) + ':' + Title + hhf +
                                   hhf + '填空题(客观)答案:' + y + hhf + hhf)
                    if item['queTypeName'] == '填空题(主观)':
                        y = item['answer']
                        file.write('题目' + str(index) + ':' + Title + '\n\n' +
                                   '填空题(主观)答案:' + y + '\n\n')
                    index += 1
            except json.JSONDecodeError as e:
                print(PreviewList)
                pass
        print(f"{filename}已下载")
        print("答案已保存软件根目录下!")
        input("回车后返回首页!")
        from Main import main as menu
        menu()
예제 #12
0
def Rinse(PreviewList):
    tihuana = {
        '0': 'A',
        '1': 'B',
        '2': 'C',
        '3': 'D',
        '4': 'E',
        '5': 'F',
        '6': 'G',
        '7': 'H',
        '8': 'I',
    }
    if str(PreviewList).find('<img') > 0:
        hhf = '<br />'
        kzm = '.html'
    else:
        hhf = '\n'
        kzm = '.txt'
    title = PreviewList["title"]
    questions = PreviewList['questions']
    index = 1

    for item in questions:
        Title = item['title']
        dataJson = item['dataJson']
        try:
            with open(f"{title}" + kzm, "a", encoding="utf-8") as file:
                if item['queTypeName'] == "单选题":
                    dataJsons = json.loads(item['dataJson'])
                    Contents = ''
                    for SortOrder_i in range(len(dataJsons)):
                        tihao = tihuana[str(
                            dataJsons[SortOrder_i]['SortOrder'])]
                        Content = dataJsons[SortOrder_i]['Content']
                        if dataJsons[SortOrder_i]['IsAnswer'] == True:
                            key = '单选题答案:' + tihao + '.' + Content
                        Contents = Contents + tihao + '.' + Content + hhf
                    Contents = Contents + key
                    # file.write('题目' + str(index) + ':' + Title + '\n' + '单选题答案:' + dataJson + '\n\n')
                    file.write('题目' + str(index) + ':' + Title + hhf +
                               Contents + hhf + hhf)
                    # file.write('题目' + str(index) + ':' + Title + '\n\n' + '单选题答案:' + dataJson + '\n\n')
                if item['queTypeName'] == "多选题":
                    dataJsons = json.loads(item['dataJson'])
                    Contents = ''
                    key = '多选题答案:'
                    for SortOrder_i in range(len(dataJsons)):
                        tihao = tihuana[str(
                            dataJsons[SortOrder_i]['SortOrder'])]
                        Content = dataJsons[SortOrder_i]['Content']
                        if dataJsons[SortOrder_i]['IsAnswer'] == True:
                            key = key + tihao + '.' + Content + ','
                        Contents = Contents + tihao + '.' + Content + hhf
                    if key[-1] == ',':
                        key = key[0:-1]
                    Contents = Contents + key

                    # file.write('题目' + str(index) + ':' + Title + '\n' + '多选题答案:' + dataJson + '\n\n')
                    file.write('题目' + str(index) + ':' + Title + hhf +
                               Contents + hhf + hhf)
                if item['queTypeName'] == "判断题":
                    x = item['answer'].replace('0',
                                               '错').replace('1', '对').replace(
                                                   '2', '').replace('3', '')
                    file.write('题目' + str(index) + ':' + Title + hhf + hhf +
                               "判断题答案:" + x + '\n\n')
                if item['queTypeName'] == "问答题":
                    y = item['answer'].replace('&nbsp;', ' ')
                    file.write('题目' + str(index) + ':' + Title + hhf + hhf +
                               '问答题答案:' + y + hhf + hhf)
                if item['queTypeName'] == "填空题(客观)":
                    y = item['answer']
                    file.write('题目' + str(index) + ':' + Title + hhf + hhf +
                               '填空题(客观)答案:' + y + hhf + hhf)
                if item['queTypeName'] == '填空题(主观)':
                    y = item['answer']
                    file.write('题目' + str(index) + ':' + Title + '\n\n' +
                               '填空题(主观)答案:' + y + '\n\n')
                index += 1
        except json.JSONDecodeError as e:
            print(PreviewList)
            pass
    time.sleep(3)
    print("答案已保存软件根目录下!")
    input('返回首页中。。。。。')
    from Main import main as menu
    menu()
예제 #13
0
def main(stuid, schoolid):
    allcourse = get_all_course(stuid)
    courseOpenId = allcourse['courseOpenId']
    url = 'https://zjyapp.icve.com.cn/newmobileapi/coursequestion/getCourseQuestionList'
    data = {
        'schoolId': schoolid,
        'courseOpenId': courseOpenId,
        'limit': '1000',
    }
    tihuana = {
        '0': 'A',
        '1': 'B',
        '2': 'C',
        '3': 'D',
        '4': 'E',
        '5': 'F',
        '6': 'G',
        '7': 'H',
        '8': 'I',
    }
    # PreviewList = requests.post(url=url, data=data).json()
    # 先转为文本删除无效内容再转回去json处理
    PreviewListReq = requests.post(url=url, data=data).text
    PreviewListReq = PreviewListReq.replace('&nbsp;', '')
    PreviewListReq = re.sub('<.*?>', "", PreviewListReq)
    PreviewList = json.loads(PreviewListReq)

    if PreviewList['code'] == 1:
        questions = PreviewList['questionList']
        index = 1
        filename = time.strftime("%Y-%m-%d-%H-%M", time.localtime())
        for item in questions:
            # Title = item['title'].replace('&nbsp;', '').replace('<p>', '').replace('</p>', '').replace('<strong>',
            # '').replace(
            #   '</strong>', '').replace('<br/>', '')
            Title = item['title']
            # Title = re.sub('<.*?>', "", Title)
            # dataJson = item['dataJson'].replace('true', ':对').replace('false', '').replace('[', '').replace(']', '') \
            # .replace('"', '').replace('SortOrder', '').replace('0', '').replace('1', '').replace('2', '').replace(
            # '4', '').replace(
            # '3', '') \
            # .replace('Content', '').replace(':', '').replace('IsAnswer', '').replace(',', '  ').replace('&nbsp;',
            # '')
            # dataJson = re.sub('<.*?>', "", dataJson)
            dataJson = item['dataJson']
            try:
                with open(f"{filename}.txt", "a", encoding="utf-8") as file:
                    if item['queTypeName'] == "单选题":
                        dataJsons = json.loads(item['dataJson'])
                        Contents = ''
                        for SortOrder_i in range(len(dataJsons)):
                            tihao = tihuana[str(
                                dataJsons[SortOrder_i]['SortOrder'])]
                            Content = dataJsons[SortOrder_i]['Content']
                            if dataJsons[SortOrder_i]['IsAnswer'] == True:
                                key = '单选题答案:' + tihao + '.' + Content
                            Contents = Contents + tihao + '.' + Content + '\n'
                        Contents = Contents + key
                        # file.write('题目' + str(index) + ':' + Title + '\n' + '单选题答案:' + dataJson + '\n\n')
                        file.write('题目' + str(index) + ':' + Title + '\n' +
                                   Contents + '\n\n')
                    if item['queTypeName'] == "多选题":
                        dataJsons = json.loads(item['dataJson'])
                        Contents = ''
                        key = '多选题答案:'
                        for SortOrder_i in range(len(dataJsons)):
                            tihao = tihuana[str(
                                dataJsons[SortOrder_i]['SortOrder'])]
                            Content = dataJsons[SortOrder_i]['Content']
                            if dataJsons[SortOrder_i]['IsAnswer'] == True:
                                key = key + tihao + '.' + Content + ','
                            Contents = Contents + tihao + '.' + Content + '\n'
                        if key[-1] == ',':
                            key = key[0:-1]
                        Contents = Contents + key
                        file.write('题目' + str(index) + ':' + Title + '\n' +
                                   Contents + '\n\n')
                    if item['queTypeName'] == "判断题":
                        x = item['answer'].replace('0', '错').replace(
                            '1', '对').replace('2',
                                              '').replace('3',
                                                          '').replace('4', '')
                        file.write('题目' + str(index) + ':' + Title + '\n' +
                                   "判断题答案:" + x + '\n\n')
                    if item['queTypeName'] == "问答题":
                        y = item['answer']
                        file.write('题目' + str(index) + ':' + Title + '\n\n' +
                                   '问答题答案:' + y + '\n\n')
                    if item['queTypeName'] == "填空题(客观)":
                        y = item['answer']
                        file.write('题目' + str(index) + ':' + Title + '\n\n' +
                                   '填空题(客观)答案:' + y + '\n\n')
                    index += 1
            except json.JSONDecodeError as e:
                print(PreviewList)
                pass
        print(f"{filename}已下载")
        print("答案已保存软件根目录下!")
        sele = input("【1】返回首页\n【2】返回上级\n请选择:")
        if sele == 2:
            main(stuid, schoolid)
        else:
            from Main import main as menu
            menu()