Skip to content

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_SCORES permission

Requirements

The component expects the following on the model:

  • scoring_enabled boolean field
  • score numeric field
  • final_score boolean field
  • convenor_id field that matches the user's engauge_user_id
  • A relationship to a category model with a requires_scoring boolean 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