Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

是否可以添加随堂练习的答案获取? #18

Open
cibimo opened this issue Oct 14, 2022 · 3 comments
Open

是否可以添加随堂练习的答案获取? #18

cibimo opened this issue Oct 14, 2022 · 3 comments
Labels
✨ feature request New feature or request

Comments

@cibimo
Copy link

cibimo commented Oct 14, 2022

以下是自己写的实现代码 未验证未提交时是否可以获取到正确选项

import requests

mobtokan = 'xxx'
userid = 'xxx'
classid = 'xxx'

HEADER = {
    'eds-scope': 'xxx',
    'cookie':'STUDY_SESS="xxx"'
}

def getClassActivity(classroomId):
    return requests.post("https://www.icourse163.org/mm-classroom/mob/j/v1/classroomManageBean.getClassroomLessonActivity4Stu.rpc",data={"mob-token":mobtokan,"classroomId":classroomId}).json()

def getAnswerFrom(answerFormId,paperId,userId):
    return requests.get("https://www.icourse163.org/mm-tiku/api/mobile/paper/answerform/view",params={"answerFormId":answerFormId,"paperId":paperId,"userId":userId},headers=HEADER,cookies=COOKIE).json()

classActivity = getClassActivity(classid)['results']

for i in classActivity['activities']:
    if i['activityType'] == 2:
        print(i['paper'])
        answerFrom = getAnswerFrom(i['paper']['answerformId'],i['paper']['id'],userid)

HTMLContent = ""

num = 1
for i in answerFrom['result']['nodes']:
    if i['questionData']['trueOrFalseQuestionContent']:
        HTMLContent += f"<br><br>{num}. 判断题:{i['questionData']['trueOrFalseQuestionContent']['title'].replace('<br>','')}"
        HTMLContent += f"<br>答案:{'对' if i['questionData']['trueOrFalseQuestionContent']['stdAnswer'] else '错'}"
        
    if i['questionData']['singleChoiceQuestionContent']:
        HTMLContent += f"<br><br>{num}. 单选题:{i['questionData']['singleChoiceQuestionContent']['title'].replace('<br>','')}"
        for p in i['questionData']['singleChoiceQuestionContent']['choicesAnswers']:
            HTMLContent += f"<br>{p['content'].replace('<br>','')} ({'<span style=color:red>正确</span>' if p['correct'] else '错误'})"
    
    HTMLContent += "<br><br><br>"
    num += 1

with open("output.html",'w+') as f:
    f.write(HTMLContent)

效果:
image

@28742
Copy link

28742 commented Oct 18, 2022

哦哦,懂了懂了

@xiaolu-lujunji
Copy link
Collaborator

xiaolu-lujunji commented Nov 18, 2022

你目前验证了在未提交的情况下是否可以修改请求参数实现获取测试答案吗?

@cibimo
Copy link
Author

cibimo commented Nov 18, 2022

你目前验证了在未提交的情况下是否可以修改请求参数实现获取测试答案吗?

之后尝试过好像是不太行

@xiaolu-lujunji xiaolu-lujunji added the ✨ feature request New feature or request label Nov 18, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
✨ feature request New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants