Reusable Session Scoring Component
The SessionScoringFields component provides a reusable way to add session scoring functionality to any Filament resource that needs it.
Usage
Basic Usage
To add session scoring to a Filament resource, simply import and use the component:
use App\Filament\Forms\Components\SessionScoringFields;
// In your form schema
SessionScoringFields::sessionScoringSection(),
Complete Example
<?php
namespace App\Filament\Resources\MySessionResource;
use App\Filament\Forms\Components\SessionScoringFields;
use Filament\Forms\Form;
use Filament\Resources\Resource;
class MySessionResource extends Resource
{
public static function form(Form $form): Form
{
return $form
->schema([
// Other form fields...
SessionScoringFields::sessionScoringSection(),
// More form fields...
]);
}
}
Individual Fields
You can also use individual fields if you need more control:
use App\Filament\Forms\Components\SessionScoringFields;
// Just the scoring enabled toggle
SessionScoringFields::scoringEnabledToggle(),
// Just the score input
SessionScoringFields::scoreInput(),
// Just the final score toggle
SessionScoringFields::finalScoreToggle(),
Features
The component includes:
- Scoring Enabled Toggle: Allows admins to enable/disable scoring for a session
- Score Input: Numeric input for scores between 1.00 and 100.00 with 2 decimal places
- Final Score Toggle: Allows marking scores as final (cannot be changed after)
- Permission-based Visibility: Only shows to users with appropriate permissions
- Admin Override: Admins can always see and modify scoring fields
- Convenor Permissions: Convenors can add scores if they have the
ADD_SESSION_SCORESpermission
Requirements
The component expects the following on the model:
scoring_enabledboolean fieldscorenumeric fieldfinal_scoreboolean fieldconvenor_idfield that matches the user'sengauge_user_id- A relationship to a
categorymodel with arequires_scoringboolean field
Permissions
The component respects the following permissions:
UserPermissions::ADD_SESSION_SCORES- Required for convenors to add scores- Admin role - Can always see and modify scoring fields