diff --git a/app/Models/ScoringGuide.php b/app/Models/ScoringGuide.php index 41eb451..3b6195a 100644 --- a/app/Models/ScoringGuide.php +++ b/app/Models/ScoringGuide.php @@ -6,10 +6,6 @@ use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Relations\HasMany; -use function array_diff_key; -use function array_key_exists; -use function is_null; - class ScoringGuide extends Model { use HasFactory; @@ -27,32 +23,4 @@ class ScoringGuide extends Model { return $this->hasMany(SubscoreDefinition::class); } - - /** - * Validate a set of subscores. Expects an array in the form of subscore_id => score - * - * @return string - */ - public function validateScores(array $prospective_score) - { - foreach ($this->subscores as $subscore) { - if (! array_key_exists($subscore->id, $prospective_score)) { - return 'A score must be provided for '.$subscore->name; - } - if (is_null($prospective_score[$subscore->id])) { - return 'A score must be provided for '.$subscore->name; - } - if ($prospective_score[$subscore->id] > $subscore->max_score) { - return 'The '.$subscore->name.' score must be less than or equal to '.$subscore->max_score; - } - } - - $subscore_ids = $this->subscores->pluck('id')->flip()->all(); - $diff = array_diff_key($prospective_score, $subscore_ids); - if (! empty($diff)) { - return 'Invalid scores submitted'; - } - - return 'success'; - } }