Changeset - 7d36a6a1f3b6
[Not reviewed]
default
0 1 0
Nathan Brink (binki) - 15 years ago 2011-02-05 11:40:48
ohnobinki@ohnopublishing.net
calvin: When crawling, add courses to the autocomplete cache even if they have no valid sections. This should reduce user confusion.
1 file changed with 26 insertions and 0 deletions:
0 comments (0 inline, 0 general)
school.d/calvin.crawl.inc
Show inline comments
 
@@ -306,6 +306,8 @@ function calvin_crawl(Semester $semester
 
			  . implode('-', $section_id) . ' has meeting info of `'
 
			  . $sec_meeting_info . '\'');
 
	      $skipped_sections['incomplete meeting info'] ++;
 
	      /* Still add to have less confusing autocomplete */
 
	      calvin_crawl_course_add($semester, $section_id['department'], $section_id['course']);
 
	      continue;
 
	    }
 

	
 
@@ -314,6 +316,11 @@ function calvin_crawl(Semester $semester
 
	      error_log('Unable to parse calvin section meeting info string into start/end/days information for '
 
			. implode('-', $section_id) . ': ``' . $sec_meeting_info . '\'\'');
 
	      $skipped_sections['invalid meeting info format'] ++;
 
	      /*
 
	       * Still add at least the course to the semester so that
 
	       * it shows up in autocmoplete.
 
	       */
 
	      calvin_crawl_course_add($semester, $section_id['department'], $section_id['course']);
 
	      continue;
 
	    }
 
	  $date_start = $meeting_info_matches[1];
 
@@ -428,3 +435,22 @@ function calvin_crawl_noscript_filter($h
 
{
 
  return preg_replace(';\<(noscript)\>.*?\</\1\>;s', '', $html);
 
}
 

	
 
/**
 
 * \brief
 
 *   Add a course to a semester if that semester doesn't yet have this
 
 *   course.
 
 *
 
 * \param $semester
 
 *   The semester to which the course should be appended.
 
 * \param $deparmtent
 
 *   The department of the course to add.
 
 * \param $course_id
 
 *   The course_id which, with the department string, forms a
 
 *   fully-qualified course_id.
 
 */
 
function calvin_crawl_course_add(Semester $semester, $department, $course_id)
 
{
 
  if ($semester->class_get($department, $course_id) == NULL)
 
    $semester->class_add(new Course($department . '-' . $course_id));
 
}
0 comments (0 inline, 0 general)