diff --git a/inc/class.schedule.php b/inc/class.schedule.php --- a/inc/class.schedule.php +++ b/inc/class.schedule.php @@ -1,4 +1,4 @@ - Course converter class for the sake of the @@ -188,7 +189,7 @@ class Schedule * NULL on success, a string on error which is a message for the * user and a valid XHTML fragment. */ - function addSection($course_name, $letter, $time_start, $time_end, $days, $synonym = NULL, $instructor = NULL, $location = NULL, $type = 'lecture', $slot = 'default') + function addSection($course_name, $letter, $time_start, $time_end, $days, $synonym = NULL, $instructor = NULL, $location = NULL, $type = 'lecture', $slot = 'default', $credit_hours = -1.0) { if (empty($letter) && (empty($time_start) || !strcmp($time_start, 'none')) && (empty($time_end) || !strcmp($time_end, 'none')) && empty($days) && empty($synonym) && empty($instructor) && empty($location) && (empty($type) || !strcmp($type, 'lecture')) @@ -203,13 +204,18 @@ class Schedule . '. Start time: ' . htmlentities($time_start) . '. End time: ' . htmlentities($time_end) . '.'; } + if (!empty($credit_hours) && !is_numeric($credit_hours)) + { + return 'Invalid credit-hour specification of ' . htmlentities($credit_hours) . ' for ' . htmlentities($course_name) . '-' . htmlentities($letter) . '. Please use a floating point number or do not enter anything if the number of credit hours is not known.'; + } + foreach ($this->courses as $course) if (!strcmp($course_name, $course->getName())) { $section = $course->section_get($letter); if (!$section) { - $section = new Section($letter, array(), $synonym); + $section = new Section($letter, array(), $synonym, $credit_hours); $course->section_add($section, $slot); } $section->meeting_add(new SectionMeeting($days, $time_start, $time_end, $location, $type, $instructor)); @@ -529,7 +535,7 @@ class Schedule foreach ($course as $course_slot) { for ($si = 0; $si < $course_slot->sections_count(); $si ++) - foreach ($course_slot->section_get_i($si)->getMeetings() as $meeting) + foreach ($course_slot->section_get_i($si)->getMeetings() as $meeting) { /* Saturdayness */ if ($meeting->getDay(5)) @@ -587,6 +593,7 @@ class Schedule +

' @@ -645,6 +652,13 @@ class Schedule */ $permutation_courses = array(); + /* + * Count the number of credit hours in this particular + * schedule. + */ + $credit_hours = array(); + $have_credit_hours = FALSE; + echo '
\n"; // Beginning of table @@ -724,13 +738,24 @@ class Schedule . '" title="' . htmlentities($title, ENT_QUOTES) . $carret . 'Prof: ' . htmlentities($current_meeting->instructor_get(), ENT_QUOTES) . $carret . 'Room: ' . htmlentities($current_meeting->getLocation(), ENT_QUOTES) . $carret - . 'Type: ' . htmlentities($current_meeting->type_get(), ENT_QUOTES) . $carret . '">' + . 'Type: ' . htmlentities($current_meeting->type_get(), ENT_QUOTES) . $carret; + + $section_credit_hours = $section->credit_hours_get(); + if ($section_credit_hours >= 0) + { + $credit_hours[$section->getSynonym()] = $section_credit_hours; + $have_credit_hours = TRUE; + + echo 'Credits: ' . htmlentities($section_credit_hours, ENT_QUOTES) . $carret; + } + echo '">' . '' . htmlentities($title) . '' . PHP_EOL . htmlentities($course->getName(), ENT_QUOTES) . '-' . htmlentities($section->getLetter(), ENT_QUOTES) . "\n" . '' . htmlentities($current_meeting->instructor_get(), ENT_QUOTES) . "\n" . '' . htmlentities($current_meeting->getLocation(), ENT_QUOTES) . "\n" . '' . htmlentities($section->getSynonym(), ENT_QUOTES) . "\n" + . '' . htmlentities($section_credit_hours, ENT_QUOTES) . ' Credits' . PHP_EOL . "\n"; /* for the ``Registration Codes'' dialogue: */ @@ -766,8 +791,13 @@ class Schedule } // End of table - echo " \n" - . ' '. htmlentities(json_encode($permutation_courses)) . "\n" + echo " \n"; + + if ($have_credit_hours) + echo '

Credit Hours: ' . sum($credit_hours) . '

' . PHP_EOL; + + echo '' + . ' '. htmlentities(json_encode($permutation_courses)) . "\n" . '
\n"; }