Skip to content

Commit

Permalink
docs: add freshcup mid. add problem type description.
Browse files Browse the repository at this point in the history
  • Loading branch information
ballade0d committed Oct 21, 2024
1 parent f978b60 commit 5c10be1
Show file tree
Hide file tree
Showing 4 changed files with 145 additions and 3 deletions.
4 changes: 4 additions & 0 deletions docs/.vitepress/config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,10 @@ export default withMermaid({
{
text: 'Go-judge 中间件',
link: '/gojudge-mid'
},
{
text: 'FreshCup 中间件',
link: '/freshcup-mid'
}
]
},
Expand Down
106 changes: 106 additions & 0 deletions docs/dev-guide/backend/judge-mid/freshcup-mid.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
# FreshCup 中间件

## 简介

sastoj 通过 FreshCup 中间件提供了对 `单选题、多选题、简答题` 的支持

## 题目类型

该评测机支持的题目类型为选择题、填空题。对应的题目类型信息如下:

``` json
// 单选题
{
// 题目类型的简化名称
"slug_name": "freshcup-single-choice",
// 显示名
"display_name": "Single-Choice",
// 题目类型描述
"description": "Single Choice Problem powered by Freshcup",
// 在消息队列中的提交通道名称
"submission_channel_name": "freshcup-submission",
// 在消息队列中的自测通道名称
"self_test_channel_name": "freshcup-self-test",
// 评测机名称
"judge": "freshcup"
}
// 多选题
{
"slug_name": "freshcup-multiple-choice",
"display_name": "Multiple-Choice",
"description": "Multiple Choice Problem powered by Freshcup",
"submission_channel_name": "freshcup-submission",
"self_test_channel_name": "freshcup-self-test",
"judge": "freshcup"
}
// 填空题
{
"slug_name": "freshcup-short-answer",
"display_name": "Short-Answer",
"description": "Short Answer Problem powered by Freshcup",
"submission_channel_name": "freshcup-submission",
"self_test_channel_name": "freshcup-self-test",
"judge": "freshcup"
}
```

## 代码结构

``` plaintext
.
├── Dockerfile
├── Makefile
├── cmd
│   └── freshcup
│   ├── main.go
│   ├── wire.go
│   └── wire_gen.go
└── internal
├── biz
│   ├── biz.go
│   ├── submission.go
├── conf
│   ├── conf.pb.go
│   └── conf.proto
├── data
│   ├── data.go
│   └── submission.go
├── server
│   ├── server.go
│   └── submission.go
└── service
   ├── service.go
   └── submission.go
```

## 评测流程

1. 监听消息队列,接收提交消息。
2. 从消息中提取提交信息,包括提交 ID、题目 ID、提交内容等。
3. 通过题目 ID 获取题目信息,包括题目的测试数据。
4. 根据题目类型(单选、多选、填空)不同,决定立即评分还是等待手动评分。
5. 若题目为选择题,根据答案对提交进行评分。
6. 将评分结果持久化到数据库中,并同步缓存至 Redis 中。
7. 结束评测。

## 元数据

题目元数据包括题目选项等信息

以下是选择题的元数据示例:

```json
{
"options": {
"A": "选项A",
"B": "选项B",
"C": "选项C",
"D": "选项D",
......
// 更多选项
},
"size": "4"
// 选项数量
}
```
27 changes: 25 additions & 2 deletions docs/dev-guide/backend/judge-mid/gojudge-mid.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,30 @@

sastoj 通过 Go-judge 中间件提供了对 [`Go-judge`](https://github.com/criyle/go-judge) 评测机的支持。

Go-judge 中间件是搭建了 sastoj 和 Go-judge 服务直接的桥梁,将 sastoj 的提交和自测发送到 Go-judge 服务,通过分析 Go-judge 的回传对提交进行评分,并持久化数据。
Go-judge 中间件是搭建了 sastoj 和 Go-judge 服务直接的桥梁,将 sastoj 的提交和自测发送到 Go-judge 服务,通过分析 Go-judge
的回传对提交进行评分,并持久化数据。

## 题目类型

该评测机支持的题目类型为编程题。对应的题目类型信息如下:

``` json
// 编程题
{
// 题目类型的简化名称
"slug_name": "gojudge-classic-algo",
// 显示名
"display_name": "Classic-Algo",
// 题目类型描述
"description": "Classic Algo Problem powered by Gojudge",
// 在消息队列中的提交通道名称
"submission_channel_name": "gojudge-submission",
// 在消息队列中的自测通道名称
"self_test_channel_name": "gojudge-self-test",
// 评测机名称
"judge": "gojudge"
}
```

## 代码结构

Expand Down Expand Up @@ -115,7 +138,7 @@ message ExecConfig{
1. 监听消息队列,接收提交消息。
2. 从消息中提取提交信息,包括提交 ID、题目 ID、语言、代码等。
3. 通过题目 ID 获取题目信息,包括题目的测试数据。
4. 根据题目类型(simple, subtasks)不同,调用不同的评测函数。
4. 根据评测类型(simple, subtasks)不同,调用不同的评测函数。
5. 从配置文件中获取对应语言的编译、运行、源文件、目标文件等信息。
6. 编译代码,运行代码,获取运行结果。
7. 根据运行结果,对提交进行评分。
Expand Down
11 changes: 10 additions & 1 deletion docs/user-guide/admin-console/judge/config.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

在sastoj上传题目时,配置文件的命名应为 `config.toml`,并放置在题目的根目录下。

以下是一份传统题、简易任务类型的配置文件示例:
以下是一份编程题、传统评测类型、简易任务类型的配置文件示例:

```toml
# 题目总分
Expand Down Expand Up @@ -39,6 +39,15 @@ answer = "2.ans"
score = 60
```

以下是选择题或主观题的配置文件示例:

```toml
# 参考答案
ReferenceAnswer = "A"
# 多选题未完全正确的得分(总分为100)
PartialScore = 50
```

字段含义将在下文进行解释。

## 评测类型 (`judgeType`)
Expand Down

0 comments on commit 5c10be1

Please sign in to comment.