# HG changeset patch # User Nathan Phillip Brink # Date 2011-03-26 11:34:05 # Node ID fc1e0b24a7ebfe3296f9c139f86760e619665ee5 # Parent 00ee77c16418443647b1fa26693ed03c9b648c7b Move the professor field to the section_meeting class as at least cedarville has different professors for different section meetings. diff --git a/inc/class.page.php b/inc/class.page.php --- a/inc/class.page.php +++ b/inc/class.page.php @@ -254,7 +254,7 @@ class page ' Contact Us'. PHP_EOL . ' '. PHP_EOL . '
'. PHP_EOL . - '
© '. date('Y').' Nathan Gelderloos
Ethan Zonca
Nathan Phillip Brink
'. PHP_EOL . + '
© '. date('Y').' Nathan Gelderloos
Ethan Zonca
Nathan Phillip Brink
'. PHP_EOL . '
'. PHP_EOL . ' '. PHP_EOL . ' '. PHP_EOL; diff --git a/inc/class.schedule.php b/inc/class.schedule.php --- a/inc/class.schedule.php +++ b/inc/class.schedule.php @@ -529,13 +529,13 @@ class Schedule echo ' ' . '' . htmlentities($title) . '' . PHP_EOL . htmlentities($course->getName(), ENT_QUOTES) . '-' . htmlentities($section->getLetter(), ENT_QUOTES) . "\n" - . '' . htmlentities($section->getProf(), ENT_QUOTES) . "\n" + . '' . htmlentities($current_meeting->instructor_get(), ENT_QUOTES) . "\n" . '' . htmlentities($current_meeting->getLocation(), ENT_QUOTES) . "\n" . '' . htmlentities($section->getSynonym(), ENT_QUOTES) . "\n" . "\n"; diff --git a/inc/class.section.php b/inc/class.section.php --- a/inc/class.section.php +++ b/inc/class.section.php @@ -30,7 +30,7 @@ class Section { private $letter; // Section letter - private $prof; // Professor + private $prof; // Professor, preserved for Section::__wakeup() /* meeting times, array of SectionMeeting */ private $meetings; @@ -56,18 +56,14 @@ class Section * \param $synonym * Some schools have a unique number for each section. This field * is for that number. - * \param $prof - * The faculty person(s) who teaches this section. */ - function __construct ($letter, array $section_meetings = array(), $synonym = NULL, $prof = NULL) + function __construct ($letter, array $section_meetings = array(), $synonym = NULL) { $this->letter = $letter; $this->meetings = $section_meetings; $this->synonym = $synonym; - - $this->prof = $prof; } public function getLetter() @@ -75,11 +71,6 @@ class Section return $this->letter; } - public function getProf() - { - return $this->prof; - } - /** * \return * This section's synonym -- a unique numeric identifier for this @@ -214,7 +205,6 @@ class Section foreach ($this->meetings as $meeting) { $json_array = array('section' => $this->letter, - 'prof' => $this->prof, 'synonym' => $this->synonym, ); @@ -249,15 +239,13 @@ class Section $section_meetings = array(); $letter = ''; $synonym = NULL; - $prof = NULL; foreach ($json_arrays as $meeting) { $letter = $meeting['section']; $synonym = $meeting['synonym']; - $prof = $meeting['prof']; $section_meetings[] = SectionMeeting::from_json_array($meeting); } - $section = new Section($letter, $section_meetings, $synonym, $prof); + $section = new Section($letter, $section_meetings, $synonym); return $section; } @@ -287,12 +275,19 @@ class Section $this->prof = ''; $this->meetings = array(); - $this->meeting_add(new SectionMeeting($days, $this->start, $this->tend, '', 'lecture')); + $this->meeting_add(new SectionMeeting($days, $this->start, $this->tend, '', 'lecture', $this->prof)); /* * if we're reserialized in the future, make sure we don't do this same upgrade procedure again ;-). */ unset($this->start); } + elseif (!empty($this->prof)) + /* Move the instructor (old $this->prof) property to our SectionMeeting children */ + foreach ($this->meetings as $meeting) + { + $meeting->instructor_set(); + unset($this->prof); + } } } diff --git a/inc/class.section_meeting.inc b/inc/class.section_meeting.inc --- a/inc/class.section_meeting.inc +++ b/inc/class.section_meeting.inc @@ -39,6 +39,7 @@ class SectionMeeting private $time_end; private $days; private $location; + private $instructor; /** * \brief @@ -58,8 +59,10 @@ class SectionMeeting * The type of meeting this is. For lectures, please use * 'lecture'. For labs, please use 'lab'. For others, use the * school's notation. + * \param $instructor + * The instructor for this section meeting. */ - public function __construct($days, $time_start, $time_end, $location = NULL, $type = 'lecture') + public function __construct($days, $time_start, $time_end, $location = NULL, $type = 'lecture', $instructor = NULL) { $this->days_set($days); @@ -69,6 +72,7 @@ class SectionMeeting $this->location = $location; $this->type = $type; + $this->instructor = $instructor; } /** @@ -105,6 +109,31 @@ class SectionMeeting /** * \brief + * For Section::__wakeup(). + * + * \param $instructor + * New instructor's name, a string. + */ + public function instructor_set($instructor) + { + $this->instructor = $instructor; + } + + /** + * \brief + * Get the instructor's name. + * + * \return + * The instructor's name as a string or NULL if there is no given + * instructor. + */ + public function instructor_get() + { + return $this->instructor; + } + + /** + * \brief * Determine whether or not this class meeting time meets on a * specified day of the week or not. * @@ -218,6 +247,7 @@ class SectionMeeting 'time_end' => $this->time_end, 'days' => array(), 'location' => $this->location, + 'instructor' => $this->instructor, 'type' => $this->type, ); @@ -242,6 +272,6 @@ class SectionMeeting foreach ($json_array['days'] as $day => $meets) if ($meets) $days .= $day; - return new SectionMeeting($days, $json_array['time_start'], $json_array['time_end'], $json_array['location'], $json_array['type']); + return new SectionMeeting($days, $json_array['time_start'], $json_array['time_end'], $json_array['location'], $json_array['type'], $json_array['instructor']); } } diff --git a/inc/class.semester.inc b/inc/class.semester.inc --- a/inc/class.semester.inc +++ b/inc/class.semester.inc @@ -195,13 +195,11 @@ class Semester * The letter or numbers which make up the section's name. * \param $synonym * The section synonym or NULL. - * \param $professor - * The section's professor or NULL. * \param $section_meeting * The SectionMeeting to be added to a section which may or may * not already be in this Semester. */ - public function section_meeting_add($dept, $course, $title, $section, $synonym, $professor, $section_meeting) + public function section_meeting_add($dept, $course, $title, $section, $synonym, $section_meeting) { $dept = strtoupper($dept); $course = strtoupper($course); @@ -214,7 +212,7 @@ class Semester $section_obj = $course_obj->section_get($section); } if (empty($course_obj) || empty($section_obj)) - return $this->section_add($dept, $course, new Section($section, array($section_meeting), $synonym, $professor), $title); + return $this->section_add($dept, $course, new Section($section, array($section_meeting), $synonym), $title); $section_obj->meeting_add($section_meeting); return; diff --git a/input.php b/input.php --- a/input.php +++ b/input.php @@ -269,7 +269,7 @@ function input_class_js(Course $course, . json_encode($meeting->getEndTime()) . ', ' . json_encode(array('m' => $meeting->getDay(0), 't' => $meeting->getDay(1), 'w' => $meeting->getDay(2), 'h' => $meeting->getDay(3), 'f' => $meeting->getDay(4), 's' => $meeting->getDay(5))) . ', ' - . json_encode($section->getProf()) . ', ' + . json_encode($meeting->instructor_get()) . ', ' . json_encode($meeting->getLocation()) . ',' . json_encode($meeting->type_get()) . ');' . PHP_EOL; } diff --git a/school.d/calvin.crawl.inc b/school.d/calvin.crawl.inc --- a/school.d/calvin.crawl.inc +++ b/school.d/calvin.crawl.inc @@ -351,7 +351,7 @@ function calvin_crawl(array &$semesters, foreach (array('date_start', 'date_end', 'meeting_type', 'days', 'time_start', 'time_end', 'meeting_place', 'meeting_type') as $var) school_crawl_logf($school_crawl_log, 10, "%s:%s", $var, ${$var}); - $section = new Section($section_id['section'], array(new SectionMeeting($days, $time_start, $time_end, $meeting_place, $meeting_type)), $synonym, $faculty_name); + $section = new Section($section_id['section'], array(new SectionMeeting($days, $time_start, $time_end, $meeting_place, $meeting_type, $faculty_name)), $synonym); $semester->section_add($section_id['department'], $section_id['course'], $section, $title); /* diff --git a/school.d/ccbcmd.crawl.inc b/school.d/ccbcmd.crawl.inc --- a/school.d/ccbcmd.crawl.inc +++ b/school.d/ccbcmd.crawl.inc @@ -193,7 +193,7 @@ function ccbcmd_crawl(array &$semesters, * empty now). */ $semester->section_add($section_id_parts['department'], $section_id_parts['course'], - new Section($section_id_parts['section'], $section_meetings, $registration_number, $instructor)); + new Section($section_id_parts['section'], $section_meetings, $registration_number)); continue; } @@ -231,7 +231,8 @@ function ccbcmd_crawl(array &$semesters, $days = school_crawl_days_str_format($children->item($section_offsets['days'])->textContent); $section_meetings[] = new SectionMeeting($days, school_crawl_time_format($time_start), school_crawl_time_format($time_end), - $children->item($section_offsets['location'])->textContent); + $children->item($section_offsets['location'])->textContent, + $instructor); /* check if a semester's date range should be increased */ $section_dates = $children->item($section_offsets['dates'])->textContent; @@ -243,7 +244,7 @@ function ccbcmd_crawl(array &$semesters, } $semester->section_add($section_id_parts['department'], $section_id_parts['course'], - new Section($section_id_parts['section'], $section_meetings, $registration_number, $instructor)); + new Section($section_id_parts['section'], $section_meetings, $registration_number)); } $semesters[] = $semester; diff --git a/school.d/cedarville.crawl.inc b/school.d/cedarville.crawl.inc --- a/school.d/cedarville.crawl.inc +++ b/school.d/cedarville.crawl.inc @@ -132,8 +132,6 @@ function cedarville_crawl(array &$semest $tables[$department] = table_parse(cedarville_html_fix($html)); } - $meeting_type_maps = array('LAB' => 'lab', 'LECT' => 'lecture'); - foreach ($tables as $dept_table) { /* @@ -236,10 +234,7 @@ function cedarville_crawl(array &$semest $time_end = school_crawl_time_format(strptime($meeting_matches[5] . 'M', '%I:%M%p')); $room = $meeting_matches[2]; - $type = $meeting_matches[1]; - while (isset($meeting_type_maps[$type])) - $type = $meeting_type_maps[$type]; - $type = strtolower($type); + $type = school_crawl_meeting_type($meeting_matches[1]); /* check for daterange information -- i.e., if the first regex successfully matched: */ if (count($meeting_matches) > 7) @@ -254,12 +249,12 @@ function cedarville_crawl(array &$semest } $meetings[] = new SectionMeeting($days, $time_start, $time_end, - $room, $type); + $room, $type, $instructor); } $semester->section_add($section_parts['department'], $section_parts['course'], new Section($section_parts['section'], $meetings, - $synonym, $instructor), $title); + $synonym), $title); } } diff --git a/school.d/umich.crawl.inc b/school.d/umich.crawl.inc --- a/school.d/umich.crawl.inc +++ b/school.d/umich.crawl.inc @@ -230,8 +230,11 @@ function umich_crawl_csv($school_crawl_l $time_start = umich_crawl_time($matches[1], FALSE, $time_end); $semester->section_meeting_add($dept, $course_id, trim($row[$fields['Course Title']]), - trim($row[$fields['Section']]), $synonym, trim($row[$fields['Instructor']]), - new SectionMeeting($days, $time_start, $time_end, trim($row[$fields['Location']]), school_crawl_meeting_type(trim($row[$fields['Component']])))); + trim($row[$fields['Section']]), $synonym, + new SectionMeeting($days, $time_start, $time_end, + trim($row[$fields['Location']]), + school_crawl_meeting_type(trim($row[$fields['Component']])), + trim($row[$fields['Instructor']]))); } } diff --git a/scripts/scheduleInput.js b/scripts/scheduleInput.js --- a/scripts/scheduleInput.js +++ b/scripts/scheduleInput.js @@ -102,7 +102,7 @@ function addTips() * \brief * Add a section to a class. */ -function add_section_n(cnum, name, synonym, stime, etime, days, prof, location, type) +function add_section_n(cnum, name, synonym, stime, etime, days, instructor, location, type) { var snum = last_section_i ++; var cssclasses = 'section class' + cnum; @@ -189,7 +189,7 @@ function add_section_n(cnum, name, synon */ section_tr.find('.section-letter-entry').val(name); section_tr.find('.section-synonym-entry').val(synonym); - section_tr.find('.profName').val(prof); + section_tr.find('.profName').val(instructor); section_tr.find('.section-location-entry').val(location); section_tr.find('.section-type-entry').val(type); @@ -227,7 +227,7 @@ function add_sections(cnum, data) for (i = data.sections.length - 1; i >= 0; i --) { section = data.sections[i]; - add_section_n(cnum, section.section, section.synonym, section.time_start, section.time_end, section.days, section.prof, section.location, section.type); + add_section_n(cnum, section.section, section.synonym, section.time_start, section.time_end, section.days, section.instructor, section.location, section.type); } /*