-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
✨ Enable to show and update submission statuses in detail page of workbook (#779)
- Loading branch information
Showing
7 changed files
with
174 additions
and
55 deletions.
There are no files selected for viewing
This file contains 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,31 @@ | ||
import { fail } from '@sveltejs/kit'; | ||
|
||
import * as crud from '$lib/services/task_results'; | ||
import { BAD_REQUEST, UNAUTHORIZED } from '$lib/constants/http-response-status-codes'; | ||
|
||
// HACK: clickを1回実行するとactionsが2回実行されてしまう。原因と修正方法が分かっていない状態。 | ||
export const updateTaskResult = async ( | ||
{ request, locals }: { request: Request; locals: App.Locals }, | ||
operationLog: string, | ||
) => { | ||
console.log(operationLog); | ||
const response = await request.formData(); | ||
const session = await locals.auth.validate(); | ||
|
||
if (!session || !session.user || !session.user.userId) { | ||
return fail(UNAUTHORIZED, { | ||
message: 'ログインしていないか、もしくは、ログイン情報が不正です。', | ||
}); | ||
} | ||
|
||
const userId = session.user.userId; | ||
|
||
try { | ||
const taskId = response.get('taskId') as string; | ||
const submissionStatus = response.get('submissionStatus') as string; | ||
|
||
await crud.updateTaskResult(taskId, submissionStatus, userId); | ||
} catch (error) { | ||
return fail(BAD_REQUEST); | ||
} | ||
}; |
28 changes: 28 additions & 0 deletions
28
src/lib/components/SubmissionStatus/SubmissionStatusImage.svelte
This file contains 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,28 @@ | ||
<script lang="ts"> | ||
import { Img } from 'flowbite-svelte'; | ||
// @ts-ignore | ||
import ChevronDownOutline from 'flowbite-svelte-icons/ChevronDownOutline.svelte'; | ||
import type { TaskResult } from '$lib/types/task'; | ||
export let taskResult: TaskResult; | ||
export let isLoggedIn: boolean; | ||
let imagePath = ''; | ||
let imageAlt = ''; | ||
$: if (taskResult) { | ||
imagePath = `../../${taskResult.submission_status_image_path}`; | ||
imageAlt = taskResult.submission_status_label_name; | ||
} | ||
</script> | ||
|
||
<Img src={imagePath} alt={imageAlt} class="h-8 w-8" /> | ||
{#if isLoggedIn} | ||
<div class="flex flex-col items-center ml-2 md:ml-4 text-xs"> | ||
<div class="mb-1"> | ||
{'更新'} | ||
</div> | ||
<ChevronDownOutline class="w-3 h-3 text-primary-600 dark:text-white inline" /> | ||
</div> | ||
{/if} |
This file contains 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 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 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 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 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