-
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 mail for close quiz action * add queue:listen to makefile * remove duplicate recipes * split quiz controller logic into action files * add tests for actions * test user model * remove randomness from test * fix command name * implement sending notification when quiz is closed * fix wasClosedManually method * prepare quizzes for testing * fix filterArchivedQuizzes method * add archived quiz to seeder * fix code style * fix no answer warning * change number to int * add return type * move isClosingToday logic to sql * revert to non-SQL version * Revert "- Update all non-major dependencies with digest and pinDigest (#122)" This reverts commit 1a20886. * fix namespaces * fix code style * replace nunomaduro/larastan with larastan/larastan
- Loading branch information
1 parent
8ec02ac
commit f79996e
Showing
61 changed files
with
1,908 additions
and
813 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
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 |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace App\Actions; | ||
|
||
use App\Models\Question; | ||
use App\Models\UserQuestion; | ||
use App\Models\UserQuiz; | ||
|
||
class CreateUserQuestionAction | ||
{ | ||
public function execute(Question $question, UserQuiz $userQuiz): UserQuestion | ||
{ | ||
$userQuestion = new UserQuestion(); | ||
$userQuestion->userQuiz()->associate($userQuiz); | ||
$userQuestion->question()->associate($question); | ||
$userQuestion->save(); | ||
|
||
return $userQuestion; | ||
} | ||
} |
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 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace App\Actions; | ||
|
||
use App\Models\Quiz; | ||
use App\Models\User; | ||
use App\Models\UserQuiz; | ||
|
||
class CreateUserQuizAction | ||
{ | ||
public function __construct( | ||
protected CreateUserQuestionAction $action, | ||
) {} | ||
|
||
public function execute(Quiz $quiz, User $user): UserQuiz | ||
{ | ||
$userQuiz = new UserQuiz(); | ||
$userQuiz->closed_at = $quiz->closeAt; | ||
$userQuiz->quiz()->associate($quiz); | ||
$userQuiz->user()->associate($user); | ||
$userQuiz->save(); | ||
|
||
foreach ($quiz->questions as $question) { | ||
$this->action->execute($question, $userQuiz); | ||
} | ||
|
||
return $userQuiz; | ||
} | ||
} |
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,22 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace App\Actions; | ||
|
||
use App\Jobs\CloseUserQuizJob; | ||
use App\Models\Quiz; | ||
use Carbon\Carbon; | ||
|
||
class LockQuizAction | ||
{ | ||
public function execute(Quiz $quiz): void | ||
{ | ||
$quiz->locked_at = Carbon::now(); | ||
$quiz->save(); | ||
|
||
if ($quiz->isClosingToday()) { | ||
CloseUserQuizJob::dispatch($quiz)->delay($quiz->closeAt); | ||
} | ||
} | ||
} |
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,16 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace App\Actions; | ||
|
||
use App\Models\Quiz; | ||
|
||
class UnlockQuizAction | ||
{ | ||
public function execute(Quiz $quiz): void | ||
{ | ||
$quiz->locked_at = null; | ||
$quiz->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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace App\Console\Commands; | ||
|
||
use App\Jobs\CloseUserQuizJob; | ||
use App\Models\Quiz; | ||
use Illuminate\Console\Command; | ||
|
||
class DispatchUserQuizClosedEvent extends Command | ||
{ | ||
protected $signature = "app:dispatch-user-quiz-closed-event"; | ||
protected $description = "Dispatches the UserQuizClosed event for quizzes that are closing today."; | ||
|
||
public function handle(): void | ||
{ | ||
foreach (Quiz::all() as $quiz) { | ||
if ($quiz->isClosingToday()) { | ||
CloseUserQuizJob::dispatch($quiz)->delay($quiz->closeAt); | ||
} | ||
} | ||
} | ||
} |
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,23 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace App\Events; | ||
|
||
use App\Models\Quiz; | ||
use App\Models\User; | ||
use Illuminate\Broadcasting\InteractsWithSockets; | ||
use Illuminate\Foundation\Events\Dispatchable; | ||
use Illuminate\Queue\SerializesModels; | ||
|
||
class AssignedQuizClosed | ||
{ | ||
use Dispatchable; | ||
use InteractsWithSockets; | ||
use SerializesModels; | ||
|
||
public function __construct( | ||
public Quiz $quiz, | ||
public User $user, | ||
) {} | ||
} |
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,21 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace App\Events; | ||
|
||
use App\Models\UserQuiz; | ||
use Illuminate\Broadcasting\InteractsWithSockets; | ||
use Illuminate\Foundation\Events\Dispatchable; | ||
use Illuminate\Queue\SerializesModels; | ||
|
||
class UserQuizClosed | ||
{ | ||
use Dispatchable; | ||
use InteractsWithSockets; | ||
use SerializesModels; | ||
|
||
public function __construct( | ||
public UserQuiz $userQuiz, | ||
) {} | ||
} |
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
Oops, something went wrong.