diff --git a/package.json b/package.json index c4983c0..42e5689 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "schedulemaker", - "version": "3.0.29", + "version": "3.0.30", "private": true, "description": "A course database lookup tool and schedule building web application for use at Rochester Institute of Technology.", "main": "index.php", diff --git a/schema/migrationScripts/3.0.30.sql b/schema/migrationScripts/3.0.30.sql new file mode 100644 index 0000000..de90a6c --- /dev/null +++ b/schema/migrationScripts/3.0.30.sql @@ -0,0 +1,38 @@ +ALTER TABLE `sections` + CHANGE `type` `type` ENUM ('R', 'N', 'H', 'BL', 'OL', 'O') +CHARACTER SET latin1 +COLLATE latin1_swedish_ci NOT NULL DEFAULT 'R' +COMMENT 'R=regular, N=night, OL=online, H=honors, BL=????', + CHANGE `maxenroll` `maxenroll` SMALLINT(3) UNSIGNED NOT NULL +COMMENT 'max enrollment', + CHANGE `curenroll` `curenroll` SMALLINT(3) UNSIGNED NOT NULL +COMMENT 'current enrollment', + CHANGE `instructor` `instructor` VARCHAR(64) NOT NULL DEFAULT 'TBA' +COMMENT 'Instructor\'s Name'; + +UPDATE `sections` +SET `type` = 'OL' +WHERE `type` = 'O'; + +ALTER TABLE `sections` + CHANGE `type` `type` ENUM ('R', 'N', 'H', 'BL', 'OL') +CHARACTER SET latin1 +COLLATE latin1_swedish_ci NOT NULL DEFAULT 'R' +COMMENT 'R=regular, N=night, OL=online, H=honors, BL=????'; + +ALTER TABLE `times` + CHANGE `room` `room` VARCHAR(10) +CHARACTER SET latin1 +COLLATE latin1_swedish_ci NOT NULL +COMMENT 'room number'; + +INSERT INTO `buildings` (`number`, `code`, `name`) VALUES ('ZAG', 'ZAG', 'Building in Croatia'); + +ALTER TABLE `quarters` + DROP `breakstart`, + DROP `breakend`; + +ALTER TABLE `departments` + CHANGE `title` `title` VARCHAR(30) +CHARACTER SET latin1 +COLLATE latin1_swedish_ci NULL; \ No newline at end of file diff --git a/schema/procedures/InsertOrUpdateSection.sql b/schema/procedures/InsertOrUpdateSection.sql index 8ef8d0f..2fe4ddd 100644 --- a/schema/procedures/InsertOrUpdateSection.sql +++ b/schema/procedures/InsertOrUpdateSection.sql @@ -4,8 +4,8 @@ CREATE PROCEDURE InsertOrUpdateSection( IN p_course INT, IN p_section VARCHAR(4), IN p_title VARCHAR(50), - IN p_instructor VARCHAR(30), - IN p_type VARCHAR(1), + IN p_instructor VARCHAR(64), + IN p_type VARCHAR(2), IN p_status VARCHAR(1), IN p_maxenroll INT, IN p_curenroll INT diff --git a/schema/tables/quarters.sql b/schema/tables/quarters.sql index cbe500c..efa898a 100644 --- a/schema/tables/quarters.sql +++ b/schema/tables/quarters.sql @@ -11,7 +11,5 @@ CREATE TABLE quarters ( `quarter` SMALLINT(5) UNSIGNED NOT NULL PRIMARY KEY, `start` DATE NOT NULL, - `end` DATE NOT NULL, - `breakstart` DATE NOT NULL, - `breakend` DATE NOT NULL + `end` DATE NOT NULL ) ENGINE=InnoDb; \ No newline at end of file diff --git a/schema/tables/sections.sql b/schema/tables/sections.sql index b3f59f1..a23bb3a 100644 --- a/schema/tables/sections.sql +++ b/schema/tables/sections.sql @@ -12,11 +12,11 @@ CREATE TABLE sections ( `course` INT UNSIGNED NOT NULL, `section` VARCHAR(4) NOT NULL, `title` VARCHAR(30) NOT NULL, - `type` ENUM('R','N','O','H') NOT NULL DEFAULT 'R', + `type` ENUM('R','N','OL','H', 'BL') NOT NULL DEFAULT 'R', `status` ENUM('O','C','X') NOT NULL, - `instructor` VARCHAR(30) NOT NULL DEFAULT 'TBA', - `maxenroll` TINYINT(3) UNSIGNED NOT NULL, - `curenroll` TINYINT(3) UNSIGNED NOT NULL + `instructor` VARCHAR(64) NOT NULL DEFAULT 'TBA', + `maxenroll` SMALLINT(3) UNSIGNED NOT NULL, + `curenroll` SMALLINT(3) UNSIGNED NOT NULL ) ENGINE=InnoDB; -- UNIQUE KEYS ------------------------------------------------------------- diff --git a/schema/tables/times.sql b/schema/tables/times.sql index 717b352..c13c26b 100644 --- a/schema/tables/times.sql +++ b/schema/tables/times.sql @@ -15,7 +15,7 @@ CREATE TABLE times ( `start` SMALLINT(4) UNSIGNED NOT NULL, `end` SMALLINT(4) UNSIGNED NOT NULL, `building` VARCHAR(5) NULL DEFAULT NULL, - `room` VARCHAR(4) NULL DEFAULT NULL + `room` VARCHAR(10) NULL DEFAULT NULL )ENGINE=InnoDB; -- FOREIGN KEY CONSTRAINTS ------------------------------------------------- diff --git a/tools/processDump.php b/tools/processDump.php index f3e0c54..2d12850 100644 --- a/tools/processDump.php +++ b/tools/processDump.php @@ -80,8 +80,8 @@ function halt($messages) { * Inserts or updates a course. This function calls the stored procedure for * inserting or updating a course. * @param $quarter int The term that the course is in - * @param $departNum int The number of the department - * @param $departCode int The code for the department + * @param $departCode String The code of the department + * @param $classCode String The code for the class * @param $course int The number of the course * @param $credits int The credits the course offers * @param $title String The title of the course @@ -89,15 +89,22 @@ function halt($messages) { * @return mixed String of error message returned on failure. * Integer of course ID returned on success */ -function insertOrUpdateCourse($quarter, $departNum, $departCode, $course, $credits, $title, $description) { +function insertOrUpdateCourse($quarter, $departCode, $classCode, $course, $credits, $title, $description) { global $dbConn, $coursesUpdated, $coursesAdded; // Call the stored proc - $query = "CALL InsertOrUpdateCourse({$quarter}, {$departNum}, '{$departCode}', '{$course}', {$credits}, '{$title}', '{$description}')"; + // TODO: Refactor out department ID number (0000) + $query = "CALL InsertOrUpdateCourse({$quarter}, 0000, '{$classCode}', '{$course}', {$credits}, '{$title}', '{$description}')"; $success = mysqli_multi_query($dbConn, $query); // Catch errors or return the id if(!$success) { - return mysqli_error($dbConn); + // If the class code errors out, try the department code + // TODO: Refactor out department ID number (0000) + $query = "CALL InsertOrUpdateCourse({$quarter}, 0000, '{$departCode}', '{$course}', {$credits}, '{$title}', '{$description}')"; + $success = mysqli_multi_query($dbConn, $query); + if(!$success) { + return mysqli_error($dbConn); + } } // First result set is updated vs inserted @@ -457,13 +464,10 @@ function procInstrArray($lineSplit) { preg_match("/(\d)(\d{3})/", $row['strm'], $match); $row['strm'] = $match[1] . 0 . $match[2]; - // Create a default break value - $break = '0000-00-00'; - // Insert the quarter // TODO: Change schema from quarters to semesters (I doubt they're switching back anytime soon) - $query = "INSERT INTO quarters (quarter, start, end, breakstart, breakend)"; - $query .= " VALUES({$row['strm']}, '{$row['start_dt']}', '{$row['end_dt']}', $break, $break)"; + $query = "INSERT INTO quarters (`quarter`, `start`, `end`)"; + $query .= " VALUES({$row['strm']}, '{$row['start_dt']}', '{$row['end_dt']}')"; $query .= " ON DUPLICATE KEY UPDATE"; $query .= " start='{$row['start_dt']}', end='{$row['end_dt']}'"; @@ -561,10 +565,10 @@ function procInstrArray($lineSplit) { $row['course_descrlong'] = mysqli_real_escape_string($dbConn, $row['course_descrlong']); // Insert or update the course - $courseId = insertOrUpdateCourse($row['qtr'], 0000, $row['acad_org'], $row['catalog_nbr'], + $courseId = insertOrUpdateCourse($row['qtr'], $row['acad_org'], $row['subject'], $row['catalog_nbr'], $row['units'], $row['descr'], $row['course_descrlong']); - if(!is_numeric($courseId)) { - echo(" *** Error: Failed to update {$row['qtr']} {$row['subject']}{$row['acad_org']}-{$row['catalog_nbr']}\n"); + if (!is_numeric($courseId)) { + echo(" *** Error: Failed to update {$row['qtr']} {$row['subject']}-{$row['catalog_nbr']}\n"); echo(" "); var_dump($courseId); echo("\n");