Skip to content

Commit 6f06bf7

Browse files
committed
✨ Add task index to contest name (#1145)
1 parent 6e2a89d commit 6f06bf7

File tree

6 files changed

+21
-9
lines changed

6 files changed

+21
-9
lines changed

src/lib/components/TaskForm.svelte

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
Button,
1212
} from 'flowbite-svelte';
1313
14+
import { addContestNameToTaskIndex } from '$lib/utils/contest';
1415
import { taskGradeValues, type Task } from '$lib/types/task';
1516
import { getTaskGradeLabel, removeTaskIndexFromTitle } from '$lib/utils/task';
1617
@@ -43,7 +44,7 @@
4344
<TableBodyRow>
4445
<TableBodyCell>出典</TableBodyCell>
4546
<TableBodyCell>
46-
{task.contest_id}
47+
{addContestNameToTaskIndex(task.contest_id, task.task_table_index)}
4748
</TableBodyCell>
4849
</TableBodyRow>
4950
<TableBodyRow>

src/lib/components/TaskList.svelte

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
import ExternalLinkWrapper from '$lib/components/ExternalLinkWrapper.svelte';
1919
import AcceptedCounter from '$lib/components/SubmissionStatus/AcceptedCounter.svelte';
2020
import { getBackgroundColorFrom } from '$lib/services/submission_status';
21-
import { getContestNameLabel } from '$lib/utils/contest';
21+
import { addContestNameToTaskIndex } from '$lib/utils/contest';
2222
import { toWhiteTextIfNeeds, taskUrl, removeTaskIndexFromTitle } from '$lib/utils/task';
2323
2424
export let grade: string;
@@ -92,7 +92,7 @@
9292
/>
9393
</TableBodyCell>
9494
<TableBodyCell class="pl-0 xs:text-lg text-gray-700 dark:text-gray-300">
95-
{getContestNameLabel(taskResult.contest_id)}
95+
{addContestNameToTaskIndex(taskResult.contest_id, taskResult.task_table_index)}
9696
</TableBodyCell>
9797
<TableBodyCell class="px-0">
9898
{#if isAdmin}

src/lib/components/TaskListSorted.svelte

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
1212
import type { TaskResults } from '$lib/types/task';
1313
14-
import { getContestNameLabel } from '$lib/utils/contest';
14+
import { addContestNameToTaskIndex } from '$lib/utils/contest';
1515
import { removeTaskIndexFromTitle } from '$lib/utils/task';
1616
1717
export let taskResults: TaskResults;
@@ -43,7 +43,7 @@
4343
</a>
4444
</TableBodyCell>
4545
<TableBodyCell>
46-
{getContestNameLabel(taskResult.contest_id)}
46+
{addContestNameToTaskIndex(taskResult.contest_id, taskResult.task_table_index)}
4747
</TableBodyCell>
4848
<TableBodyCell>{taskResult.updated_at.toLocaleString()}</TableBodyCell>
4949
</TableBodyRow>

src/lib/components/WorkBookTasks/WorkBookTasksTable.svelte

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
} from 'flowbite-svelte';
1111
1212
import ExternalLinkWrapper from '$lib/components/ExternalLinkWrapper.svelte';
13-
import { getContestNameLabel } from '$lib/utils/contest';
13+
import { addContestNameToTaskIndex } from '$lib/utils/contest';
1414
import { taskUrl, removeTaskIndexFromTitle } from '$lib/utils/task';
1515
1616
import type { WorkBookTaskBase, WorkBookTaskCreate, WorkBookTaskEdit } from '$lib/types/workbook';
@@ -128,7 +128,10 @@
128128

129129
<!-- 出典 -->
130130
<TableBodyCell class="xs:text-lg text-gray-700 dark:text-gray-300 truncate">
131-
{getContestNameLabel(task.contestId)}
131+
{addContestNameToTaskIndex(
132+
task.contestId,
133+
getTaskTableIndex(tasksMapByIds, task.taskId),
134+
)}
132135
</TableBodyCell>
133136

134137
<!-- 一言(コメント・ヒント) -->

src/lib/utils/contest.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,3 +132,9 @@ export const getContestNameLabel = (contest_id: string) => {
132132

133133
return contest_id.toUpperCase();
134134
};
135+
136+
export const addContestNameToTaskIndex = (contestId: string, taskTableIndex: string): string => {
137+
const contestName = getContestNameLabel(contestId);
138+
139+
return `${contestName} - ${taskTableIndex}`;
140+
};

src/routes/workbooks/[slug]/+page.svelte

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
import { getBackgroundColorFrom } from '$lib/services/submission_status';
2323
2424
import { taskUrl, removeTaskIndexFromTitle } from '$lib/utils/task';
25-
import { getContestNameLabel } from '$lib/utils/contest';
25+
import { addContestNameToTaskIndex } from '$lib/utils/contest';
2626
2727
import type { WorkBookTaskBase } from '$lib/types/workbook';
2828
import type { TaskResult, TaskGrade } from '$lib/types/task';
@@ -50,7 +50,9 @@
5050
5151
const getContestNameFrom = (taskId: string): string => {
5252
const contestId = getContestIdFrom(taskId);
53-
return getContestNameLabel(contestId);
53+
const taskTableIndex = getTaskTableIndex(taskId);
54+
55+
return addContestNameToTaskIndex(contestId, taskTableIndex);
5456
};
5557
5658
const getTaskName = (taskId: string): string => {

0 commit comments

Comments
 (0)