-
-
Notifications
You must be signed in to change notification settings - Fork 10
feat(admin): enable to search tasks and update grade in admin page #3689
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
b303985
feat(admin): rename vote_management to tasks/grade route
KATO-Hiro 426259a
docs(dev-notes): remove completed plan for tasks/grade migration
KATO-Hiro 4ebc530
fix(admin): improve accessibility on tasks/grade page
KATO-Hiro 091390c
Merge branch 'staging' of github.com:AtCoder-NoviSteps/AtCoderNoviSte…
KATO-Hiro 6554b62
refactor(problems): simplify tagIds nullish check
KATO-Hiro bcd2031
feat(admin): strip task index prefix from title in tasks/grade page
KATO-Hiro File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,141 @@ | ||
| <script lang="ts"> | ||
| import { enhance } from '$app/forms'; | ||
| import { resolve } from '$app/paths'; | ||
| import { | ||
| Table, | ||
| TableBody, | ||
| TableBodyCell, | ||
| TableBodyRow, | ||
| TableHead, | ||
| TableHeadCell, | ||
| Input, | ||
| } from 'flowbite-svelte'; | ||
|
|
||
| import HeadingOne from '$lib/components/HeadingOne.svelte'; | ||
| import GradeLabel from '$lib/components/GradeLabel.svelte'; | ||
| import RelativeEvaluationBadge from '$features/votes/components/RelativeEvaluationBadge.svelte'; | ||
|
|
||
| import { taskGradeValues, TaskGrade } from '$lib/types/task'; | ||
| import type { TaskWithVoteInfo } from '$features/votes/services/vote_statistics'; | ||
|
|
||
| import { addContestNameToTaskIndex } from '$lib/utils/contest'; | ||
| import { | ||
| getTaskGradeLabel, | ||
| compareByContestIdAndTaskId, | ||
| removeTaskIndexFromTitle, | ||
| } from '$lib/utils/task'; | ||
| import { filterTasksBySearch } from '$lib/utils/task_filter'; | ||
|
|
||
| const MAX_SEARCH_RESULTS = 20; | ||
|
|
||
| let { data } = $props(); | ||
|
|
||
| let search = $state(''); | ||
|
|
||
| const sortedTasks = $derived([...data.tasks].sort(compareByContestIdAndTaskId)); | ||
| const filteredTasks = $derived(filterTasksBySearch(sortedTasks, search, MAX_SEARCH_RESULTS)); | ||
| </script> | ||
|
|
||
| <div class="container mx-auto w-5/6"> | ||
| <HeadingOne title="グレード管理" /> | ||
|
|
||
| <div class="mb-4 max-w-md"> | ||
| <Input aria-label="Search tasks" placeholder="問題名・問題ID・出典で検索" bind:value={search} /> | ||
| </div> | ||
|
|
||
| <Table hoverable> | ||
| <TableHead> | ||
| <TableHeadCell scope="col">問題名</TableHeadCell> | ||
| <TableHeadCell scope="col">出典</TableHeadCell> | ||
| <TableHeadCell scope="col">グレード(admin)</TableHeadCell> | ||
| <TableHeadCell scope="col">グレード(ユーザ投票)</TableHeadCell> | ||
| </TableHead> | ||
| <TableBody class="divide-y"> | ||
| {#if search === ''} | ||
| <TableBodyRow> | ||
| <TableBodyCell colspan={4} class="text-center text-gray-500 dark:text-gray-400"> | ||
| 問題名・問題ID・出典を入力してください | ||
| </TableBodyCell> | ||
| </TableBodyRow> | ||
| {:else} | ||
| {#each filteredTasks as task (task.task_id)} | ||
| <TableBodyRow> | ||
| <!-- Task name --> | ||
| <TableBodyCell> | ||
| <a | ||
| href={resolve('/votes/[slug]', { slug: task.task_id })} | ||
| class="text-primary-600 dark:text-primary-400 hover:underline text-sm" | ||
| > | ||
| {removeTaskIndexFromTitle(task.title, task.task_table_index)} | ||
| </a> | ||
| </TableBodyCell> | ||
|
|
||
| <!-- Reference --> | ||
| <TableBodyCell class="text-sm"> | ||
| {addContestNameToTaskIndex(task.contest_id, task.task_table_index)} | ||
| </TableBodyCell> | ||
|
|
||
| <!-- Grade for admin --> | ||
| {@render adminGradeCell(task)} | ||
|
|
||
| <!-- Grade for user votes --> | ||
| <TableBodyCell> | ||
| {#if task.estimatedGrade} | ||
| <GradeLabel | ||
| taskGrade={task.estimatedGrade} | ||
| defaultPadding={0.25} | ||
| defaultWidth={6} | ||
| reducedWidth={6} | ||
| /> | ||
| {/if} | ||
| </TableBodyCell> | ||
| </TableBodyRow> | ||
| {:else} | ||
| <TableBodyRow> | ||
| <TableBodyCell colspan={4} class="text-center text-gray-500 dark:text-gray-400"> | ||
| 該当する問題が見つかりませんでした | ||
| </TableBodyCell> | ||
| </TableBodyRow> | ||
| {/each} | ||
| {/if} | ||
| </TableBody> | ||
| </Table> | ||
| </div> | ||
|
|
||
| {#snippet adminGradeCell(task: TaskWithVoteInfo)} | ||
| <TableBodyCell> | ||
| <div class="flex items-center gap-2"> | ||
| <form method="POST" action="?/setTaskGrade" use:enhance> | ||
| <input type="hidden" name="taskId" value={task.task_id} /> | ||
| <select | ||
| name="grade" | ||
| aria-label="Select grade for {task.title}" | ||
| onchange={(e) => (e.currentTarget as HTMLSelectElement).form?.requestSubmit()} | ||
| class="text-sm rounded-md border border-gray-300 dark:border-gray-600 bg-white dark:bg-gray-800 text-gray-700 dark:text-gray-300 px-2 py-1 focus:ring-primary-500 focus:border-primary-500 min-w-20" | ||
| > | ||
| {#each taskGradeValues as grade (grade)} | ||
| <option value={grade} selected={task.grade === grade}> | ||
| {grade === 'PENDING' ? '-' : getTaskGradeLabel(grade)} | ||
| </option> | ||
| {/each} | ||
| </select> | ||
| </form> | ||
|
|
||
| {#if task.grade !== TaskGrade.PENDING && task.estimatedGrade} | ||
| <div class="relative inline-block"> | ||
| <GradeLabel | ||
| taskGrade={task.grade} | ||
| defaultPadding={0.25} | ||
| defaultWidth={6} | ||
| reducedWidth={6} | ||
| /> | ||
| <RelativeEvaluationBadge | ||
| officialGrade={task.grade} | ||
| medianGrade={task.estimatedGrade} | ||
| badgeId="relative-eval-{task.task_id}" | ||
| /> | ||
| </div> | ||
| {/if} | ||
| </div> | ||
| </TableBodyCell> | ||
| {/snippet} |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.