-
Notifications
You must be signed in to change notification settings - Fork 0
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
* create button components * update favicon * clean up route files structure * create layouts * fix code style * add mobile version * make mobile version hidden by default * change logout button to text * fix button styles * remove 'mój' * fix linter errors * fix Admin tests * fix user tests * create guest layout * fix dashboard * fix profile title * fix user tests * move user crud to admin folder * refactor routes for admin/user CRUDs * fix status messages * Add user quiz seeder, ranking test, attribute for quiz submission that returns amount of points for user * Improve seeder * Remove unused imports * fix layouts * Add ranking controller * implement user dashboard * add mobile version * add non-content message * disable button while processing * add tests for quiz * move user submission check to model * remove extra semicolon * Add ranking resource * fix code style * changed status to be gender-neutral * fix tests * Modify policy for ranking Add ranking_published_at to quizzes table * Modify QuizPolicy - User can/cannot view ranking if he is/isn't in the ranking * Modify QuizPolicy - User can/cannot view ranking if he is/isn't in the ranking Modify tests * create quiz page * fix code style * preserve scroll * hide closed quizzes * remove extra semicolon * add time left * fix code style * add timer * fix timer * center close submission text * fix code style * Fix github warnings with linter * Fix route in verify email * Add action for publishing and unpublishing quiz * Add return type * Apply suggestions from code review Co-authored-by: Aleksandra Kozubal <104600942+AleksandraKozubal@users.noreply.github.com> * Remove not existing policy from AuthServiceProvider * fix code style * rename migration * Create action for publishing and unpublishing ranking * create MessageBox component * add ziggy * fix code style * handle timeout * create quiz result page * fix auth test * fix time & radio * change FormButton to LinkButton * fix code style * add title * add route parameter * fix code style * fix code style * implement backend for viewing quiz result * fix tests * import carbon * rename page * remove redeclared methods * change default timezone * fix tests * rename Verify-Email to VerifyEmail * remove ziggy * import watch * import watch * fix result route url * fix seeder * fix code style * Migrate button from useForm to router * remove ziggy * improve isClosed function * fix code style * improve 404 text * remove unused import * fix code style * fix code style * Apply suggestions from code review * fixed js warnings * Remove unused files * move logic of closing submissions into action * fix code style * Apply suggestions from code review Co-authored-by: Dawid Rudnik <48356242+dawidrudnik@users.noreply.github.com> * improve message box title * remove polish-plurals * fix code style * catch axios errors * change md:w-x/12 to md:max-w * rename FakeRadio to AnswerResult * convert TimeLeft component into function * fix code style * fix linter error * fix Timer * make time left sticky * Revert "make time left sticky" This reverts commit f1be288. * fix messageboxes * fix code style * remove scroll.y logging * Update resources/js/components/Common/FormButton.vue Co-authored-by: Dawid Rudnik <48356242+dawidrudnik@users.noreply.github.com> * Apply suggestions from code review Co-authored-by: Dawid Rudnik <48356242+dawidrudnik@users.noreply.github.com> * fix calculation of submission duration * change class to buttonClass * fix code style * fix code style * remove class from props * fix id warning * remove useMessageBox function * fix code style * Update resources/js/components/Common/LinkButton.vue Co-authored-by: Dawid Rudnik <48356242+dawidrudnik@users.noreply.github.com> * Update resources/js/Pages/User/Quiz.vue Co-authored-by: Dawid Rudnik <48356242+dawidrudnik@users.noreply.github.com> * remove empty file --------- Co-authored-by: Dominik Prabucki <dominikprabucki.2002@gmail.com> Co-authored-by: Dominikaninn <130690231+PrabuckiDominik@users.noreply.github.com> Co-authored-by: Aleksandra Kozubal <104600942+AleksandraKozubal@users.noreply.github.com> Co-authored-by: Dawid Rudnik <48356242+dawidrudnik@users.noreply.github.com>
- Loading branch information
1 parent
51f1262
commit 3b5b366
Showing
49 changed files
with
666 additions
and
90 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,17 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace App\Actions; | ||
|
||
use App\Models\QuizSubmission; | ||
use Carbon\Carbon; | ||
|
||
class CloseQuizSubmissionAction | ||
{ | ||
public function execute(QuizSubmission $submission): void | ||
{ | ||
$submission->closed_at = Carbon::now(); | ||
$submission->save(); | ||
} | ||
} |
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
export const usePlurals = (singular: string, pluralNominativ: string, pluralGenitive: string) => (value: number) => { | ||
value = Math.abs(value) | ||
|
||
if (value === 1) { | ||
return singular | ||
} | ||
|
||
if (value % 10 >= 2 && value % 10 <= 4 && (value % 100 < 10 || value % 100 >= 20)) { | ||
return pluralNominativ | ||
} | ||
|
||
return pluralGenitive | ||
} |
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,46 @@ | ||
import {type TimeObject} from '@/Types/TimeObject' | ||
import dayjs, { type Dayjs } from 'dayjs' | ||
import {usePlurals} from '@/Helpers/Plurals' | ||
|
||
export function calcSecondsBetweenDates(from: string | number | Dayjs = 0, to: string | number | Dayjs = 0): number { | ||
return dayjs(from).diff(dayjs(to), 's') | ||
} | ||
|
||
export function calcSecondsLeftToDate(date: string | number | Dayjs = 0): number { | ||
return Math.max(calcSecondsBetweenDates(date, dayjs()), 0) | ||
} | ||
|
||
export function secondsToHour(seconds: number): TimeObject { | ||
return { | ||
'h': Math.floor(seconds / 3600), | ||
'm': Math.floor(seconds % 3600 / 60), | ||
's': seconds % 60, | ||
} | ||
} | ||
|
||
const translateLeft = usePlurals('Pozostała', 'Pozostały', 'Pozostało') | ||
const translateSecondsLeft = usePlurals('sekunda', 'sekundy', 'sekund') | ||
const translateMinutesLeft = usePlurals('minuta', 'minuty', 'minut') | ||
const translateHoursLeft = usePlurals('godzina', 'godziny', 'godzin') | ||
|
||
export function timeToString(time: TimeObject, withLeft = false): string { | ||
const { s, m, h } = time | ||
|
||
if (h <= 0 && m <= 0) { | ||
return `${withLeft ? translateLeft(s) : ''} ${s} ${translateSecondsLeft(s)}`.trimStart() | ||
} | ||
|
||
if (h <= 0 && m < 10 && s > 0 ) { | ||
return `${withLeft ? translateLeft(m) : ''} ${m} ${translateMinutesLeft(m)} i ${s} ${translateSecondsLeft(s)}`.trimStart() | ||
} | ||
|
||
if (h <= 0) { | ||
return `${withLeft ? translateLeft(m) : ''} ${m} ${translateMinutesLeft(m)}`.trimStart() | ||
} | ||
|
||
if (h <= 0 && m > 0) { | ||
return `${withLeft ? translateLeft(h) : ''} ${h} ${translateHoursLeft(h)} i ${m} ${translateMinutesLeft(m)}`.trimStart() | ||
} | ||
|
||
return `${withLeft ? translateLeft(h) : ''} ${h} ${translateHoursLeft(h)}`.trimStart() | ||
} |
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,17 @@ | ||
import {computed, ref} from 'vue' | ||
import {calcSecondsLeftToDate, secondsToHour, timeToString} from '@/Helpers/Time' | ||
|
||
export function useTimer(to: string | number, timeout: () => void) { | ||
const left = ref(calcSecondsLeftToDate(to)) | ||
|
||
const interval = setInterval(() => { | ||
left.value = Math.max(0, left.value - 1) | ||
|
||
if (left.value === 0) { | ||
timeout() | ||
clearInterval(interval) | ||
} | ||
}, 1000) | ||
|
||
return computed(() => timeToString(secondsToHour(left.value), true)) | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,21 @@ | ||
<script setup lang="ts"> | ||
import {Head} from '@inertiajs/vue3' | ||
import {type Quiz} from '@/Types/Quiz' | ||
import LinkButton from '@/components/Common/LinkButton.vue' | ||
defineProps<{ quizzes: Quiz[] }>() | ||
</script> | ||
|
||
<template> | ||
<Head> | ||
<title>Testy</title> | ||
</Head> | ||
|
||
Quizzes - CRUD | ||
|
||
<div class="w-4/5"> | ||
<div v-for="quiz in quizzes" :key="quiz.id" class="m-4 bg-white w-100 rounded-2xl p-4 border shadow flex gap-4 items-center justify-between"> | ||
<b>{{ quiz.name }}</b> | ||
<LinkButton :href="`/admin/quizzes/${quiz.id}/ranking`" small>Ranking</LinkButton> | ||
</div> | ||
</div> | ||
</template> |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,4 @@ | ||
<script setup lang="ts"> | ||
import {useForm} from '@inertiajs/vue3' | ||
const form = useForm({}) | ||
|
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
Oops, something went wrong.