suncloud 1 éve
szülő
commit
d66ee08ebf
1 módosított fájl, 4 hozzáadás és 1 törlés
  1. 4 1
      src/api/test.go

+ 4 - 1
src/api/test.go

@@ -175,16 +175,20 @@ func ImportTest(c *gin.Context, apictx *ApiSession) (interface{}, error) {
 
 	if len(tests) > 0 {
 		for index, ts := range tests {
+			rowNum := index + 1
 			// 标题行
 			if index == 0 {
+				rowNum++
 				continue
 			}
 			// 表头
 			if index == 1 {
+				rowNum++
 				continue
 			}
 			// 去除可能的空行
 			if len(ts[0]) < 3 {
+				rowNum++
 				continue
 			}
 			// 问题(content) 试题类型(type)  (options)选项A 选项B 选项C 选项D 分值(score) (answer)答案
@@ -213,7 +217,6 @@ func ImportTest(c *gin.Context, apictx *ApiSession) (interface{}, error) {
 			test.CreateTime = time.Now()
 			test.UpdateTime = time.Now()
 
-			rowNum := index + 1
 			_, err = repo.RepoAddDbDoc(apictx.CreateRepoCtx(), db, repo.CollectionTest, test)
 			if err != nil {
 				errors = append(errors, fmt.Sprintf("第%d行错误: %s", rowNum, "保存数据失败, 请检查数据格式是否正确"))