Remove depricated validateScores method from ScoringGuide model

Closes #34
This commit is contained in:
Matt Young 2025-06-30 08:51:41 -05:00
parent f0ad56e0d2
commit c4e8cbfe53
1 changed files with 0 additions and 32 deletions

View File

@ -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';
}
}