Code Duplication    Length = 24-27 lines in 2 locations

main/gradebook/lib/be/category.class.php 2 locations

@@ 930-953 (lines=24) @@
927
            $ressum = 0;
928
            $weightsum = 0;
929
930
            if (!empty($cats)) {
931
                /** @var Category $cat */
932
                foreach ($cats as $cat) {
933
                    $cat->set_session_id($session_id);
934
                    $cat->set_course_code($course_code);
935
                    $cat->setStudentList($this->getStudentList());
936
                    $score = $cat->calc_score(
937
                        $stud_id,
938
                        null,
939
                        $course_code,
940
                        $session_id
941
                    );
942
943
                    $catweight = 0;
944
                    if ($cat->get_weight() != 0) {
945
                        $catweight = $cat->get_weight();
946
                        $weightsum += $catweight;
947
                    }
948
949
                    if (isset($score) && !empty($score[1]) && !empty($catweight)) {
950
                        $ressum += $score[0]/$score[1] * $catweight;
951
                    }
952
                }
953
            }
954
955
            $students = array();
956
@@ 1021-1047 (lines=27) @@
1018
            $weightsum = 0;
1019
            $bestResult = 0;
1020
1021
            if (!empty($cats)) {
1022
                /** @var Category $cat */
1023
                foreach ($cats as $cat) {
1024
                    $cat->setStudentList($this->getStudentList());
1025
                    $score = $cat->calc_score(
1026
                        null,
1027
                        $type,
1028
                        $course_code,
1029
                        $session_id
1030
                    );
1031
1032
                    $catweight = 0;
1033
                    if ($cat->get_weight() != 0) {
1034
                        $catweight = $cat->get_weight();
1035
                        $weightsum += $catweight;
1036
                    }
1037
1038
                    if (isset($score) && !empty($score[1]) && !empty($catweight)) {
1039
                        $ressum += $score[0]/$score[1] * $catweight;
1040
1041
                        if ($ressum > $bestResult) {
1042
                            $bestResult = $ressum;
1043
                        }
1044
                    }
1045
1046
                }
1047
            }
1048
1049
            if (!empty($evals)) {
1050
                /** @var Evaluation $eval */