Skip to content

Commit

Permalink
update edge case professors & grades graph
Browse files Browse the repository at this point in the history
  • Loading branch information
GiridharRNair committed Nov 11, 2024
1 parent 3c4b2e6 commit 79e1647
Show file tree
Hide file tree
Showing 8 changed files with 34 additions and 34 deletions.
14 changes: 3 additions & 11 deletions api/controllers/professor_information.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,6 @@ import (
"github.com/gin-gonic/gin"
)

// Edge case professors with different names in the database than on RateMyProfessor
var professorNameCorrections = map[string]string{
"Ding-Zhu Du": "Ding Du",
"Sue Brookshire": "Susan Brookshire",
"Chitturi Bhadrachalam": "Bhadrachalam Chitturi",
}

const ValidateTeacherNameRegex = `[^a-zA-Z\s.\-]|.*\-.*\-`

func GetProfessorInformation(c *gin.Context) {
Expand Down Expand Up @@ -46,13 +39,12 @@ func GetProfessorInformation(c *gin.Context) {
return
}

professorName := professorNameCorrections[professor.Name]
if professorName == "" {
professorName = professor.Name
if professor.Name == "Chitturi Bhadrachalam" {
professor.Name = "Bhadrachalam Chitturi"
}

// possible chance RMP name has middle name
profNameArray := strings.Fields(professorName)
profNameArray := strings.Fields(professor.Name)
profNameWithoutMiddle := fmt.Sprintf("%s %s", profNameArray[0], profNameArray[len(profNameArray)-1])

resultData := gin.H{
Expand Down
2 changes: 1 addition & 1 deletion api/controllerstest/professor_information_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ const timothyFarageExpectedJSON = `{
"Respected",
"Test Heavy"
],
"would_take_again": 77
"would_take_again": 78
}`

func TestGetProfessorInformation(t *testing.T) {
Expand Down
12 changes: 6 additions & 6 deletions api/professor/professor.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,16 +99,16 @@ func (p *Professor) getProfessorTags() {
}

func getProfessorID(professorName, schoolID string) (string, error) {
// Temporary fix for Scott Dollinger
if professorName == "Scott Dollinger" {
return "2523207", nil
}

// Temporary fix for Wei-Pang Chin
if professorName == "Wei-Pang Chin" {
if regexp.MustCompile(`[^a-zA-Z0-9]+`).ReplaceAllString(professorName, "") == "weipangchin" {
return "2420900", nil
}

// Temporary fix for Bo Park
if regexp.MustCompile(`[^a-zA-Z0-9]+`).ReplaceAllString(professorName, "") == "bopark" {
return "2680140", nil
}

url := fmt.Sprintf(RateMyProfessorSearchURL, schoolID, url.QueryEscape(professorName))

resp, err := http.Get(url)
Expand Down
1 change: 1 addition & 0 deletions db_setup/create_db.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@

# Some professors have their names in different formats in RMP and the UTD data
edge_case_professors = {
"Du, Ding Z": "Ding-Zhu Du",
"Nishi, Hirofumi": "Hiro Nishi",
"Macalevey, Paul J": "Paul MacAlevey",
"Mac Alevey, Paul J": "Paul MacAlevey",
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "profstatsutd",
"description": "This extension offers a user-friendly interface for accessing aggregated grades and professor ratings effortlessly.",
"private": true,
"version": "1.1.6",
"version": "1.1.7",
"type": "module",
"scripts": {
"install-packages": "npm install && cd api && go mod download",
Expand Down
17 changes: 12 additions & 5 deletions src/components/GradesGraph.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { gradeMappings, colorMap } from "../../utils/defaults.js";

ChartJS.register(CategoryScale, LinearScale, BarElement, Tooltip);

function GradesGraph({ grades }) {
function GradesGraph({ grades, subject, course_number }) {

Check failure on line 9 in src/components/GradesGraph.jsx

View workflow job for this annotation

GitHub Actions / Run ESLint + Prettier

'subject' is missing in props validation

Check failure on line 9 in src/components/GradesGraph.jsx

View workflow job for this annotation

GitHub Actions / Run ESLint + Prettier

'course_number' is missing in props validation
const gradeLabels = Object.keys(grades).map((grade) => gradeMappings[grade] || grade);

const chartData = {
Expand All @@ -29,10 +29,17 @@ function GradesGraph({ grades }) {
titleColor: useColorModeValue("black", "white"),
bodyColor: useColorModeValue("black", "white"),
callbacks: {
label: (context) => [
`Students: ${context.parsed.y}`,
`Percentage: ${((context.parsed.y / Object.values(grades).reduce((acc, count) => acc + count, 0)) * 100).toFixed(2)}%`,
],
label: (context) => {
const tooltipLines = [];
if (subject && course_number) {
tooltipLines.push(`${subject} ${course_number}`);
}
tooltipLines.push(`Students: ${context.parsed.y}`);
tooltipLines.push(
`Percentage: ${((context.parsed.y / Object.values(grades).reduce((acc, count) => acc + count, 0)) * 100).toFixed(2)}%`,
);
return tooltipLines;
},
},
},
},
Expand Down
2 changes: 1 addition & 1 deletion src/components/ProfessorResults.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ function ProfResults({ professorInfo }) {
/>
</HStack>

<GradesGraph grades={grades} />
<GradesGraph grades={grades} subject={subject} course_number={course_number} />

<Drawer isOpen={isOpen} onClose={onClose} placement="bottom" size="md">
<DrawerOverlay />
Expand Down
18 changes: 9 additions & 9 deletions utils/defaults.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,31 +45,31 @@ export const colorMap = {
export const timothyFarage = {
course_number: "",
department: "Computer Science",
difficulty: 2.3,
difficulty: 2.1,
grades: {
aPlus: 1026,
a: 1186,
aMinus: 277,
bPlus: 232,
aPlus: 1026,
b: 296,
bMinus: 77,
cPlus: 60,
bPlus: 232,
c: 129,
cMinus: 44,
dPlus: 26,
cPlus: 60,
cr: 29,
d: 34,
dMinus: 25,
dPlus: 26,
f: 47,
cr: 29,
nc: 5,
w: 40,
},
id: "138341",
name: "Timothy Farage",
rating: 4.3,
rating: 4.2,
subject: "",
tags: ["Amazing Lectures", "Graded By Few Things", "Hilarious", "Respected", "Test Heavy"],
would_take_again: 81,
would_take_again: 78,
};

export const scottDollinger = {
Expand Down Expand Up @@ -103,4 +103,4 @@ export const scottDollinger = {

export const defaultTeacherSuggestions = ["John Cole", "Regina Ybarra", "Stephanie Taylor", "Bentley Garrett", "Karl Sengupta"];

export const defaultCourseSuggestions = ["CE 2336", "MATH 2418", "CHEM 2401", "ACCT 6305", "SPAN 2311"];
export const defaultCourseSuggestions = ["CS 2305", "MATH 2418", "CHEM 2401", "ACCT 6305", "SPAN 2311"];

0 comments on commit 79e1647

Please sign in to comment.