Skip to content

Contest

Siyuan Zhang | 张豆 edited this page Oct 11, 2019 · 1 revision

Get All Contests

HTTP Request

GET /api/v1/contests

URL Parameters

Parameter Default Description
page 0
size 10

Query Parameters

Parameter Default Description
name null fuzzy query
type null PUBLIC / SECRET_WITH_PASSWORD / SECRET_WITHOUT_PASSWORD
status null NOT_STARTED / PROCESSING / ENDED

Example

GET /api/v1/contests?page=0&size=2&name=testContest1

Response

{
    "currentPage": 0,
    "currentSize": 1,
    "total": 1,
    "list": [
        {
            "id": 558,
            "authorId": 20,
            "authorName": "kastnerorz",
            "password": null,
            "name": "testContestSecretWithoutPassword",
            "description": "testDescriptionSecretWithoutPassword",
            "contestType": "SECRET_WITHOUT_PASSWORD",
            "status": "NOT_STARTED",
            "judgeType": "IMMEDIATELY",
            "startDate": "2018-10-05 21:00:00",
            "endDate": "2018-10-06 02:00:00",
            "createDate": "2018-10-07 19:01:43",
            "enable": false,
            "visible": false
        }
    ]
}

Get a Specific Contest

HTTP Request

GET /api/v1/contests/:id

Response

{
    "id": 558,
    "authorId": 20,
    "authorName": "kastnerorz",
    "password": null,
    "name": "testContestSecretWithoutPassword",
    "description": "testDescriptionSecretWithoutPassword",
    "contestType": "SECRET_WITHOUT_PASSWORD",
    "status": "NOT_STARTED",
    "judgeType": "IMMEDIATELY",
    "startDate": "2018-10-05 21:00:00",
    "endDate": "2018-10-06 02:00:00",
    "createDate": "2018-10-07 19:01:43",
    "enable": false,
    "visible": false
	
}

Create a Contest

HTTP Request

POST /api/v1/contests

Request Parameters

The parameter which default is "null" must be provided

Parameter Default Description
authorId
name Unique
description
contestType PUBLIC PUBLIC / SECRET_WITH_PASSWORD / SECRET_WITHOUT_PASSWORD
password null Only SECRET_WITH_PASSWORD has password
judgeType IMMEDIATELY IMMEDIATELY(提交即判题) / DELAY(考试结束后判题)
enable false 是否开启
visible false 非管理员是否可见
startDate format: "YYYY-MM-DD hh:mm:ss"
endDate format: "YYYY-MM-DD hh:mm:ss"

Response

It will return the contest just created.

{
    "id": 558,
    "authorId": 20,
    "authorName": "kastnerorz",
    "password": null,
    "name": "testContestSecretWithoutPassword",
    "description": "testDescriptionSecretWithoutPassword",
    "contestType": "SECRET_WITHOUT_PASSWORD",
    "status": "NOT_STARTED",
    "judgeType": "IMMEDIATELY",
    "startDate": "2018-10-05 21:00:00",
    "endDate": "2018-10-06 02:00:00",
    "createDate": "2018-10-07 19:01:43",
    "enable": false,
    "visible": false
	
}

Update a Specific Contest

HTTP Request

PUT /api/v1/contests/:id

Request Parameters

The parameter which default is "null" must be provided

Parameter Default Description
authorId
name Unique
description
contestType PUBLIC PUBLIC / SECRET_WITH_PASSWORD / SECRET_WITHOUT_PASSWORD
password null Only SECRET_WITH_PASSWORD has password
judgeType IMMEDIATELY IMMEDIATELY(提交即判题) / DELAY(考试结束后判题)
enable false 是否开启
visible false 非管理员是否可见
startDate format: "YYYY-MM-DD hh:mm:ss"
endDate format: "YYYY-MM-DD hh:mm:ss"

Response

It will return the contest just updated.

{
    "id": 558,
    "authorId": 20,
    "authorName": "kastnerorz",
    "password": null,
    "name": "testContestSecretWithoutPassword",
    "description": "testDescriptionSecretWithoutPassword",
    "contestType": "SECRET_WITHOUT_PASSWORD",
    "status": "NOT_STARTED",
    "judgeType": "IMMEDIATELY",
    "startDate": "2018-10-05 21:00:00",
    "endDate": "2018-10-06 02:00:00",
    "createDate": "2018-10-07 19:01:43",
    "enable": false,
    "visible": false
	
}

Part Update a Specific Contest

HTTP Request

PATCH /api/v1/contests/:id

URL Parameters

Parameter Default Description
visible null true / false

Response

{
    "id": 558,
    "authorId": 20,
    "authorName": "kastnerorz",
    "password": null,
    "name": "testContestSecretWithoutPassword",
    "description": "testDescriptionSecretWithoutPassword",
    "contestType": "SECRET_WITHOUT_PASSWORD",
    "status": "NOT_STARTED",
    "judgeType": "IMMEDIATELY",
    "startDate": "2018-10-05 21:00:00",
    "endDate": "2018-10-06 02:00:00",
    "createDate": "2018-10-07 19:01:43",
    "enable": false,
    "visible": false
	
}

Delete a Specific Contest

HTTP Request

DELETE /api/v1/contests/:id

Response

{
    "id": 558,
    "authorId": 20,
    "authorName": "kastnerorz",
    "password": null,
    "name": "testContestSecretWithoutPassword",
    "description": "testDescriptionSecretWithoutPassword",
    "contestType": "SECRET_WITHOUT_PASSWORD",
    "status": "NOT_STARTED",
    "judgeType": "IMMEDIATELY",
    "startDate": "2018-10-05 21:00:00",
    "endDate": "2018-10-06 02:00:00",
    "createDate": "2018-10-07 19:01:43",
    "enable": false,
    "visible": false
	
}

Get All Users from a Specific Contest

HTTP Request

GET /api/v1/contests/:id/users

Response

[
    {
        "id": 97,
        "username": "shu-test",
        "firstname": null,
        "lastname": null,
        "email": "[email protected]",
        "school": "上海大学",
        "signature": null,
        "acCount": 0,
        "submitCount": 0,
        "acRate": 0,
        "enabled": true,
        "authorities": [
            {
                "authority": "ROLE_USER"
            }
        ]
    }
]

Add Users to Contest

ADMIN Required

HTTP Request

POST /api/v1/contests/:id/users

Request Parameters

The parameter which default is "null" must be provided

Parameter Default Description
userIds

Example

Request Body:

[47,50]

Response

It will return all users after added.

[
    {
        "id": 97,
        "username": "shu-test",
        "firstname": null,
        "lastname": null,
        "email": "[email protected]",
        "school": "上海大学",
        "signature": null,
        "acCount": 0,
        "submitCount": 0,
        "acRate": 0,
        "enabled": true,
        "authorities": [
            {
                "authority": "ROLE_USER"
            }
        ]
    }
]

Add Users To Contest By Group

HTTP Request

POST /api/v1/contests/:id/groups

Request Parameters

The parameter which default is "null" must be provided

Parameter Default Description
groupIds

Response

It will response the users in that group just added (It won't add duplicate users).

⚠️ The list returned is empty means the contest already has all of the users in selected group.

⚠️ Users added via groups can only delete manually.

[
    {
        "id": 91,
        "username": "iris",
        "firstname": null,
        "lastname": null,
        "email": "[email protected]",
        "school": "上海大学",
        "signature": null,
        "acCount": 4,
        "submitCount": 4,
        "acRate": 0,
        "enabled": true,
        "authorities": [
            {
                "authority": "ROLE_USER"
            }
        ]
    },
    {
        "id": 20,
        "username": "kastnerorz",
        "firstname": null,
        "lastname": null,
        "email": "[email protected]",
        "school": "上海大学",
        "signature": null,
        "acCount": 111,
        "submitCount": 5,
        "acRate": 0,
        "enabled": true,
        "authorities": [
            {
                "authority": "ROLE_ADMIN"
            }
        ]
    },
    {
        "id": 97,
        "username": "shu-test",
        "firstname": null,
        "lastname": null,
        "email": "[email protected]",
        "school": "上海大学",
        "signature": null,
        "acCount": 2,
        "submitCount": 2,
        "acRate": 0,
        "enabled": true,
        "authorities": [
            {
                "authority": "ROLE_ADMIN"
            }
        ]
    }
]

Delete Users in a Specific Contest

HTTP Request

DELETE /api/v1/contests/:id/users

Request Parameters

The parameter which default is "null" must be provided

Parameter Default Description
userIds

Response

It will return the users in contest after deleted.

[
    {
        "id": 97,
        "username": "shu-test",
        "firstname": null,
        "lastname": null,
        "email": "[email protected]",
        "school": "上海大学",
        "signature": null,
        "acCount": 0,
        "submitCount": 0,
        "acRate": 0,
        "enabled": true,
        "authorities": [
            {
                "authority": "ROLE_USER"
            }
        ]
    }
]

Get All Problems from a Specific Contest

HTTP Request

GET /api/v1/contests/:id/problems

Response

[
    {
        "id": 82,
        "authorId": 20,
        "authorName": "kastnerorz",
        "name": "testContest1",
        "description": "testDescription",
        "contestType": "PUBLIC",
        "judgeType": "IMMEDIATELY",
        "startDate": "2018-08-27 06:42:00",
        "endDate": "2018-08-28 06:42:00",
        "createDate": "2018-08-27 22:37:46"
    }
]

Add Problems to Contest

HTTP Request

POST /api/v1/contests/:id/problems

Request Parameters

The parameter which default is "null" must be provided

Parameter Default Description
problemId An array containing the problemIds

Example

Request Body:

[47,50]

Response

It will return the problems just added.


Delete Problems in Contest

HTTP Request

DELETE /api/v1/contests/:id/problems

Request Parameters

The parameter which default is "null" must be provided

Parameter Default Description
problemId An array containing the problemIds

Example

Request Body:

[47,50]

Response

It will return the problems which contest has after delete the problems.


Set Status of a Specific Contest

HTTP Request

PATCH /api/v1/contests/:id/status

URL Parameters

Parameter Default Description
option null ENABLE / DISABLE / RESET

Response

{
    "id": 780,
    "authorId": 20,
    "authorName": "kastnerorz",
    "password": null,
    "name": "withpassword",
    "description": "<p>dddd</p>",
    "contestType": "SECRET_WITH_PASSWORD",
    "status": "PROCESSING",
    "judgeType": "IMMEDIATELY",
    "startDate": "2018-10-13 00:00:00",
    "endDate": "2018-10-14 00:00:00",
    "createDate": "2018-10-13 13:05:43",
    "enable": true,
    "visible": true
}

Join a Specific Contest

HTTP Request

POST /api/v1/contests/:id/join

URL Parameters

Parameter Default Description
password password

Response

{
    "code": 200,
    "message": "加入成功",
    "data": true
}

Get Contest Ranking

HTTP Request

GET /api/v1/contests/:id/ranking

Response

{
    "id": 609,
    "contestId": 608,
    "contestName": "testContestPublic",
    "rankingUserList": [
        {
            "id": 682,
            "userId": 91,
            "userName": "iris",
            "acceptCount": 0,
            "submitCount": 0,
            "totalTime": {
                "id": 681,
                "contestId": null,
                "problemId": null,
                "totalTime": 0,
                "errorCount": 0,
                "userId": null,
                "userName": null,
                "submitted": false,
                "passed": false,
                "firstPassed": false
            },
            "timeList": [
                {
                    "id": 684,
                    "contestId": 608,
                    "problemId": 53,
                    "totalTime": 0,
                    "errorCount": 0,
                    "userId": 91,
                    "userName": "iris",
                    "submitted": false,
                    "passed": false,
                    "firstPassed": false
                },
                {
                    "id": 683,
                    "contestId": 608,
                    "problemId": 50,
                    "totalTime": 0,
                    "errorCount": 0,
                    "userId": 91,
                    "userName": "iris",
                    "submitted": false,
                    "passed": false,
                    "firstPassed": false
                }
            ],
            "ranked": true,
            "rank": null
        },
        {
            "id": 678,
            "userId": 20,
            "userName": "kastnerorz",
            "acceptCount": 0,
            "submitCount": 0,
            "totalTime": {
                "id": 677,
                "contestId": null,
                "problemId": null,
                "totalTime": 0,
                "errorCount": 0,
                "userId": null,
                "userName": null,
                "submitted": false,
                "passed": false,
                "firstPassed": false
            },
            "timeList": [
                {
                    "id": 680,
                    "contestId": 608,
                    "problemId": 53,
                    "totalTime": 0,
                    "errorCount": 0,
                    "userId": 20,
                    "userName": "kastnerorz",
                    "submitted": false,
                    "passed": false,
                    "firstPassed": false
                },
                {
                    "id": 679,
                    "contestId": 608,
                    "problemId": 50,
                    "totalTime": 0,
                    "errorCount": 0,
                    "userId": 20,
                    "userName": "kastnerorz",
                    "submitted": false,
                    "passed": false,
                    "firstPassed": false
                }
            ],
            "ranked": true,
            "rank": null
        }
    ]
}
Clone this wiki locally