Changeset - 435c41f135a5
[Not reviewed]
default
0 1 0
Nathan Brink (binki) - 14 years ago 2012-02-19 00:39:23
ohnobinki@ohnopublishing.net
Fix autocomplete of the course number part of a course identifier, fixing a regression from ff180c328353.
1 file changed with 3 insertions and 1 deletions:
0 comments (0 inline, 0 general)
auto.php
Show inline comments
 
@@ -141,25 +141,27 @@ if ($getsections)
 
if (file_exists($classes_file))
 
  {
 
    $classes = unserialize(file_get_contents($classes_file));
 
    $class_start = '';
 
    if (count($term_parts) > 1)
 
      $class_start = $term_parts['course'];
 
    $class_start_strlen = strlen($class_start);
 

	
 
    /* reduce/create resultset */
 
    $json_classes = array();
 
    if (!empty($classes) && is_array($classes[0]))
 
      {
 
	$class_start = $dept . '-' . $class_start;
 
	$class_start_strlen = strlen($class_start);
 
	foreach ($classes as $course)
 
	  if (!strncmp($course['value'], $class_start, $class_start_strlen))
 
	    $json_classes[] = $course;
 
      }
 
    else
 
      {
 
	/* Old format with just course id. */
 
	$class_start_strlen = strlen($class_start);
 
	foreach ($classes as $class)
 
	  if (!strncmp($class, $class_start, $class_start_strlen))
 
	    $json_classes[] = $dept . '-' . $class;
 
      }
 

	
 
    echo json_encode($json_classes);
0 comments (0 inline, 0 general)