Skip to content

Commit 06f4060

Browse files
committed
This better fixes #87
1 parent f53ace5 commit 06f4060

File tree

2 files changed

+15
-12
lines changed

2 files changed

+15
-12
lines changed

api/generate.php

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -184,16 +184,6 @@ function timeStringToMinutes($str) {
184184
return $hour * 60 + $minute;
185185
}
186186

187-
/**
188-
* Checks if a section is a special section (lab/studio/etc)
189-
* Now also ignores "H" for honors classes, which are separate
190-
* @param $courseInfo
191-
* @return int
192-
*/
193-
function isSpecialSection($courseInfo) {
194-
return preg_match('/[A-GI-Z]\d{0,2}$/', $courseInfo['courseNum']) === 1;
195-
}
196-
197187
/**
198188
* Returns a cleaned course number, free of special sections or designators
199189
* @param $courseInfo
@@ -241,8 +231,6 @@ function pruneSpecialCourses($schedules, $courseGroups) {
241231
$flattenedSchedule[$course['courseNum']] = array_keys($courseGroups[$cleanCourseNum]);
242232
} else {
243233
$flattenedSchedule[$course['courseNum']] = true;
244-
245-
$course['credits'] = '0';
246234
}
247235
} else {
248236
$flattenedSchedule[$course['courseNum']] = false;

inc/databaseConn.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,16 @@
2424
////////////////////////////////////////////////////////////////////////////
2525
// FUNCTIONS
2626

27+
/**
28+
* Checks if a section is a special section (lab/studio/etc)
29+
* Now also ignores "H" for honors classes, which are separate
30+
* @param $courseInfo
31+
* @return int
32+
*/
33+
function isSpecialSection($courseInfo) {
34+
return preg_match('/[A-GI-Z]\d{0,2}$/', $courseInfo['courseNum']) === 1;
35+
}
36+
2737
/**
2838
* Retrieves the meeting information for a section
2939
* @param $sectionData array Information about a section MUST HAVE:
@@ -52,6 +62,11 @@ function getMeetingInfo($sectionData) {
5262
$course['description'] = $sectionData['description'];
5363
}
5464

65+
// Make sure special sections don't get double-counted for their credits
66+
if(isSpecialSection($course)) {
67+
$course['credits'] = "0"; // string for consistency's sake
68+
}
69+
5570
// Now we query for the times of the section
5671
$query = "SELECT b.code, b.number, b.off_campus, t.room, t.day, t.start, t.end ";
5772
$query .= "FROM times AS t JOIN buildings AS b ON b.number=t.building ";

0 commit comments

Comments
 (0)