-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathClass.js
More file actions
86 lines (71 loc) · 1.74 KB
/
Copy pathClass.js
File metadata and controls
86 lines (71 loc) · 1.74 KB
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
const RawData = require("../lib/RawData");
const Classroom = require("./Classroom");
const Edupage = require("./Edupage");
const Teacher = require("./Teacher");
/**
* @typedef {import("../lib/RawData").RawDataObject} RawDataObject
*/
class Class extends RawData {
/**
* Creates an instance of Class.
* @param {RawDataObject} [data={}] Raw data to initialize the instance with.
* @param {Edupage} [edupage=null] Edupage instance to use.
* @memberof Class
*/
constructor(data = {}, edupage = null) {
super(data);
/**
* Edupage instance associated to this object
* @type {Edupage}
*/
this.edupage = edupage;
/**
* Grade of the class
* @type {number}
*/
this.grade = +data.grade ?? null;
/**
* ID of the class
* @type {string}
*/
this.id = data.id;
/**
* Name of the class
* @type {string}
*/
this.name = data.name;
/**
* Short name of the class
* @type {string}
*/
this.short = data.short;
/**
* Classroom associated to this class
* @type {Classroom}
*/
this.classroom = null;
/**
* Teacher associated to this class
* @type {Teacher}
*/
this.teacher = null;
/**
* Teacher 2 associated to this class
* @type {Teacher}
*/
this.teacher2 = null;
if(this.edupage) Class.prototype.init.call(this);
}
/**
* Initializes instance.
* @param {Edupage} [edupage=null] Edupage instance to use.
* @memberof Class
*/
init(edupage = null) {
if(edupage) this.edupage = edupage;
this.classroom = this.edupage.classrooms.find(e => e.id == this._data.classroomid);
this.teacher = this.edupage.teachers.find(e => e.id == this._data.teacherid);
this.teacher2 = this.edupage.teachers.find(e => e.id == this._data.teacher2id);
}
}
module.exports = Class;