Skip to content

Commit b905621

Browse files
committed
Refactor ExportUtil
- Removed the HTML generation logic from ExportUtil::exportHtml and replaced it with JSON output. - Introduced a new method, ExportUtil::buildExportJson, to construct a JSON representation of contest results. - Updated the exportHtml method to read from an HTML template and insert the generated JSON data. - Cleaned up unused methods and includes related to HTML generation. - Enhanced the structure of the JSON output to include contestant details, task scores, and additional metadata.
1 parent 962d29e commit b905621

7 files changed

Lines changed: 619 additions & 677 deletions

File tree

.github/workflows/windows-qt6.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,7 @@ jobs:
8282
-GNinja \
8383
-DCMAKE_BUILD_TYPE=${{ matrix.build_type }} \
8484
-DLEMON_BUILD_INFO="Build for Windows" \
85-
-DLEMON_BUILD_EXTRA_INFO="Build on Windows x64" \
86-
-DENABLE_XLS_EXPORT=ON
85+
-DLEMON_BUILD_EXTRA_INFO="Build on Windows x64"
8786
cmake --build . --parallel $(nproc)
8887
- name: Deploy Qt for tests
8988
shell: pwsh

CMakeLists.txt

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,6 @@ option(EMBED_TRANSLATIONS "Embed translations" ON)
1919
LEMONLOG(EMBED_TRANSLATIONS)
2020
option(EMBED_DOCS "Embed documents" ON)
2121
LEMONLOG(EMBED_DOCS)
22-
option(ENABLE_XLS_EXPORT "XLS Result Export Support (Windows Only)" OFF)
23-
LEMONLOG(ENABLE_XLS_EXPORT)
2422
option(BUILD_DEB "Build deb format package" OFF)
2523
LEMONLOG(BUILD_DEB)
2624
option(BUILD_RPM "Build rpm format package" OFF)
@@ -287,12 +285,6 @@ endif()
287285

288286
target_include_directories(lemon PUBLIC ${CMAKE_SOURCE_DIR}/src)
289287

290-
if(WIN32 AND ENABLE_XLS_EXPORT)
291-
find_package(${LEMON_QT_LIBNAME} COMPONENTS AxContainer REQUIRED)
292-
list(APPEND LEMON_QT_LIBS ${LEMON_QT_LIBNAME}::AxContainer)
293-
add_definitions(-DENABLE_XLS_EXPORT)
294-
endif()
295-
296288
target_precompile_headers(lemon PUBLIC ${CMAKE_SOURCE_DIR}/src/pch.h)
297289

298290
target_link_libraries(lemon PRIVATE ${LEMON_QT_LIBS} lemon-core lemon-base SingleApplication::SingleApplication spdlog::spdlog)

resource.qrc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@
77
<file>makespec/VERSIONSUFFIX</file>
88
<file>assets/lemon-lime.ico</file>
99
</qresource>
10+
<qresource prefix="/export">
11+
<file alias="export_template.html">src/component/exportutil/export_template.html</file>
12+
</qresource>
1013
<qresource prefix="/icon">
1114
<file alias="icon.png">assets/icons/lemon-lime.png</file>
1215
<file alias="code-function.svg">assets/pics/code-function.svg</file>

src/component/exportutil/README.md

Lines changed: 143 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,143 @@
1+
# README
2+
3+
### 顶级字段
4+
5+
| 字段名 | 类型 | 说明 | 举例 |
6+
| ------------- | ---------- | ---------------- | ------------------------------------- |
7+
| `name` | `string` | 比赛名称 | `"contest"` |
8+
| `version` | `string` | LemonLime 版本 | `"Lemonlime Version 0.3.6.1:7545e02"` |
9+
| `task_names` | `string[]` | 题目名称数组 | `["plus", "minus"]` |
10+
| `i18n` | `object` | i18n 字典 | 见下节 |
11+
| `contestants` | `object[]` | 选手成绩数据数组 | 见下节 |
12+
13+
### i18n
14+
15+
| 字段名 | 举例 |
16+
| ------------- | --------------------------------------------------------- |
17+
| `rank_list` | `"排名表"` |
18+
| `hint` | `"点击名字或单题分数跳转到详细信息。使用 LemonLime 评测"` |
19+
| `rank` | `"排名"` |
20+
| `name` | `"名称"` |
21+
| `total` | `"总分"` |
22+
| `contestant` | `"选手"` |
23+
| `task` | `"试题"` |
24+
| `source_file` | `"源程序:"` |
25+
| `no_source` | `"未找到选手程序"` |
26+
| `testcase` | `"测试点"` |
27+
| `input` | `"输入文件"` |
28+
| `result` | `"测试结果"` |
29+
| `time` | `"运行用时"` |
30+
| `memory` | `"内存消耗"` |
31+
| `score` | `"得分"` |
32+
33+
---
34+
35+
### contestants 数组内对象
36+
37+
| 字段名 | 类型 | 说明 | 举例 |
38+
| -------------- | ---------- | -------------------- | --------------- |
39+
| `name` | `string` | 选手姓名 | `"Alice"` |
40+
| `total_score` | `number` | 选手总分 | `200` |
41+
| `total_bg` | `string` | 总分单元格背景 (HSL) | `"0, 70%, 90%"` |
42+
| `total_border` | `string` | 总分单元格边框 (HSL) | `"0, 70%, 50%"` |
43+
| `tasks` | `object[]` | 题目结果数组 | 见下节 |
44+
45+
---
46+
47+
### tasks 数组内对象
48+
49+
| 字段名 | 类型 | 说明 | 举例 |
50+
| --------- | ---------- | ------------------ | ----------------- |
51+
| `score` | `number` | 该题单项得分 | `100` |
52+
| `bg` | `string` | 该题得分背景 (HSL) | `"120, 30%, 60%"` |
53+
| `file` | `string` | 选手程序文件名(可选,若无该字段则表示找不到选手程序) | `"plus.cpp"` |
54+
| `details` | `object[]` | 测试点详情数组 | 见下节 |
55+
56+
---
57+
58+
### details 数组内对象
59+
60+
| 字段名 | 类型 | 说明 | 举例 |
61+
| ------------ | -------- | ---------------------------------------------------- | ------------------------------ |
62+
| `label` | `string` | 测试点编号或子任务信息,允许使用 `<br>` | `"#2<br/>子任务依赖情况:Pure"` |
63+
| `row_span` | `number` | 合并单元格行数(0 表示该行被合并,1 表示该行不合并) | `1` |
64+
| `input` | `string` | 该测试点输入文件名 | `"plus2.in"` |
65+
| `result` | `string` | 评测状态结果文字 | `"评测通过"` |
66+
| `time` | `string` | 运行耗时字符串 | `"0.005 s"` |
67+
| `memory` | `string` | 内存占用字符串 | `"5.34 MB"` |
68+
| `score` | `number` | 该项得分 | `20` |
69+
| `full_score` | `number` | 该项满分 | `20` |
70+
| `bg` | `string` | 状态背景 (RGB) | `"rgb(192, 255, 192)"` |
71+
| `info` | `string` | 测评信息(可选) | `在第四行,读取到 123456,但期望 789123` |
72+
73+
---
74+
75+
### 示例 JSON
76+
77+
以下 JSON 可用于调试模板渲染:
78+
79+
```json
80+
{
81+
"name": "example contest",
82+
"version": "Lemonlime Version 0.3.6.1:7545e02",
83+
"i18n": {
84+
"rank_list": "排名表",
85+
"hint": "点击名字或单题分数跳转到详细信息。使用 LemonLime 评测",
86+
"rank": "排名",
87+
"name": "名称",
88+
"total": "总分",
89+
"contestant": "选手",
90+
"task": "试题",
91+
"source_file": "源程序:",
92+
"no_source": "未找到选手程序",
93+
"testcase": "测试点",
94+
"input": "输入文件",
95+
"result": "测试结果",
96+
"time": "运行用时",
97+
"memory": "内存消耗",
98+
"score": "得分"
99+
},
100+
"task_names": ["plus", "minus"],
101+
"contestants": [
102+
{
103+
"name": "Alice",
104+
"rank": 1,
105+
"total_score": 150,
106+
"total_bg": "120, 30%, 90%",
107+
"total_border": "120, 30%, 50%",
108+
"tasks": [
109+
{
110+
"score": 100,
111+
"bg": "120, 30%, 70%",
112+
"file": "plus.cpp",
113+
"details": [
114+
{ "label": "#1", "row_span": 1, "input": "plus1.in", "result": "评测通过", "time": "0.001 s", "memory": "1.2 MB", "score": 50, "full_score": 50, "bg": "rgb(192, 255, 192)" },
115+
{ "label": "#2", "row_span": 1, "input": "plus2.in", "result": "评测通过", "time": "0.002 s", "memory": "1.2 MB", "score": 50, "full_score": 50, "bg": "rgb(192, 255, 192)" }
116+
]
117+
},
118+
{
119+
"score": 50,
120+
"bg": "120,28.9006%,82.3499%",
121+
"file": "minus.cpp",
122+
"details": [
123+
{ "label": "#1", "row_span": 1, "input": "minus1.in", "result": "评测通过", "time": "0.001 s", "memory": "1.2 MB", "score": 50, "full_score": 50, "bg": "rgb(192, 255, 192)" },
124+
{ "label": "#2<br>子任务依赖情况:Pure", "row_span": 2, "input": "minus2.in", "result": "答案错误", "time": "0.001 s", "memory": "2.0 MB", "score": 0, "full_score": 50, "bg": "rgb(255, 192, 192)", "info": "在第四行,读取到 123456,但期望 789123" },
125+
{ "label": "", "row_span": 0, "input": "minus3.in", "result": "运行错误", "time": "0.001 s", "memory": "2.0 MB", "score": 0, "full_score": 50, "bg": "rgb(255, 192, 192)" }
126+
]
127+
}
128+
]
129+
},
130+
{
131+
"name": "Bob",
132+
"rank": 2,
133+
"total_score": 0,
134+
"total_bg": "0, 0%, 90%",
135+
"total_border": "0, 0%, 70%",
136+
"tasks": [
137+
{ "score": 0, "bg": "0, 0%, 90%" },
138+
{ "score": 0, "bg": "0, 0%, 90%" }
139+
]
140+
}
141+
]
142+
}
143+
```

0 commit comments

Comments
 (0)