|
@@ -48,31 +48,34 @@ def login():
|
|
def doExport():
|
|
def doExport():
|
|
print('')
|
|
print('')
|
|
|
|
|
|
- if len(config.examId) == 0:
|
|
|
|
- print("配置参数“examId”不能为空!")
|
|
|
|
|
|
+ if len(config.examIds) == 0:
|
|
|
|
+ print("配置参数“examIds”不能为空!")
|
|
return None
|
|
return None
|
|
|
|
|
|
login()
|
|
login()
|
|
|
|
|
|
- if len(config.courseIds) > 0:
|
|
|
|
- courseIds = config.courseIds.split(',')
|
|
|
|
- for courseId in courseIds:
|
|
|
|
- querydetail(1, courseId)
|
|
|
|
- else:
|
|
|
|
- querydetail(1, None)
|
|
|
|
|
|
+ examIds = config.examIds.split(',')
|
|
|
|
+ for examId in examIds:
|
|
|
|
+ if len(config.courseIds) > 0:
|
|
|
|
+ courseIds = config.courseIds.split(',')
|
|
|
|
+ for courseId in courseIds:
|
|
|
|
+ querydetail(1, examId, courseId)
|
|
|
|
+ else:
|
|
|
|
+ querydetail(1, examId, None)
|
|
|
|
|
|
- print("执行完成,失败数:" + str(errCount))
|
|
|
|
|
|
+ print('')
|
|
|
|
+ print("全部执行完成,失败数:" + str(errCount))
|
|
|
|
|
|
|
|
|
|
@calctime
|
|
@calctime
|
|
-def querydetail(curpage, courseId):
|
|
|
|
|
|
+def querydetail(curpage, examId, courseId):
|
|
print('')
|
|
print('')
|
|
global errCount
|
|
global errCount
|
|
|
|
|
|
url = "https://" + config.domain + "/api/ecs_oe_admin/exam/record/detail/list"
|
|
url = "https://" + config.domain + "/api/ecs_oe_admin/exam/record/detail/list"
|
|
params = {"rootOrgId": config.rootOrgId, "examRecordDataId": None, "hasStranger": None, "courseId": courseId,
|
|
params = {"rootOrgId": config.rootOrgId, "examRecordDataId": None, "hasStranger": None, "courseId": courseId,
|
|
"courseLevel": None,
|
|
"courseLevel": None,
|
|
- "examId": config.examId, "faceSuccessPercentLower": None, "faceSuccessPercentUpper": None,
|
|
|
|
|
|
+ "examId": examId, "faceSuccessPercentLower": None, "faceSuccessPercentUpper": None,
|
|
"identityNumber": None,
|
|
"identityNumber": None,
|
|
"orgId": None, "studentCode": None, "studentName": None, "isWarn": None, "pageNo": curpage,
|
|
"orgId": None, "studentCode": None, "studentName": None, "isWarn": None, "pageNo": curpage,
|
|
"pageSize": 500,
|
|
"pageSize": 500,
|
|
@@ -85,18 +88,18 @@ def querydetail(curpage, courseId):
|
|
totalPages = result.json()["totalPages"]
|
|
totalPages = result.json()["totalPages"]
|
|
totalElements = result.json()["totalElements"]
|
|
totalElements = result.json()["totalElements"]
|
|
print("---> totalElements=" + str(totalElements) + " totalPages=" + str(totalPages)
|
|
print("---> totalElements=" + str(totalElements) + " totalPages=" + str(totalPages)
|
|
- + " curPage=" + str(curpage) + " courseId=" + str(courseId))
|
|
|
|
|
|
+ + " curPage=" + str(curpage) + " examId=" + str(examId) + " courseId=" + str(courseId))
|
|
|
|
|
|
for content in contents:
|
|
for content in contents:
|
|
try:
|
|
try:
|
|
- solveexamRecord(content)
|
|
|
|
|
|
+ solveexamRecord(examId, content)
|
|
except Exception as e:
|
|
except Exception as e:
|
|
errCount += 1
|
|
errCount += 1
|
|
print("网络异常,下载失败! " + content["courseCode"] + "_" + content["identityNumber"]
|
|
print("网络异常,下载失败! " + content["courseCode"] + "_" + content["identityNumber"]
|
|
+ "_" + content["studentName"] + " 失败数:" + str(errCount))
|
|
+ "_" + content["studentName"] + " 失败数:" + str(errCount))
|
|
|
|
|
|
if curpage < totalPages:
|
|
if curpage < totalPages:
|
|
- querydetail(curpage + 1, courseId)
|
|
|
|
|
|
+ querydetail(curpage + 1, examId, courseId)
|
|
else:
|
|
else:
|
|
raise Exception("获取数据失败,请检查配置参数或网络是否正常!")
|
|
raise Exception("获取数据失败,请检查配置参数或网络是否正常!")
|
|
|
|
|
|
@@ -145,9 +148,9 @@ def getExamRecordQuestions(examRecordDataId):
|
|
|
|
|
|
|
|
|
|
@calctime
|
|
@calctime
|
|
-def getQuesitons(courseCode, groupCode, questionId):
|
|
|
|
|
|
+def getQuesitons(examId, courseCode, groupCode, questionId):
|
|
url = "https://" + config.domain + "/api/ecs_ques/default_question/question"
|
|
url = "https://" + config.domain + "/api/ecs_ques/default_question/question"
|
|
- data = {"examId": config.examId, "courseCode": courseCode, "groupCode": groupCode, "questionId": questionId}
|
|
|
|
|
|
+ data = {"examId": examId, "courseCode": courseCode, "groupCode": groupCode, "questionId": questionId}
|
|
result = requests.post(url, json=data, headers=config.header, verify=False)
|
|
result = requests.post(url, json=data, headers=config.header, verify=False)
|
|
if result.status_code == 200:
|
|
if result.status_code == 200:
|
|
return result.json()
|
|
return result.json()
|
|
@@ -155,7 +158,7 @@ def getQuesitons(courseCode, groupCode, questionId):
|
|
return None
|
|
return None
|
|
|
|
|
|
|
|
|
|
-def solveexamRecord(examRecorddetail):
|
|
|
|
|
|
+def solveexamRecord(examId, examRecorddetail):
|
|
identityNumber = examRecorddetail["identityNumber"]
|
|
identityNumber = examRecorddetail["identityNumber"]
|
|
studentName = examRecorddetail["studentName"]
|
|
studentName = examRecorddetail["studentName"]
|
|
examrRecordDataId = examRecorddetail["id"]
|
|
examrRecordDataId = examRecorddetail["id"]
|
|
@@ -172,7 +175,7 @@ def solveexamRecord(examRecorddetail):
|
|
features="html.parser")
|
|
features="html.parser")
|
|
|
|
|
|
filepath = config.outputpath + os.sep + str(
|
|
filepath = config.outputpath + os.sep + str(
|
|
- config.examId) + os.sep + courseCode + "_" + identityNumber + "_" + studentName + ".pdf"
|
|
|
|
|
|
+ examId) + os.sep + courseCode + "_" + identityNumber + "_" + studentName + ".pdf"
|
|
if os.path.exists(filepath):
|
|
if os.path.exists(filepath):
|
|
print("已处理,跳过! " + courseCode + "_" + identityNumber + "_" + studentName + ".pdf")
|
|
print("已处理,跳过! " + courseCode + "_" + identityNumber + "_" + studentName + ".pdf")
|
|
return None
|
|
return None
|
|
@@ -211,7 +214,7 @@ def solveexamRecord(examRecorddetail):
|
|
groupDiv.string = common.four_to_han(str(main_number)) + "、" + groupName + "(" + str(groupScore) + "分" + ")"
|
|
groupDiv.string = common.four_to_han(str(main_number)) + "、" + groupName + "(" + str(groupScore) + "分" + ")"
|
|
for questionWrapper in questionWrapperList:
|
|
for questionWrapper in questionWrapperList:
|
|
questionId = questionWrapper["questionId"]
|
|
questionId = questionWrapper["questionId"]
|
|
- quesitondetail = getQuesitons(courseCode, groupCode, questionId)
|
|
|
|
|
|
+ quesitondetail = getQuesitons(examId, courseCode, groupCode, questionId)
|
|
main_body = record.new_tag("div",
|
|
main_body = record.new_tag("div",
|
|
attrs={"data-v-3575fe23": "", "style": "display: flex; flex-direction: row;"})
|
|
attrs={"data-v-3575fe23": "", "style": "display: flex; flex-direction: row;"})
|
|
datadiv1.append(main_body)
|
|
datadiv1.append(main_body)
|
|
@@ -329,8 +332,8 @@ def solveexamRecord(examRecorddetail):
|
|
with open(common.resource_path(os.path.join("template", "temp.html")), 'w', encoding="utf-8") as fp:
|
|
with open(common.resource_path(os.path.join("template", "temp.html")), 'w', encoding="utf-8") as fp:
|
|
fp.write(record.prettify())
|
|
fp.write(record.prettify())
|
|
|
|
|
|
- if not os.path.exists(config.outputpath + os.sep + str(config.examId)):
|
|
|
|
- os.makedirs(config.outputpath + os.sep + str(config.examId))
|
|
|
|
|
|
+ if not os.path.exists(config.outputpath + os.sep + str(examId)):
|
|
|
|
+ os.makedirs(config.outputpath + os.sep + str(examId))
|
|
|
|
|
|
common.convert_to_pdf(common.resource_path(os.path.join("template", "temp.html")), filepath)
|
|
common.convert_to_pdf(common.resource_path(os.path.join("template", "temp.html")), filepath)
|
|
print("已完成! " + courseCode + "_" + identityNumber + "_" + studentName + ".pdf examrRecordDataId=" + str(
|
|
print("已完成! " + courseCode + "_" + identityNumber + "_" + studentName + ".pdf examrRecordDataId=" + str(
|