Skip to content

Commit

Permalink
CSCEXAM-000 Reorganize TS models
Browse files Browse the repository at this point in the history
  • Loading branch information
lupari committed Sep 27, 2024
1 parent 342637a commit 09635cd
Show file tree
Hide file tree
Showing 166 changed files with 936 additions and 880 deletions.
41 changes: 41 additions & 0 deletions ui/src/app/administrative/administrative.model.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
// SPDX-FileCopyrightText: 2024 The members of the EXAM Consortium
//
// SPDX-License-Identifier: EUPL-1.2

import { ExamParticipation } from 'src/app/enrolment/enrolment.model';

export type QueryParams = { start?: string; end?: string; dept?: string };

export type ExamInfo = {
name: string;
participations: number;
state: string;
rank: number;
};
export type Participations = {
[room: string]: ExamParticipation[];
};

export interface AppConfig {
eula: string;
examMaxDate: string;
examDurations: number[];
examMaxDuration: number;
examMinDuration: number;
expirationPeriod: string;
anonymousReviewEnabled: boolean;
hasCourseSearchIntegration: boolean;
hasEnrolmentCheckIntegration: boolean;
isGradeScaleOverridable: boolean;
isInteroperable: boolean;
defaultTimeZone: string;
maxFileSize: number;
reservationWindowSize: number;
reviewDeadline: number;
roles: { ADMIN: string[]; TEACHER: string[]; STUDENT: string[] };
supportsMaturity: boolean;
supportsPrintouts: boolean;
isExamVisitSupported: boolean;
isExamCollaborationSupported: boolean;
courseSearchIntegrationUrls: { [key: string]: string };
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ import { NgbPopover } from '@ng-bootstrap/ng-bootstrap';
import { TranslateModule, TranslateService } from '@ngx-translate/core';
import { ToastrService } from 'ngx-toastr';
import { FileService } from 'src/app/shared/file/file.service';
import { DropdownSelectComponent, Option } from 'src/app/shared/select/dropdown-select.component';
import { DropdownSelectComponent } from 'src/app/shared/select/dropdown-select.component';
import { Option } from 'src/app/shared/select/select.model';

@Component({
template: `
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ import { NgbPopover } from '@ng-bootstrap/ng-bootstrap';
import { TranslateModule, TranslateService } from '@ngx-translate/core';
import { ToastrService } from 'ngx-toastr';
import { FileService } from 'src/app/shared/file/file.service';
import { DropdownSelectComponent, Option } from 'src/app/shared/select/dropdown-select.component';
import { DropdownSelectComponent } from 'src/app/shared/select/dropdown-select.component';
import { Option } from 'src/app/shared/select/select.model';

@Component({
template: `
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,6 @@
//
// SPDX-License-Identifier: EUPL-1.2

/*
* Copyright (c) 2018 The members of the EXAM Consortium (https://confluence.csc.fi/display/EXAM/Konsortio-organisaatio)
*
* Licensed under the EUPL, Version 1.1 or - as soon they will be approved by the European Commission - subsequent
* versions of the EUPL (the "Licence");
* You may not use this work except in compliance with the Licence.
* You may obtain a copy of the Licence at:
*
* https://joinup.ec.europa.eu/software/page/eupl/licence-eupl
*
* Unless required by applicable law or agreed to in writing, software distributed under the Licence is distributed
* on an "AS IS" basis, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the Licence for the specific language governing permissions and limitations under the Licence.
*/
import { Component } from '@angular/core';
import { NgbPopover } from '@ng-bootstrap/ng-bootstrap';
import { TranslateModule } from '@ngx-translate/core';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ import { ToastrService } from 'ngx-toastr';
import type { ExamRoom } from 'src/app/reservation/reservation.model';
import { DatePickerComponent } from 'src/app/shared/date/date-picker.component';
import { FileService } from 'src/app/shared/file/file.service';
import { DropdownSelectComponent, Option } from 'src/app/shared/select/dropdown-select.component';
import { DropdownSelectComponent } from 'src/app/shared/select/dropdown-select.component';
import { Option } from 'src/app/shared/select/select.model';

@Component({
template: `
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,11 @@ import { NgbPopover } from '@ng-bootstrap/ng-bootstrap';
import { TranslateModule, TranslateService } from '@ngx-translate/core';
import { format } from 'date-fns';
import { ToastrService } from 'ngx-toastr';
import type { User } from 'src/app/session/session.service';
import type { User } from 'src/app/session/session.model';
import { DatePickerComponent } from 'src/app/shared/date/date-picker.component';
import { FileService } from 'src/app/shared/file/file.service';
import { DropdownSelectComponent, Option } from 'src/app/shared/select/dropdown-select.component';
import { DropdownSelectComponent } from 'src/app/shared/select/dropdown-select.component';
import { Option } from 'src/app/shared/select/select.model';

@Component({
template: `
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,11 @@ import { NgbPopover } from '@ng-bootstrap/ng-bootstrap';
import { TranslateModule, TranslateService } from '@ngx-translate/core';
import { format } from 'date-fns';
import { ToastrService } from 'ngx-toastr';
import type { User } from 'src/app/session/session.service';
import type { User } from 'src/app/session/session.model';
import { DatePickerComponent } from 'src/app/shared/date/date-picker.component';
import { FileService } from 'src/app/shared/file/file.service';
import { DropdownSelectComponent, Option } from 'src/app/shared/select/dropdown-select.component';
import { DropdownSelectComponent } from 'src/app/shared/select/dropdown-select.component';
import { Option } from 'src/app/shared/select/select.model';

@Component({
template: `
Expand Down
11 changes: 8 additions & 3 deletions ui/src/app/administrative/reports/reports.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ import { Component } from '@angular/core';
import { TranslateModule } from '@ngx-translate/core';
import { RoomService } from 'src/app/facility/rooms/room.service';
import { ExamRoom } from 'src/app/reservation/reservation.model';
import { User } from 'src/app/session/session.service';
import { User } from 'src/app/session/session.model';
import { PageContentComponent } from 'src/app/shared/components/page-content.component';
import { PageHeaderComponent } from 'src/app/shared/components/page-header.component';
import { Option } from 'src/app/shared/select/dropdown-select.component';
import { Option } from 'src/app/shared/select/select.model';
import { UserService } from 'src/app/shared/user/user.service';
import { AnswersReportComponent } from './categories/answers-report.component';
import { EnrolmentsReportComponent } from './categories/enrolments-report.component';
Expand All @@ -20,8 +20,13 @@ import { ReviewsReportComponent } from './categories/reviews-report.component';
import { RoomsReportComponent } from './categories/rooms-report.component';
import { StudentsReportComponent } from './categories/students-report.component';
import { TeachersReportComponent } from './categories/teachers-report.component';
import { ReportsService, UserRole } from './reports.service';
import { ReportsService } from './reports.service';

enum UserRole {
TEACHER = 'TEACHER',
STUDENT = 'STUDENT',
ADMIN = 'ADMIN',
}
@Component({
selector: 'xm-reports',
template: `
Expand Down
13 changes: 1 addition & 12 deletions ui/src/app/administrative/reports/reports.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import { HttpClient } from '@angular/common/http';
import { Injectable } from '@angular/core';

export interface ExamName {
interface ExamName {
id: number;
name: string;
course: {
Expand All @@ -15,17 +15,6 @@ export interface ExamName {
};
}

export enum FileType {
JSON = 'json',
XLSX = 'xlsx',
}

export enum UserRole {
TEACHER = 'TEACHER',
STUDENT = 'STUDENT',
ADMIN = 'ADMIN',
}

@Injectable({ providedIn: 'root' })
export class ReportsService {
constructor(private http: HttpClient) {}
Expand Down
3 changes: 2 additions & 1 deletion ui/src/app/administrative/settings/settings.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,11 @@ import { FormsModule } from '@angular/forms';
import { NgbPopover } from '@ng-bootstrap/ng-bootstrap';
import { TranslateModule, TranslateService } from '@ngx-translate/core';
import { ToastrService } from 'ngx-toastr';
import { AppConfig } from 'src/app/administrative/administrative.model';
import { CKEditorComponent } from 'src/app/shared/ckeditor/ckeditor.component';
import { PageContentComponent } from 'src/app/shared/components/page-content.component';
import { PageHeaderComponent } from 'src/app/shared/components/page-header.component';
import { AppConfig, SettingsService } from './settings.service';
import { SettingsService } from './settings.service';

@Component({
templateUrl: './settings.component.html',
Expand Down
25 changes: 1 addition & 24 deletions ui/src/app/administrative/settings/settings.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,30 +4,7 @@

import { HttpClient } from '@angular/common/http';
import { Injectable } from '@angular/core';

export interface AppConfig {
eula: string;
examMaxDate: string;
examDurations: number[];
examMaxDuration: number;
examMinDuration: number;
expirationPeriod: string;
anonymousReviewEnabled: boolean;
hasCourseSearchIntegration: boolean;
hasEnrolmentCheckIntegration: boolean;
isGradeScaleOverridable: boolean;
isInteroperable: boolean;
defaultTimeZone: string;
maxFileSize: number;
reservationWindowSize: number;
reviewDeadline: number;
roles: { ADMIN: string[]; TEACHER: string[]; STUDENT: string[] };
supportsMaturity: boolean;
supportsPrintouts: boolean;
isExamVisitSupported: boolean;
isExamCollaborationSupported: boolean;
courseSearchIntegrationUrls: { [key: string]: string };
}
import { AppConfig } from 'src/app/administrative/administrative.model';

@Injectable({ providedIn: 'root' })
export class SettingsService {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import type { OnInit } from '@angular/core';
import { Component, Input } from '@angular/core';
import { TranslateModule } from '@ngx-translate/core';
import type { ExamInfo, QueryParams } from 'src/app/administrative/statistics/statistics.service';
import { ExamInfo, QueryParams } from 'src/app/administrative/administrative.model';
import { StatisticsService } from 'src/app/administrative/statistics/statistics.service';

@Component({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import type { OnInit } from '@angular/core';
import { Component, Input } from '@angular/core';
import { TranslateModule } from '@ngx-translate/core';
import type { QueryParams } from 'src/app/administrative/statistics/statistics.service';
import { QueryParams } from 'src/app/administrative/administrative.model';
import { StatisticsService } from 'src/app/administrative/statistics/statistics.service';

@Component({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import type { OnInit } from '@angular/core';
import { Component, Input, signal } from '@angular/core';
import { TranslateModule } from '@ngx-translate/core';
import type { QueryParams } from 'src/app/administrative/statistics/statistics.service';
import { QueryParams } from 'src/app/administrative/administrative.model';
import { StatisticsService } from 'src/app/administrative/statistics/statistics.service';

@Component({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@
import { DatePipe } from '@angular/common';
import { Component, Input } from '@angular/core';
import { TranslateModule } from '@ngx-translate/core';
import type { Participations, QueryParams } from 'src/app/administrative/statistics/statistics.service';
import { Participations, QueryParams } from 'src/app/administrative/administrative.model';
import { StatisticsService } from 'src/app/administrative/statistics/statistics.service';
import { ExamParticipation } from 'src/app/enrolment/enrolment.model';

@Component({
template: `
Expand Down Expand Up @@ -95,8 +96,8 @@ export class RoomStatisticsComponent {

totalParticipations = (month?: Date, room?: string) => {
if (!this.participations) return 0;
const isWithinBounds = (data: { date: string }) => {
const date = new Date(data.date);
const isWithinBounds = (p: ExamParticipation) => {
const date = new Date(p.externalExam ? p.externalExam.started : p.exam.created);
const current = month ? new Date(month) : new Date();
const min = new Date(current.getFullYear(), current.getMonth(), 1);
const max = new Date(current.getFullYear(), current.getMonth() + 1, 0, 23, 59, 59);
Expand Down Expand Up @@ -132,7 +133,12 @@ export class RoomStatisticsComponent {

private getMinAndMaxDates = (): { min: Date; max: Date } => {
const dates: Date[] = Object.values(this.participations)
.flatMap((ps) => ps.map((d) => new Date(d.date)))
.flatMap((ps) =>
ps
.filter((p) => p.exam || p.externalExam)
.map((p) => (p.externalExam ? p.externalExam.started : p.exam.created))
.map((d) => new Date(d)),
)
.sort((a, b) => a.getTime() - b.getTime());
let minDate = dates[0];
// Set min date to which one is earlier: participation or search date
Expand Down
3 changes: 2 additions & 1 deletion ui/src/app/administrative/statistics/statistics.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,15 @@ import {
NgbNavLink,
} from '@ng-bootstrap/ng-bootstrap';
import { TranslateModule } from '@ngx-translate/core';
import { QueryParams } from 'src/app/administrative/administrative.model';
import { PageContentComponent } from 'src/app/shared/components/page-content.component';
import { PageHeaderComponent } from 'src/app/shared/components/page-header.component';
import { DatePickerComponent } from 'src/app/shared/date/date-picker.component';
import { ExamStatisticsComponent } from './categories/exam-statistics.component';
import { ReservationStatisticsComponent } from './categories/reservation-statistics.component';
import { ResponseStatisticsComponent } from './categories/response-statistics.component';
import { RoomStatisticsComponent } from './categories/room-statistics.component';
import { QueryParams, StatisticsService } from './statistics.service';
import { StatisticsService } from './statistics.service';

interface Departments {
name: string;
Expand Down
12 changes: 1 addition & 11 deletions ui/src/app/administrative/statistics/statistics.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,7 @@

import { HttpClient } from '@angular/common/http';
import { Injectable } from '@angular/core';

export type QueryParams = { start?: string; end?: string; dept?: string };
export type ExamInfo = {
name: string;
participations: number;
state: string;
rank: number;
};
export type Participations = {
[room: string]: { date: string }[];
};
import { ExamInfo, Participations, QueryParams } from 'src/app/administrative/administrative.model';

@Injectable({ providedIn: 'root' })
export class StatisticsService {
Expand Down
5 changes: 2 additions & 3 deletions ui/src/app/administrative/users/users.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,12 @@ import { TranslateModule, TranslateService } from '@ngx-translate/core';
import { ToastrService } from 'ngx-toastr';
import { Subject } from 'rxjs';
import { debounceTime, distinctUntilChanged, takeUntil } from 'rxjs/operators';
import type { User } from 'src/app/session/session.service';
import { PermissionType, type Permission, type User } from 'src/app/session/session.model';
import { SessionService } from 'src/app/session/session.service';
import { PageContentComponent } from 'src/app/shared/components/page-content.component';
import { PageHeaderComponent } from 'src/app/shared/components/page-header.component';
import { PaginatorComponent } from 'src/app/shared/paginator/paginator.component';
import type { Permission } from './users.service';
import { PermissionType, UserManagementService } from './users.service';
import { UserManagementService } from './users.service';

interface PermissionOption extends Permission {
name?: string;
Expand Down
12 changes: 1 addition & 11 deletions ui/src/app/administrative/users/users.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,7 @@

import { HttpClient } from '@angular/common/http';
import { Injectable } from '@angular/core';
import type { Role, User } from 'src/app/session/session.service';

export enum PermissionType {
CAN_INSPECT_LANGUAGE = 'CAN_INSPECT_LANGUAGE',
CAN_CREATE_BYOD_EXAM = 'CAN_CREATE_BYOD_EXAM',
}

export interface Permission {
id: number;
type: PermissionType;
}
import type { Permission, PermissionType, Role, User } from 'src/app/session/session.model';

@Injectable({ providedIn: 'root' })
export class UserManagementService {
Expand Down
2 changes: 1 addition & 1 deletion ui/src/app/app.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import { takeUntil } from 'rxjs/operators';
import { ExaminationStatusService } from './examination/examination-status.service';
import { NavigationComponent } from './navigation/navigation.component';
import { DevLoginComponent } from './session/dev/dev-login.component';
import type { User } from './session/session.service';
import type { User } from './session/session.model';
import { SessionService } from './session/session.service';

@Component({
Expand Down
3 changes: 2 additions & 1 deletion ui/src/app/calendar/calendar.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ import { ConfirmationDialogService } from 'src/app/shared/dialogs/confirmation-d
import { HistoryBackComponent } from 'src/app/shared/history/history-back.component';
import { CourseCodeComponent } from 'src/app/shared/miscellaneous/course-code.component';
import { AutoFocusDirective } from 'src/app/shared/select/auto-focus.directive';
import { CalendarService, ExamInfo, Organisation } from './calendar.service';
import { ExamInfo, Organisation } from './calendar.model';
import { CalendarService } from './calendar.service';
import { CalendarExamInfoComponent } from './helpers/exam-info.component';
import { OptionalSectionsComponent } from './helpers/optional-sections.component';
import { OrganisationPickerComponent } from './helpers/organisation-picker.component';
Expand Down
Loading

0 comments on commit 09635cd

Please sign in to comment.