Няма описание

123456789101112131415161718192021222324252627
  1. <?php
  2. if (!function_exists('calcExtraCredits')) {
  3. /**
  4. * Calculates extra credits according to http://www.upr.edu/mdocs-posts/certificacion-num-60-2015-2016-enmienda-a-la-cert-105/
  5. * @param float $credits
  6. * @param int $student_count
  7. * @param bool $grad True if graduate course
  8. * @return float
  9. */
  10. function calcExtraCredits($credits, $student_count, $grad = false)
  11. {
  12. return max(0, round(($credits ?? 0) * (($student_count ?? 0) - ($grad ? 60 : 30)) / ($grad ? 60 : 30)) / 2);
  13. }
  14. }
  15. if (!function_exists('cmpCourseCode')) {
  16. /**
  17. * Compares courses by last 4 digits or first 4 characters if digits are equal
  18. * @param Course $c1, $c2
  19. * @return int
  20. */
  21. function cmpCourseCode($c1, $c2) {
  22. return (substr($c1->code, -4) - substr($c2->code, -4)) ?: strcmp($c1->code, $c2->code);
  23. }
  24. }