This repository has been archived by the owner on Apr 10, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 11
/
sigaa-lesson-student.ts
executable file
·108 lines (96 loc) · 2.58 KB
/
sigaa-lesson-student.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
import { CourseForum } from '@courseResources/forum/sigaa-course-forum-student';
import { Homework } from '@attachments/sigaa-homework-student';
import { LinkAttachment } from '@attachments/sigaa-link-student';
import { Quiz } from '@attachments/sigaa-quiz-student';
import { Survey } from '@attachments/sigaa-survey-student';
import { VideoAttachment } from '@attachments/sigaa-video-student';
import { WebContent } from '@attachments/sigaa-web-content-student';
import { File } from '@resources/sigaa-file';
import { UpdatableResourceData } from '@resources/sigaa-resource-manager';
import {
AbstractUpdatableResource,
UpdatableResource,
UpdatableResourceCallback
} from '@resources/updatable-resource';
/**
* @category Public
*/
export type Attachment =
| File
| Homework
| Quiz
| CourseForum
| WebContent
| Survey
| LinkAttachment
| VideoAttachment;
/**
* @category Internal
*/
export interface LessonData extends UpdatableResourceData {
title: string;
id: string;
contentText: string;
startDate: Date;
endDate: Date;
attachments: Attachment[];
}
/**
* @category Public
*/
export interface Lesson extends UpdatableResource<LessonData> {
readonly title: string;
readonly id: string;
readonly contentText: string;
readonly endDate: Date;
readonly startDate: Date;
readonly attachments: Attachment[];
}
/**
* @category Internal
*/
export class SigaaLesson extends AbstractUpdatableResource implements Lesson {
private _title!: string;
private _id!: string;
private _contextText!: string;
private _startDate!: Date;
private _endDate!: Date;
private _attachments!: Attachment[];
constructor(options: LessonData, updater?: UpdatableResourceCallback) {
super(options.instanceIndentifier, updater);
this.update(options);
}
update(options: LessonData): void {
this._title = options.title;
this._id = options.id;
this._contextText = options.contentText;
this._startDate = options.startDate;
this._endDate = options.endDate;
this._attachments = options.attachments;
this.isClosed = false;
}
get title(): string {
this.checkIfItWasClosed();
return this._title;
}
get id(): string {
this.checkIfItWasClosed();
return this._id;
}
get contentText(): string {
this.checkIfItWasClosed();
return this._contextText;
}
get endDate(): Date {
this.checkIfItWasClosed();
return this._endDate;
}
get startDate(): Date {
this.checkIfItWasClosed();
return this._startDate;
}
get attachments(): Attachment[] {
this.checkIfItWasClosed();
return this._attachments;
}
}