add test batches
This commit is contained in:
@@ -2,11 +2,11 @@
|
||||
|
||||
namespace App\Services\Grading;
|
||||
|
||||
use App\Models\ClassSection;
|
||||
use App\Models\GradingLock;
|
||||
use App\Models\ClassSection;
|
||||
use RuntimeException;
|
||||
use App\Services\Grading\Policy\GradingPolicyResolver;
|
||||
use App\Services\Grading\Validation\GradebookFinalizationValidator;
|
||||
use RuntimeException;
|
||||
|
||||
class GradingLockService
|
||||
{
|
||||
@@ -14,8 +14,8 @@ class GradingLockService
|
||||
private ?GradingPolicyResolver $policyResolver = null,
|
||||
private ?GradebookFinalizationValidator $finalizationValidator = null
|
||||
) {
|
||||
$this->policyResolver = $this->policyResolver ?? new GradingPolicyResolver;
|
||||
$this->finalizationValidator = $this->finalizationValidator ?? new GradebookFinalizationValidator;
|
||||
$this->policyResolver = $this->policyResolver ?? new GradingPolicyResolver();
|
||||
$this->finalizationValidator = $this->finalizationValidator ?? new GradebookFinalizationValidator();
|
||||
}
|
||||
|
||||
public function toggle(int $classSectionId, string $semester, string $schoolYear, ?int $userId): bool
|
||||
@@ -32,7 +32,6 @@ class GradingLockService
|
||||
'locked_by' => null,
|
||||
'locked_at' => null,
|
||||
]);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -98,7 +97,7 @@ class GradingLockService
|
||||
foreach ($sectionIds as $sid) {
|
||||
$this->assertCanLock($sid, $semester, $schoolYear);
|
||||
|
||||
if (! empty($existingBySection[$sid])) {
|
||||
if (!empty($existingBySection[$sid])) {
|
||||
if ($existingBySection[$sid]->is_locked) {
|
||||
continue;
|
||||
}
|
||||
@@ -108,7 +107,6 @@ class GradingLockService
|
||||
'locked_at' => $now,
|
||||
]);
|
||||
$count++;
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -125,7 +123,7 @@ class GradingLockService
|
||||
$count++;
|
||||
}
|
||||
|
||||
if (! empty($insertRows)) {
|
||||
if (!empty($insertRows)) {
|
||||
GradingLock::query()->insert($insertRows);
|
||||
}
|
||||
|
||||
@@ -140,7 +138,7 @@ class GradingLockService
|
||||
}
|
||||
|
||||
$result = $this->finalizationValidator->validateClassSectionBeforeLock($classSectionId, $semester, $schoolYear);
|
||||
if (! $result['valid']) {
|
||||
if (!$result['valid']) {
|
||||
$count = count($result['errors']);
|
||||
throw new RuntimeException("Cannot lock class section {$classSectionId}; strong grading validation failed with {$count} error(s).");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user