Changeset - fc1e0b24a7eb
[Not reviewed]
default
0 11 0
Nathan Brink (binki) - 15 years ago 2011-03-26 11:34:05
ohnobinki@ohnopublishing.net
Move the professor field to the section_meeting class as at least cedarville has different professors for different section meetings.
11 files changed with 65 insertions and 43 deletions:
0 comments (0 inline, 0 general)
inc/class.page.php
Show inline comments
 
@@ -254,7 +254,7 @@ class page
 
	 '          <a href="feedback.php">Contact Us</a>'. PHP_EOL .
 
         '        </div>'. PHP_EOL .
 
         '        <div id="rightfoot">'. PHP_EOL .
 
         '          <h5>&copy; '. date('Y').' <a href="http://protofusion.org/~nathang/">Nathan Gelderloos</a><br /><a href="http://ethanzonca.com">Ethan Zonca</a><br /><a href="http://ohnopub.net">Nathan Phillip Brink</a></h5>'. PHP_EOL .
 
         '          <h5>&copy; '. date('Y').' <a href="http://protofusion.org/~nathang/">Nathan Gelderloos</a><br /><a href="http://ethanzonca.com">Ethan Zonca</a><br /><a href="http://ohnopub.net">Nathan Phillip Brink</a><br /></h5>'. PHP_EOL .
 
	 '        </div>'. PHP_EOL .
 
         '      </div> <!-- id="footer" -->'. PHP_EOL .
 
         '    </div> <!-- id="page" -->'. PHP_EOL;
inc/class.schedule.php
Show inline comments
 
@@ -529,13 +529,13 @@ class Schedule
 
				      echo '            <td rowspan="' . $rowspan[$dayLoop]
 
					. '" class="qTipCell ' . $single_multi . ' class' . $j
 
					. '" title="' . htmlentities($title, ENT_QUOTES) . $carret
 
					. 'Prof: ' . htmlentities($section->getProf(), 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 . '">'
 
					. '<span class="course-title block">' . htmlentities($title) . '</span>' . PHP_EOL
 
					. htmlentities($course->getName(), ENT_QUOTES) . '-'
 
					. htmlentities($section->getLetter(), ENT_QUOTES) . "\n"
 
					. '<span class="prof block">' . htmlentities($section->getProf(), ENT_QUOTES) . "</span>\n"
 
					. '<span class="prof block">' . htmlentities($current_meeting->instructor_get(), ENT_QUOTES) . "</span>\n"
 
					. '<span class="location block">' . htmlentities($current_meeting->getLocation(), ENT_QUOTES) . "</span>\n"
 
					. '<span class="synonym block">' . htmlentities($section->getSynonym(), ENT_QUOTES) . "</span>\n"
 
					. "</td>\n";
inc/class.section.php
Show inline comments
 
@@ -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);
 
  }
 
}
 
}
inc/class.section_meeting.inc
Show inline comments
 
@@ -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']);
 
  }
 
}
inc/class.semester.inc
Show inline comments
 
@@ -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;
input.php
Show inline comments
 
@@ -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;
 
	}
school.d/calvin.crawl.inc
Show inline comments
 
@@ -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);
 

	
 
	  /*
school.d/ccbcmd.crawl.inc
Show inline comments
 
@@ -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;
school.d/cedarville.crawl.inc
Show inline comments
 
@@ -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);
 
	}
 
    }
 

	
school.d/umich.crawl.inc
Show inline comments
 
@@ -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']])));
 
    }
 
}
 

	
scripts/scheduleInput.js
Show inline comments
 
@@ -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);
 
	}
 

	
 
    /*
0 comments (0 inline, 0 general)