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
 
@@ -251,13 +251,13 @@ class page
 
    echo '      </div> <!-- id="content" -->'. PHP_EOL;
 
    echo '      <div id="footer">'. PHP_EOL .
 
  	 '        <div id="leftfoot">'. PHP_EOL .
 
	 '          <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;
 
    echo $this->trackingcode;
 
    echo '  </body>'. PHP_EOL .
 
         '</html>' . PHP_EOL;
inc/class.schedule.php
Show inline comments
 
@@ -526,19 +526,19 @@ class Schedule
 
					$title .= ' ';
 

	
 
				      $carret = '&#013;' . htmlentities("<br />");
 
				      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";
 

	
 
				      /* for the ``Registration Codes'' dialogue: */
 
				      if (empty($permutations_courses[$j]))
inc/class.section.php
Show inline comments
 
@@ -27,13 +27,13 @@
 
require_once dirname(__FILE__) . DIRECTORY_SEPARATOR . 'class.section_meeting.inc';
 
   
 
class Section
 
{
 

	
 
  private $letter;	// Section letter
 
  private $prof;	// Professor
 
  private $prof;	// Professor, preserved for Section::__wakeup()
 

	
 
  /* meeting times, array of SectionMeeting */
 
  private $meetings;
 

	
 
  /* the section synonym which uniquely identifies this section/course combination */
 
  private $synonym;
 
@@ -53,36 +53,27 @@ class Section
 
   *   this. Another example, Cedarville lists different meeting times
 
   *   inside of a single section. Cedarville also lists all lectures
 
   *   and lab meeting times directly in a section's listing.
 
   * \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()
 
  {
 
    return $this->letter;
 
  }
 

	
 
  public function getProf()
 
  {
 
    return $this->prof;
 
  }
 

	
 
  /**
 
   * \return
 
   *   This section's synonym -- a unique numeric identifier for this
 
   *   course. NULL if undefined.
 
   */
 
  public function getSynonym()
 
@@ -211,13 +202,12 @@ class Section
 
  {
 
    $json_arrays = array();
 

	
 
    foreach ($this->meetings as $meeting)
 
      {
 
	$json_array = array('section' => $this->letter,
 
			    'prof' => $this->prof,
 
			    'synonym' => $this->synonym,
 
			    );
 

	
 
	$json_array += $meeting->to_json_array();
 
	$json_arrays[] = $json_array;
 
      }
 
@@ -246,21 +236,19 @@ class Section
 
   */
 
  public static function from_json_arrays(array $json_arrays)
 
  {
 
    $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;
 
  }
 

	
 
  /* for legacy unserialization */
 
  private $start;
 
@@ -284,15 +272,22 @@ class Section
 
	    $days .= $daymap[$day];
 

	
 
	/* the old format had a ->prof but initialied it to ``unknown prof'' */
 
	$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
 
@@ -36,12 +36,13 @@
 
class SectionMeeting
 
{
 
  private $time_start;
 
  private $time_end;
 
  private $days;
 
  private $location;
 
  private $instructor;
 

	
 
  /**
 
   * \brief
 
   *   Construct a SectionMeeting.
 
   *
 
   * \param $days
 
@@ -55,23 +56,26 @@ class SectionMeeting
 
   * \param $location
 
   *   Where the meeting occurs. Often a room number of some sort.
 
   * \param $type
 
   *   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);
 

	
 
    $this->time_start = $time_start;
 
    $this->time_end = $time_end;
 

	
 
    $this->location = $location;
 

	
 
    $this->type = $type;
 
    $this->instructor = $instructor;
 
  }
 

	
 
  /**
 
   * \brief
 
   *   Take a days of week string and store it into our $days of week array.
 
   *
 
@@ -102,12 +106,37 @@ class SectionMeeting
 

	
 
    return $day_atoi[$day_c];
 
  }
 

	
 
  /**
 
   * \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.
 
   *
 
   * \param $day
 
   *   The letter or numeral of the day to retrieve.
 
   * \return
 
@@ -215,12 +244,13 @@ class SectionMeeting
 

	
 
    $json_array = array(
 
			'time_start' => $this->time_start,
 
			'time_end' => $this->time_end,
 
			'days' => array(),
 
			'location' => $this->location,
 
			'instructor' => $this->instructor,
 
			'type' => $this->type,
 
			);
 

	
 
    for ($day = 0; $day < 6; $day ++)
 
      $json_array['days'][$daymap[$day]] = $this->getDay($day);
 

	
 
@@ -239,9 +269,9 @@ class SectionMeeting
 
  public static function from_json_array(array $json_array)
 
  {
 
    $days = '';
 
    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
 
@@ -192,32 +192,30 @@ class Semester
 
   *   NULL.
 
   *   belongs to.
 
   * \param $section
 
   *   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);
 

	
 
    if (empty($this->departments[$dept][$course]))
 
      $course_obj = NULL;
 
    else
 
      {
 
	$course_obj = $this->departments[$dept][$course];
 
	$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
 
@@ -266,13 +266,13 @@ function input_class_js(Course $course, 
 
	  $js .= $whitespace . 'add_section_n(class_last, ' . json_encode($section->getLetter()) . ', '
 
	    . json_encode($section->getSynonym()) . ', '
 
	    . json_encode($meeting->getStartTime()) . ', '
 
	    . 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;
 
	}
 
    }
 

	
 
  return $js;
school.d/calvin.crawl.inc
Show inline comments
 
@@ -348,13 +348,13 @@ function calvin_crawl(array &$semesters,
 
	  $time_end = school_crawl_time_format(strptime($meeting_info_matches[7], '%I:%M%p'));
 
	  $meeting_place = $meeting_info_matches[8];
 

	
 
	  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);
 

	
 
	  /*
 
	   * Try to update semester's longetivity stats to help the
 
	   * school_semester_guess() function:
 
	   */
school.d/ccbcmd.crawl.inc
Show inline comments
 
@@ -190,13 +190,13 @@ function ccbcmd_crawl(array &$semesters,
 
	    /*
 
	     * Add the section to the autocomplete list, just without
 
	     * any meeting info (i.e., $section_meetings is still
 
	     * 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;
 

	
 
	  }
 
	if (($dash_pos = strpos($time_range_text, '-')) === FALSE)
 
	  {
 
	    school_crawl_logf($school_crawl_log, 0, "Unable to understand course's time range format, cannot find dash: ``%s''.",
 
@@ -228,25 +228,26 @@ function ccbcmd_crawl(array &$semesters,
 
	    return 1;
 
	  }
 

	
 
	$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;
 
	if (preg_match(';^([0-9]+)/([0-9]+)-([0-9]+)/([0-9]+)$;', $section_dates, $section_dates_matches))
 
	  {
 
	    $semester->time_start_set_test(mktime(0, 0, 0, $section_dates_matches[1], $section_dates_matches[2], $semester->year_get()));
 
	    $semester->time_end_set_test(  mktime(0, 0, 0, $section_dates_matches[3], $section_dates_matches[4], $semester->year_get()));
 
	  }
 
      }
 

	
 
      $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;
 
    }
 

	
 
  return 0;
school.d/cedarville.crawl.inc
Show inline comments
 
@@ -129,14 +129,12 @@ function cedarville_crawl(array &$semest
 
      $html = file_get_contents($basepath . $semester_href_parts[0] . '_' . $department . '_' . 'all.htm');
 
      if (!$html)
 
	continue;
 
      $tables[$department] = table_parse(cedarville_html_fix($html));
 
    }
 

	
 
  $meeting_type_maps = array('LAB' => 'lab', 'LECT' => 'lecture');
 

	
 
  foreach ($tables as $dept_table)
 
    {
 
      /*
 
       * Discard the first row, which has the contents of the <th />
 
       * elements.
 
       */
 
@@ -233,16 +231,13 @@ function cedarville_crawl(array &$semest
 

	
 
	      $days = school_crawl_days_str_format($meeting_matches[3]);
 
	      $time_start = school_crawl_time_format(strptime($meeting_matches[4] . 'M', '%I:%M%p'));
 
	      $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)
 
		{
 
		  $date_start = school_crawl_mktime(strptime($meeting_matches[6], '%m/%d/%y'));
 
		  $date_end = school_crawl_mktime(strptime($meeting_matches[7], '%m/%d/%y'));
 
@@ -251,18 +246,18 @@ function cedarville_crawl(array &$semest
 
		      $semester->time_start_set_test($date_start);
 
		      $semester->time_end_set_test($date_end);
 
		    }
 
		}
 

	
 
	      $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);
 
	}
 
    }
 

	
 
  $semesters[] = $semester;
 
    }
 

	
school.d/umich.crawl.inc
Show inline comments
 
@@ -227,14 +227,17 @@ function umich_crawl_csv($school_crawl_l
 
	  continue;
 
	}
 
      $time_end = umich_crawl_time($matches[2], $matches[3]);
 
      $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']])));
 
    }
 
}
 

	
 
/**
 
 * \brief
 
 *   Try to turn a umich-formatted time into something usable.
scripts/scheduleInput.js
Show inline comments
 
@@ -99,13 +99,13 @@ 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;
 

	
 
    if(type == 'lab')
 
	cssclasses += ' lab';
 
@@ -186,13 +186,13 @@ function add_section_n(cnum, name, synon
 
     * Store data into the newly created HTML. With this method we
 
     * have to _avoid_ escaping entities in the text we're setting as
 
     * values because the DOM stuff will escape it for us.
 
     */
 
    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);
 

	
 
    /* unhide the saturday columns if it's used by autocomplete data */
 
    if (days.s)
 
	jQuery('#jsrows col.saturday').removeClass('collapsed');
 
@@ -224,13 +224,13 @@ function add_sections(cnum, data)
 
     * them in the correct order, we must reverse the add_setion_n()
 
     * calls.
 
     */
 
    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);
 
	}
 

	
 
    /*
 
     * Handle course-level interdependencies.
 
     */
 
    if (data.dependencies)
0 comments (0 inline, 0 general)