Skip to content

Commit

Permalink
Automatic Class Rank calculation when automatically calculating final…
Browse files Browse the repository at this point in the history
… grades

SQL INSERT INTO grades_completed so "These grades are complete." is displayed on the Input Final Grades program
  • Loading branch information
francoisjacquet committed Oct 3, 2024
1 parent 9b53cf3 commit f130147
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 0 deletions.
2 changes: 2 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
Changes in 11.8.6
-----------------
- Fix Weight when "Group by Assignment Category" is checked in ProgressReports.php
- Automatic Class Rank calculation when automatically calculating final grades in FinalGrades.inc.php
- SQL INSERT INTO grades_completed so "These grades are complete." is displayed on the Input Final Grades program in FinalGrades.inc.php

Changes in 11.8.5
-----------------
Expand Down
39 changes: 39 additions & 0 deletions modules/Grades/includes/FinalGrades.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@ function FinalGradesAllMPSaveAJAX( $cp_id, $qtr_id )
* @uses FinalGradesSave()
*
* @since 11.8
* @since 11.8.6 Automatic Class Rank calculation.
* @since 11.8.6 SQL INSERT INTO grades_completed so "These grades are complete." is displayed on the Input Final Grades program
*
* @param int $cp_id Course Period ID.
* @param int $qtr_id Quarter ID.
Expand All @@ -100,6 +102,8 @@ function FinalGradesAllMPSave( $cp_id, $qtr_id )

FinalGradesSave( $cp_id, $qtr_id, $final_grades );

$final_grade_mps[] = $qtr_id;

$pro = GetChildrenMP( 'PRO', $qtr_id );

$pro = explode( ',', $pro );
Expand All @@ -119,6 +123,8 @@ function FinalGradesAllMPSave( $cp_id, $qtr_id )
if ( $final_grades )
{
FinalGradesSave( $cp_id, $pro_id, $final_grades );

$final_grade_mps[] = $pro_id;
}
}

Expand All @@ -132,6 +138,8 @@ function FinalGradesAllMPSave( $cp_id, $qtr_id )
if ( $final_grades )
{
FinalGradesSave( $cp_id, $sem_id, $final_grades );

$final_grade_mps[] = $sem_id;
}
}

Expand All @@ -145,7 +153,38 @@ function FinalGradesAllMPSave( $cp_id, $qtr_id )
if ( $final_grades )
{
FinalGradesSave( $cp_id, $fy_id, $final_grades );

$final_grade_mps[] = $fy_id;
}
}

require_once 'modules/Grades/includes/ClassRank.inc.php';

$teacher_id = DBGetOne( "SELECT TEACHER_ID
FROM course_periods
WHERE COURSE_PERIOD_ID='" . (int) $cp_id . "'" );

foreach ( $final_grade_mps as $mp_id )
{
$current_completed = (bool) DBGetOne( "SELECT 1
FROM grades_completed
WHERE STAFF_ID='" . (int) $teacher_id . "'
AND MARKING_PERIOD_ID='" . (int) $mp_id . "'
AND COURSE_PERIOD_ID='" . (int) $cp_id . "'" );

if ( ! $current_completed )
{
DBInsert(
'grades_completed',
[
'STAFF_ID' => (int) $teacher_id,
'MARKING_PERIOD_ID' => (int) $mp_id,
'COURSE_PERIOD_ID' => (int) $cp_id,
]
);
}

ClassRankCalculateAddMP( $mp_id );
}

return true;
Expand Down

0 comments on commit f130147

Please sign in to comment.