296 lines
8.2 KiB
PHP
296 lines
8.2 KiB
PHP
<?php
|
|
|
|
namespace App\Controllers\View;
|
|
|
|
use App\Controllers\BaseController;
|
|
|
|
class GradingController extends BaseController
|
|
{
|
|
protected string $schoolYear = '';
|
|
protected string $semester = '';
|
|
|
|
public function __construct()
|
|
{
|
|
$configModel = model(\App\Models\ConfigurationModel::class);
|
|
$this->schoolYear = (string) $configModel->getConfig('school_year');
|
|
$this->semester = (string) getSemester();
|
|
}
|
|
|
|
private function requestParams(): array
|
|
{
|
|
return [
|
|
'get' => $this->request->getGet() ?? [],
|
|
'post' => $this->request->getPost() ?? [],
|
|
];
|
|
}
|
|
|
|
private function respondGrading(array $result)
|
|
{
|
|
$kind = $result['kind'] ?? '';
|
|
|
|
if ($kind === 'view') {
|
|
return view((string) $result['view'], $result['data'] ?? []);
|
|
}
|
|
|
|
if ($kind === 'json') {
|
|
$status = (int) ($result['status'] ?? 200);
|
|
return $this->response->setStatusCode($status)->setJSON($result['data'] ?? []);
|
|
}
|
|
|
|
if ($kind === 'flash') {
|
|
$redirect = $result['redirect'] ?? 'back';
|
|
$type = (string) ($result['type'] ?? 'status');
|
|
$message = $result['message'] ?? '';
|
|
$response = ($redirect === 'back') ? redirect()->back() : redirect()->to($redirect);
|
|
if (!empty($result['withInput'])) {
|
|
$response = $response->withInput();
|
|
}
|
|
return $response->with($type, $message);
|
|
}
|
|
|
|
// Raw payload (e.g. getScoreComment)
|
|
return $this->response->setJSON($result);
|
|
}
|
|
|
|
private function scoreService()
|
|
{
|
|
$service = service('gradingScore');
|
|
$service->setTerm($this->schoolYear, $this->semester);
|
|
return $service;
|
|
}
|
|
|
|
private function placementService()
|
|
{
|
|
$service = service('placementGrading');
|
|
$service->setSchoolYear($this->schoolYear);
|
|
return $service;
|
|
}
|
|
|
|
private function belowSixtyService()
|
|
{
|
|
$service = service('belowSixty');
|
|
$service->setTerm($this->schoolYear, $this->semester);
|
|
return $service;
|
|
}
|
|
|
|
private function decisionService()
|
|
{
|
|
$service = service('studentDecision');
|
|
$service->setTerm($this->schoolYear, $this->semester);
|
|
return $service;
|
|
}
|
|
|
|
public function show($type, $classSectionId, $studentId)
|
|
{
|
|
return $this->respondGrading(
|
|
$this->scoreService()->showType($type, $classSectionId, $studentId, $this->requestParams())
|
|
);
|
|
}
|
|
|
|
public function update()
|
|
{
|
|
return $this->respondGrading(
|
|
$this->scoreService()->updateScores($this->requestParams())
|
|
);
|
|
}
|
|
|
|
public function grading()
|
|
{
|
|
return $this->respondGrading(
|
|
$this->scoreService()->gradingPage($this->requestParams())
|
|
);
|
|
}
|
|
|
|
public function toggleScoreLock()
|
|
{
|
|
return $this->respondGrading(
|
|
$this->scoreService()->toggleScoreLock($this->requestParams())
|
|
);
|
|
}
|
|
|
|
public function lockAllScores()
|
|
{
|
|
return $this->respondGrading(
|
|
$this->scoreService()->lockAllScores($this->requestParams())
|
|
);
|
|
}
|
|
|
|
public function toggleParentScoresRelease()
|
|
{
|
|
return $this->respondGrading(
|
|
$this->scoreService()->toggleParentScoresRelease($this->requestParams())
|
|
);
|
|
}
|
|
|
|
public function refreshSemesterScores()
|
|
{
|
|
return $this->respondGrading(
|
|
$this->scoreService()->refreshSemesterScores($this->requestParams())
|
|
);
|
|
}
|
|
|
|
public function getScoreComment()
|
|
{
|
|
return $this->response->setJSON(
|
|
$this->scoreService()->getScoreComment($this->requestParams())
|
|
);
|
|
}
|
|
|
|
public function updatePlacementLevel()
|
|
{
|
|
return $this->respondGrading(
|
|
$this->placementService()->updatePlacementLevel($this->requestParams())
|
|
);
|
|
}
|
|
|
|
public function placement()
|
|
{
|
|
return $this->respondGrading(
|
|
$this->placementService()->placementPage($this->requestParams())
|
|
);
|
|
}
|
|
|
|
public function updatePlacementLevels()
|
|
{
|
|
return $this->respondGrading(
|
|
$this->placementService()->updatePlacementLevels($this->requestParams())
|
|
);
|
|
}
|
|
|
|
public function updatePlacementLevelsAll()
|
|
{
|
|
return $this->respondGrading(
|
|
$this->placementService()->updatePlacementLevelsAll($this->requestParams())
|
|
);
|
|
}
|
|
|
|
public function editPlacementBatch(int $batchId)
|
|
{
|
|
return $this->respondGrading(
|
|
$this->placementService()->editPlacementBatch($batchId, $this->requestParams())
|
|
);
|
|
}
|
|
|
|
public function updatePlacementBatch(int $batchId)
|
|
{
|
|
return $this->respondGrading(
|
|
$this->placementService()->updatePlacementBatch($batchId, $this->requestParams())
|
|
);
|
|
}
|
|
|
|
public function belowSixty()
|
|
{
|
|
$params = $this->requestParams();
|
|
$params['school_year'] = $this->currentSchoolYearName((string) $this->schoolYear);
|
|
return $this->respondGrading($this->belowSixtyService()->belowSixtyPage($params));
|
|
}
|
|
|
|
public function editBelowSixtyEmail()
|
|
{
|
|
return $this->respondGrading(
|
|
$this->belowSixtyService()->editBelowSixtyEmail($this->requestParams())
|
|
);
|
|
}
|
|
|
|
public function sendBelowSixtyEmail()
|
|
{
|
|
return $this->respondGrading(
|
|
$this->belowSixtyService()->sendBelowSixtyEmail($this->requestParams())
|
|
);
|
|
}
|
|
|
|
public function updateBelowSixtyStatus()
|
|
{
|
|
return $this->respondGrading(
|
|
$this->belowSixtyService()->updateBelowSixtyStatus($this->requestParams())
|
|
);
|
|
}
|
|
|
|
public function scheduleBelowSixty()
|
|
{
|
|
return $this->respondGrading(
|
|
$this->belowSixtyService()->scheduleBelowSixtyPage($this->requestParams())
|
|
);
|
|
}
|
|
|
|
public function saveBelowSixtyMeeting()
|
|
{
|
|
return $this->respondGrading(
|
|
$this->belowSixtyService()->saveBelowSixtyMeeting($this->requestParams())
|
|
);
|
|
}
|
|
|
|
public function belowSixtyDecisions()
|
|
{
|
|
$context = $this->resolveSchoolYearContext();
|
|
$params = $this->requestParams();
|
|
$params['school_year'] = $context->yearName();
|
|
$params['is_readonly'] = $context->isReadonly();
|
|
return $this->respondGrading($this->belowSixtyService()->belowSixtyDecisionsPage($params));
|
|
}
|
|
|
|
public function saveBelowSixtyDecision()
|
|
{
|
|
$context = $this->resolveSchoolYearContext();
|
|
$params = $this->requestParams();
|
|
$params['school_year'] = $context->yearName();
|
|
return $this->respondGrading($this->belowSixtyService()->saveBelowSixtyDecision($params));
|
|
}
|
|
|
|
public function studentDecisionDetails()
|
|
{
|
|
return $this->respondGrading(
|
|
$this->belowSixtyService()->studentDecisionDetails($this->requestParams())
|
|
);
|
|
}
|
|
|
|
public function previewBelowSixtyDecisionEmail()
|
|
{
|
|
return $this->respondGrading(
|
|
$this->belowSixtyService()->previewBelowSixtyDecisionEmail($this->requestParams())
|
|
);
|
|
}
|
|
|
|
public function sendBelowSixtyDecisionEmail()
|
|
{
|
|
return $this->respondGrading(
|
|
$this->belowSixtyService()->sendBelowSixtyDecisionEmail($this->requestParams())
|
|
);
|
|
}
|
|
|
|
public function previewDecisionEmail()
|
|
{
|
|
return $this->respondGrading(
|
|
$this->decisionService()->previewDecisionEmail($this->requestParams())
|
|
);
|
|
}
|
|
|
|
public function editDecisionEmail()
|
|
{
|
|
return $this->respondGrading(
|
|
$this->decisionService()->editDecisionEmail($this->requestParams())
|
|
);
|
|
}
|
|
|
|
public function sendDecisionEmail()
|
|
{
|
|
return $this->respondGrading(
|
|
$this->decisionService()->sendDecisionEmail($this->requestParams())
|
|
);
|
|
}
|
|
|
|
public function allDecisions()
|
|
{
|
|
return $this->respondGrading(
|
|
$this->decisionService()->allDecisionsPage($this->requestParams())
|
|
);
|
|
}
|
|
|
|
public function generateAllDecisions()
|
|
{
|
|
return $this->respondGrading(
|
|
$this->decisionService()->generateAllDecisions($this->requestParams())
|
|
);
|
|
}
|
|
}
|