sakai-info 0.5.4 → 0.5.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 776948130dbcdcf1e00195b4cbcd4a105f3e15c1
4
- data.tar.gz: 04cea33e5e428557b899e086f136b5fb78478a6a
3
+ metadata.gz: c4081d75a494513f659f2e400b39b19073941efd
4
+ data.tar.gz: 0fec120b870358846426bf8e5f69480992e24d0a
5
5
  SHA512:
6
- metadata.gz: 2f73aba7f9dd1769548f0a5b17eb7adb195900a1a0a54940115e9e4805a6327fbf6a63fe5a6080427a8b0251b4da891ae2f9c0808de1550a3cf461389916a29d
7
- data.tar.gz: 1e5f042dd669ea73d1cb7f3800fe9577fdf1bb99ec45eac834ba7735567b0fa853929e4d96d9001b6363b13c203deffb1bd1e6955b26e66f5800392c8b867614
6
+ metadata.gz: b60724a90d944df64b7d89f7227ddaa21febb727b5e66bbddc9e2b088b46831bdccd9da8b8d7cbc91677606472f62bd4397126ddb944a30db669e48d785becde
7
+ data.tar.gz: 63a192c81853a701021356aca37956625c2dd45879d1dffbc3241cbe04a37c5e52ddb8928598e1f714f548ddee5ee16290b6e50da1621494ebc540d818d5075e
data/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # sakai-info Change History #
2
2
 
3
+ ### 0.5.5 ###
4
+
5
+ *Released ????-??-??*
6
+
7
+ * New object types: calendar and calendar-event
8
+ * Added Site.find_all
9
+ * Added mnemonic descriptions to quiz attempt status field
10
+
3
11
  ### 0.5.4 ###
4
12
 
5
13
  *Released 2013-06-28*
data/README.md CHANGED
@@ -24,7 +24,7 @@ Use `rake` to test and build the gem:
24
24
  $ rake gem:build
25
25
 
26
26
  The resulting gem will be saved to the working directory as
27
- `sakai-info-0.5.4.gem`.
27
+ `sakai-info-0.5.5.gem`.
28
28
 
29
29
  Cleanup built gems using:
30
30
 
data/lib/sakai-info.rb CHANGED
@@ -2,7 +2,7 @@
2
2
  # Base library file
3
3
  #
4
4
  # Created 2012-02-15 daveadams@gmail.com
5
- # Last updated 2012-10-15 daveadams@gmail.com
5
+ # Last updated 2013-08-29 daveadams@gmail.com
6
6
  #
7
7
  # https://github.com/daveadams/sakai-info
8
8
  #
@@ -37,6 +37,7 @@ require 'sakai-info/page'
37
37
  require 'sakai-info/tool'
38
38
  require 'sakai-info/announcement'
39
39
  require 'sakai-info/assignment'
40
+ require 'sakai-info/calendar'
40
41
  require 'sakai-info/authz'
41
42
  require 'sakai-info/content'
42
43
  require 'sakai-info/gradebook'
@@ -49,4 +50,3 @@ require 'sakai-info/private_message'
49
50
  require 'sakai-info/alias'
50
51
  require 'sakai-info/metaobj'
51
52
  require 'sakai-info/wiki'
52
-
@@ -0,0 +1,263 @@
1
+ # sakai-info/calendar.rb
2
+ # SakaiInfo::Calendar library
3
+ #
4
+ # Created 2013-08-29 daveadams@gmail.com
5
+ # Last updated 2013-08-30 daveadams@gmail.com
6
+ #
7
+ # https://github.com/daveadams/sakai-info
8
+ #
9
+ # This software is public domain.
10
+ #
11
+
12
+ module SakaiInfo
13
+ class Calendar < SakaiXMLEntity
14
+ attr_reader :dbrow, :next_id
15
+
16
+ def self.clear_cache
17
+ @@cache = {}
18
+ end
19
+ clear_cache
20
+
21
+ def initialize(dbrow)
22
+ @dbrow = dbrow
23
+ @id = dbrow[:calendar_id]
24
+ @next_id = dbrow[:next_id]
25
+
26
+ parse_xml
27
+ end
28
+
29
+ def self.find(id)
30
+ # if there's no slash in the id string, assume it's a site id
31
+ if id !~ /\//
32
+ id = "/calendar/calendar/#{id}/main"
33
+ end
34
+
35
+ if @@cache[id].nil?
36
+ xml = ""
37
+ row = DB.connect[:calendar_calendar].where(:calendar_id => id).first
38
+ if row.nil?
39
+ raise ObjectNotFoundException.new(Calendar, id)
40
+ end
41
+ @@cache[id] = Calendar.new(row)
42
+ end
43
+ @@cache[id]
44
+ end
45
+
46
+ def self.find!(id)
47
+ begin
48
+ Calendar.find(id)
49
+ rescue ObjectNotFoundException => e
50
+ if e.classname == Calendar.name
51
+ MissingCalendar.find(id)
52
+ end
53
+ end
54
+ end
55
+
56
+ # lazy properties
57
+ def events
58
+ @events ||= CalendarEvent.find_by_calendar_id(@id)
59
+ end
60
+
61
+ def event_count
62
+ @event_count ||= CalendarEvent.count_by_calendar_id(@id)
63
+ end
64
+
65
+ def site_id
66
+ @site_id ||= @id.split("/")[3]
67
+ end
68
+
69
+ def site
70
+ @site ||= Site.find(self.site_id)
71
+ end
72
+
73
+ def xml
74
+ if @xml.nil?
75
+ @xml = ""
76
+ REXML::Document.new(@dbrow[:xml].read).write(@xml, 2)
77
+ end
78
+ @xml
79
+ end
80
+
81
+ # serialization
82
+ def default_serialization
83
+ {
84
+ "id" => self.id,
85
+ "site" => self.site.serialize(:summary),
86
+ "next_id" => self.next_id,
87
+ "event_count" => self.event_count,
88
+ }
89
+ end
90
+
91
+ def summary_serialization
92
+ {
93
+ "id" => self.id,
94
+ }
95
+ end
96
+
97
+ def xml_serialization
98
+ {
99
+ "xml" => self.xml
100
+ }
101
+ end
102
+
103
+ def events_serialization
104
+ {
105
+ "events" => self.events.collect{|e|e.serialize(:summary)}
106
+ }
107
+ end
108
+
109
+ def self.all_serializations
110
+ [
111
+ :default,
112
+ :xml,
113
+ :mod,
114
+ :events,
115
+ ]
116
+ end
117
+ end
118
+
119
+ class MissingCalendar < Calendar
120
+ def initialize(row)
121
+ @dbrow = row
122
+
123
+ @id = @dbrow[:id]
124
+ end
125
+
126
+ def self.find(id)
127
+ MissingCalendar.new({:id => id})
128
+ end
129
+
130
+ def event_count
131
+ 0
132
+ end
133
+
134
+ def events
135
+ []
136
+ end
137
+
138
+ def default_serialization
139
+ {
140
+ "status" => "No Calendar for #{self.id}",
141
+ }
142
+ end
143
+
144
+ def summary_serialization
145
+ {
146
+ "status" => "No Calendar",
147
+ }
148
+ end
149
+
150
+ def self.all_serializations
151
+ [
152
+ :default,
153
+ ]
154
+ end
155
+ end
156
+
157
+ class CalendarEvent < SakaiXMLEntity
158
+ attr_reader :dbrow, :calendar_id, :event_start, :event_end, :range_start, :range_end
159
+
160
+ def self.clear_cache
161
+ @@cache = {}
162
+ end
163
+ clear_cache
164
+
165
+ def initialize(dbrow)
166
+ @dbrow = dbrow
167
+ @id = dbrow[:event_id]
168
+ @calendar_id = dbrow[:calendar_id]
169
+ @range_start = dbrow[:range_start]
170
+ @range_end = dbrow[:range_end]
171
+
172
+ parse_xml
173
+ end
174
+
175
+ def self.find(id)
176
+ if @@cache[id].nil?
177
+ xml = ""
178
+ row = DB.connect[:calendar_event].where(:event_id => id).first
179
+ if row.nil?
180
+ raise ObjectNotFoundException.new(CalendarEvent, id)
181
+ end
182
+ @@cache[id] = CalendarEvent.new(row)
183
+ end
184
+ @@cache[id]
185
+ end
186
+
187
+ def event_start
188
+ @event_start ||= dbrow[:event_start]
189
+ end
190
+
191
+ def event_end
192
+ @event_end ||= dbrow[:event_end]
193
+ end
194
+
195
+ def self.query_by_calendar_id(calendar_id)
196
+ DB.connect[:calendar_event].where(:calendar_id => calendar_id)
197
+ end
198
+
199
+ def self.count_by_calendar_id(calendar_id)
200
+ CalendarEvent.query_by_calendar_id(calendar_id).count
201
+ end
202
+
203
+ def self.find_by_calendar_id(calendar_id)
204
+ CalendarEvent.query_by_calendar_id(calendar_id).all.collect do |row|
205
+ @@cache[row[:event_id]] = CalendarEvent.new(row)
206
+ end
207
+ end
208
+
209
+ def calendar
210
+ @calendar ||= Calendar.find(self.calendar_id)
211
+ end
212
+
213
+ def display_name
214
+ @display_name ||= self.properties["DAV:displayname"]
215
+ end
216
+
217
+ def description
218
+ @description ||= self.properties["CHEF:description"]
219
+ end
220
+
221
+ def type
222
+ @type ||= self.properties["CHEF:calendar-type"]
223
+ end
224
+
225
+ # serialization
226
+ def default_serialization
227
+ {
228
+ "id" => self.id,
229
+ "calendar_id" => self.calendar_id,
230
+ "display_name" => self.display_name,
231
+ "description" => self.description,
232
+ "type" => self.type,
233
+ "event_start" => self.event_start,
234
+ "event_end" => self.event_end,
235
+ }
236
+ end
237
+
238
+ def summary_serialization
239
+ {
240
+ "id" => self.id,
241
+ "display_name" => self.display_name,
242
+ "type" => self.type,
243
+ "event_start_date" => self.event_start.strftime("%Y-%m-%d"),
244
+ }
245
+ end
246
+
247
+ def xml_serialization
248
+ {
249
+ "xml" => self.xml
250
+ }
251
+ end
252
+
253
+ def self.all_serializations
254
+ [
255
+ :default,
256
+ :attributes,
257
+ :properties,
258
+ :mod,
259
+ :xml,
260
+ ]
261
+ end
262
+ end
263
+ end
@@ -144,7 +144,11 @@ module SakaiInfo
144
144
  "wiki" => WikiPage,
145
145
  "wiki-page-history" => WikiPageHistory,
146
146
  "wiki-history" => WikiPageHistory,
147
+ "cal" => Calendar,
148
+ "calendar" => Calendar,
149
+ "calendar-event" => CalendarEvent,
150
+ "calevent" => CalendarEvent,
151
+ "ce" => CalendarEvent,
147
152
  }
148
153
  end
149
154
  end
150
-
@@ -2,7 +2,7 @@
2
2
  # SakaiInfo::Quiz library
3
3
  #
4
4
  # Created 2012-02-17 daveadams@gmail.com
5
- # Last updated 2013-06-28 daveadams@gmail.com
5
+ # Last updated 2014-07-08 daveadams@gmail.com
6
6
  #
7
7
  # https://github.com/daveadams/sakai-info
8
8
  #
@@ -821,6 +821,21 @@ module SakaiInfo
821
821
  @is_late == 1
822
822
  end
823
823
 
824
+ # status definitions from samigo-api/src/java/org/sakaiproject/tool/assessment/data/ifc/grading/AssessmentGradingIfc.java
825
+ ATTEMPT_STATUS = {
826
+ "0" => "unsubmitted",
827
+ "1" => "submitted-ungraded",
828
+ "2" => "submitted-auto-graded",
829
+ "3" => "submitted-needs-human-attention",
830
+ "4" => "needs-resubmit",
831
+ "5" => "unsubmitted-but-graded",
832
+ "6" => "updated-in-progress",
833
+ }
834
+ def status
835
+ ATTEMPT_STATUS[@dbrow[:status].to_i.to_s] || "unknown status '#{@dbrow[:status].to_i}'"
836
+ end
837
+
838
+
824
839
  def default_serialization
825
840
  {
826
841
  "id" => self.id,
@@ -2,7 +2,7 @@
2
2
  # SakaiInfo::Site library
3
3
  #
4
4
  # Created 2012-02-17 daveadams@gmail.com
5
- # Last updated 2013-06-28 daveadams@gmail.com
5
+ # Last updated 2014-01-30 daveadams@gmail.com
6
6
  #
7
7
  # https://github.com/daveadams/sakai-info
8
8
  #
@@ -174,6 +174,15 @@ module SakaiInfo
174
174
  @forums ||= Forum.find_by_site_id(@id)
175
175
  end
176
176
 
177
+ # calendar
178
+ def calendar
179
+ @calendar ||= Calendar.find!(@id)
180
+ end
181
+
182
+ def calendar_event_count
183
+ @calendar_event_count ||= self.calendar.event_count
184
+ end
185
+
177
186
  # content properties
178
187
  def resource_storage
179
188
  resource_collection_id = "/group/#{@id}/"
@@ -229,6 +238,10 @@ module SakaiInfo
229
238
  Site.find_ids_by_property("term_eid", term_eid)
230
239
  end
231
240
 
241
+ def self.find_all
242
+ DB.connect[:sakai_site].select(:site_id).all.collect{|row| @@cache[row[:site_id]] = Site.new(row)}
243
+ end
244
+
232
245
  def self.find_all_ids
233
246
  DB.connect[:sakai_site].select(:site_id).all.collect{|r| r[:site_id]}
234
247
  end
@@ -294,7 +307,8 @@ module SakaiInfo
294
307
  "assignment_count" => self.assignment_count,
295
308
  "announcement_count" => self.announcement_count,
296
309
  "gradebook_item_count" => (self.gradebook.nil? ? 0 : self.gradebook.item_count),
297
- "forum_count" => self.forum_count
310
+ "forum_count" => self.forum_count,
311
+ "calendar_event_count" => self.calendar_event_count,
298
312
  }
299
313
  if result["providers"].nil? or result["providers"] == "" or result["providers"] == []
300
314
  result.delete("providers")
@@ -425,6 +439,12 @@ module SakaiInfo
425
439
  end
426
440
  end
427
441
 
442
+ def calendar_events_serialization
443
+ {
444
+ "calendar_events" => self.calendar.events.collect { |e| e.serialize(:summary) }
445
+ }
446
+ end
447
+
428
448
  def self.all_serializations
429
449
  [
430
450
  :default,
@@ -438,6 +458,7 @@ module SakaiInfo
438
458
  :gradebook,
439
459
  :realm,
440
460
  :forums,
461
+ :calendar_events,
441
462
  :mod,
442
463
  ]
443
464
  end
@@ -1,3 +1,3 @@
1
1
  module SakaiInfo
2
- VERSION = "0.5.4"
2
+ VERSION = "0.5.5"
3
3
  end
metadata CHANGED
@@ -1,57 +1,69 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sakai-info
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.4
4
+ version: 0.5.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Adams
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-06-28 00:00:00.000000000 Z
11
+ date: 2014-07-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sequel
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - '>='
17
+ - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '0'
19
+ version: '4.12'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - '>='
24
+ - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '0'
26
+ version: '4.12'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: sqlite3
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - '>='
31
+ - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '0'
33
+ version: '1.3'
34
+ - - ">="
35
+ - !ruby/object:Gem::Version
36
+ version: 1.3.9
34
37
  type: :development
35
38
  prerelease: false
36
39
  version_requirements: !ruby/object:Gem::Requirement
37
40
  requirements:
38
- - - '>='
41
+ - - "~>"
42
+ - !ruby/object:Gem::Version
43
+ version: '1.3'
44
+ - - ">="
39
45
  - !ruby/object:Gem::Version
40
- version: '0'
46
+ version: 1.3.9
41
47
  - !ruby/object:Gem::Dependency
42
48
  name: marky_markov
43
49
  requirement: !ruby/object:Gem::Requirement
44
50
  requirements:
45
- - - '>='
51
+ - - "~>"
46
52
  - !ruby/object:Gem::Version
47
- version: '0'
53
+ version: '0.3'
54
+ - - ">="
55
+ - !ruby/object:Gem::Version
56
+ version: 0.3.5
48
57
  type: :development
49
58
  prerelease: false
50
59
  version_requirements: !ruby/object:Gem::Requirement
51
60
  requirements:
52
- - - '>='
61
+ - - "~>"
62
+ - !ruby/object:Gem::Version
63
+ version: '0.3'
64
+ - - ">="
53
65
  - !ruby/object:Gem::Version
54
- version: '0'
66
+ version: 0.3.5
55
67
  description: A command line tool and a suite of libraries for representing the objects
56
68
  and relationships defined by a Sakai CLE database.
57
69
  email: daveadams@gmail.com
@@ -60,45 +72,46 @@ executables:
60
72
  extensions: []
61
73
  extra_rdoc_files: []
62
74
  files:
75
+ - CHANGELOG.md
76
+ - LICENSE
77
+ - README.md
78
+ - ROADMAP.md
79
+ - bin/sin
63
80
  - lib/sakai-info.rb
64
- - lib/sakai-info/wiki.rb
65
- - lib/sakai-info/exceptions.rb
81
+ - lib/sakai-info/alias.rb
82
+ - lib/sakai-info/announcement.rb
83
+ - lib/sakai-info/assignment.rb
66
84
  - lib/sakai-info/authz.rb
67
- - lib/sakai-info/forum.rb
68
- - lib/sakai-info/metaobj.rb
69
- - lib/sakai-info/version.rb
85
+ - lib/sakai-info/cache.rb
86
+ - lib/sakai-info/calendar.rb
70
87
  - lib/sakai-info/cli.rb
88
+ - lib/sakai-info/cli/help.rb
89
+ - lib/sakai-info/cli/lookup.rb
90
+ - lib/sakai-info/cli/query.rb
91
+ - lib/sakai-info/cli/shell.rb
92
+ - lib/sakai-info/cli/special.rb
93
+ - lib/sakai-info/content.rb
94
+ - lib/sakai-info/database.rb
95
+ - lib/sakai-info/exceptions.rb
96
+ - lib/sakai-info/forum.rb
97
+ - lib/sakai-info/generic_message.rb
98
+ - lib/sakai-info/gradebook.rb
71
99
  - lib/sakai-info/group.rb
72
- - lib/sakai-info/quiz.rb
100
+ - lib/sakai-info/hacks.rb
101
+ - lib/sakai-info/metaobj.rb
73
102
  - lib/sakai-info/mod_props.rb
74
- - lib/sakai-info/gradebook.rb
75
- - lib/sakai-info/util.rb
76
- - lib/sakai-info/assignment.rb
103
+ - lib/sakai-info/page.rb
77
104
  - lib/sakai-info/private_message.rb
78
- - lib/sakai-info/sakai_xml_entity.rb
79
- - lib/sakai-info/database.rb
80
- - lib/sakai-info/generic_message.rb
105
+ - lib/sakai-info/question_pool.rb
106
+ - lib/sakai-info/quiz.rb
81
107
  - lib/sakai-info/sakai_object.rb
82
- - lib/sakai-info/page.rb
83
- - lib/sakai-info/user.rb
84
- - lib/sakai-info/announcement.rb
108
+ - lib/sakai-info/sakai_xml_entity.rb
85
109
  - lib/sakai-info/site.rb
86
- - lib/sakai-info/content.rb
87
- - lib/sakai-info/hacks.rb
88
- - lib/sakai-info/alias.rb
89
- - lib/sakai-info/cli/lookup.rb
90
- - lib/sakai-info/cli/help.rb
91
- - lib/sakai-info/cli/special.rb
92
- - lib/sakai-info/cli/query.rb
93
- - lib/sakai-info/cli/shell.rb
94
110
  - lib/sakai-info/tool.rb
95
- - lib/sakai-info/cache.rb
96
- - lib/sakai-info/question_pool.rb
97
- - bin/sin
98
- - README.md
99
- - LICENSE
100
- - CHANGELOG.md
101
- - ROADMAP.md
111
+ - lib/sakai-info/user.rb
112
+ - lib/sakai-info/util.rb
113
+ - lib/sakai-info/version.rb
114
+ - lib/sakai-info/wiki.rb
102
115
  homepage: https://github.com/daveadams/sakai-info
103
116
  licenses:
104
117
  - Public Domain
@@ -109,17 +122,17 @@ require_paths:
109
122
  - lib
110
123
  required_ruby_version: !ruby/object:Gem::Requirement
111
124
  requirements:
112
- - - '>='
125
+ - - ">="
113
126
  - !ruby/object:Gem::Version
114
127
  version: '0'
115
128
  required_rubygems_version: !ruby/object:Gem::Requirement
116
129
  requirements:
117
- - - '>='
130
+ - - ">="
118
131
  - !ruby/object:Gem::Version
119
132
  version: '0'
120
133
  requirements: []
121
134
  rubyforge_project:
122
- rubygems_version: 2.0.0
135
+ rubygems_version: 2.2.2
123
136
  signing_key:
124
137
  specification_version: 4
125
138
  summary: Tools and library for exploring a Sakai database