Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix grade discrepancies, faster RMP #95

Merged
merged 1 commit into from
May 8, 2024
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
35 changes: 24 additions & 11 deletions server/harmonize.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,13 @@
else:
class_data["sched"].extend(class_sem["sched"])
class_data["terms"].append(class_sem["term"])
class_data["instructor"][class_sem["term"]] = class_sem["instructor"]

# formatting instructor names to only First Last
instrs = []
for instr in class_sem["instructor"]:
instrs.append(instr.split(" ")[0] + " " + instr.split(" ")[-1])
class_data["instructor"][class_sem["term"]] = instrs

if "<a href=" not in class_sem["description"]:
class_data["description"] = class_sem["description"]
class_data["title"] = instances[0]["title"]
Expand Down Expand Up @@ -232,23 +238,30 @@
for semester, data in course_data[i]["gpa"].items():
for entry in data:
instructor = entry[0]
if instructor in gpa_data:
if semester in gpa_data[instructor]:
for k in range(len(gpa_data[instructor][semester])):
gpa_data[instructor][semester][k] = round(
if instructor.find(",") == -1:
formattedInstructor = instructor
else:
formattedInstructor = (instructor.split(", ")[1] + " " + instructor.split(", ")[0]).strip()

formattedInstructor = formattedInstructor.split(" ")[0] + " " + formattedInstructor.split(" ")[-1]

if formattedInstructor in gpa_data:
if semester in gpa_data[formattedInstructor]:
for k in range(len(gpa_data[formattedInstructor][semester])):
gpa_data[formattedInstructor][semester][k] = round(
(
gpa_data[instructor][semester][k] * gpa_data_count[instructor][semester]
gpa_data[formattedInstructor][semester][k] * gpa_data_count[formattedInstructor][semester]
+ entry[1][k]
)
/ (gpa_data_count[instructor][semester] + 1),
/ (gpa_data_count[formattedInstructor][semester] + 1),
2,
)
else:
gpa_data[instructor][semester] = entry[1]
gpa_data_count[instructor][semester] = 1
gpa_data[formattedInstructor][semester] = entry[1]
gpa_data_count[formattedInstructor][semester] = 1
else:
gpa_data[instructor] = {semester: entry[1]}
gpa_data_count[instructor] = {semester: 1}
gpa_data[formattedInstructor] = {semester: entry[1]}
gpa_data_count[formattedInstructor] = {semester: 1}

course_data[i]["gpa"] = gpa_data

Expand Down
23 changes: 4 additions & 19 deletions src/components/fullInstructorModal.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,20 +54,6 @@ const FullInstructorModal = ({ isOpen, onClose, course }) => {
};


// Helper function to format instructor name
function formatInstructorName(name) {
if (name === "TBA") return 'TBA';
const splitName = name.split(' ');
const lastName = splitName.pop();
const firstName = splitName.shift();
const middleName = splitName.join(' ');
if (middleName.length >= 1) {
splitName[0] = middleName[0] + '.';
}
return `${lastName}, ${firstName}${splitName.length > 0 ? ' ' + splitName.join(' ') : ''}`;
}


useEffect(() => {
if (!course) return;
// @unkn-wn @knightron0 delete this comment after review:
Expand All @@ -84,14 +70,13 @@ const FullInstructorModal = ({ isOpen, onClose, course }) => {
for (const semester in course.instructor) {
consolidatedData[semester] = {};
for (const instructor of course.instructor[semester]) {
const formattedInstructor = formatInstructorName(instructor);
let gpa = "No GPA";
let color = getColor(0);
if (course.gpa[formattedInstructor] && course.gpa[formattedInstructor][semester]) {
gpa = course.gpa[formattedInstructor][semester][13] || "No GPA";
color = getColor(course.gpa[formattedInstructor][semester][13] || 0);
if (course.gpa[instructor] && course.gpa[instructor][semester]) {
gpa = course.gpa[instructor][semester][13] || "No GPA";
color = getColor(course.gpa[instructor][semester][13] || 0);
}
consolidatedData[semester][formattedInstructor] = {
consolidatedData[semester][instructor] = {
gpa: gpa,
color: color
};
Expand Down
2 changes: 1 addition & 1 deletion src/components/infoModal.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ const InfoModal = ({ isOpen, onClose }) => {
The <span className='font-bold text-yellow-500'>last instructor selected</span> represents the Average GPA and RateMyProfessors Rating on the circle graphs! To view a different average GPA or RateMyProfessor (RMP) rating, click the instructor dropdown and select a different instructor.
<br />
<br />
Sometimes, the GPA data or RMP rating my not be available for a specific instructor, and may be blank.
Sometimes, the RateMyProfessor rating may take a moment to load.
<br />
<br />
To view <span className='font-bold text-yellow-500'>all instructor GPAs</span>, click on the "Average GPA" circle graph. It will display the breakdown of each professor's GPA per semester. 0 means that the professor has not taught that semester.
Expand Down
Loading