Skip to content

Commit

Permalink
Merge pull request #96 from lost-university/fix-search-for-accredited…
Browse files Browse the repository at this point in the history
…-modules

Fix search for accredited modules and categories
  • Loading branch information
StefanieJaeger authored Jan 29, 2025
2 parents 1294cb5 + 1b9e9db commit 2102441
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 18 deletions.
1 change: 1 addition & 0 deletions src/components/AccreditedModulesModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@
:show-chevron="true"
:show-next-possible-semester="false"
:text-for-button="'Modul auswählen'"
:disable-invalid-modules="false"
@on-module-selected="moduleId => onModuleSelected(moduleId)"
/>
</div>
Expand Down
3 changes: 1 addition & 2 deletions src/components/ModuleSearch.vue
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,6 @@ import {
} from '@headlessui/vue';
import { getColorClassForCategoryId } from '../helpers/color-helper';
import { ValidationHelper } from '../helpers/validation-helper';
import { SemesterInfo } from '../helpers/semester-info';
export type GroupedModule = {id: string, name: string, modules: Module[], isOpen: boolean, colorClass: object };
Expand Down Expand Up @@ -201,7 +200,7 @@ export default defineComponent({
return store.getters.allPlannedModuleIds.includes(module.id);
},
moduleHasWrongTerm(module: Module): boolean {
return ValidationHelper.isModuleInWrongTerm(module, SemesterInfo.nextSemester(this.termForWhichToSearch)!);
return ValidationHelper.isModuleInWrongTerm(module, this.termForWhichToSearch);
},
selectModule(moduleId: string) {
if (moduleId) {
Expand Down
25 changes: 9 additions & 16 deletions src/helpers/validation-helper.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { AccreditedModule, Module, Semester } from '../helpers/types';
import type { AccreditedModule, Module, Semester, Term } from '../helpers/types';
import { SemesterInfo } from './semester-info';
import { store } from './store';

Expand Down Expand Up @@ -63,7 +63,7 @@ export class ValidationHelper {
};
}
}
if(this.isModuleInWrongTerm(module, semesterInfoForModule)) {
if(this.isModuleInWrongTermForSemester(module, semesterInfoForModule)) {
const targetSemesterNumber = semesterForModule.number + 1;
return {
type: 'wrongTerm',
Expand Down Expand Up @@ -92,7 +92,7 @@ export class ValidationHelper {
moduleId: module.id
};
}
if(this.isModuleInWrongTerm(module, semesterInfoForModule)) {
if(this.isModuleInWrongTermForSemester(module, semesterInfoForModule)) {
const targetSemesterNumber = semesterForModule.number + 1;
return {
type: 'wrongTerm',
Expand Down Expand Up @@ -134,19 +134,12 @@ export class ValidationHelper {
};
}

static isModuleInWrongTerm(module: Module, semesterInfo: SemesterInfo): boolean {
switch (module.term) {
case 'FS':
return !semesterInfo.isSpringSemester;
case 'HS':
return semesterInfo.isSpringSemester;
case 'both':
case '':
return false;
default:
console.error(`Invalid term ${module.term} for module ${module.id}`);
return true;
}
static isModuleInWrongTerm(module: Module, term: Term): boolean {
return term === 'both' ? false : module.term === term;
}

private static isModuleInWrongTermForSemester(module: Module, semesterInfo: SemesterInfo): boolean {
return this.isModuleInWrongTerm(module, semesterInfo.isSpringSemester ? 'FS' : 'HS');
}

private static isSemesterInThePast(semesterInfo: SemesterInfo) {
Expand Down

0 comments on commit 2102441

Please sign in to comment.