Skip to content

Update and add new routes to view submissions.#438

Merged
sukhman-sukh merged 8 commits intobl4ze/devfrom
submissions-route
Mar 21, 2026
Merged

Update and add new routes to view submissions.#438
sukhman-sukh merged 8 commits intobl4ze/devfrom
submissions-route

Conversation

@ayu-ch
Copy link
Copy Markdown

@ayu-ch ayu-ch commented Dec 13, 2025

Addition of new routes and features:

  • /api/info/submissions/challenge/:name -> Returns all submissions for a specific challenge. Admin sees all attempts including flags, whereas contestants just see the successful attempts without flag.

  • /api/info/submissions/user/:id -> Returns all submissions made by a specific user. Admin sees all attempts including flags, contestants see the successful ones without the flag.

  • Cheating field in the submissions which the admin can use to filter cheated submissions on the frontend.

@sukhman-sukh
Copy link
Copy Markdown
Collaborator

Thanks for the PR. But Why was this needed. Have a look at /api/challenges/{challenge_id}/attempts route. I think it is already solving some part of your need, rest you can write on same pattern.

@ayu-ch
Copy link
Copy Markdown
Author

ayu-ch commented Dec 29, 2025

Oh. I just checked, I mistook the tries, which made me think it is a user and challenge pair and that it only gets updated. I can just make use of the existing table then...

@sukhman-sukh
Copy link
Copy Markdown
Collaborator

Cool, ping me when done

@ayu-ch ayu-ch force-pushed the submissions-route branch 2 times, most recently from c334ab7 to 34dcdf0 Compare December 30, 2025 19:15
Comment thread api/info.go Outdated
SolvedAt: submission.CreatedAt,
Flag: submission.Flag,
Success: submission.Solved,
Cheating: submission.Cheating,
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are we showing to contestants that if this challenge is cheating or not?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it is strictly for admin

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ALSO, Why are we showing points? Isn't it same for all always ?

Comment thread api/info.go
Comment thread api/info.go
}

submissionResp := SubmissionResp{
UserId: submissionUser.ID,
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FIx cheating here. Points make sense here, so your choice to keep it or remove it.

Comment thread api/submit.go Outdated
CreatedAt: time.Now(),
UserID: user.ID,
ChallengeID: challenge.ID,
Solved: false,
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Solved is also true in case of cheating.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think you should do this here. See the end of this function. It contains a lot of other preq like updating dynamic points and staling cache, etc. So, the solved:true version should be at end only.

Comment thread core/database/challenges.go Outdated
Signed-off-by: ayu-ch <ayu.chandekar@gmail.com>
Signed-off-by: ayu-ch <ayu.chandekar@gmail.com>
…from admin to public

Signed-off-by: ayu-ch <ayu.chandekar@gmail.com>
Signed-off-by: ayu-ch <ayu.chandekar@gmail.com>
Comment thread api/info.go
Comment thread api/submit.go Outdated
@sukhman-sukh
Copy link
Copy Markdown
Collaborator

@ayu-ch please fix this.
Rest of the things looks good to me.

ayu-ch added 3 commits March 18, 2026 04:26
Signed-off-by: ayu-ch <ayu.chandekar@gmail.com>
Signed-off-by: ayu-ch <ayu.chandekar@gmail.com>
Signed-off-by: ayu-ch <ayu.chandekar@gmail.com>
@ayu-ch ayu-ch force-pushed the submissions-route branch from 786f425 to 3454799 Compare March 17, 2026 22:56
@ayu-ch
Copy link
Copy Markdown
Author

ayu-ch commented Mar 20, 2026

There's another issue that when a flag is submitted, solvedAt time of every submission made by the user is changed to the latest submission time.

Signed-off-by: ayu-ch <ayu.chandekar@gmail.com>
@sukhman-sukh
Copy link
Copy Markdown
Collaborator

There's another issue that when a flag is submitted, solvedAt time of every submission made by the user is changed to the latest submission time.

Why don't you just update the entry,
I don't think it will update solved_at by self.

@sukhman-sukh sukhman-sukh merged commit 0d62fe4 into bl4ze/dev Mar 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants