Changeset - 3441c7023bc1
[Not reviewed]
default
0 3 0
Nathan Brink (binki) - 15 years ago 2010-10-20 18:09:59
ohnobinki@ohnopublishing.net
Support default classes per school profile. Inserted incorrect chapel entry into Cedarville for an example.
3 files changed with 77 insertions and 28 deletions:
0 comments (0 inline, 0 general)
inc/school.inc
Show inline comments
 
@@ -252,6 +252,25 @@ function school_instructions_html($schoo
 

	
 
/**
 
 * \brief
 
 *   Return an array of default classes for a particular school.
 
 *
 
 * \param $school
 
 *   The school's handle.
 
 */
 
function school_default_classes($school)
 
{
 
  $school_default_classes = $school['id'] . '_default_classes';
 
  if (function_exists($school_default_classes))
 
    {
 
      require_once(dirname(__FILE__) . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'class.class.php');
 
      return $school_default_classes();
 
    }
 

	
 
  return array();
 
}
 

	
 
/**
 
 * \brief
 
 *   Used to load the school cache.
 
 *
 
 * \return
input.php
Show inline comments
 
@@ -11,6 +11,8 @@ require_once('inc/schedule_store.inc');
 

	
 
$schedule_store = FALSE;
 
$sch = FALSE;
 
$school = $inputPage->get_school();
 

	
 
if (isset($_REQUEST['s']))
 
  {
 
    $schedule_store = schedule_store_init();
 
@@ -18,43 +20,31 @@ if (isset($_REQUEST['s']))
 
    $sch = schedule_store_retrieve($schedule_store, $schedule_id);
 
  }
 

	
 
if ($sch)
 
{
 
  $nclasses = $sch->nclasses_get();
 
  $my_hc = 'jQuery(document).ready(
 
$my_hc = 'jQuery(document).ready(
 
  function()
 
  {
 
    var class_last = 0;
 

	
 
';
 
if ($sch)
 
{
 
  $nclasses = $sch->nclasses_get();
 
  for ($class_key = 0; $class_key < $nclasses; $class_key ++)
 
    {
 
      $class = $sch->class_get($class_key);
 
      $my_hc .= '    class_last = add_class_n(\'' . htmlentities($class->getName(), ENT_QUOTES) . "');\n";
 

	
 
      $nsections = $class->getnsections();
 
      for ($section_key = $nsections - 1; $section_key >= 0; $section_key --)
 
	{
 
	  $section = $class->getSection($section_key);
 
	  $meetings = $section->getMeetings();
 
	  foreach ($meetings as $meeting)
 
	    {
 
	      $my_hc .= '    add_section_n(class_last, \'' . htmlentities($section->getLetter(), ENT_QUOTES) . '\', \''
 
		. htmlentities($section->getSynonym(), ENT_QUOTES) . '\', \''
 
		. $meeting->getStartTime() . '\', \''
 
		. $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))) . ', \''
 
		. htmlentities($section->getProf(), ENT_QUOTES) . '\', \''
 
		. htmlentities($meeting->getLocation(), ENT_QUOTES) . "');\n";
 
	    }
 
	}
 
      $my_hc .= input_class_js($sch->class_get($class_key), '    ');
 
    }
 
  $my_hc .= '  });
 
';
 
  $inputPage->headcode_add('scheduleInput', $inputPage->script_wrap($my_hc), TRUE);
 
}
 
else
 
  $inputPage->headcode_add('schduleInput', $inputPage->script_wrap('jQuery(document).ready( function() { add_class(); } );'), TRUE);
 
  {
 
    $default_classes = school_default_classes($school);
 
    foreach ($default_classes as $default_class)
 
      $my_hc .= input_class_js($default_class, '    ');
 
    $my_hc .= '    class_last = add_class();
 
';
 
  }
 
$my_hc .= '  });
 
';
 
$inputPage->headcode_add('scheduleInput', $inputPage->script_wrap($my_hc), TRUE);
 

	
 
$inputPage->head();
 

	
 
@@ -63,7 +53,6 @@ else
 
 * student before displaying the input form. To do this, we need
 
 * another variable in $_SESSION: $_SESSION['school_chosen'].
 
 */
 
$school = $inputPage->get_school();
 
if ($school && (!empty($_REQUEST['school']) || $school['id'] != 'default'))
 
  $_SESSION['school_chosen'] = TRUE;
 
if (!empty($_REQUEST['selectschool'])
 
@@ -134,3 +123,27 @@ if (!empty($_REQUEST['selectschool'])
 
<?php
 
$inputPage->showSchoolInstructions();
 
$inputPage->foot();
 

	
 
function input_class_js(Classes $class, $whitespace = '  ')
 
{
 
  $js = $whitespace . 'class_last = add_class_n(\'' . htmlentities($class->getName(), ENT_QUOTES) . "');\n";
 

	
 
  $nsections  = $class->getnsections();
 
  for ($section_key = $nsections - 1; $section_key >= 0; $section_key --)
 
    {
 
      $section = $class->getSection($section_key);
 
      $meetings = $section->getMeetings();
 
      foreach ($meetings as $meeting)
 
	{
 
	  $js .= $whitespace . 'add_section_n(class_last, \'' . htmlentities($section->getLetter(), ENT_QUOTES) . '\', \''
 
	    . htmlentities($section->getSynonym(), ENT_QUOTES) . '\', \''
 
	    . $meeting->getStartTime() . '\', \''
 
	    . $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))) . ', \''
 
	    . htmlentities($section->getProf(), ENT_QUOTES) . '\', \''
 
	    . htmlentities($meeting->getLocation(), ENT_QUOTES) . "');\n";
 
	}
 
    }
 

	
 
  return $js;
 
}
school.d/cedarville.inc
Show inline comments
 
@@ -29,6 +29,23 @@ EOF;
 

	
 
/**
 
 * \brief
 
 *   Get a list of default classes (with sections (with meeting
 
 *   times)) for Cedarville students.
 
 *
 
 * \return
 
 *   An array of Classes objects.
 
 */
 
function cedarville_default_classes()
 
{
 
  $chapel = new Classes('Chapel');
 
  $chapel->section_add(new Section('_', array(new SectionMeeting('mtwhf', '0900', '0945', '', 'chapel')),
 
				   '', '_'));
 

	
 
  return array($chapel);
 
}
 

	
 
/**
 
 * \brief
 
 *   Parse given html into an array, first row is row headers
 
 *
 
 * \param $html
0 comments (0 inline, 0 general)