added new excel field - score
Some checks failed
Some checks failed
This commit is contained in:
parent
22febb9953
commit
d54ffe956e
1
go.mod
1
go.mod
@ -24,6 +24,7 @@ require (
|
|||||||
)
|
)
|
||||||
|
|
||||||
require (
|
require (
|
||||||
|
gitea.pena/PenaSide/linters-golang v0.0.0-20241207122018-933207374735 // indirect
|
||||||
github.com/ClickHouse/clickhouse-go v1.5.4 // indirect
|
github.com/ClickHouse/clickhouse-go v1.5.4 // indirect
|
||||||
github.com/andybalholm/brotli v1.1.1 // indirect
|
github.com/andybalholm/brotli v1.1.1 // indirect
|
||||||
github.com/cespare/xxhash/v2 v2.3.0 // indirect
|
github.com/cespare/xxhash/v2 v2.3.0 // indirect
|
||||||
|
|||||||
4
go.sum
4
go.sum
@ -1,10 +1,10 @@
|
|||||||
cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
|
cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
|
||||||
gitea.pena/PenaSide/common v0.0.0-20250421103113-7e4b3ae9e1e0 h1:+gvpAPo1+1WtCpA+QaCWNy4R9/cIERBBzrVSYrx7hNo=
|
|
||||||
gitea.pena/PenaSide/common v0.0.0-20250421103113-7e4b3ae9e1e0/go.mod h1:91EuBCgcqgJ6mG36n2pds8sPwwfaJytLWOzY3h2YFKU=
|
|
||||||
gitea.pena/PenaSide/common v0.0.0-20250609100303-3b7c00cc97bc h1:xwojlRrEl2hjZxgoMqSz8pkWmQRYq7LsDdeAExtgyQE=
|
gitea.pena/PenaSide/common v0.0.0-20250609100303-3b7c00cc97bc h1:xwojlRrEl2hjZxgoMqSz8pkWmQRYq7LsDdeAExtgyQE=
|
||||||
gitea.pena/PenaSide/common v0.0.0-20250609100303-3b7c00cc97bc/go.mod h1:91EuBCgcqgJ6mG36n2pds8sPwwfaJytLWOzY3h2YFKU=
|
gitea.pena/PenaSide/common v0.0.0-20250609100303-3b7c00cc97bc/go.mod h1:91EuBCgcqgJ6mG36n2pds8sPwwfaJytLWOzY3h2YFKU=
|
||||||
gitea.pena/PenaSide/hlog v0.0.0-20241125221102-a54c29c002a9 h1:tBkXWNIt8icmkMMnq8MA421RWkUy4OZh5P7C3q8uCu4=
|
gitea.pena/PenaSide/hlog v0.0.0-20241125221102-a54c29c002a9 h1:tBkXWNIt8icmkMMnq8MA421RWkUy4OZh5P7C3q8uCu4=
|
||||||
gitea.pena/PenaSide/hlog v0.0.0-20241125221102-a54c29c002a9/go.mod h1:sanhSL8aEsfcq21P+eItYiAnKAre+B67nGJmDfk2cf0=
|
gitea.pena/PenaSide/hlog v0.0.0-20241125221102-a54c29c002a9/go.mod h1:sanhSL8aEsfcq21P+eItYiAnKAre+B67nGJmDfk2cf0=
|
||||||
|
gitea.pena/PenaSide/linters-golang v0.0.0-20241207122018-933207374735 h1:jDVeUhGBTXBibmW5dmtJg2m2+z5z2Rf6J4G0LpjVoJ0=
|
||||||
|
gitea.pena/PenaSide/linters-golang v0.0.0-20241207122018-933207374735/go.mod h1:gdd+vOT6up9STkEbxa2qESLIMZFjCmRbkcheFQCVgZU=
|
||||||
gitea.pena/PenaSide/trashlog v0.0.0-20250224122049-ddb4d72e9d07 h1:bUIUgzXQt16aBqSccI//BaODpRCTIaqlddSepM98QSc=
|
gitea.pena/PenaSide/trashlog v0.0.0-20250224122049-ddb4d72e9d07 h1:bUIUgzXQt16aBqSccI//BaODpRCTIaqlddSepM98QSc=
|
||||||
gitea.pena/PenaSide/trashlog v0.0.0-20250224122049-ddb4d72e9d07/go.mod h1:GRfWJerTUlgy82CiYAxE4tVYSVV54zEJJQy17Fx46E4=
|
gitea.pena/PenaSide/trashlog v0.0.0-20250224122049-ddb4d72e9d07/go.mod h1:GRfWJerTUlgy82CiYAxE4tVYSVV54zEJJQy17Fx46E4=
|
||||||
gitea.pena/SQuiz/common v0.0.0-20250629151736-5656e784ba68 h1:U+rO77EY1Cp7RAEtDjLIl1Z2tFcEouUuQ+J4LnFUe6g=
|
gitea.pena/SQuiz/common v0.0.0-20250629151736-5656e784ba68 h1:U+rO77EY1Cp7RAEtDjLIl1Z2tFcEouUuQ+J4LnFUe6g=
|
||||||
|
|||||||
@ -3,8 +3,6 @@ package tools
|
|||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"gitea.pena/SQuiz/common/model"
|
|
||||||
"github.com/xuri/excelize/v2"
|
|
||||||
_ "image/gif"
|
_ "image/gif"
|
||||||
_ "image/jpeg"
|
_ "image/jpeg"
|
||||||
_ "image/png"
|
_ "image/png"
|
||||||
@ -18,6 +16,9 @@ import (
|
|||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
|
|
||||||
|
"gitea.pena/SQuiz/common/model"
|
||||||
|
"github.com/xuri/excelize/v2"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@ -85,6 +86,7 @@ func prepareHeaders(questions []model.Question) ([]string, map[uint64]string) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
headers = append(headers, "Результат")
|
headers = append(headers, "Результат")
|
||||||
|
headers = append(headers, "Баллов получено")
|
||||||
return headers, mapQueRes
|
return headers, mapQueRes
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -132,10 +134,25 @@ func processSession(file *excelize.File, sheet, session, s3Prefix string, respon
|
|||||||
count++
|
count++
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
cell := ToAlphaString(len(headers)) + strconv.Itoa(row)
|
cell := ToAlphaString(len(headers)-1) + strconv.Itoa(row)
|
||||||
if err := file.SetCellValue(sheet, cell, mapQueRes[results[session].QuestionId]); err != nil {
|
if err := file.SetCellValue(sheet, cell, mapQueRes[results[session].QuestionId]); err != nil {
|
||||||
fmt.Println(err.Error())
|
fmt.Println(err.Error())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
score := extractScoreFromResult(results[session].Content)
|
||||||
|
scoreCell := ToAlphaString(len(headers)) + strconv.Itoa(row)
|
||||||
|
if err := file.SetCellValue(sheet, scoreCell, score); err != nil {
|
||||||
|
fmt.Println(err.Error())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func extractScoreFromResult(content string) int32 {
|
||||||
|
var resultContent model.ResultContent
|
||||||
|
err := json.Unmarshal([]byte(content), &resultContent)
|
||||||
|
if err != nil {
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
return resultContent.Score
|
||||||
}
|
}
|
||||||
|
|
||||||
func handleAnswer(file *excelize.File, sheet, cell, s3Prefix string, answer model.Answer, question model.Question, count, row int) {
|
func handleAnswer(file *excelize.File, sheet, cell, s3Prefix string, answer model.Answer, question model.Question, count, row int) {
|
||||||
|
|||||||
0
main.go
0
main.go
Loading…
Reference in New Issue
Block a user