Changeset - 60bdc2d2972a
[Not reviewed]
default
0 5 0
Nathan Brink (binki) - 15 years ago 2010-10-16 20:49:32
ohnobinki@ohnopublishing.net
Make the professor attribute of the Section class optionalish.
5 files changed with 10 insertions and 18 deletions:
0 comments (0 inline, 0 general)
class.class.php
Show inline comments
 
@@ -14,33 +14,24 @@ class Classes
 
  private $sections;	// Array of sections
 
  private $nsections;	// int
 
    
 
  //--------------------------------------------------
 
  // Creates a class with the given name.
 
  //--------------------------------------------------
 
  function __construct($n)
 
  {
 
    $this->name = $n;
 
    $this->nsections = 0;
 
  }
 
	
 
  //--------------------------------------------------
 
  // Adds a new section to the class.
 
  //--------------------------------------------------
 
  function addSection($l, $p, $s, $e, $d)
 
  {
 
    $this->sections[$this->nsections] = new Section($l, $p, $s, $e, $d);
 
    $this->nsections++;
 
  }
 

	
 
  /**
 
   * \brief
 
   *   Adds an already-instantiated section to this class.
 
   */
 
  public function section_add(Section $section)
 
  {
 
    $this->sections[$this->nsections] = $section;
 
    $this->nsections ++;
 
  }
 

	
 
  //--------------------------------------------------
 
  // Returns the number of sections in the class.
class.schedule.php
Show inline comments
 
@@ -83,26 +83,25 @@ class Schedule
 
	if((strcmp($temp,$n)) == 0)
 
	  {
 
	    $found = true;
 
	  } else {
 
	  $counter++;
 
	}
 
      }
 
		
 
    if($counter == $this->nclasses)
 
      {
 
	echo "Could not find class: " . $n . "<br />";
 
      } else {
 
      $p = "unknown prof";
 
      $this->classStorage[$counter]->addSection($l, $p, $s, $e, $d);
 
      $this->classStorage[$counter]->section_add(new Section($l, $s, $e, $d));
 
    }
 
  }
 

	
 
  //--------------------------------------------------
 
  // Finds all of the possible permutations and stores
 
  // the results in the storage array.
 
  //--------------------------------------------------
 
	function findPossibilities()
 
	{
 
		$this->possiblePermutations = 1;
 
		/* special case: there is nothing entered into the schedule and thus there is one, NULL permutation */
 
		if (!$this->nclasses)
class.section.php
Show inline comments
 
@@ -14,49 +14,51 @@ class Section
 
  private $start;	// Start time
 
  private $tend;	// End time
 
  private $idays;	// Integer version of meeting days
 
  private $bdays;	// Boolean array of meeting days
 

	
 
  /**
 
   * \brief
 
   *   Construct a Section.
 
   *
 
   * \param $letter
 
   *   The identifier (often a letter or numeral) of this section. For
 
   *   CS-262-A, this would be 'a'.
 
   * \param $prof
 
   *   The faculty person(s) who teaches this section.
 
   * \param $time_start
 
   *   The time of day when this section meets. Formatted as a string,
 
   *   with the 24-hr representation of the hour taking the first two
 
   *   characters and a two-digit representation of minutes taking the
 
   *   next two characters.
 
   * \param $time_end
 
   *   The time of day when this section's meeting is over.
 
   * \param $days
 
   *   A string representing the days that this section meets. The
 
   *   format of this string is an ordered series of numerals less
 
   *   than or equal to 5. Each numeral from 1 through 5 represents
 
   *   one of Monday, Tuesday, Wednesday, Thursday, and Friday. For
 
   *   example, '135' would be for a course which meets on Monday,
 
   *   Wednesday, and Friday.
 
   * \param $prof
 
   *   The faculty person(s) who teaches this section.
 
   */
 
  function __construct ($letter, $prof, $time_start, $time_end, $days)
 
  function __construct ($letter, $time_start, $time_end, $days, $prof = '')
 
  {
 
    $this->letter = $letter;
 
    $this->prof = $prof;
 
    $this->start = $time_start;
 
    $this->tend = $time_end;
 

	
 
    $this->idays = $days;
 
    $this->bdays = $this->setbdays();
 

	
 
    $this->prof = $prof;
 
  }
 

	
 
  function setbdays()
 
  {
 
    $result = array(FALSE, FALSE, FALSE, FALSE, FALSE);
 

	
 
    if($this->idays == 12345)
 
      {$result[0] = true; $result[1] = true; $result[2] = true; $result[3] = true; $result[4] = true;}
 

	
 
    if($this->idays == 1234)
 
      {$result[0] = true; $result[1] = true; $result[2] = true; $result[3] = true; $result[4] = false;}
 
    if($this->idays == 1235)
school.d/calvin.crawl.inc
Show inline comments
 
@@ -311,25 +311,25 @@ function calvin_crawl(Semester $semester
 
	  $date_end = $meeting_info_matches[2];
 
	  /* e.g., 'Lecture', 'Practicum' */
 
	  $meeting_type = $meeting_info_matches[3];
 
	  $days = school_crawl_days_format(explode(', ', $meeting_info_matches[4]));
 
	  $time_start = school_crawl_time_format(strptime($meeting_info_matches[5], '%I:%M%p'));
 
	  $time_end = school_crawl_time_format(strptime($meeting_info_matches[6], '%I:%M%p'));
 
	  $meeting_place = $meeting_info_matches[7];
 

	
 
	  if ($verbosity > 5)
 
	    foreach (array('date_start', 'date_end', 'meeting_type', 'days', 'time_start', 'time_end', 'meeting_place') as $var)
 
	      echo $var . ':' . ${$var} . "\n";
 

	
 
	  $section = new Section($section_id['section'], $faculty_name, $time_start, $time_end, $days);
 
	  $section = new Section($section_id['section'], $time_start, $time_end, $days, $faculty_name);
 
	  $semester->section_add($section_id['department'], $section_id['course'], $section);
 
	}
 

	
 
      if (!preg_match(';Page ([0-9]+) of ([0-9]+)\</td\>$;m', $html, $pages))
 
	{
 
	  error_log('Unable to determine the number of pages in this Calvin resultset');
 
	  break;
 
	}
 

	
 
      if ($verbosity > 0)
 
	{
 
	  echo 'calvin_crawl(): finished page ' . $pages[1] . ' of ' . $pages[2] . ' with ' . ($list_row - 1) . " courses.\n";
school.d/cedarville.inc
Show inline comments
 
@@ -193,27 +193,27 @@ function cedarville_crawl($semester, $ve
 
			);
 
	    }
 

	
 
	  foreach ($meetings as $meeting)
 
	    {
 
	      $section_letter = $section_parts['section'];
 
	      if ($meeting['type'] == 'LECT')
 
		/**
 
		 * \todo this might not make much sense.		 
 
		 */
 
		$section_letter = 'L' . $section_letter;
 
	      $semester->section_add($section_parts['department'], $section_parts['course'],
 
				     new Section($section_letter, $instructor,
 
				     new Section($section_letter,
 
						 $meeting['time_start'], $meeting['time_end'],
 
						 $meeting['days']));
 
						 $meeting['days'], $instructor));
 
	    }
 
	}
 
    }
 

	
 
  return 0;
 
}
 

	
 
/**
 
 * \brief
 
 *   Fix some incorrect usage of the HTML entity delimiter, the ampersand.
 
 */
 
function cedarville_html_fix($html)
0 comments (0 inline, 0 general)