deason 1 년 전
부모
커밋
706aaa56bb
1개의 변경된 파일7개의 추가작업 그리고 4개의 파일을 삭제
  1. 7 4
      exportexamdetail/examInf.py

+ 7 - 4
exportexamdetail/examInf.py

@@ -244,11 +244,14 @@ def solveexamRecord(examId, examRecorddetail):
                 content_div.append(soup)
 
                 rightAnswer = questionUnit["rightAnswer"]
+                curRightAnswer = ''
+                if rightAnswer and len(rightAnswer) > 0:
+                    curRightAnswer = rightAnswer[0]
+
                 quesitonEntity = quesitonEntites[sub_number - 1]
                 optionorder = quesitonEntity["optionPermutation"]
                 questionScore = quesitonEntity["questionScore"]
                 studentAnswer = quesitonEntity["studentAnswer"]
-
                 studentScore = quesitonEntity["studentScore"]
 
                 questionOptionList = questionUnit["questionOptionList"]
@@ -298,12 +301,12 @@ def solveexamRecord(examId, examRecorddetail):
                         selectorder(studentAnswer, optionorder))
                 elif questionType == "TRUE_OR_FALSE":
                     f = lambda x: "" if not x else "正确" if x == "true" else "错误"
-                    # print(f(rightAnswer[0]))
-                    rightAnswerdivcontent.append(f(rightAnswer[0]))
+                    # print(f(curRightAnswer))
+                    rightAnswerdivcontent.append(f(curRightAnswer))
                     studentAnswercontentspan.append(f(studentAnswer))
                 else:
                     rightAnswerdivcontent.append(
-                        bs4.BeautifulSoup(rightAnswer[0] if rightAnswer[0] else '', features="html.parser"))
+                        bs4.BeautifulSoup(curRightAnswer if curRightAnswer else '', features="html.parser"))
                     studentAnswercontentspan.append(
                         bs4.BeautifulSoup(studentAnswer if studentAnswer else '', features="html.parser"))