Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
3bd6d94
fixed summation after long fight with git :!
LSKpr May 6, 2025
c6a79a2
sorting kinda works - some problems exist
LSKpr May 7, 2025
6ef0ac0
Merge branch 'main' of github.com:InferenceKTH/Find-My-Next-Course
LSKpr May 7, 2025
1d02b82
fixed search + filter interaction
LSKpr May 7, 2025
9e6da22
sorting is better now / Metallic Materials are the only issue
LSKpr May 7, 2025
ed3e93f
asc/desc have correct icon now
LSKpr May 7, 2025
b4a43a4
Merge branch 'main' of github.com:InferenceKTH/Find-My-Next-Course in…
LSKpr May 7, 2025
1973a40
Merge branch 'main' of github.com:InferenceKTH/Find-My-Next-Course in…
LSKpr May 7, 2025
1880408
added favicon
LSKpr May 8, 2025
2e799ef
Merge branch 'main' of github.com:InferenceKTH/Find-My-Next-Course in…
LSKpr May 8, 2025
43a430f
fixed the website name in index.html
LSKpr May 8, 2025
9e57a66
Merge branch 'main' of github.com:InferenceKTH/Find-My-Next-Course in…
LSKpr May 8, 2025
1e2ac77
Merge branch 'main' of github.com:InferenceKTH/Find-My-Next-Course in…
LSKpr May 8, 2025
7fafcfb
Merge branch 'main' of github.com:InferenceKTH/Find-My-Next-Course in…
LSKpr May 8, 2025
45b7ae2
Merge branch 'main' of github.com:InferenceKTH/Find-My-Next-Course in…
LSKpr May 8, 2025
a6fce52
Merge branch 'main' of github.com:InferenceKTH/Find-My-Next-Course in…
LSKpr May 8, 2025
e7f0385
Merge branch 'main' of github.com:InferenceKTH/Find-My-Next-Course in…
LSKpr May 8, 2025
811154c
Merge branch 'main' of github.com:InferenceKTH/Find-My-Next-Course in…
LSKpr May 8, 2025
8662574
Merge branch 'main' of github.com:InferenceKTH/Find-My-Next-Course in…
LSKpr May 8, 2025
fd86c41
ArrowLeft closes the CoursePopup
LSKpr May 8, 2025
c461366
popup variables moved to the model
LSKpr May 8, 2025
f5a14d6
popup variables moved to the model
LSKpr May 8, 2025
8358f73
Merge branch 'main' of github.com:InferenceKTH/Find-My-Next-Course in…
LSKpr May 8, 2025
d80e280
Merge branch 'main' of github.com:InferenceKTH/Find-My-Next-Course in…
LSKpr May 8, 2025
df37e10
Merge branch 'main' of github.com:InferenceKTH/Find-My-Next-Course in…
LSKpr May 9, 2025
d18cc83
bug fix
LSKpr May 9, 2025
47bdcfc
prefix matching is preffered in search function
LSKpr May 9, 2025
5413a01
Merge branch 'main' of github.com:InferenceKTH/Find-My-Next-Course in…
LSKpr May 9, 2025
77d8ec0
Merge branch 'main' of github.com:InferenceKTH/Find-My-Next-Course in…
LSKpr May 9, 2025
aed5bb1
git stash fight
LSKpr May 9, 2025
8f37a32
Merge branch 'main' of github.com:InferenceKTH/Find-My-Next-Course in…
LSKpr May 9, 2025
1b3bd81
searchbar escape char bug fix
LSKpr May 9, 2025
f59d944
Merge branch 'main' of github.com:InferenceKTH/Find-My-Next-Course in…
LSKpr May 9, 2025
4fd77eb
Merge branch 'main' of github.com:InferenceKTH/Find-My-Next-Course in…
LSKpr May 9, 2025
35ed659
added srot by rating
LSKpr May 9, 2025
b326b11
Merge branch 'main' of github.com:InferenceKTH/Find-My-Next-Course in…
LSKpr May 9, 2025
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
1 change: 1 addition & 0 deletions my-app/src/model.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ export const model = {
locations: [],
// indexes: 0 -> overall rating; 1 -> difficulty; 2->teacher rating
avgRatings: [],
// model.avgRatings["IK1203"][0]
/* courses the user selected as their favourite */
favourites: [],
searchHistory:[],
Expand Down
49 changes: 48 additions & 1 deletion my-app/src/presenters/ListViewPresenter.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import CoursePagePopup from '../views/Components/CoursePagePopup.jsx';
import PrerequisitePresenter from './PrerequisitePresenter.jsx';
import {ReviewPresenter} from "./ReviewPresenter.jsx"
import {syncScrollPositionToFirebase} from "../../firebase.js"
import { model } from '../model.js';

const ListViewPresenter = observer(({ model }) => {
const scrollContainerRef = useRef(null);
Expand Down Expand Up @@ -91,6 +92,52 @@ const ListViewPresenter = observer(({ model }) => {
case 'credits':
return sortedCourses.sort((a, b) =>
direction * (parseFloat(a.credits) - parseFloat(b.credits)));


// indexes: 0 -> overall rating; 1 -> difficulty; 2->teacher rating
case 'avg_rating':
return sortedCourses.sort((a, b) => {
let aScore = 0;
let bScore = 0;

if (model.avgRatings[a.code] != null && model.avgRatings[a.code][0] != null) {
aScore = model.avgRatings[a.code][0] + 10; // +10 so courses with no reviews are shown before those with bad reviews (0/5 stars)
}

if (model.avgRatings[b.code] != null && model.avgRatings[b.code][0] != null) {
bScore = model.avgRatings[b.code][0] + 10;
}
return direction * (aScore - bScore);
});
case 'diff_rating':
return sortedCourses.sort((a, b) => {
let aScore = 0;
let bScore = 0;

if (model.avgRatings[a.code] != null && model.avgRatings[a.code][1] != null) {
aScore = model.avgRatings[a.code][1] + 10; // +10 so courses with no reviews are shown before those with bad reviews (0/5 stars)
}

if (model.avgRatings[b.code] != null && model.avgRatings[b.code][1] != null) {
bScore = model.avgRatings[b.code][1] + 10;
}

return direction * (aScore - bScore);
});
case 'teacher_rating':
return sortedCourses.sort((a, b) => {
let aScore = 0;
let bScore = 0;

if (model.avgRatings[a.code] != null && model.avgRatings[a.code][2] != null) {
aScore = model.avgRatings[a.code][2] + 10; // +10 so courses with no reviews are shown before those with bad reviews (0/5 stars)
}

if (model.avgRatings[b.code] != null && model.avgRatings[b.code][2] != null) {
bScore = model.avgRatings[b.code][2] + 10;
}
return direction * (aScore - bScore);
});
case 'relevance':
return direction === -1 ? sortedCourses : sortedCourses.reverse();
default:
Expand Down Expand Up @@ -183,4 +230,4 @@ const ListViewPresenter = observer(({ model }) => {
/>;
});

export { ListViewPresenter };
export { ListViewPresenter };
3 changes: 3 additions & 0 deletions my-app/src/views/ListView.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,9 @@ function ListView(props) {
<option value="relevance">Sort by Relevance</option>
<option value="name">Sort by Name</option>
<option value="credits">Sort by Credits</option>
<option value="avg_rating">Sort by Overall Rating</option>
<option value="diff_rating">Sort by Difficulty Rating</option>
<option value="teacher_rating">Sort by Professor Rating</option>
</select>

<button
Expand Down