magister 1.0.1 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: edc3c4fe8ca4447cfddc0af720486f52df39d69a88c079b8186552aa8cbbc5a5
4
- data.tar.gz: 98e0824985ff7cea6ede1524e746580b3e9e2a4027fed30dbb0e8838581a3ac8
3
+ metadata.gz: faf4f432a878e25770d0a9faf41d4d1691332a60ce70d0bf5d71087da14d080e
4
+ data.tar.gz: 7e8fdd7861269b393f96af946b4790a682a5b9661ec99ec8a0435303e95924b6
5
5
  SHA512:
6
- metadata.gz: add8ff231c89d8721ab592306b00108ac74f3de61fdc66be0a5771a8a49f6f0c8c890d73b701ed8bca3257ac167586bf462ff0f05c94a034f7a19a8138117bd8
7
- data.tar.gz: 61a64312eeeb3ac760722c517d2c2f88bdb1c24e1f161d6c0abc1c1a9b70555e7513d55116ab18bd6297aab2be5e504325bf71eef7db8119a357c5a897955890
6
+ metadata.gz: 88ebd7702f2ac21a3724b131da9b374847b6412d66b17d55a722f1c04769c56cc48b3e9e33855e1d40dc6a4b10f7462c0db7496dbe460809c53410cbbb88a981
7
+ data.tar.gz: fcb21e21d0dc94c815cf1b75e08a573c7ed66463e5060e244517c54ec145358c7786d21235242f40c64c292af4beb29e13387e6fb93696ad5efcbec54b9873d3
data/lib/magister/data.rb CHANGED
@@ -1,7 +1,10 @@
1
1
  # This Source Code Form is subject to the terms of the Mozilla Public
2
2
  # License, v. 2.0. If a copy of the MPL was not distributed with this
3
3
  # file, You can obtain one at https://mozilla.org/MPL/2.0/.
4
+ require 'magister/types/class'
5
+ require 'magister/types/grade'
4
6
  require 'date'
7
+ require 'json'
5
8
 
6
9
  def validate_date(date)
7
10
  format = '%Y-%m-%d'
@@ -14,9 +17,23 @@ end
14
17
  module MagisterData
15
18
  def get_classes(dateFrom, dateTo)
16
19
  if validate_date(dateFrom) && validate_date(dateTo)
17
- @profile.authenticatedRequest("/personen/{*id*}/afspraken?status=1&van=#{dateFrom}&tot=#{dateTo}")
20
+ data = @profile.authenticatedRequest("/personen/{*id*}/afspraken?status=1&van=#{dateFrom}&tot=#{dateTo}")
21
+ classes = Array.new
22
+ data["Items"].each do |classItem|
23
+ classes.push MagClass.new(classItem)
24
+ end
25
+ classes
18
26
  else
19
27
  puts "Invalid date, Format is yyyy-mm-dd"
20
28
  end
21
29
  end
30
+
31
+ def get_grades(count = 5, page = 0)
32
+ data = @profile.authenticatedRequest("/personen/{*id*}/cijfers/laatste?top=#{count}&skip=#{count * page}")
33
+ grades = Array.new
34
+ data["items"].each do |grade|
35
+ grades.push Grade.new(grade)
36
+ end
37
+ grades
38
+ end
22
39
  end
@@ -0,0 +1,140 @@
1
+ # This Source Code Form is subject to the terms of the Mozilla Public
2
+ # License, v. 2.0. If a copy of the MPL was not distributed with this
3
+ # file, You can obtain one at https://mozilla.org/MPL/2.0/.
4
+ require "magister/types/classroom.rb"
5
+ require "magister/types/subject.rb"
6
+ require "magister/types/teacher.rb"
7
+
8
+ # MagClass instead of Class becasue ruby got confused with class
9
+ class MagClass
10
+ def initialize(rawParsed)
11
+ @id = rawParsed["Id"]
12
+ @classStart = rawParsed["Start"]
13
+ @classEndInclusive = rawParsed["Einde"]
14
+ @wholeDay = rawParsed["DuurtHeleDag"]
15
+ @description = rawParsed["Omschrijving"]
16
+ # I dont know why location is here when theres also classrooms
17
+ @location = rawParsed["Lokatie"]
18
+ @content = rawParsed["Inhoud"]
19
+ @remark = rawParsed["Opmerking"]
20
+ @note = rawParsed["Aantekening"]
21
+ @finished = rawParsed["Afgerond"]
22
+ @repeatStatus = rawParsed["HerhaalStatus"]
23
+ @repeat = rawParsed["Herhaling"]
24
+
25
+ @subjects = Array.new
26
+ rawParsed["Vakken"].each do |subject|
27
+ @subjects.push Subject.new(subject)
28
+ end
29
+
30
+ @teachers = Array.new
31
+ rawParsed["Docenten"].each do |teacher|
32
+ @teachers.push Teacher.new(teacher)
33
+ end
34
+
35
+ @classrooms = Array.new
36
+ rawParsed["Lokalen"].each do |classRoom|
37
+ @classrooms.push ClassRoom.new(classRoom)
38
+ end
39
+
40
+ @hasAttachments = rawParsed["HeeftBijlagen"]
41
+ @attachments = rawParsed["Bijlagen"]
42
+
43
+ # I dont know what these values do
44
+ @infoType = rawParsed["InfoType"] # I think what kind of content like homework/test
45
+ @status = rawParsed["Status"] # I think the status as in cancelled
46
+ @type = rawParsed["Type"]
47
+ @subtype = rawParsed["SubType"]
48
+ @isOnline = rawParsed["IsOnlineDeelname"] # Wether there is a way to participate online?
49
+ @viewType = rawParsed["WeergaveType"]
50
+ @assignmentId = rawParsed["OpdrachtId"]
51
+ @groups = rawParsed["Groepen"]
52
+ end
53
+
54
+ def inspect
55
+ "#<#{self.class}:0x#{object_id} @id=#{@id}, @description=#{@description}, @subjects[0]=#{@subjects[0].inspect}, @teachers[0]=#{@teachers[0].inspect}, @location=#{@location}>"
56
+ end
57
+
58
+ # getters
59
+ def id
60
+ @id
61
+ end
62
+ def classStart
63
+ @classStart
64
+ end
65
+ def startTime
66
+ @classStart
67
+ end
68
+ def classEndInclusive
69
+ @classEndInclusive
70
+ end
71
+ def endTime
72
+ @classEndInclusive
73
+ end
74
+ def wholeDay
75
+ @wholeDay
76
+ end
77
+ def description
78
+ @description
79
+ end
80
+ def location
81
+ @location
82
+ end
83
+ def content
84
+ @content
85
+ end
86
+ def remark
87
+ @remark
88
+ end
89
+ def note
90
+ @note
91
+ end
92
+ def finished
93
+ @finished
94
+ end
95
+ def repeatStatus
96
+ @repeatStatus
97
+ end
98
+ def repeat
99
+ @repeat
100
+ end
101
+ def subjects
102
+ @subjects
103
+ end
104
+ def teachers
105
+ @teachers
106
+ end
107
+ def classrooms
108
+ @classrooms
109
+ end
110
+ def hasAttachments
111
+ @hasAttachments
112
+ end
113
+ def attachments
114
+ @attachments
115
+ end
116
+ def infoType
117
+ @infoType
118
+ end
119
+ def status
120
+ @status
121
+ end
122
+ def type
123
+ @type
124
+ end
125
+ def subtype
126
+ @subtype
127
+ end
128
+ def usOnline
129
+ @isOnline
130
+ end
131
+ def viewType
132
+ @viewType
133
+ end
134
+ def assignmentId
135
+ @assignmentId
136
+ end
137
+ def groups
138
+ @groups
139
+ end
140
+ end
@@ -0,0 +1,14 @@
1
+ # This Source Code Form is subject to the terms of the Mozilla Public
2
+ # License, v. 2.0. If a copy of the MPL was not distributed with this
3
+ # file, You can obtain one at https://mozilla.org/MPL/2.0/.
4
+
5
+ class ClassRoom
6
+ def initialize(rawParsed)
7
+ @name = rawParsed["Naam"]
8
+ end
9
+
10
+ # singular getter
11
+ def name
12
+ @name
13
+ end
14
+ end
@@ -0,0 +1,71 @@
1
+ # This Source Code Form is subject to the terms of the Mozilla Public
2
+ # License, v. 2.0. If a copy of the MPL was not distributed with this
3
+ # file, You can obtain one at https://mozilla.org/MPL/2.0/.
4
+ require 'json'
5
+
6
+ class Grade
7
+ def initialize(rawParsed)
8
+ @id = rawParsed["kolomId"]
9
+ @description = rawParsed["omschrijving"]
10
+ # This is an attrocity and shouldnt exist. yet here it is.
11
+ @subject = Subject.new(JSON.parse("{\"Id\": \"#{rawParsed["vak"]["code"]}\", \"Naam\": \"#{rawParsed["vak"]["omschrijving"]}\"}"))
12
+
13
+ @grade = rawParsed["waarde"].gsub(",", ".").to_f
14
+ @weight = rawParsed["weegfactor"]
15
+
16
+ @isSufficient = rawParsed["isVoldoende"]
17
+ @counts = rawParsed["teltMee"]
18
+ @toBeCaughtUp = rawParsed["moetInhalen"]
19
+
20
+ @isExempt = rawParsed["heeftVrijstelling"]
21
+
22
+ # addedOn is when the teacher added it to magister
23
+ # earnedOn is when the test was done, most teachers dont put this in
24
+ @addedOn = rawParsed["ingevoerdOp"]
25
+ @earnedOn = rawParsed["behaaldOp"]
26
+ end
27
+
28
+ # getters
29
+ def id
30
+ @id
31
+ end
32
+ def description
33
+ @description
34
+ end
35
+ def subject
36
+ @subject
37
+ end
38
+ def isSufficient
39
+ @isSufficient
40
+ end
41
+ def isInsufficient
42
+ !@isSufficient
43
+ end
44
+ def grade
45
+ @grade
46
+ end
47
+ def values
48
+ @grade
49
+ end
50
+ def weight
51
+ @weight
52
+ end
53
+ def counts
54
+ @counts
55
+ end
56
+ def toBeCaughtUp
57
+ @toBeCaughtUp
58
+ end
59
+ def isExempt
60
+ @isExempt
61
+ end
62
+ def exempt
63
+ @isExempt
64
+ end
65
+ def addedOn
66
+ @addedOn
67
+ end
68
+ def earnedOn
69
+ @earnedOn
70
+ end
71
+ end
@@ -0,0 +1,18 @@
1
+ # This Source Code Form is subject to the terms of the Mozilla Public
2
+ # License, v. 2.0. If a copy of the MPL was not distributed with this
3
+ # file, You can obtain one at https://mozilla.org/MPL/2.0/.
4
+
5
+ class Subject
6
+ def initialize(rawParsed)
7
+ @id = rawParsed["Id"]
8
+ @name = rawParsed["Naam"]
9
+ end
10
+
11
+ # getters
12
+ def id
13
+ @id
14
+ end
15
+ def name
16
+ @name
17
+ end
18
+ end
@@ -0,0 +1,28 @@
1
+ # This Source Code Form is subject to the terms of the Mozilla Public
2
+ # License, v. 2.0. If a copy of the MPL was not distributed with this
3
+ # file, You can obtain one at https://mozilla.org/MPL/2.0/.
4
+
5
+ class Teacher
6
+ def initialize(rawParsed)
7
+ @id = rawParsed["Id"]
8
+ @name = rawParsed["Naam"]
9
+ @abrev = rawParsed["Docentcode"]
10
+ end
11
+
12
+ # getters
13
+ def id
14
+ @id
15
+ end
16
+ def name
17
+ @name
18
+ end
19
+ def abrev
20
+ @abrev
21
+ end
22
+ def abreviaton
23
+ @abrev
24
+ end
25
+ def code
26
+ @abrev
27
+ end
28
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: magister
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Riley0122
@@ -82,6 +82,11 @@ files:
82
82
  - lib/magister/authenticator.rb
83
83
  - lib/magister/data.rb
84
84
  - lib/magister/profile.rb
85
+ - lib/magister/types/class.rb
86
+ - lib/magister/types/classroom.rb
87
+ - lib/magister/types/grade.rb
88
+ - lib/magister/types/subject.rb
89
+ - lib/magister/types/teacher.rb
85
90
  homepage: https://github.com/riley0122/rubymag#readme
86
91
  licenses:
87
92
  - MPL-2.0