feat: Initial commit for Saqel Platform architecture, backend, Docker, and documentation
This commit is contained in:
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
namespace App\Jobs;
|
||||
|
||||
use App\Contracts\AiService;
|
||||
use App\Models\User;
|
||||
use App\Services\ProgressTrackingService;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Foundation\Queue\Queueable;
|
||||
use Throwable;
|
||||
|
||||
class AnalyzeStudentPerformance implements ShouldQueue
|
||||
{
|
||||
use Queueable;
|
||||
|
||||
public int $tries = 3;
|
||||
|
||||
public function __construct(public int $studentId) {}
|
||||
|
||||
public function handle(ProgressTrackingService $tracking, AiService $ai): void
|
||||
{
|
||||
/** @var User|null $student */
|
||||
$student = User::query()->find($this->studentId);
|
||||
|
||||
if ($student === null) {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
$payload = $ai->analyzeStudentPerformance($tracking->buildPerformanceSnapshot($student));
|
||||
} catch (Throwable $exception) {
|
||||
report($exception);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$student->aiReports()->create([
|
||||
'type' => 'weakness_analysis',
|
||||
'payload' => $payload,
|
||||
'summary' => is_string($payload['summary'] ?? null) ? $payload['summary'] : null,
|
||||
]);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user