Skip to content

Commit

Permalink
Merge pull request #48 from acmauth/gradesPage
Browse files Browse the repository at this point in the history
added settings
  • Loading branch information
itsMyrto authored Feb 17, 2024
2 parents 6090f6b + 9dab05d commit ca18499
Show file tree
Hide file tree
Showing 10 changed files with 219 additions and 72 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
"cross-fetch": "^4.0.0",
"fetch-cookie": "^2.1.0",
"flowbite-svelte": "^0.44.19",
"fuse.js": "^7.0.0",
"ionic-svelte": "^0.5.82",
"ionicons": "^7.2.1",
"isomorphic-fetch": "^3.0.0",
Expand Down
33 changes: 20 additions & 13 deletions src/lib/components/courses/courseInfo.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,8 @@
<ion-card>
<ion-card-header>
<ion-card-title>{course.title}</ion-card-title>
<ion-card-subtitle>{course.code}</ion-card-subtitle>
<ion-card-subtitle>{course.courseType}</ion-card-subtitle>
<ion-card-subtitle># {course.code}</ion-card-subtitle>
<ion-card-subtitle>Τύπος: {course.courseType}</ion-card-subtitle>
</ion-card-header>

<!-- Checking if there is a grade and displays the corresponding color depending if you passed or not -->
Expand All @@ -142,20 +142,20 @@

<ion-list>

<ion-item>
<ion-item lines ="full">
<ion-label>ECTS</ion-label>
<ion-text slot="end">{course.ects}</ion-text>
</ion-item>

<ion-item>
<ion-item lines ="full">
<ion-label>Εξάμηνο</ion-label>
<ion-text slot="end">{course.semester}ο</ion-text>
</ion-item>
<ion-item>
<ion-item lines ="full">
<ion-label>Περίοδος</ion-label>
<ion-text slot="end">{course.season}</ion-text>
</ion-item>
<ion-item>
<ion-item lines ="full">
<ion-label >Εβδομαδιαίες ώρες</ion-label>
<ion-text slot="end">{course.weeklyHours}</ion-text>
</ion-item>
Expand Down Expand Up @@ -183,33 +183,34 @@
<ion-card-subtitle>-</ion-card-subtitle>
{/if}
</ion-card-header>
<ion-card-content>
{#if stats.grade}
<ion-list>
<ion-item>
<ion-item lines ="full">
<ion-label>Βαθμολογημένοι</ion-label>
<ion-text slot="end">{stats.totalStudents}</ion-text>
</ion-item>
<ion-item>
<ion-item lines ="full">
<ion-label>Φοιτητές με ίδιο βαθμό</ion-label>
<ion-text slot="end">{stats.studentsLikeMe}</ion-text>
</ion-item>
<ion-item>
<ion-item lines ="full">
<ion-label>Φοιτητές με καλύτερο βαθμό</ion-label>
<ion-text slot="end">{stats.studentsBetterThanMe}</ion-text>
</ion-item>
<ion-item>
<ion-item lines ="full">
<ion-label>Φοιτητές με χειρότερο βαθμό</ion-label>
<ion-text slot="end">{stats.studentsWorseThanMe}</ion-text>
</ion-item>
<ion-item>
<ion-item lines ="full">
<ion-label>Φοιτητές που πέρασαν</ion-label>
<ion-text slot="end">{stats.passedCount}</ion-text>
</ion-item>
<ion-item>
<ion-item lines ="full">
<ion-label>Φοιτητές που κόπηκαν</ion-label>
<ion-text slot="end">{stats.failedCount}</ion-text>
</ion-item>
<ion-item>
<ion-item lines ="full">
<ion-label>Μέσος όρος</ion-label>
<ion-text slot="end">{stats.averageGrade}</ion-text>
</ion-item>
Expand All @@ -227,6 +228,7 @@
</ion-item>
</ion-list>
{/if}
</ion-card-content>
</ion-card>

<canvas id="gradeChart" />
Expand All @@ -248,6 +250,11 @@
box-shadow: none;
}
ion-accordion-group {
margin-top: 0.2rem;
}
Expand Down
54 changes: 39 additions & 15 deletions src/lib/components/grades/gradeCard.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -11,49 +11,51 @@
<ion-card-header>

<ion-card-title><b>{semesterId}ο Εξάμηνο</b></ion-card-title>

{#if semesterAverage}
<ion-card-subtitle>Μ.Ο Εξαμήνου: {semesterAverage}</ion-card-subtitle>
{:else}
<ion-card-subtitle>Μ.Ο Εξαμήνου: -</ion-card-subtitle>
{/if}

</ion-card-header>

<ion-card-content>
<ion-list lines="none">
{#each filteredSubjects as course}
<ion-label class="ion-padding-start">{course.course}</ion-label>

{#each filteredSubjects as course,index}

<ion-item href={`/courses/${course.course}`}>
<ion-label class="ion-text-wrap title">{course.courseTitle}</ion-label>
{#if course.grade !== null}
{#if course.grade * 10 >= 5}
<ion-text class="ion-padding-start" color="success">
<ion-text class="ion-padding-start success">
<h2>{course.formattedGrade}</h2>
</ion-text>
{:else}
<ion-text class="ion-padding-start" color="danger">
<ion-text class="ion-padding-start danger">
<h2>{course.formattedGrade}</h2>
</ion-text>
{/if}
{:else}
<ion-text class="ion-padding-start" color="danger">
<h2><b>-</b></h2>
</ion-text>


{/if}
</ion-item>
{#if course.examPeriod !== null}
<ion-label class="ion-padding-start examPeriod">
{#if course.examPeriod && course.gradeYear}
{course.examPeriod.name} {course.gradeYear.name}
{:else}
-
ΔΗΛΩΜΕΝΟ
{/if}
</ion-label>

{:else}
<ion-label class="ion-padding-start examPeriod">-</ion-label>
{/if}
<span class="line"></span>
{#if index !== filteredSubjects.length - 1}
<span class="line"></span>
{/if}



{/each}
Expand All @@ -65,10 +67,7 @@

<style>
.scroll {
display: block;
height: 35px;
}
ion-item { --min-height: 0; }
Expand All @@ -77,7 +76,20 @@ ion-label {
margin: 0.3rem 0rem;
}
ion-card-subtitle {
color: var(--app-color-primary-dark);
}
h2 {
font-size: 1.5rem;
font-weight: bold;
}
.scroll {
display: block;
height: 35px;
}
.line {
display: block;
Expand All @@ -89,6 +101,18 @@ ion-label {
margin-top: 1rem;
}
.success {
color: var(--app-color-green-dark);
}
.danger {
color: var(--app-color-orange-dark);
}
.examPeriod{
font-size: 0.8rem;
}
Expand Down
32 changes: 21 additions & 11 deletions src/lib/components/grades/grades.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,20 @@
import Card from './gradeCard.svelte';
import { coursesPerSemester } from '$lib/functions/coursePerSemester/coursesPerSemester';
import { averagesPerSemester } from '$lib/functions/gradeAverages/averagesPerSemester';
import Fuse from 'fuse.js';
export let searchQuery;
export let semesterId;
let courseBySemester = writable([]);
let filteredSubjects = writable([]);
const fuseOptions = {
keys: ['course', 'courseTitle'],
threshold: 0.3,
};
// Get the courses per semester and the average per semester
async function gatherGrades() {
Expand Down Expand Up @@ -42,16 +50,18 @@
if (searchQuery.length === 0) {
filteredSubjects.set(courses);
} else {
const filtered = courses.map((semester) => {
return {
...semester,
courses: semester.courses.filter(
(course) =>
course.courseTitle.toLowerCase().includes(searchQuery.toLowerCase()) ||
course.course.toLowerCase().includes(searchQuery.toLowerCase())
),
};
});
const subjects = courses.reduce((acc, curr) => acc.concat(curr.courses), []);
const fuse = new Fuse(subjects, fuseOptions);
const searchResults = fuse.search(searchQuery);
const filtered = courses.map((semester) => {
return {
...semester,
courses: searchResults.filter(result =>
semester.courses.some(course => course.course === result.item.course)
).map(result => result.item),
};
});
filteredSubjects.set(filtered);
}
Expand Down
Loading

0 comments on commit ca18499

Please sign in to comment.