add some class
This commit is contained in:
parent
8994b50b1d
commit
8c89c2d752
115
src/renderer/src/models/Assessment.ts
Normal file
115
src/renderer/src/models/Assessment.ts
Normal file
@ -0,0 +1,115 @@
|
||||
/*
|
||||
*
|
||||
* Copyright (c) 2025. Jeffery Hsu - Achievement Report Generator
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
import { IAssessment, IAssessmentMethod } from '@renderer/types'
|
||||
|
||||
export class AssessmentData implements IAssessment {
|
||||
private readonly _method: IAssessmentMethod[]
|
||||
private _stage: string
|
||||
private _weight: number
|
||||
|
||||
constructor(stage: string, weight: number | string, method?: IAssessmentMethod[]) {
|
||||
this._method = method ?? []
|
||||
this._stage = stage
|
||||
this._weight = Number(weight)
|
||||
}
|
||||
|
||||
get method(): IAssessmentMethod[] {
|
||||
return this._method
|
||||
}
|
||||
|
||||
get stage(): string {
|
||||
return this._stage
|
||||
}
|
||||
|
||||
set stage(value: string) {
|
||||
this._stage = value
|
||||
}
|
||||
|
||||
get weight(): number {
|
||||
return this._weight
|
||||
}
|
||||
|
||||
set weight(value: number | string) {
|
||||
this._weight = Number(value)
|
||||
}
|
||||
|
||||
public addMethod(method: IAssessmentMethod) {
|
||||
this._method.push({ ...method, weight: Number(method.weight) })
|
||||
}
|
||||
|
||||
public modifyMethod(method: IAssessmentMethod, idx: number) {
|
||||
if (idx < 0 || idx >= this._method.length) {
|
||||
return
|
||||
}
|
||||
this._method[idx] = { ...method, weight: Number(method.weight) }
|
||||
}
|
||||
|
||||
public removeMethod(idx: number) {
|
||||
this.method.splice(idx, 1)
|
||||
}
|
||||
|
||||
public static factory() {
|
||||
return new AssessmentData('', 0, [])
|
||||
}
|
||||
}
|
||||
|
||||
export class Assessment {
|
||||
private _daily: AssessmentData
|
||||
private _progress: AssessmentData
|
||||
private _final: AssessmentData
|
||||
|
||||
constructor(daily: AssessmentData, progress: AssessmentData, final: AssessmentData) {
|
||||
this._daily = daily
|
||||
this._progress = progress
|
||||
this._final = final
|
||||
}
|
||||
|
||||
public static factory() {
|
||||
return new Assessment(
|
||||
AssessmentData.factory(),
|
||||
AssessmentData.factory(),
|
||||
AssessmentData.factory()
|
||||
)
|
||||
}
|
||||
|
||||
get daily(): AssessmentData {
|
||||
return this._daily
|
||||
}
|
||||
|
||||
set daily(value: AssessmentData) {
|
||||
this._daily = value
|
||||
}
|
||||
|
||||
get progress(): AssessmentData {
|
||||
return this._progress
|
||||
}
|
||||
|
||||
set progress(value: AssessmentData) {
|
||||
this._progress = value
|
||||
}
|
||||
|
||||
get final(): AssessmentData {
|
||||
return this._final
|
||||
}
|
||||
|
||||
set final(value: AssessmentData) {
|
||||
this._final = value
|
||||
}
|
||||
}
|
107
src/renderer/src/models/Course.ts
Normal file
107
src/renderer/src/models/Course.ts
Normal file
@ -0,0 +1,107 @@
|
||||
/*
|
||||
*
|
||||
* Copyright (c) 2025. Jeffery Hsu - Achievement Report Generator
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
import { ICourse } from '@renderer/types'
|
||||
|
||||
export class Course implements ICourse {
|
||||
private _campus: string
|
||||
private _className: string
|
||||
private _credit: number
|
||||
private _id: string
|
||||
private _master: string
|
||||
private _name: string
|
||||
private _teacher: string
|
||||
|
||||
constructor(
|
||||
campus: string,
|
||||
className: string,
|
||||
credit: number | string,
|
||||
id: string,
|
||||
master: string,
|
||||
name: string,
|
||||
teacher: string
|
||||
) {
|
||||
this._campus = campus
|
||||
this._className = className
|
||||
this._credit = Number(credit)
|
||||
this._id = id
|
||||
this._master = master
|
||||
this._name = name
|
||||
this._teacher = teacher
|
||||
}
|
||||
|
||||
public static factory() {
|
||||
return new Course('', '', 0, '', '', '', '')
|
||||
}
|
||||
|
||||
set campus(value: string) {
|
||||
this._campus = value
|
||||
}
|
||||
|
||||
set className(value: string) {
|
||||
this._className = value
|
||||
}
|
||||
|
||||
set credit(value: number | string) {
|
||||
this._credit = Number(value)
|
||||
}
|
||||
|
||||
set id(value: string) {
|
||||
this._id = value
|
||||
}
|
||||
|
||||
set master(value: string) {
|
||||
this._master = value
|
||||
}
|
||||
|
||||
set name(value: string) {
|
||||
this._name = value
|
||||
}
|
||||
|
||||
set teacher(value: string) {
|
||||
this._teacher = value
|
||||
}
|
||||
get campus(): string {
|
||||
return this._campus
|
||||
}
|
||||
|
||||
get className(): string {
|
||||
return this._className
|
||||
}
|
||||
|
||||
get credit(): number {
|
||||
return this._credit
|
||||
}
|
||||
|
||||
get id(): string {
|
||||
return this._id
|
||||
}
|
||||
|
||||
get master(): string {
|
||||
return this._master
|
||||
}
|
||||
|
||||
get name(): string {
|
||||
return this._name
|
||||
}
|
||||
|
||||
get teacher(): string {
|
||||
return this._teacher
|
||||
}
|
||||
}
|
62
src/renderer/src/models/ReportDocument.ts
Normal file
62
src/renderer/src/models/ReportDocument.ts
Normal file
@ -0,0 +1,62 @@
|
||||
/*
|
||||
*
|
||||
* Copyright (c) 2025. Jeffery Hsu - Achievement Report Generator
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
import { Course } from '@renderer/models/Course'
|
||||
import { Assessment } from '@renderer/models/Assessment'
|
||||
import { Student } from '@renderer/models/Student'
|
||||
|
||||
export class ReportDocument {
|
||||
private _course: Course
|
||||
private _assessment: Assessment
|
||||
private _students: Student[]
|
||||
|
||||
constructor(course: Course, assessment: Assessment, students: Student[]) {
|
||||
this._course = course
|
||||
this._assessment = assessment
|
||||
this._students = students
|
||||
}
|
||||
|
||||
public static factory() {
|
||||
return new ReportDocument(Course.factory(), Assessment.factory(), [])
|
||||
}
|
||||
|
||||
get course(): Course {
|
||||
return this._course
|
||||
}
|
||||
|
||||
set course(value: Course) {
|
||||
this._course = value
|
||||
}
|
||||
|
||||
get assessment(): Assessment {
|
||||
return this._assessment
|
||||
}
|
||||
|
||||
set assessment(value: Assessment) {
|
||||
this._assessment = value
|
||||
}
|
||||
|
||||
get students(): Student[] {
|
||||
return this._students
|
||||
}
|
||||
|
||||
set students(value: Student[]) {
|
||||
this._students = value
|
||||
}
|
||||
}
|
86
src/renderer/src/models/Student.ts
Normal file
86
src/renderer/src/models/Student.ts
Normal file
@ -0,0 +1,86 @@
|
||||
/*
|
||||
*
|
||||
* Copyright (c) 2025. Jeffery Hsu - Achievement Report Generator
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
import { IStudent } from '@renderer/types'
|
||||
|
||||
export class Student implements IStudent {
|
||||
private _className: string
|
||||
private _major: string
|
||||
private _name: string
|
||||
private _resitTag: boolean
|
||||
private _serialNumber: string
|
||||
|
||||
constructor(
|
||||
className: string,
|
||||
major: string,
|
||||
name: string,
|
||||
resitTag: boolean,
|
||||
serialNumber: string
|
||||
) {
|
||||
this._className = className
|
||||
this._major = major
|
||||
this._name = name
|
||||
this._resitTag = resitTag
|
||||
this._serialNumber = serialNumber
|
||||
}
|
||||
|
||||
public static factory() {
|
||||
return new Student('', '', '', false, '')
|
||||
}
|
||||
|
||||
get className(): string {
|
||||
return this._className
|
||||
}
|
||||
|
||||
set className(value: string) {
|
||||
this._className = value
|
||||
}
|
||||
|
||||
get major(): string {
|
||||
return this._major
|
||||
}
|
||||
|
||||
set major(value: string) {
|
||||
this._major = value
|
||||
}
|
||||
|
||||
get name(): string {
|
||||
return this._name
|
||||
}
|
||||
|
||||
set name(value: string) {
|
||||
this._name = value
|
||||
}
|
||||
|
||||
get resitTag(): boolean {
|
||||
return this._resitTag
|
||||
}
|
||||
|
||||
set resitTag(value: boolean) {
|
||||
this._resitTag = value
|
||||
}
|
||||
|
||||
get serialNumber(): string {
|
||||
return this._serialNumber
|
||||
}
|
||||
|
||||
set serialNumber(value: string) {
|
||||
this._serialNumber = value
|
||||
}
|
||||
}
|
20
src/renderer/src/types/share.ts
Normal file
20
src/renderer/src/types/share.ts
Normal file
@ -0,0 +1,20 @@
|
||||
/*
|
||||
*
|
||||
* Copyright (c) 2025. Jeffery Hsu - Achievement Report Generator
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
export type Operation = 'save' | 'cancel' | 'modify'
|
Loading…
x
Reference in New Issue
Block a user