This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
|
||||
namespace App\Controllers\View;
|
||||
|
||||
use CodeIgniter\Controller;
|
||||
use App\Controllers\BaseController;
|
||||
use App\Models\TeacherClassModel;
|
||||
use App\Models\StudentClassModel;
|
||||
use App\Models\StudentModel;
|
||||
@@ -17,7 +17,7 @@ use Config\Services;
|
||||
use App\Models\GradingLockModel;
|
||||
use App\Models\MissingScoreOverrideModel;
|
||||
|
||||
class QuizController extends Controller
|
||||
class QuizController extends BaseController
|
||||
{
|
||||
protected $db;
|
||||
protected $semesterScoreService;
|
||||
@@ -50,7 +50,7 @@ class QuizController extends Controller
|
||||
$this->missingScoreOverrideModel = new MissingScoreOverrideModel();
|
||||
}
|
||||
|
||||
public function updateQuizScores(array $scores = null, int $updatedBy = null, int $classSectionId = null)
|
||||
public function updateQuizScores(?array $scores = null, ?int $updatedBy = null, ?int $classSectionId = null)
|
||||
{
|
||||
$scores = $this->request->getPost('scores');
|
||||
log_message('error', '✅ Raw Scores: ' . print_r($scores, true));
|
||||
@@ -60,7 +60,8 @@ class QuizController extends Controller
|
||||
}
|
||||
$classSectionId = $this->request->getPost('class_section_id') ?? session()->get('class_section_id');
|
||||
$semester = $this->request->getPost('semester') ?? $this->getTeacherSelectedSemester();
|
||||
$schoolYear = $this->request->getPost('school_year') ?? $this->schoolYear;
|
||||
$schoolYear = $this->currentSchoolYearName((string) ($this->schoolYear ?? ''));
|
||||
$this->assertSchoolYearWritable($this->resolveSchoolYearContext());
|
||||
$classSectionId = (int) ($classSectionId ?? 0);
|
||||
if ($classSectionId > 0 && $this->isScoresLocked($classSectionId, $semester, $schoolYear)) {
|
||||
return redirect()->back()->with('error', 'Scores are locked for this class. Unlock to edit.');
|
||||
@@ -206,7 +207,7 @@ class QuizController extends Controller
|
||||
|
||||
// 3) Headers: distinct quiz_index for this class/term
|
||||
$semester = $this->getTeacherSelectedSemester();
|
||||
$schoolYear = $this->schoolYear;
|
||||
$schoolYear = $this->currentSchoolYearName((string) ($this->schoolYear ?? ''));
|
||||
$quizHeaderRows = $this->quizModel->select('quiz_index')
|
||||
->where('class_section_id', $classSectionId)
|
||||
->where('school_year', $schoolYear)
|
||||
@@ -272,9 +273,9 @@ class QuizController extends Controller
|
||||
'students' => $students,
|
||||
'quizHeaders' => $quizHeaders, // e.g., [1,2,3]
|
||||
'semester' => $semester,
|
||||
'schoolYear' => $this->schoolYear,
|
||||
'schoolYear' => $schoolYear,
|
||||
'classSectionId' => $classSectionId,
|
||||
'missingOkMap' => $this->missingScoreOverrideModel->getOverridesMap($classSectionId, $semester, $this->schoolYear, 'quiz'),
|
||||
'missingOkMap' => $this->missingScoreOverrideModel->getOverridesMap($classSectionId, $semester, $schoolYear, 'quiz'),
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -294,7 +295,8 @@ class QuizController extends Controller
|
||||
try {
|
||||
|
||||
$semester = $this->getTeacherSelectedSemester();
|
||||
$schoolYear = $this->schoolYear;
|
||||
$schoolYear = $this->currentSchoolYearName((string) ($this->schoolYear ?? ''));
|
||||
$this->assertSchoolYearWritable($this->resolveSchoolYearContext());
|
||||
$existingQuizNumbers = $this->quizModel
|
||||
->select('quiz_index')
|
||||
->where('class_section_id', $classSectionId)
|
||||
@@ -323,6 +325,7 @@ class QuizController extends Controller
|
||||
|
||||
$students = $this->studentClassModel
|
||||
->where('class_section_id', $classSectionId)
|
||||
->where('school_year', $schoolYear)
|
||||
->findAll();
|
||||
|
||||
if (empty($students)) {
|
||||
@@ -341,8 +344,8 @@ class QuizController extends Controller
|
||||
'quiz_index' => $nextQuizNumber,
|
||||
'class_section_id' => $classSectionId,
|
||||
'updated_by' => $updatedBy,
|
||||
'semester' => $this->semester,
|
||||
'school_year' => $this->schoolYear,
|
||||
'semester' => $semester,
|
||||
'school_year' => $schoolYear,
|
||||
])
|
||||
->first();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user