Skip to content

Commit

Permalink
Feat/daily questions (#32)
Browse files Browse the repository at this point in the history
* edit daily questions cleaner

* edit daily questions cleaner change ctx

* add admin flow daily questions

* update docs

* update docs add requests fo dq admin

* update docs add requests fo dq admin 2

* update docs add requests fo dq admin 3

* update docs add admin route for dq

* DQ admin fix

* changed the deadline for editing and fixed daily_questin_select

* return auth

* fix bugs with edit question add validate func for options

* return auth

* fix router

* add location to DQ admin fix bug with uneditable starts_at

* before megre main

* megre to origin main

* clean DQ

* add go.sum go.buil

* fix resp err add return

* handle error daily_question_edit

* handle error daily_question_create

* Fix options unmarshaling

* fix req

* fix fix req

* change requests

* validate type for req in DQ

* fix the bug with -reward, add description for bad request

* fix misspell

---------

Co-authored-by: Zaptoss <[email protected]>
  • Loading branch information
kish1n and Zaptoss authored Aug 29, 2024
1 parent 09fa079 commit 4617d21
Show file tree
Hide file tree
Showing 30 changed files with 1,377 additions and 17 deletions.
55 changes: 55 additions & 0 deletions docs/spec/components/schemas/DailyQuestionCreate.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
allOf:
- $ref: "#/components/schemas/DailyQuestionEditKey"
- type: object
required:
- attributes
properties:
attributes:
type: object
required:
- title
- reward
- options
- correct_answer
- time_for_answer
- starts_at
properties:
title:
type: string
description: Question title
example: Georgian capital
reward:
type: integer
format: int64
description: Reward for a correct answer
options:
type: array
description: Answer options. Minimum 2, maximum 6
items:
$ref: "#/components/schemas/DailyQuestionOptions"
example: [
{
"id": 0,
"title": ""
},
{
"id": 1,
"title": ""
},
{
"id": 2,
"title": ""
}
]
correct_answer:
type: integer
format: int64
description: Correct answer ID
time_for_answer:
type: integer
format: int64
description: Time for answer
starts_at:
type: string
description: Start date when this question is available, hours and minutes are always 0
example: "2024-08-23"
11 changes: 11 additions & 0 deletions docs/spec/components/schemas/DailyQuestionCreateKey.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
type: object
required:
- id
- type
properties:
id:
type: string
description: Question id
type:
type: string
enum: [ daily_questions ]
15 changes: 15 additions & 0 deletions docs/spec/components/schemas/DailyQuestionDel.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
allOf:
- $ref: "#/components/schemas/DailyQuestionDelKey"
- type: object
required:
- attributes
properties:
attributes:
type: object
required:
- title
properties:
title:
type: string
description: Question title
example: Georgian capital
11 changes: 11 additions & 0 deletions docs/spec/components/schemas/DailyQuestionDelKey.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
type: object
required:
- id
- type
properties:
id:
type: string
description: Question id
type:
type: string
enum: [ daily_questions ]
77 changes: 77 additions & 0 deletions docs/spec/components/schemas/DailyQuestionDetails.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
allOf:
- $ref: "#/components/schemas/DailyQuestionDetailsKey"
- type: object
required:
- attributes
properties:
attributes:
type: object
required:
- title
- reward
- options
- correct_answer
- time_for_answer
- starts_at
- created_at
- num_correct_answers
- num_incorrect_answers
- num_all_participants
properties:
title:
type: string
description: Question title
example: Georgian capital
reward:
type: integer
format: int64
description: Reward for a correct answer
options:
type: array
description: Answer options. Minimum 2, maximum 6
items:
$ref: "#/components/schemas/DailyQuestionOptions"
example: [
{
"id": 0,
"title": ""
},
{
"id": 1,
"title": ""
},
{
"id": 2,
"title": ""
}
]
correct_answer:
type: integer
format: int64
description: Correct answer ID
time_for_answer:
type: integer
format: int64
description: Time for answer
starts_at:
type: string
description: Start date when this question is available, hours and minutes are always 0
example: "2024-08-26T00:00:00Z"
created_at:
type: string
description: Start date when this question was create
example: "2024-08-26T00:00:00Z"
num_correct_answers:
type: integer
format: int64
description: Number of correct answers
num_incorrect_answers:
type: integer
format: int64
description: Number of incorrect answers
num_all_participants:
type: integer
format: int64
description: |
Users who received the question, those who answered and
those who did not answer in the time given to them
11 changes: 11 additions & 0 deletions docs/spec/components/schemas/DailyQuestionDetailsKey.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
type: object
required:
- id
- type
properties:
id:
type: string
description: Question id
type:
type: string
enum: [ daily_questions ]
48 changes: 48 additions & 0 deletions docs/spec/components/schemas/DailyQuestionEdit.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
allOf:
- $ref: "#/components/schemas/DailyQuestionEditKey"
- type: object
required:
- attributes
properties:
attributes:
type: object
properties:
title:
type: string
description: Question title
example: Georgian capital
reward:
type: integer
format: int64
description: Reward for a correct answer
options:
type: array
description: Answer options. Minimum 2, maximum 6
items:
$ref: "#/components/schemas/DailyQuestionOptions"
example: [
{
"id": 0,
"title": ""
},
{
"id": 1,
"title": ""
},
{
"id": 2,
"title": ""
}
]
correct_answer:
type: integer
format: int64
description: Correct answer ID
time_for_answer:
type: integer
format: int64
description: Time for answer
starts_at:
type: string
description: Start date when this question is available, hours and minutes are always 0
example: "2024-08-23"
11 changes: 11 additions & 0 deletions docs/spec/components/schemas/DailyQuestionEditKey.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
type: object
required:
- id
- type
properties:
id:
type: string
description: Question id
type:
type: string
enum: [ daily_questions ]
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
post:
tags:
- Daily Questions
summary: Create daily question
description: |
Create Daily Question user must be superuser
operationId: createDailyQuestion
security:
- BearerAuth: []
requestBody:
content:
application/vnd.api+json:
schema:
type: object
required:
- data
properties:
data:
$ref: '#/components/schemas/DailyQuestionCreate'
responses:
200:
description: Success
content:
application/vnd.api+json:
schema:
type: object
required:
- data
properties:
data:
$ref: '#/components/schemas/DailyQuestionDetails'
400:
$ref: '#/components/responses/invalidParameter'
401:
$ref: '#/components/responses/invalidAuth'
409:
description: On this day, the daily question already exists
content:
application/vnd.api+json:
schema:
$ref: '#/components/schemas/Errors'
500:
$ref: '#/components/responses/internalError'

get:
tags:
- Daily Questions
summary: Filter Daily Question by start
description: |
Filtering of daily questions by their activation time
operationId: filterStartAtDailyQuestion
security:
- BearerAuth: []
responses:
200:
description: Success
content:
application/vnd.api+json:
schema:
type: object
required:
- data
properties:
data:
type: array
items:
$ref: '#/components/schemas/DailyQuestionDetails'
500:
$ref: '#/components/responses/internalError'
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
delete:
tags:
- Daily Questions
summary: Delete daily question
description: |
Delete Daily Question user must be superuser
operationId: deleteDailyQuestion
security:
- BearerAuth: []
responses:
200:
description: Success
content:
application/vnd.api+json:
schema:
type: object
required:
- data
properties:
data:
$ref: '#/components/schemas/DailyQuestionDetails'
204:
description: No content
400:
$ref: '#/components/responses/invalidParameter'
404:
description: Question with ID not found
content:
application/vnd.api+json:
schema:
$ref: '#/components/schemas/Errors'
500:
$ref: '#/components/responses/internalError'

patch:
tags:
- Daily Questions
summary: Edit daily question
description: |
Edit Daily Question user must be superuser
operationId: editDailyQuestion
security:
- BearerAuth: []
requestBody:
content:
application/vnd.api+json:
schema:
type: object
required:
- data
properties:
data:
$ref: '#/components/schemas/DailyQuestionEdit'
responses:
204:
description: No content
200:
description: Success
content:
application/vnd.api+json:
schema:
type: object
required:
- data
properties:
data:
$ref: '#/components/schemas/DailyQuestionDetails'
400:
$ref: '#/components/responses/invalidParameter'
409:
description: On this day, the daily question already exists
content:
application/vnd.api+json:
schema:
$ref: '#/components/schemas/Errors'
500:
$ref: '#/components/responses/internalError'
Loading

0 comments on commit 4617d21

Please sign in to comment.