diff --git a/app/Http/Requests/UpdateQuizRequest.php b/app/Http/Requests/UpdateQuizRequest.php index b888323d..3561383a 100644 --- a/app/Http/Requests/UpdateQuizRequest.php +++ b/app/Http/Requests/UpdateQuizRequest.php @@ -24,6 +24,10 @@ public function prepareForValidation(): void if ($this->has("isPublic")) { $this->merge(["is_public" => $this->input("isPublic")]); } + + if ($this->has("isLocal")) { + $this->merge(["is_local" => $this->input("isLocal")]); + } } /** @@ -35,6 +39,7 @@ public function rules(): array "title" => ["required", "string", "max:255"], "scheduled_at" => ["date", "after:now"], "is_public" => ["boolean"], + "is_local" => ["boolean"], "duration" => ["integer", "min:1", "max:2147483647"], "description" => ["string", "nullable"], "questions" => ["array"], diff --git a/app/Http/Resources/QuizResource.php b/app/Http/Resources/QuizResource.php index 43e9ec51..f6396636 100644 --- a/app/Http/Resources/QuizResource.php +++ b/app/Http/Resources/QuizResource.php @@ -22,7 +22,7 @@ public function toArray($request): array "isPublic" => $this->is_public, "canBeLocked" => $this->canBeLocked, "canBeUnlocked" => $this->canBeUnlocked, - "questions" => $this->is_local ? [] : QuestionResource::collection($this->questions), + "questions" => QuestionResource::collection($this->questions), "isUserAssigned" => $this->isUserAssigned($request->user()), "isRankingPublished" => $this->isRankingPublished, "isLocal" => $this->is_local, diff --git a/app/Http/Resources/UserQuizResource.php b/app/Http/Resources/UserQuizResource.php index 36149b17..628136a7 100644 --- a/app/Http/Resources/UserQuizResource.php +++ b/app/Http/Resources/UserQuizResource.php @@ -14,6 +14,7 @@ public function toArray(Request $request): array return [ "id" => $this->id, "title" => $this->quiz->title, + "description" => $this->quiz->description, "createdAt" => $this->created_at, "updatedAt" => $this->updated_at, "closedAt" => $this->closed_at, diff --git a/app/Models/Quiz.php b/app/Models/Quiz.php index 5625b187..3268666d 100644 --- a/app/Models/Quiz.php +++ b/app/Models/Quiz.php @@ -48,6 +48,7 @@ class Quiz extends Model "ranking_published_at", "description", "is_public", + "is_local", ]; protected $guarded = []; diff --git a/database/seeders/AdminSeeder.php b/database/seeders/AdminSeeder.php index 497d6064..1a523be5 100644 --- a/database/seeders/AdminSeeder.php +++ b/database/seeders/AdminSeeder.php @@ -35,7 +35,7 @@ public function run(): void "firstname" => "Example", "surname" => "Super Admin", "email_verified_at" => Carbon::now(), - "password" => Hash::make("password"), + "password" => Hash::make("interns2024b"), "remember_token" => Str::random(10), "school_id" => $school->id, ], @@ -48,7 +48,7 @@ public function run(): void "firstname" => "Example", "surname" => "Admin", "email_verified_at" => Carbon::now(), - "password" => Hash::make("password"), + "password" => Hash::make("interns2024b"), "remember_token" => Str::random(10), "school_id" => $school->id, ], @@ -61,7 +61,7 @@ public function run(): void "firstname" => "Example", "surname" => "User", "email_verified_at" => Carbon::now(), - "password" => Hash::make("password"), + "password" => Hash::make("interns2024b"), "remember_token" => Str::random(10), "school_id" => School::factory()->create()->id, ], diff --git a/resources/js/Helpers/vDynamicInputWidth.ts b/resources/js/Helpers/vDynamicInputWidth.ts index d795fdd4..dac5070f 100644 --- a/resources/js/Helpers/vDynamicInputWidth.ts +++ b/resources/js/Helpers/vDynamicInputWidth.ts @@ -24,6 +24,7 @@ function calculateDynamicWidth(input: HTMLInputElement, binding?: DirectiveBindi context.font = `${fontWeight} ${fontSize} ${fontFamily}` const width = context.measureText(input.value || input.placeholder).width + input.style.minWidth = `${width}px` input.style.width = `clamp(1.1rem,${width}px,100%)` } diff --git a/resources/js/Helpers/vDynamicTextAreaHeight.ts b/resources/js/Helpers/vDynamicTextAreaHeight.ts index 849beef9..70d4c060 100644 --- a/resources/js/Helpers/vDynamicTextAreaHeight.ts +++ b/resources/js/Helpers/vDynamicTextAreaHeight.ts @@ -1,13 +1,13 @@ import { type DirectiveBinding } from 'vue' function initDynamicHeightCalc(input: HTMLTextAreaElement & { _calculateDynamicHeight: () => void }, binding?: DirectiveBinding) { + input.style.resize = 'none' input._calculateDynamicHeight = () => calculateDynamicHeight(input, binding) document.fonts.addEventListener('loadingdone', input._calculateDynamicHeight) input.addEventListener('transitionend', input._calculateDynamicHeight) input._calculateDynamicHeight() - input.style.resize = 'none' } function calculateDynamicHeight(input: HTMLTextAreaElement, binding?: DirectiveBinding){ @@ -17,8 +17,8 @@ function calculateDynamicHeight(input: HTMLTextAreaElement, binding?: DirectiveB // Reset the height to a minimal value to refresh scrollHeight. // This ensures the textarea will shrink when text is removed. - input.style.height = '5px' - input.style.height = `${input.scrollHeight}px` + input.style.height = '0' + input.style.height = `${input.scrollHeight+1}px` } function removeDynamicHeightCalc(input: HTMLTextAreaElement & { _calculateDynamicHeight: () => void }) { @@ -26,10 +26,10 @@ function removeDynamicHeightCalc(input: HTMLTextAreaElement & { _calculateDynami input.removeEventListener('transitionend', input._calculateDynamicHeight) } -const vDynamicInputHeight = { +const vDynamicTextAreaHeight = { mounted: initDynamicHeightCalc, updated: calculateDynamicHeight, unmounted: removeDynamicHeightCalc, } -export default vDynamicInputHeight +export default vDynamicTextAreaHeight diff --git a/resources/js/Pages/User/Dashboard.vue b/resources/js/Pages/User/Dashboard.vue index e11312bb..40cee3bc 100644 --- a/resources/js/Pages/User/Dashboard.vue +++ b/resources/js/Pages/User/Dashboard.vue @@ -37,9 +37,11 @@ const history = computed(() => props.userQuizzes.filter(userQuiz => userQuiz.clo v-for="quiz in started" :key="quiz.id" :title="quiz.title" + :description="quiz.description" :time="quiz.scheduledAt" > props.userQuizzes.filter(userQuiz => userQuiz.clo v-for="quiz in scheduled" :key="quiz.id" :title="quiz.title" + :description="quiz.description" :time="quiz.scheduledAt" > - - Zapisz się - - - - Zapisano - +
@@ -99,6 +104,7 @@ const history = computed(() => props.userQuizzes.filter(userQuiz => userQuiz.clo v-for="userQuiz in history" :key="userQuiz.id" :title="userQuiz.title" + :description="userQuiz.description" :time="userQuiz.closedAt" > document.body.style.overflow = isOpen ? 'hidden' : '') :class="{'bg-primary/[.02] backdrop-blur-md pointer-events-auto':open}" >
diff --git a/resources/js/components/Crud/CrudInput.vue b/resources/js/components/Crud/CrudInput.vue index 8ddd9649..3c3dd09f 100644 --- a/resources/js/components/Crud/CrudInput.vue +++ b/resources/js/components/Crud/CrudInput.vue @@ -13,6 +13,8 @@ const props = defineProps<{ error?: string password?: boolean large?: boolean + row?: boolean + column?: boolean format?: (value: T) => any } & InputProps>() @@ -28,10 +30,12 @@ function handleInput() {