Changeset - f652ff09d273
[Not reviewed]
default
0 8 0
Nathan Brink (binki) - 15 years ago 2011-02-04 22:59:53
ohnobinki@ohnopublishing.net
Add an example course ID to the school profile's metadata and use this example course ID on input.php and in the qTip.
8 files changed with 35 insertions and 5 deletions:
0 comments (0 inline, 0 general)
inc/school.inc
Show inline comments
 
@@ -33,24 +33,25 @@
 
 * when the identifier is already known.
 
 */
 

	
 
/**
 
 * \brief
 
 *   Load a school profile based on its identifier.
 
 *
 
 * This function loads the school's description file and asks for info
 
 * from a callback called $school_id . '_info' which must return an
 
 * array with the following keys:
 
 * - name: a friendly name for the school. Must be a valid XHTML attribute string.
 
 * - url: the school's website URL as a valid XHTML attribute string. (i.e., escape ampersands).
 
 * - example_course_id: An example course identifier representative of a school's course IDs. (e.g., CS-101 for Calvin).
 
 *
 
 * \param $school_id
 
 *   The school's alphanumeric identifier (which determines the name
 
 *   of the school's *.inc file).
 
 * \param $load_all_inc
 
 *   Asks for a school's extraneous .inc files to be loaded
 
 *   to. Intended for use by rehash.php only.
 
 * \return
 
 *   A school_profile handle or NULL on error.
 
 */
 
function school_load($school_id, $load_all_inc = FALSE)
 
{
 
@@ -281,24 +282,43 @@ function school_default_courses($school)
 
  $school_default_courses = $school['id'] . '_default_courses';
 
  if (function_exists($school_default_courses))
 
    {
 
      require_once(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'class.course.inc');
 
      return $school_default_courses();
 
    }
 

	
 
  return array();
 
}
 

	
 
/**
 
 * \brief
 
 *   Return an example course id for the school.
 
 *
 
 * Each school may specify an example course ID by placing a key
 
 * called 'example_course_id' into the array returned by its
 
 * <school_id>_info() function. See school_load().
 
 *
 
 * \param $school
 
 *   The school's handle.
 
 * \return
 
 *   A string containing a representative example of a course ID for
 
 *   the given school.
 
 */
 
function school_example_course_id(array $school)
 
{
 
  return $school['example_course_id'];
 
}
 

	
 
/**
 
 * \brief
 
 *   Determine if a school has crawler data stored.
 
 *
 
 * \param $school
 
 *   The which should be checked.
 
 */
 
function school_has_auto(array $school)
 
{
 
  return isset($school['crawled']) && $school['crawled'];
 
}
 

	
 
/**
 
 * \brief
input.php
Show inline comments
 
@@ -29,49 +29,51 @@ require_once('inc' . DIRECTORY_SEPARATOR
 

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

	
 
if (isset($_REQUEST['s']))
 
  {
 
    $schedule_store = schedule_store_init();
 
    $schedule_id = (int)$_REQUEST['s'];
 
    $sch = schedule_store_retrieve($schedule_store, $schedule_id);
 
  }
 

	
 
$my_hc = 'jQuery(document).ready(
 
$my_hc = 'var slate_permutate_example_course_id = \'' . str_replace('\'', '\\\'', school_example_course_id($inputPage->get_school())) . '\';
 

	
 
jQuery(document).ready(
 
  function()
 
  {
 
    var class_last = 0;
 

	
 
';
 
if ($sch)
 
{
 
  $nclasses = $sch->nclasses_get();
 
  for ($class_key = 0; $class_key < $nclasses; $class_key ++)
 
    {
 
      $my_hc .= input_class_js($sch->class_get($class_key), '    ');
 
    }
 
}
 
else
 
  {
 
    $default_courses = school_default_courses($school);
 
    foreach ($default_courses as $default_class)
 
      $my_hc .= input_class_js($default_class, '    ');
 
    $my_hc .= '    class_last = add_class();
 
';
 
  }
 
if ($qtips_always || !isset($_SESSION['saw_qtips']))
 
  {
 
    $my_hc .= '        addTips();';
 
    $my_hc .= '        addTips();' . PHP_EOL;
 
    $_SESSION['saw_qtips'] = TRUE;
 
  }
 
$my_hc .= '  });
 
';
 

	
 
$inputPage->headcode_add('scheduleInput', $inputPage->script_wrap($my_hc), TRUE);
 

	
 
$inputPage->head();
 

	
 
/*
 
 * Force a student to choose a school or declare he's a generic
 
 * student before displaying the input form. To do this, we need
 
@@ -95,26 +97,28 @@ if (!empty($_REQUEST['selectschool'])
 
</p>
 
<?php
 
    $inputPage->showSchools($next_page);
 
    $inputPage->foot();
 
    exit;
 
  }
 

	
 
$inputPage->showSavedScheds($_SESSION);
 
?>
 
<p>
 
  Welcome to SlatePermutate<?php $inputPage->addressStudent(', ', '', FALSE); ?>!
 
  <?php if (school_has_auto($inputPage->get_school())): ?>
 
  To get started, enter in some a course identifier and click the
 
  autosuggestion to automatically load available sections for each class.
 
  To get started, enter in some a course identifier (e.g., <em>
 
  <?php echo school_example_course_id($inputPage->get_school()); ?></em>)
 
  and click the autosuggestion to automatically load available sections
 
  for each class.
 
  <?php else: ?>
 
  To get started, enter a course number and add some sections to it.
 
  Then specify each section's letter/number and what times it meets,
 
  add more courses, and click &ldquo;Find a Schedule&rdquo;.
 
  <?php endif; ?>
 
</p>
 

	
 
<form method="post" action="process.php" id="scheduleForm">
 
<p class="nospace"><label>Schedule Name</label><br />
 
  <input id="scheduleName" style="margin-bottom: 1em;" class="defText required" type="text" size="25" title="Spring 2011" name="postData[name]" <?php if ($sch) echo 'value="' . htmlentities($sch->getName(), ENT_QUOTES) . '"'; /*"*/ ?> />
 
</p>
 

	
school.d/calvin.inc
Show inline comments
 
@@ -20,24 +20,25 @@
 

	
 
function calvin_info()
 
{
 
  return array('name' => 'Calvin College',
 
	       'url' => 'http://calvin.edu/',
 
	       /*
 
		* rDNS postfixes which indicate a student is
 
		* connecting from that college campus
 
		*/
 
	       'domains' => array(
 
				  'calvin.edu',
 
				  ),
 
	       'example_course_id' => 'CS-232',
 
	       'student_address' => 'Knight',
 
	       );
 
}
 

	
 
function calvin_instructions_html()
 
{
 
  return <<<EOF
 
<h2>Instructions</h2>
 
<!--<p>
 
  SlatePermutate can be a useful tool for scheduling your next semester at <a href="http://calvin.edu/">Calvin College</a>.
 
</p>-->
 
<h3>
school.d/cedarville.inc
Show inline comments
 
@@ -16,24 +16,25 @@
 
 *
 
 * You should have received a copy of the GNU Affero General Public License
 
 * along with SlatePermutate.  If not, see <http://www.gnu.org/licenses/>.
 
 */
 

	
 
function cedarville_info()
 
{
 
  return array('name' => 'Cedarville University',
 
	       'url' => 'http://cedarville.edu/',
 
	       'domains' => array(
 
				  'cedarville.edu',
 
				  ),
 
	       'example_course_id' => 'MATH-2510',
 
	       'student_address' => 'Cedarville Student',
 
	       );
 
}
 

	
 
function cedarville_instructions_html()
 
{
 
  return <<<EOF
 
<h2>Instructions</h2>
 
<p>
 
  SlatePermutate can be a useful tool for scheduling your next semester at <a href="http://cedarville.edu/" rel="external">Cedarville University</a>.
 
</p>
 
<ol>
school.d/default.inc
Show inline comments
 
@@ -19,24 +19,25 @@
 
 */
 

	
 
function default_info()
 
{
 
  return array('name' => 'Generic College',
 
	       'url' => 'http://example.edu/',
 
	       /*
 
		* rDNS postfixes which indicate a student is
 
		* connecting from that college campus.
 
		*/
 
	       'domains' => array(
 
				  ),
 
	       'example_course_id' => 'ENGL-101',
 
	       'student_address' => 'student',
 
	       );
 
}
 

	
 
function default_instructions_html()
 
{
 
  return <<<EOF
 
<h2>Generic Instructions</h2>
 
<p>
 
  <tt>slate_permutate</tt> can be a useful tool for scheduling your next semester at the college you attend.
 
</p>
 
<ol>
school.d/msu.inc
Show inline comments
 
@@ -16,24 +16,25 @@
 
 *
 
 * You should have received a copy of the GNU Affero General Public License
 
 * along with slate_permutate.  If not, see <http://www.gnu.org/licenses/>.
 
 */
 

	
 
function msu_info()
 
{
 
  return array('name' => 'Michigan State University',
 
               'url' => 'http://msu.edu/',
 
               'domains' => array(
 
                                  'msu.edu',
 
                                  ),
 
	       'example_course_id' => 'ENG-129',
 
               'student_address' => 'Spartan',
 
               );
 
}
 

	
 
function msu_instructions_html()
 
{
 
  return <<<EOF
 
<h2>Instructions</h2>
 
<ol>
 
  <li>Get in touch with your advisor during advising/reading recess.</li>
 
  <li>Look up each class your advisor specified on the course listing pages.</li>
 
  <li>Enter each class into a SlatePermutate schedule and add each section that is listed that you are willing to take.</li>
school.d/umich.inc
Show inline comments
 
@@ -16,24 +16,25 @@
 
 *
 
 * You should have received a copy of the GNU Affero General Public License
 
 * along with SlatePermutate.  If not, see <http://www.gnu.org/licenses/>.
 
 */
 

	
 
function umich_info()
 
{
 
  return array('name' => 'University of Michigan',
 
               'url' => 'http://umich.edu/',
 
               'domains' => array(
 
                                  'umich.edu',
 
                                  ),
 
	       'example_course_id' => 'MATH-161',
 
               'student_address' => 'Wolverine',
 
               );
 
}
 

	
 
function umich_instructions_html()
 
{
 
  return <<<EOF
 
<h2>U of M-specific Instructions</h2>
 
<p>
 
  SlatePermutate can be a useful tool for scheduling your next semester.
 
</p>
 
<ol>
scripts/scheduleInput.js
Show inline comments
 
@@ -215,25 +215,26 @@ function genOptionHtml(value, content, t
 
	selected = '';
 
    return '<option value="' + value + '"' + selected + '>' + content + "</option>\n";
 
}
 

	
 

	
 
/** Add tooltips for user guidance */
 
function addTips()
 
{
 
  var tr = jQuery('tr');
 
  var td = tr.eq(tr.length-2);
 

	
 
  jQuery('td:first', td).qtip({
 
    content: 'Start typing your class ID (such as PEF-1010) and click a suggestion to add sections',
 
    /* slate_permutate_example_course_id is set globally in input.php. */
 
    content: 'Start typing your class ID (such as ' + slate_permutate_example_course_id + ') and click a suggestion to add sections',
 
    style: {
 
      border: { 
 
        width: 3,
 
        radius: 4,
 
        color: '#333'
 
      },
 
      name: 'dark',
 
      tip: true
 
    },
 
    show: { effect: { type: 'fade', length: 2000 } },
 
    show: { ready: true }, 
 
/*    hide: { when: { event: 'inactive' } }, */
0 comments (0 inline, 0 general)