Changeset - 3a5b03ccb906
[Not reviewed]
default
0 4 0
Nathan Brink (binki) - 15 years ago 2010-11-29 23:42:03
ohnobinki@ohnopublishing.net
Propagate the section meeting type through the JSON, JS, and form submission.
4 files changed with 12 insertions and 9 deletions:
0 comments (0 inline, 0 general)
class.schedule.php
Show inline comments
 
@@ -84,13 +84,13 @@ class Schedule
 
    $this->nclasses++;
 
  }
 

	
 
  //--------------------------------------------------
 
  // Adds a section to the desired class.
 
  //--------------------------------------------------
 
  function addSection($course_name, $letter, $time_start, $time_end, $days, $synonym = NULL, $faculty = NULL, $location = NULL)
 
  function addSection($course_name, $letter, $time_start, $time_end, $days, $synonym = NULL, $faculty = NULL, $location = NULL, $type = 'lecture')
 
  {
 
    $found = false;
 
    $counter = 0;
 
      
 
    while(!$found && ($counter < $this->nclasses))
 
      {
 
@@ -111,13 +111,13 @@ class Schedule
 
      $section = $this->classStorage[$counter]->section_get($letter);
 
      if (!$section)
 
	{
 
	  $section = new Section($letter, array(), $synonym, $faculty);
 
	  $this->classStorage[$counter]->section_add($section);
 
	}
 
      $section->meeting_add(new SectionMeeting($days, $time_start, $time_end, $location));
 
      $section->meeting_add(new SectionMeeting($days, $time_start, $time_end, $location, $type));
 
    }
 
  }
 

	
 
  //--------------------------------------------------
 
  // Finds all of the possible permutations and stores
 
  // the results in the storage array.
inc/class.section_meeting.inc
Show inline comments
 
@@ -215,12 +215,13 @@ class SectionMeeting
 

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

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

	
 
    return $json_array;
process.php
Show inline comments
 
@@ -136,13 +136,13 @@ if(!$DEBUG)
 
				$allClasses->addClass($class['name']);
 
		
 
				foreach($class as $section)
 
				  /* Skip the section name, which isn't a section */
 
					if(is_array($section))
 
					{
 
					  $allClasses->addSection($class['name'], $section['letter'], $section['start'], $section['end'], arrayToDays($section['days'], 'alpha'), $section['synonym'], $section['professor'], $section['location']);
 
					  $allClasses->addSection($class['name'], $section['letter'], $section['start'], $section['end'], arrayToDays($section['days'], 'alpha'), $section['synonym'], $section['professor'], $section['location'], $section['type']);
 
					}
 
			}
 
		}
 
		$allClasses->findPossibilities();
 
		if (!isset($_SESSION['saved']))
 
		  $_SESSION['saved'] = array();
scripts/scheduleInput.js
Show inline comments
 
@@ -127,13 +127,13 @@ jQuery.validator.addClassRules('classReq
 
function genSectionHtml(cnum)
 
{
 
    genSectionHtml_n(cnum, '', '', '', '', '', '', '');
 
}
 

	
 
/* @TODO: This should select & set items based on args, if the args != '' */
 
function genSectionHtml_n(cnum, name, synonym, stime, etime, days, prof, location)
 
function genSectionHtml_n(cnum, name, synonym, stime, etime, days, prof, location, type)
 
{
 
		var snum = sectionsOfClass[cnum];
 

	
 
		var result = '<tr class="section class' + cnum + '"><td class="none"></td>';
 
	        result = result + '<td class="sectionIdentifier center"><input type="hidden" name="postData[' + cnum + '][' + snum + '][synonym]" value="' + synonym + '" /><input type="text" size="1" class="required" name="postData[' + cnum + '][' + snum + '][letter]" value="' + name + '" /></td>';
 
		result = result + '<td class="professor center"><input type="text" size="10" class="" name="postData[' + cnum + ']['+ snum + '][professor]" value="' + prof + '" /></td>';
 
@@ -190,13 +190,15 @@ function genSectionHtml_n(cnum, name, sy
 
			<td class="cbrow"><input type="checkbox" class="daysRequired" name="postData[' + cnum + '][' + snum + '][days][0]" value="1" ' + (days.m ? 'checked="checked"' : '') + ' /></td> \
 
			<td class="cbrow"><input type="checkbox" class="daysRequired" name="postData[' + cnum + '][' + snum + '][days][1]" value="1" ' + (days.t ? 'checked="checked"' : '') + ' /></td>\
 
			<td class="cbrow"><input type="checkbox" class="daysRequired" name="postData[' + cnum + '][' + snum + '][days][2]" value="1" ' + (days.w ? 'checked="checked"' : '') + ' /></td>\
 
			<td class="cbrow"><input type="checkbox" class="daysRequired" name="postData[' + cnum + '][' + snum + '][days][3]" value="1" ' + (days.h ? 'checked="checked"' : '') + ' /></td>\
 
			<td class="cbrow"><input type="checkbox" class="daysRequired" name="postData[' + cnum + '][' + snum + '][days][4]" value="1" ' + (days.f ? 'checked="checked"' : '') + ' /></td>';
 
		result = result + '<td><div class="deleteSection"><input type="button" value="x" class="gray" /></div></td><td>' 
 
		    + '<input type="hidden" name="postData[' + cnum + '][' + snum + '][location]" value="' + location + '" />'+ '</td></tr>';
 
		    + '<input type="hidden" name="postData[' + cnum + '][' + snum + '][location]" value="' + location + '" />'
 
		    + '<input type="hidden" name="postData[' + cnum + '][' + snum + '][type]" value="' + type + '" />'
 
		    + '</td></tr>';
 
		return result;
 
	}
 

	
 
/**
 
 * Outputs an <option/> element. It will inlcude selected="selected"
 
 * if the value param equals the test_value param.
 
@@ -210,20 +212,20 @@ function genOptionHtml(value, content, t
 
}
 

	
 
/**
 
 * \brief
 
 *   Add a section to a class.
 
 */
 
function add_section_n(cnum, name, synonym, stime, etime, days, prof, location)
 
function add_section_n(cnum, name, synonym, stime, etime, days, prof, location, type)
 
{
 
    jQuery('.pclass'+cnum).after(genSectionHtml_n(cnum, name, synonym, stime, etime, days, prof, location));
 
    jQuery('.pclass'+cnum).after(genSectionHtml_n(cnum, name, synonym, stime, etime, days, prof, location, type));
 
    sectionsOfClass[cnum] ++;
 
}
 
function add_section(cnum)
 
{
 
    return add_section_n(cnum, '', '', '', '', {'m':false, 't':false, 'w':false, 'h':false, 'f':false}, '', '');
 
    return add_section_n(cnum, '', '', '', '', {'m':false, 't':false, 'w':false, 'h':false, 'f':false}, '', '', '');
 
}
 

	
 
/**
 
 * Add a list of sections gotten via an AJAX call.
 
 */
 
function add_sections(cnum, data)
 
@@ -236,13 +238,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);
 
	    add_section_n(cnum, section.section, section.synonym, section.time_start, section.time_end, section.days, section.prof, section.location, section.type);
 
	}
 
}
 

	
 
	//--------------------------------------------------
 
	// Adds a new class to the input.
 
	//--------------------------------------------------
0 comments (0 inline, 0 general)