Skip to content

Commit

Permalink
✨ 为互评添加申诉功能
Browse files Browse the repository at this point in the history
  • Loading branch information
loheagn committed Mar 19, 2022
1 parent dfb4519 commit 01dca29
Show file tree
Hide file tree
Showing 8 changed files with 465 additions and 0 deletions.
166 changes: 166 additions & 0 deletions openapi/cloudapi_v2.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -646,6 +646,111 @@ paths:
name: expId
required: true
parameters: []
/peerAppeal:
post:
summary: 提起申诉
operationId: post-peerAppeal
responses:
'200':
description: OK
content:
application/json:
schema:
$ref: '#/components/schemas/PeerAppealResponse'
tags:
- 互评
description: 学生提起申诉
security:
- Authorization: []
requestBody:
content:
application/json:
schema:
$ref: '#/components/schemas/CreatePeerAppealRequest'
'/peerAppeal/{peerAppealId}':
parameters:
- schema:
type: integer
format: int32
name: peerAppealId
in: path
required: true
get:
summary: 查看一项互评申诉
tags:
- 互评
responses:
'200':
description: OK
content:
application/json:
schema:
$ref: '#/components/schemas/PeerAppealResponse'
operationId: get-peerAppeal-peerAppealId
security:
- Authorization: []
description: 查看一项互评申诉
delete:
summary: 删除一项互评申诉
operationId: delete-peerAppeal-peerAppealId
responses:
'200':
description: OK
security:
- Authorization: []
tags:
- 互评
description: 删除一项互评申诉(学生主动撤销)
patch:
summary: 修改互评申诉
operationId: patch-peerAppeal-peerAppealId
responses:
'200':
description: OK
content:
application/json:
schema:
$ref: '#/components/schemas/PeerAppealResponse'
tags:
- 互评
requestBody:
content:
application/json:
schema:
$ref: '#/components/schemas/PatchPeerAppealRequest'
description: 两种应用场景:学生修改申诉的内容;教师或助教处理申诉
security:
- Authorization: []
/peerAppeals:
get:
summary: 获取互评申诉列表
tags:
- 互评
responses:
'200':
description: OK
content:
application/json:
schema:
type: array
items:
$ref: '#/components/schemas/PeerAppealResponse'
operationId: get-peerAppeals
description: 获取互评申诉列表
security:
- Authorization: []
parameters:
- schema:
type: integer
format: int32
in: query
name: expId
required: true
- schema:
type: integer
in: query
name: studentId
description: 如果调用者为学生,那么即使设置了该字段,也会被忽略
components:
schemas:
AssignmentResponse:
Expand Down Expand Up @@ -1335,6 +1440,67 @@ components:
required:
- id
- peerInfoList
PeerAppealResponse:
title: PeerAppealResponse
type: object
properties:
id:
type: integer
format: int32
expId:
type: integer
format: int32
studentId:
type: string
content:
type: string
appealedAt:
type: integer
format: int64
processor:
$ref: '#/components/schemas/SimpleUser'
processContent:
type: string
processStatus:
type: integer
description: |-
0: 未处理
1: 批准
2: 驳回
format: int32
processedAt:
type: integer
format: int64
required:
- id
- expId
- studentId
- content
- appealedAt
- processStatus
CreatePeerAppealRequest:
title: CreatePeerAppealRequest
type: object
properties:
content:
type: string
expId:
type: integer
format: int32
required:
- content
- expId
PatchPeerAppealRequest:
title: PatchPeerAppealRequest
type: object
properties:
content:
type: string
processStatus:
type: integer
format: int32
processContent:
type: string
securitySchemes:
Authorization:
type: apiKey
Expand Down
12 changes: 12 additions & 0 deletions src/main/kotlin/cn/edu/buaa/scs/auth/User.kt
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@ fun User.authRead(entity: IEntity): Boolean {
FileType.ExperimentResource -> authRead(Experiment.id(entity.involvedId))
}

is PeerAppeal ->
entity.studentId == this.id
|| authWrite(Experiment.id(entity.expId))

else -> throw BadRequestException("unsupported auth entity: $entity")
}
}
Expand Down Expand Up @@ -68,6 +72,10 @@ fun User.authWrite(entity: IEntity): Boolean {
FileType.ExperimentResource -> authWrite(Experiment.id(entity.involvedId))
}

is PeerAppeal ->
entity.studentId == this.id
|| authWrite(Experiment.id(entity.expId))

else -> throw BadRequestException("unsupported auth entity: $entity")
}
}
Expand Down Expand Up @@ -105,6 +113,10 @@ fun User.authAdmin(entity: IEntity): Boolean {
FileType.ExperimentResource -> authWrite(Experiment.id(entity.involvedId))
}

is PeerAppeal ->
entity.studentId == this.id
|| authWrite(Experiment.id(entity.expId))

else -> throw BadRequestException("unsupported auth entity: $entity")
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/**
* cloudapi_v2
* buaa scs cloud api v2
*
* The version of the OpenAPI document: 2.0
* Contact: [email protected]
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/
package cn.edu.buaa.scs.controller.models


/**
*
* @param content
* @param expId
*/
data class CreatePeerAppealRequest(
val content: kotlin.String,
val expId: kotlin.Int
)

Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/**
* cloudapi_v2
* buaa scs cloud api v2
*
* The version of the OpenAPI document: 2.0
* Contact: [email protected]
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/
package cn.edu.buaa.scs.controller.models


/**
*
* @param content
* @param processStatus
* @param processContent
*/
data class PatchPeerAppealRequest(
val content: kotlin.String? = null,
val processStatus: kotlin.Int? = null,
val processContent: kotlin.String? = null
)

Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/**
* cloudapi_v2
* buaa scs cloud api v2
*
* The version of the OpenAPI document: 2.0
* Contact: [email protected]
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/
package cn.edu.buaa.scs.controller.models

import cn.edu.buaa.scs.controller.models.SimpleUser

/**
*
* @param id
* @param expId
* @param studentId
* @param content
* @param appealedAt
* @param processStatus 0: 未处理 1: 批准 2: 驳回
* @param processor
* @param processContent
* @param processedAt
*/
data class PeerAppealResponse(
val id: kotlin.Int,
val expId: kotlin.Int,
val studentId: kotlin.String,
val content: kotlin.String,
val appealedAt: kotlin.Long,
/* 0: 未处理 1: 批准 2: 驳回 */
val processStatus: kotlin.Int,
val processor: SimpleUser? = null,
val processContent: kotlin.String? = null,
val processedAt: kotlin.Long? = null
)

37 changes: 37 additions & 0 deletions src/main/kotlin/cn/edu/buaa/scs/model/PeerAppeal.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package cn.edu.buaa.scs.model

import org.ktorm.database.Database
import org.ktorm.entity.Entity
import org.ktorm.entity.sequenceOf
import org.ktorm.schema.*

interface PeerAppeal : Entity<PeerAppeal>, IEntity {
companion object : Entity.Factory<PeerAppeal>()

var id: Int
var expId: Int
var studentId: String
var content: String
var appealedAt: Long
var processorId: String?
var processorName: String?
var processContent: String?
var processStatus: Int
var processedAt: Long?
}

object PeerAppeals : Table<PeerAppeal>("peer_appeal") {
val id = int("id").primaryKey().bindTo { it.id }
val expId = int("exp_id").bindTo { it.expId }
val studentId = varchar("student_id").bindTo { it.studentId }
val content = text("content").bindTo { it.content }
val appealedAt = long("appealed_at").bindTo { it.appealedAt }
val processorId = varchar("processor_id").bindTo { it.processorId }
val processorName = varchar("processor_name").bindTo { it.processorName }
val processContent = text("process_content").bindTo { it.processContent }
val processStatus = int("process_status").bindTo { it.processStatus }
val processAt = long("processed_at").bindTo { it.processedAt }
}

val Database.peerAppeals
get() = this.sequenceOf(PeerAppeals)
Loading

0 comments on commit 01dca29

Please sign in to comment.