40 lines
1.2 KiB
PHP
40 lines
1.2 KiB
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use CodeIgniter\Model;
|
|
|
|
class FinalScoreModel extends Model
|
|
{
|
|
protected $table = 'final_score';
|
|
protected $primaryKey = 'id';
|
|
protected $useAutoIncrement = true;
|
|
|
|
protected $allowedFields = [
|
|
'student_id',
|
|
'school_id',
|
|
'class_section_id',
|
|
'teacher_id',
|
|
'score',
|
|
'score_letter',
|
|
'comment',
|
|
'semester',
|
|
'school_year',
|
|
'created_at',
|
|
'updated_at'
|
|
];
|
|
|
|
// Function to get the final exam score for a specific student, semester, and school year
|
|
public function getFinalExamScore($studentId, $semester, $schoolYear)
|
|
{
|
|
// Query the final_score table for the final exam score based on student ID, semester, and school year
|
|
$result = $this->select('score') // We only need the score
|
|
->where('student_id', $studentId)
|
|
->where('semester', $semester)
|
|
->where('school_year', $schoolYear)
|
|
->first(); // Get the first matching result
|
|
|
|
// Return the score, or null if no result is found
|
|
return $result ? $result['score'] : null;
|
|
}
|
|
} |