Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
38 changes: 38 additions & 0 deletions schema/migrationScripts/3.0.30.sql
Original file line number Diff line number Diff line change
@@ -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;
4 changes: 2 additions & 2 deletions schema/procedures/InsertOrUpdateSection.sql
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 1 addition & 3 deletions schema/tables/quarters.sql
Original file line number Diff line number Diff line change
Expand Up @@ -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;
8 changes: 4 additions & 4 deletions schema/tables/sections.sql
Original file line number Diff line number Diff line change
Expand Up @@ -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 -------------------------------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion schema/tables/times.sql
Original file line number Diff line number Diff line change
Expand Up @@ -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 -------------------------------------------------
Expand Down
30 changes: 17 additions & 13 deletions tools/processDump.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,24 +80,31 @@ 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
* @param $description String The description for the course
* @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
Expand Down Expand Up @@ -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']}'";

Expand Down Expand Up @@ -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");
Expand Down