deason hace 3 años
padre
commit
153179ebec
Se han modificado 2 ficheros con 10 adiciones y 10 borrados
  1. 2 2
      exportexamdetail/common.py
  2. 8 8
      exportexamdetail/examInf.py

+ 2 - 2
exportexamdetail/common.py

@@ -34,8 +34,8 @@ def convert_to_pdf(sourceHtml,outpdffile):
     }
     try:
        pdfkit.from_file(sourceHtml, outpdffile, configuration=configuration, options=options)
-    except:
-        print("错误忽略")
+    except Exception as e:
+        print('ignore exception..')
 
 
 #生成资源文件目录访问路径

+ 8 - 8
exportexamdetail/examInf.py

@@ -14,7 +14,7 @@ def calctime(m_func):
         start=time.time()
         res=m_func(*args,**kwargs)
         end=time.time()
-        print(m_func.__name__+" spend time is "+str(end-start))
+        # print(m_func.__name__+" spend time is "+str(end-start))
         return res
     return decorter
 
@@ -106,13 +106,13 @@ def getQuesitons(courseCode, groupCode, questionId):
 
 def solveexamRecord(examRecorddetail):
     record = bs4.BeautifulSoup(open(common.resource_path(os.path.join("template","template.html")), "r", encoding="utf-8"), features="html.parser")
+    identityNumber = examRecorddetail["identityNumber"]
     studentName = examRecorddetail["studentName"]
     examrRecordDataId = examRecorddetail["id"]
-    print("start to solve" + str(examrRecordDataId))
+    # print("Start examRecordDataId" + str(examrRecordDataId))
     courseCode = examRecorddetail["courseCode"]
     courseName = examRecorddetail["courseName"]
     studentCode = examRecorddetail["studentCode"]
-    print(examrRecordDataId)
     result=findExamRecordDataEntity(examrRecordDataId)
     #print(result)
     groupCode = result["examRecord"]["paperType"]
@@ -216,7 +216,7 @@ def solveexamRecord(examRecorddetail):
 
                 if questionType == "SINGLE_CHOICE" or questionType == "MULTIPLE_CHOICE":
                     correctAnswer=quesitonEntity["correctAnswer"]
-                    print(correctAnswer,studentAnswer)
+                    # print(correctAnswer,studentAnswer)
 
                     rightAnswerdivcontent.append(
                         selectorder(correctAnswer,optionorder))
@@ -224,7 +224,7 @@ def solveexamRecord(examRecorddetail):
                        selectorder(studentAnswer,optionorder))
                 elif questionType=="TRUE_OR_FALSE":
                     f=lambda x: "" if not x else "正确" if x=="true" else "错误"
-                    print(f(rightAnswer[0]))
+                    # print(f(rightAnswer[0]))
                     rightAnswerdivcontent.append(f(rightAnswer[0]))
                     studentAnswercontentspan.append(f(studentAnswer))
                 else:
@@ -244,16 +244,16 @@ def solveexamRecord(examRecorddetail):
         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))
-    filepath=config.outputpath+os.sep+str(config.examId)+os.sep+str(examrRecordDataId)+".pdf"
+    filepath=config.outputpath+os.sep+str(config.examId)+os.sep+identityNumber+'_'+studentName+".pdf"
     common.convert_to_pdf(common.resource_path(os.path.join("template","temp.html")),filepath)
-    print("finish solve" + str(examrRecordDataId))
+    print("Finish examRecordDataId " + str(examrRecordDataId))
 
 
 def selectorder(answer,optionpremutation):
     if answer:
         answerstr=[]
         for answerorder in answer:
-            print(optionpremutation)
+            # print(optionpremutation)
             index=optionpremutation.index(int(answerorder))
             answerstr.append(chr(65+index))
         answerstr.sort()