Skip to content
  • 4 commits
  • 4 files changed
  • 0 commit comments
  • 1 contributor
View
33 scripts/find_course_data_errors.php
@@ -15,43 +15,22 @@
foreach ($subject_area->courses as $course) {
/* @var $course UNL_Services_CourseApproval_Course */
// Find courses within prereqs
- foreach (UNL_UndergraduateBulletin_EPUB_Utilities::findCourses($course->prerequisite) as $prereq_subject_code => $prereq_courses) {
- try {
- $prereq_subject = new UNL_Services_CourseApproval_SubjectArea($prereq_subject_code);
- foreach ($prereq_courses as $prereq_course) {
- // try and get the listing
- $prereq_subject->courses[$prereq_course];
- }
- } catch (Exception $e) {
+ foreach (UNL_UndergraduateBulletin_EPUB_Utilities::findUnknownCourses($course->prerequisite) as $prereq_subject_code => $prereq_courses) {
+ foreach ($prereq_courses as $prereq_course) {
$missing_courses["$prereq_subject_code $prereq_course"][] = "Found in $subject_area {$course->getHomeListing()->courseNumber} prereqs";
}
- unset($prereq_subject);
}
// Find courses within notes
- foreach (UNL_UndergraduateBulletin_EPUB_Utilities::findCourses($course->notes) as $notes_subject_code => $notes_courses) {
- try {
- $notes_subject = new UNL_Services_CourseApproval_SubjectArea($notes_subject_code);
- foreach ($notes_courses as $notes_course) {
- // try and get the listing
- $notes_subject->courses[$notes_course];
- }
- } catch (Exception $e) {
+ foreach (UNL_UndergraduateBulletin_EPUB_Utilities::findUnknownCourses($course->notes) as $notes_subject_code => $notes_courses) {
+ foreach ($notes_courses as $notes_course) {
$missing_courses["$notes_subject_code $notes_course"][] = "Found in $subject_area {$course->getHomeListing()->courseNumber} notes";
}
- unset($notes_subject);
}
// Find courses within description
- foreach (UNL_UndergraduateBulletin_EPUB_Utilities::findCourses($course->description) as $desc_subject_code => $desc_courses) {
- try {
- $desc_subject = new UNL_Services_CourseApproval_SubjectArea($desc_subject_code);
- foreach ($desc_courses as $desc_course) {
- // try and get the listing
- $desc_subject->courses[$desc_course];
- }
- } catch (Exception $e) {
+ foreach (UNL_UndergraduateBulletin_EPUB_Utilities::findUnknownCourses($course->description) as $desc_subject_code => $desc_courses) {
+ foreach ($desc_courses as $desc_course) {
$missing_courses["$desc_subject_code $desc_course"][] = "Found in $subject_area {$course->getHomeListing()->courseNumber} description";
}
- unset($desc_subject);
}
}
}
View
33 scripts/find_missing_prereq_courses.php
@@ -1,33 +0,0 @@
-#!/usr/bin/env php -q
-<?php
-if (file_exists(dirname(__FILE__).'/../config.inc.php')) {
- include_once dirname(__FILE__).'/../config.inc.php';
-} else {
- include_once dirname(__FILE__).'/../config.sample.php';
-}
-
-error_reporting(E_ALL);
-
-$missing_courses = array();
-
-foreach (new UNL_UndergraduateBulletin_SubjectAreas() as $subject_area) {
- /* @var $subject_area UNL_UndergraduateBulletin_SubjectArea */
- foreach ($subject_area->courses as $course) {
- /* @var $course UNL_Services_CourseApproval_Course */
- // Find courses within prereqs
- foreach (UNL_UndergraduateBulletin_EPUB_Utilities::findCourses($course->prerequisite) as $prereq_subject_code => $prereq_courses) {
- try {
- $prereq_subject = new UNL_Services_CourseApproval_SubjectArea($prereq_subject_code);
- foreach ($prereq_courses as $prereq_course) {
- // try and get the listing
- $prereq_subject->courses[$prereq_course];
- }
- } catch (Exception $e) {
- $missing_courses["$prereq_subject_code $prereq_course"][] = "Found in $subject_area {$course->getHomeListing()->courseNumber} prereqs";
- }
- unset($prereq_subject);
- }
- }
-}
-
-var_dump($missing_courses);
View
24 scripts/find_missing_requirements_courses.php
@@ -18,26 +18,20 @@
/* @var $college UNL_UndergraduateBulletin_College */
foreach ($college->majors as $major) {
+
/* @var $major UNL_UndergraduateBulletin_Major */
+ $missing_courses = UNL_UndergraduateBulletin_EPUB_Utilities::findUnknownCourses($major->getDescription()->description);
+ if (empty($missing_courses)) {
+ continue;
+ }
echo $major->title.' unknown courses:'.PHP_EOL;
-
- /* @var $major UNL_UndergraduateBulletin_Major */
- foreach (UNL_UndergraduateBulletin_EPUB_Utilities::findCourses($major->getDescription()->description) as $description_subject_code => $description_courses) {
- try {
- $description_subject = new UNL_Services_CourseApproval_SubjectArea($description_subject_code);
- foreach ($description_courses as $description_course) {
- // try and get the listing
- $check_course = $description_subject->courses[$description_course];
- unset($check_course);
- }
- } catch (Exception $e) {
- echo " - $description_subject_code $description_course\n";
- $missing_courses["$description_subject_code $description_course"][] = "Found in $major->title description";
+ foreach ($missing_courses as $missing_subject_code=>$missing_course_numbers) {
+ foreach ($missing_course_numbers as $missing_course_number) {
+ echo " - $missing_subject_code $missing_course_number\n";
}
- unset($description_subject);
}
+
}
}
-var_dump($missing_courses);
View
32 src/UNL/UndergraduateBulletin/EPUB/Utilities.php
@@ -138,6 +138,38 @@ public static function findCourses($text)
}
/**
+ * Find MISSING courses within a block of raw text
+ *
+ * @param string $text Generic text with inline course references
+ *
+ * @return array Subject codes and course numbers, e.g. array('AGRO'=>array('153'))
+ */
+ public static function findUnknownCourses($text)
+ {
+ $missing_courses = array();
+
+ foreach (self::findCourses($text) as $subject_code => $courses) {
+ try {
+ $subject = new UNL_Services_CourseApproval_SubjectArea($subject_code);
+ foreach ($courses as $course) {
+ try {
+ // try and get the listing
+ $check_course = $subject->courses[$course];
+ unset($check_course);
+ } catch (Exception $e) {
+ $missing_courses[$subject_code][] = $course;
+ }
+ }
+ } catch (Exception $e) {
+ // Missing subject code, all the courses are unknown
+ $missing_courses[$subject_code] = $courses;
+ }
+ unset($subject);
+ }
+ return $missing_courses;
+ }
+
+ /**
* Link courses found within the text
*
* @param string $text Text to scan for links

No commit comments for this range

Something went wrong with that request. Please try again.