@@ -345,6 +345,7 @@ function FinalGradesQtrOrProCalculate( $cp_id, $mp_id, $assignment_type_id = 0 )
345345 *
346346 * @since 11.8
347347 * @since 12.2.3 Fix SQL error when percent grade > 999.9
348+ * @since 12.3 Save null percent: N/A final grade
348349 *
349350 * @global $warning Warning: Add "Final Grading Percentages are not configured."
350351 *
@@ -429,7 +430,14 @@ function FinalGradesSemOrFYCalculate( $cp_id, $mp_id, $mode = 'continue' )
429430
430431 foreach ( (array ) $ percents_RET as $ student_id => $ percents )
431432 {
432- $ total = $ total_percent = 0 ;
433+ $ total_percent = 0 ;
434+
435+ /**
436+ * N/A for all children Marking Periods case
437+ *
438+ * @since 12.3 Save null percent: N/A final grade
439+ */
440+ $ total = null ;
433441
434442 foreach ( (array ) $ percents as $ percent )
435443 {
@@ -450,6 +458,12 @@ function FinalGradesSemOrFYCalculate( $cp_id, $mp_id, $mode = 'continue' )
450458 }
451459 }
452460
461+ if ( is_null ( $ percent ['GRADE_PERCENT ' ] ) )
462+ {
463+ // N/A final grade
464+ continue ;
465+ }
466+
453467 $ total += $ percent ['GRADE_PERCENT ' ] *
454468 issetVal ( $ gradebook_config [$ prefix . $ percent ['MARKING_PERIOD_ID ' ]] );
455469
@@ -459,11 +473,14 @@ function FinalGradesSemOrFYCalculate( $cp_id, $mp_id, $mode = 'continue' )
459473 if ( $ total_percent != 0 )
460474 {
461475 $ total /= $ total_percent ;
476+
477+ $ total /= 100 ;
462478 }
463479
464- if ( $ total > 999.9 )
480+ if ( $ total > 9.999 )
465481 {
466- $ total = '999.9 ' ;
482+ // Fix SQL error when percent grade > 999.9
483+ $ total = '9.999 ' ;
467484 }
468485 elseif ( $ total < 0 )
469486 {
@@ -472,9 +489,9 @@ function FinalGradesSemOrFYCalculate( $cp_id, $mp_id, $mode = 'continue' )
472489
473490 $ import_RET [$ student_id ] = [
474491 1 => [
475- 'REPORT_CARD_GRADE_ID ' => _makeLetterGrade ( $ total / 100 , $ cp_id , 0 , 'ID ' ),
476- 'GRADE_LETTER ' => _makeLetterGrade ( $ total / 100 , $ cp_id , 0 , 'TITLE ' ),
477- 'GRADE_PERCENT ' => round ( $ total , 1 ),
492+ 'REPORT_CARD_GRADE_ID ' => _makeLetterGrade ( $ total , $ cp_id , 0 , 'ID ' ),
493+ 'GRADE_LETTER ' => _makeLetterGrade ( $ total , $ cp_id , 0 , 'TITLE ' ),
494+ 'GRADE_PERCENT ' => is_null ( $ total ) ? null : round ( $ total * 100 , 1 ),
478495 ],
479496 ];
480497 }
0 commit comments