Browse Source

[新增]考试系统api

soleil 7 years ago
parent
commit
aa263dedec

+ 10 - 0
exam/README.md

@@ -0,0 +1,10 @@
+### 负责人
+
+- 【后端】张怡
+- 【前端】周玮璐
+
+### 修改记录
+
+| 修改人 | 修改内容             | 修改时间   |
+| ------ | -------------------- | ---------- |
+| 周玮璐 | 初始化 api           | 2018/12/22 |

+ 24 - 0
exam/api/Commit-提交记录.md

@@ -0,0 +1,24 @@
+# Commit - 提交记录
+
+> url 前缀:**commit**
+>
+> 示例:**https://xxxxxxxxx/api/commit/xxxx**
+
+## 查看考试提交记录
+
+```http
+get /commit/{commitId:\d+}
+```
+
+### PathVariable
+
+- commitId: **number**,考试提交记录编号
+
+### Response
+
+```json
+{
+  "res": CommitSerializer,
+}
+```
+see [CommitSerializer](./CommitSerializer.md)

+ 124 - 0
exam/api/Exam-考试.md

@@ -0,0 +1,124 @@
+# Exam - 题目
+
+> url 前缀:**exam**
+>
+> 示例:**https://xxxxxxxxx/api/exam/xxxx**
+
+## 创建考试
+
+[TEACHER]
+
+```http
+post /exam
+```
+
+### Parameters
+
+```json
+{
+  "name": string,
+  "startAt": timestamp,
+  "endAt": timestamp,
+  "problem": Array<ProblemSerializer>,
+}
+```
+
+see [ProblemSerializer](../../problem/serializer/ProblemSerializer.md)
+
+### Response
+
+```json
+{
+  "res": ExamSerializer,
+}
+```
+see [ExamSerializer](../serializer/ExamSerializer.md)
+
+
+## 查询某状态下考试
+
+```http
+get /exam
+```
+
+### Parameters
+
+| Name     | Type   | Description      |
+| -------- | ------ | ---------------- |
+| status | string | 考试状态 |
+| page | number | 当前页数 |
+| limit | number | 考试状态 |
+
+
+### Response
+
+```json
+{
+  "res": Array<ExamSerializer>,
+}
+```
+
+see [ExamSerializer](../serializer/ExamSerializer.md)
+
+## 查询单个考试
+
+```http
+get /exam/{examId:\d+}
+```
+
+### PathVariable
+
+- examId: **number**,考试编号
+
+### Response
+
+```json
+{
+  "res": ExamSerializer,
+}
+```
+
+see [ExamSerializer](../serializer/ExamSerializer.md)
+
+## 更新考试信息
+
+[TEACHER]
+
+```http
+put /exam/{examId:\d+}
+```
+
+### Parameters
+
+```json
+{
+  "name": string,
+  "startAt": timestamp,
+  "endAt": timestamp,
+  "problems": Array<ProblemSerializer>,
+}
+```
+
+see [ProblemSerializer](../../problem/serializer/ProblemSerializer.md)
+
+## 删除考试
+
+[TEACHER]
+
+```http
+delete /exam/{examId:\d+}
+```
+
+### PathVariable
+
+- examId: **number**,考试编号
+
+## 参加考试
+
+```http
+post /exam/{examId:\d+}/join
+```
+
+### PathVariable
+
+- examId: **number**,考试编号

+ 24 - 0
exam/api/Record-运行记录.md

@@ -0,0 +1,24 @@
+# Record - 提交记录
+
+> url 前缀:**record**
+>
+> 示例:**https://xxxxxxxxx/api/record/xxxx**
+
+## 查看考试提交记录中某个题目的运行情况
+
+```http
+get /record/{recordId:\d+}
+```
+
+### PathVariable
+
+- recordId: **number**,提交记录中某题目的运行记录编号
+
+### Response
+
+```json
+{
+  "res": RecordSerializer,
+}
+```
+see [RecordSerializer](./RecordSerializer.md)

+ 108 - 0
exam/api/Result-考试结果.md

@@ -0,0 +1,108 @@
+# Result - 考试结果
+
+> url 前缀:**result**
+>
+> 示例:**https://xxxxxxxxx/api/result/xxxx**
+
+## 根据resultId查询考试结果
+
+```http
+get /result/{resultId:\d+}
+```
+
+### PathVariable
+
+- resultId: **number**,考试结果编号
+
+### Response
+
+```json
+{
+  "res": ResultSerializer,
+}
+```
+see [ResultSerializer](./ResultSerializer.md)
+
+
+## 根据用户查询考试结果
+
+```http
+get /result
+或 get /user/{userId:\d+}/result
+```
+
+### PathVariable
+
+- userId: **number**,用户编号
+
+### Response
+
+```json
+{
+  "res": Array<ResultSerializer>,
+}
+```
+see [ResultSerializer](./ResultSerializer.md)
+
+## 根据考试查询所有考试结果
+
+```http
+get /exam/{examId:\d+}/result
+```
+
+### PathVariable
+
+- examId: **number**,考试编号
+
+### Response
+
+```json
+{
+  "res": Array<ResultSerializer>,
+}
+```
+
+see [ResultSerializer](./ResultSerializer.md)
+
+## 更新考试信息
+
+[TEACHER]
+
+```http
+put /exam/{examId:\d+}
+```
+
+### Parameters
+
+```json
+{
+  "name": string,
+  "startAt": timestamp,
+  "endAt": timestamp,
+  "problems": Array<ProblemSerializer>,
+}
+```
+
+see [ProblemSerializer](../../problem/serializer/ProblemSerializer.md)
+
+## 删除考试
+
+[TEACHER]
+
+```http
+delete /exam/{examId:\d+}
+```
+
+### PathVariable
+
+- examId: **number**,考试编号
+
+## 参加考试
+
+```http
+post /exam/{examId:\d+}/join
+```
+
+### PathVariable
+
+- examId: **number**,考试编号

+ 15 - 0
exam/serializer/CommitSerializer.md

@@ -0,0 +1,15 @@
+# CommitSerializer
+
+考试提交记录基本信息
+
+## Attributes
+- id: **number** - 提交记录编号
+- hash: **String** -
+- finished: **boolean** - 是否运行结束
+- deleted: **boolean** - 考试是否删除
+- createdAt: **timestamp** - 提交时间
+- result: {
+  id: **number** - 编号
+  score: **number** - 成绩
+} - 结果
+- records: [**Array<RecordSerializer>**](./RecordSerializer.md) - 一次提交中各题的运行情况

+ 23 - 0
exam/serializer/ExamSerializer.md

@@ -0,0 +1,23 @@
+# ExamSerializer
+
+考试的基本信息
+
+## Attributes
+
+- examId: **number** - 考试编号
+- name:  **String** -  考试名称 | `{2-20}`
+- createdAt: *timestamp* - 创建时间
+- startAt: **timestamp** -  开始时间
+- endAt: **timestamp** -  结束时间
+- status: **enum** - 考试状态 | `{2-10}`
+- creator: [**UserSerializer**](../../User/serializer/UserSerializer.md) - 创建者
+- joined: *boolean* - 当前用户是否参加
+
+### ExamStatus
+
+- **PREPARING**:正在准备试题,
+- **UNAVAILABLE**:考试不可用,
+- **READY**:考试已准备好,在考试尚未开始时使用,
+- **AVAILABLE**:考试可用,表示考试正在进行,
+- **FINISHED**:考试已完成,
+- **CLOSED**:考试已关闭,

+ 21 - 0
exam/serializer/JoinedExamSerializer.md

@@ -0,0 +1,21 @@
+# JoinedExamSerializer
+
+参加考试后,即joined为true时,会返回JoinedExamSerializer
+对于学生来说,考试进行中,才会返回试卷地址(url)和试题(problems)
+
+## Attributes
+
+- examId: **number** - 编号
+- name:  **String** -  考试名称 | `{2-20}`
+- createdAt: *timestamp* - 创建时间
+- startAt: **timestamp** -  开始时间
+- endAt: **timestamp** -  结束时间
+- status: **enum** - 考试状态 | `{2-10}`
+- creator: [**UserSerializer**](../../User/serializer/UserSerializer.md) - 创建者
+- joined: *boolean* - 当前用户是否参加
+- url: **string** - 试卷地址
+- problems: [**Array<ProblemSerializer>**](../../problem/serializer/PProblemSerializer.md)
+- result: {
+  id:  编号
+  score: 分数
+} - 考试结果

+ 24 - 0
exam/serializer/RecordSerializer.md

@@ -0,0 +1,24 @@
+# RecordSerializer
+
+题目运行记录基本信息
+
+## Attributes
+- id: **number** - 题目运行记录编号
+- number: **number** - jenkins项目中的运行编号
+- status: **BuildStatus** - 构建状态
+- consoleOutput: **string** - 控制台输出
+- score: **number** - 题目该次运行的分数 | [0-100]
+- failures: {
+  name: **String** - 测试用例名 | [1-10]
+  details: **String** - 错误信息
+  trace: **String** - 错误栈
+} - 错误用例
+
+## BuildStatus
+
+- **SUCCESS**:构建成功
+- **UNSTABLE**:有测试用例错误
+- **FAILURE**:构建失败(有编译错误等)
+- **TIMEOUT**:构建超时
+- **WAITING**:等待构建
+- **RUNNING**:正在构建

+ 18 - 0
exam/serializer/ResultSerializer.md

@@ -0,0 +1,18 @@
+# ResultSerializer
+
+考试结果基本信息
+
+## Attributes
+- resultId: **number** - 考试结果编号
+- score: **number** - 考试成绩 | `[0-100]`
+- lastCommitAt: **timestamp** - 最后提交时间
+- deleted: **boolean** - 考试是否删除
+- exam: [**ExamSerializer**](./ExamSerializer.md) - 考试信息
+- owner: [**UserSerializer**](../../user/serializer/UserSerializer.md) - 拥有者
+- commits:
+{
+  id:编号
+  finished:是否运行结束
+  score:本次提交的成绩
+  createdAt:提交时间,timestamp
+} - 提交记录

+ 5 - 0
prefix.md

@@ -6,6 +6,7 @@
 | ------ | -------- | ---------- |
 | ------ | -------- | ---------- |
 | 吴新宇 | 创建     | 2018/12/18 |
 | 吴新宇 | 创建     | 2018/12/18 |
 | 周玮璐 | 新增题目前缀     | 2018/12/20 |
 | 周玮璐 | 新增题目前缀     | 2018/12/20 |
+| 周玮璐 | 新增考试&&考试结果&&考试提交记录&&运行记录前缀     | 2018/12/22 |
 
 
 ## 前缀列表
 ## 前缀列表
 
 
@@ -14,3 +15,7 @@
 - [auth](user/api/Auth-权限.md)
 - [auth](user/api/Auth-权限.md)
 - [user](user/api/User-用户.md)
 - [user](user/api/User-用户.md)
 - [problem](problem/api/Problem-题目.md)
 - [problem](problem/api/Problem-题目.md)
+- [exam](exam/api/Exam-考试.md)
+- [result](exam/api/Result-考试结果.md)
+- [commit](exam/api/Commit-提交记录.md)
+- [record](exam/api/Record-运行记录.md)