sakai-info 0.4.2 → 0.4.3

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG.md CHANGED
@@ -1,5 +1,15 @@
1
1
  # sakai-info Change History #
2
2
 
3
+ ### 0.4.3 ###
4
+
5
+ *Released 2012-05-10*
6
+
7
+ * Tweaked site summary serialization to display creator EID
8
+ * Added attempted_at field to quiz attempt item serializations
9
+ * Added CLI support for announcement and announcement-channel
10
+ * Added clear_cache class method to all objects using caches
11
+ * Added Cache.clear_all class and method to SakaiInfo module
12
+
3
13
  ### 0.4.2 ###
4
14
 
5
15
  *Released 2012-05-04*
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # sakai-info #
2
2
 
3
- last updated: 2012-05-04
3
+ last updated: 2012-05-10
4
4
  author: David Adams (daveadams@gmail.com)
5
5
  github url: https://github.com/daveadams/sakai-info
6
6
 
@@ -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.4.2.gem`.
27
+ `sakai-info-0.4.3.gem`.
28
28
 
29
29
  Cleanup built gems using:
30
30
 
data/ROADMAP.md CHANGED
@@ -1,10 +1,6 @@
1
1
  # sakai-info Roadmap #
2
2
 
3
- *Last updated 2012-05-04*
4
-
5
- ### 0.4.3 ###
6
-
7
- * CLI access to announcements
3
+ *Last updated 2012-05-10*
8
4
 
9
5
  ### 0.4.4 ###
10
6
 
@@ -25,11 +21,11 @@
25
21
 
26
22
  ### 0.7.0 ###
27
23
 
28
- * Basic OSP support
24
+ * OSP support
29
25
 
30
26
  ------
31
27
 
32
- Other things on the wishlist for future releases:
28
+ Ideas for future releases:
33
29
 
34
30
  * More complete object relationship support for full drilldown capability
35
31
  * Gradebook/assignment/quiz interaction
@@ -37,6 +33,7 @@ Other things on the wishlist for future releases:
37
33
  * Assignment submissions per-assignment and per-student
38
34
  * Support for more Sakai objects
39
35
  * OSP
36
+ * Evaluations
40
37
  * Forum topics and posts
41
38
  * Private messages
42
39
  * Events
@@ -52,4 +49,6 @@ Other things on the wishlist for future releases:
52
49
  * httpd log analysis helper
53
50
  * RPC client for Sakai-monitoring servlet
54
51
  * schema analysis and generators
52
+ * web UI
53
+ * CLI shell
55
54
 
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-04-22 daveadams@gmail.com
5
+ # Last updated 2012-05-10 daveadams@gmail.com
6
6
  #
7
7
  # https://github.com/daveadams/sakai-info
8
8
  #
@@ -69,6 +69,17 @@ module SakaiInfo
69
69
  end
70
70
  end
71
71
  end
72
+
73
+ # cache control
74
+ class Cache
75
+ def self.clear_all
76
+ SakaiObject.descendants.select { |klass|
77
+ klass.methods.include? :clear_cache
78
+ }.each { |klass|
79
+ klass.clear_cache
80
+ }
81
+ end
82
+ end
72
83
  end
73
84
 
74
85
  ######################################################################
@@ -2,7 +2,7 @@
2
2
  # SakaiInfo::Announcement library
3
3
  #
4
4
  # Created 2012-02-16 daveadams@gmail.com
5
- # Last updated 2012-02-24 daveadams@gmail.com
5
+ # Last updated 2012-05-10 daveadams@gmail.com
6
6
  #
7
7
  # https://github.com/daveadams/sakai-info
8
8
  #
@@ -10,24 +10,29 @@
10
10
  #
11
11
 
12
12
  module SakaiInfo
13
- class AnnouncementChannel < SakaiXMLEntity
14
- attr_reader :next
13
+ class AnnouncementChannel < SakaiObject
14
+ attr_reader :dbrow
15
15
 
16
- @@cache = {}
17
- @@site_cache = {}
16
+ def self.clear_cache
17
+ @@cache = {}
18
+ @@site_cache = {}
19
+ end
20
+ clear_cache
21
+
22
+ def initialize(dbrow)
23
+ @dbrow = dbrow
24
+ @id = dbrow[:channel_id]
25
+ end
18
26
 
19
27
  def self.find(id)
20
28
  if @@cache[id].nil?
21
29
  xml = ""
22
- row = DB.connect[:announcement_channel].filter(:channel_id => id).first
30
+ row = DB.connect[:announcement_channel].where(:channel_id => id).first
23
31
  if row.nil?
24
32
  raise ObjectNotFoundException.new(AnnouncementChannel, id)
25
33
  end
26
- nextid = row[:next_id].to_i
27
- REXML::Document.new(row[:xml].read).write(xml, 2)
28
- channel = AnnouncementChannel.new(id, nextid, xml)
29
- @@cache[id] = channel
30
- @@site_cache[channel.site_id] = channel
34
+ @@cache[id] = AnnouncementChannel.new(row)
35
+ @@site_cache[@@cache[id].site_id] = @@cache[id]
31
36
  end
32
37
  @@cache[id]
33
38
  end
@@ -41,32 +46,31 @@ module SakaiInfo
41
46
  end
42
47
  end
43
48
 
44
- # raw data constructor
45
- def initialize(id, nextid, xml)
46
- @id = id
47
- @next = nextid
48
- @xml = xml
49
- parse_xml
50
- end
51
-
52
- # properties
49
+ # lazy properties
53
50
  def announcements
54
51
  @announcements ||= Announcement.find_by_channel_id(@id)
55
52
  end
56
53
 
57
54
  def announcement_count
58
- @announcement_count ||= self.announcements.length
55
+ @announcement_count ||= Announcement.count_by_channel_id(@id)
59
56
  end
60
57
 
61
58
  def site_id
62
59
  @site_id ||= @id.split("/")[3]
63
60
  end
64
61
 
62
+ def xml
63
+ if @xml.nil?
64
+ @xml = ""
65
+ REXML::Document.new(@dbrow[:xml].read).write(@xml, 2)
66
+ end
67
+ @xml
68
+ end
69
+
65
70
  # serialization
66
71
  def default_serialization
67
72
  {
68
73
  "id" => self.id,
69
- "next" => self.next,
70
74
  "site_id" => self.site_id,
71
75
  "announcement_count" => self.announcement_count
72
76
  }
@@ -75,72 +79,86 @@ module SakaiInfo
75
79
  def summary_serialization
76
80
  {
77
81
  "id" => self.id,
78
- "site_id" => self.site_id,
79
82
  "announcement_count" => self.announcement_count
80
83
  }
81
84
  end
85
+
86
+ def xml_serialization
87
+ {
88
+ "xml" => self.xml
89
+ }
90
+ end
91
+
92
+ def announcements_serialization
93
+ {
94
+ "announcements" => self.announcements.collect { |ann| ann.serialize(:summary) }
95
+ }
96
+ end
97
+
98
+ def self.all_serializations
99
+ [
100
+ :default,
101
+ :xml,
102
+ :announcements,
103
+ ]
104
+ end
82
105
  end
83
106
 
84
- class Announcement < SakaiXMLEntity
85
- attr_reader :channel, :owner, :date
86
- attr_reader :draft, :pubview
107
+ class Announcement < SakaiObject
108
+ attr_reader :channel_id, :owner, :date, :draft, :pubview, :dbrow
109
+
110
+ def self.clear_cache
111
+ @@cache = {}
112
+ end
113
+ clear_cache
114
+
115
+ def initialize(dbrow)
116
+ @dbrow = dbrow
117
+
118
+ @id = @dbrow[:message_id]
119
+ @channel_id = @dbrow[:channel_id]
120
+ @draft = @dbrow[:draft]
121
+ @pubview = @dbrow[:pubview]
122
+ @owner = User.find(@dbrow[:owner])
123
+ @date = @dbrow[:message_date]
124
+ end
87
125
 
88
- @@cache = {}
89
126
  def self.find(id)
90
127
  if @@cache[id].nil?
91
- xml = ""
92
- row = DB.connect.fetch("select channel_id, draft, pubview, owner, xml, " +
93
- "to_char(message_date,'YYYY-MM-DD HH24:MI:SS') as message_date " +
94
- "from announcement_message " +
95
- "where message_id = ?", id).first
128
+ row = DB.connect[:announcement_message].where(:message_id => id).first
96
129
  if row.nil?
97
130
  raise ObjectNotFoundException.new(Announcement, id)
98
131
  end
99
-
100
- channel = AnnouncementChannel.find(row[:channel_id])
101
- draft = row[:draft]
102
- pubview = row[:pubview]
103
- owner = User.find(row[:owner])
104
- date = row[:message_date]
105
- REXML::Document.new(row[:xml].read).write(xml, 2)
106
- @@cache[id] = Announcement.new(id, channel, draft, pubview, owner, date, xml)
132
+ @@cache[id] = Announcement.new(row)
107
133
  end
108
134
  @@cache[id]
109
135
  end
110
136
 
111
- # raw data constructor
112
- def initialize(id, channel, draft, pubview, owner, date, xml)
113
- @id = id
114
- @channel = channel
115
- @draft = draft
116
- @pubview = pubview
117
- @owner = owner
118
- @date = date
119
- @xml = xml
120
- parse_xml
137
+ def self.query_by_channel_id(channel_id)
138
+ DB.connect[:announcement_message].where(:channel_id => channel_id)
139
+ end
140
+
141
+ def self.count_by_channel_id(channel_id)
142
+ Announcement.query_by_channel_id(channel_id).count
121
143
  end
122
144
 
123
- # helpers
124
145
  def self.find_by_channel_id(channel_id)
125
- announcements = []
126
- channel = AnnouncementChannel.find(channel_id)
146
+ Announcement.query_by_channel_id(channel_id).all.collect do |row|
147
+ @@cache[row[:message_id]] = Announcement.new(row)
148
+ end
149
+ end
127
150
 
128
- DB.connect.fetch("select message_id, draft, pubview, owner, xml, " +
129
- "to_char(message_date,'YYYY-MM-DD HH24:MI:SS') as message_date " +
130
- "from announcement_message " +
131
- "where channel_id = ?", channel_id) do |row|
132
- xml = ""
133
- id = row[:message_id]
134
- draft = row[:draft]
135
- pubview = row[:pubview]
136
- owner = User.find(row[:owner])
137
- REXML::Document.new(row[:xml].read).write(xml, 2)
138
- date = row[:message_date]
139
-
140
- @@cache[id] = Announcement.new(id, channel, draft, pubview, owner, date, xml)
141
- announcements << @@cache[id]
151
+ # lazy properties
152
+ def channel
153
+ @channel ||= AnnouncementChannel.find(self.channel_id)
154
+ end
155
+
156
+ def xml
157
+ if @xml.nil?
158
+ @xml = ""
159
+ REXML::Document.new(@dbrow[:xml].read).write(@xml, 2)
142
160
  end
143
- announcements
161
+ @xml
144
162
  end
145
163
 
146
164
  # serialization
@@ -151,7 +169,7 @@ module SakaiInfo
151
169
  "owner" => self.owner.serialize(:summary),
152
170
  "draft" => self.draft,
153
171
  "pubview" => self.pubview,
154
- "channel" => self.channel.serialize(:summary)
172
+ "channel" => self.channel_id,
155
173
  }
156
174
  end
157
175
 
@@ -161,6 +179,19 @@ module SakaiInfo
161
179
  "date" => self.date
162
180
  }
163
181
  end
182
+
183
+ def xml_serialization
184
+ {
185
+ "xml" => self.xml
186
+ }
187
+ end
188
+
189
+ def self.all_serializations
190
+ [
191
+ :default,
192
+ :xml,
193
+ ]
194
+ end
164
195
  end
165
196
  end
166
197
 
@@ -2,7 +2,7 @@
2
2
  # SakaiInfo::Assignment library
3
3
  #
4
4
  # Created 2012-02-17 daveadams@gmail.com
5
- # Last updated 2012-05-02 daveadams@gmail.com
5
+ # Last updated 2012-05-10 daveadams@gmail.com
6
6
  #
7
7
  # https://github.com/daveadams/sakai-info
8
8
  #
@@ -13,7 +13,11 @@ module SakaiInfo
13
13
  class Assignment < SakaiXMLEntity
14
14
  attr_reader :dbrow, :site_id
15
15
 
16
- @@cache = {}
16
+ def self.clear_cache
17
+ @@cache = {}
18
+ end
19
+ clear_cache
20
+
17
21
  def self.find(id)
18
22
  if @@cache[id].nil?
19
23
  xml = ""
@@ -95,6 +99,11 @@ module SakaiInfo
95
99
  class AssignmentSubmission < SakaiXMLEntity
96
100
  attr_reader :dbrow, :assignment_id, :submitter_id
97
101
 
102
+ def self.clear_cache
103
+ @@cache = {}
104
+ end
105
+ clear_cache
106
+
98
107
  def initialize(dbrow)
99
108
  @dbrow = dbrow
100
109
 
@@ -107,7 +116,6 @@ module SakaiInfo
107
116
  parse_xml
108
117
  end
109
118
 
110
- @@cache = {}
111
119
  def self.find(id)
112
120
  if @@cache[id].nil?
113
121
  row = DB.connect[:assignment_submission].where(:submission_id => id).first
@@ -204,6 +212,11 @@ module SakaiInfo
204
212
  class AssignmentContent < SakaiXMLEntity
205
213
  attr_reader :owner
206
214
 
215
+ def self.clear_cache
216
+ @@cache = {}
217
+ end
218
+ clear_cache
219
+
207
220
  def initialize(id, owner, xml)
208
221
  @id = id
209
222
  @owner = owner
@@ -211,7 +224,6 @@ module SakaiInfo
211
224
  parse_xml
212
225
  end
213
226
 
214
- @@cache = {}
215
227
  def self.find(id)
216
228
  if @@cache[id].nil?
217
229
  row = DB.connect[:assignment_content].where(:content_id => id).first
@@ -2,7 +2,7 @@
2
2
  # SakaiInfo::Authz library
3
3
  #
4
4
  # Created 2012-02-17 daveadams@gmail.com
5
- # Last updated 2012-02-17 daveadams@gmail.com
5
+ # Last updated 2012-05-10 daveadams@gmail.com
6
6
  #
7
7
  # https://github.com/daveadams/sakai-info
8
8
  #
@@ -13,6 +13,11 @@ module SakaiInfo
13
13
  class AuthzRole < SakaiObject
14
14
  attr_reader :name
15
15
 
16
+ def self.clear_cache
17
+ @@cache = {}
18
+ end
19
+ clear_cache
20
+
16
21
  def initialize(id, name)
17
22
  @id = id
18
23
  @name = name
@@ -22,7 +27,6 @@ module SakaiInfo
22
27
  name
23
28
  end
24
29
 
25
- @@cache = {}
26
30
  def self.find_by_id(id)
27
31
  id = id.to_s
28
32
  if @@cache[id].nil?
@@ -87,6 +91,11 @@ module SakaiInfo
87
91
  class AuthzFunction < SakaiObject
88
92
  attr_reader :name
89
93
 
94
+ def self.clear_cache
95
+ @@cache = {}
96
+ end
97
+ clear_cache
98
+
90
99
  def initialize(id, name)
91
100
  @id = id
92
101
  @name = name
@@ -96,7 +105,6 @@ module SakaiInfo
96
105
  name
97
106
  end
98
107
 
99
- @@cache = {}
100
108
  def self.find_by_id(id)
101
109
  id = id.to_s
102
110
  if @@cache[id].nil?
@@ -164,6 +172,11 @@ module SakaiInfo
164
172
  class AuthzRealm < SakaiObject
165
173
  attr_reader :name, :providers, :maintain_role
166
174
 
175
+ def self.clear_cache
176
+ @@cache = {}
177
+ end
178
+ clear_cache
179
+
167
180
  def initialize(id, name, providers, maintain_role)
168
181
  @id = id
169
182
  @name = name
@@ -191,7 +204,6 @@ module SakaiInfo
191
204
  @membership ||= AuthzRealmMembership.find_by_realm_id(@id)
192
205
  end
193
206
 
194
- @@cache = {}
195
207
  def self.find_by_id(id)
196
208
  id = id.to_s
197
209
  if @@cache[id].nil?
@@ -2,7 +2,7 @@
2
2
  # - sakai-info command line tool support
3
3
  #
4
4
  # Created 2012-02-19 daveadams@gmail.com
5
- # Last updated 2012-04-02 daveadams@gmail.com
5
+ # Last updated 2012-05-10 daveadams@gmail.com
6
6
  #
7
7
  # https://github.com/daveadams/sakai-info
8
8
  #
@@ -36,6 +36,8 @@ module SakaiInfo
36
36
  "forum-thread" => ForumThread,
37
37
  "forum-post" => ForumPost,
38
38
  "content" => Content,
39
+ "announcement" => Announcement,
40
+ "announcement-channel" => AnnouncementChannel,
39
41
  }
40
42
  end
41
43
  end
@@ -2,7 +2,7 @@
2
2
  # - sin command line help
3
3
  #
4
4
  # Created 2012-02-19 daveadams@gmail.com
5
- # Last updated 2012-04-02 daveadams@gmail.com
5
+ # Last updated 2012-05-10 daveadams@gmail.com
6
6
  #
7
7
  # https://github.com/daveadams/sakai-info
8
8
  #
@@ -20,7 +20,8 @@ sin #{VERSION}
20
20
  Object commands:
21
21
  user, group, site, page, tool, quiz, quiz-section, quiz-item, quiz-attempt,
22
22
  quiz-attempt-item, quiz-attempt-item-attachment, question-pool, assignment,
23
- assignment-submission, forum, forum-thread, forum-post, content
23
+ assignment-submission, forum, forum-thread, forum-post, content,
24
+ announcement, announcement-channel
24
25
 
25
26
  Misc commands:
26
27
  test Tests configured database connections
@@ -327,6 +328,29 @@ sin content
327
328
  --children Recursively print collection children
328
329
  --mod Print creation/modification info
329
330
  --all Print all possible details
331
+ EOF
332
+ "announcement" => <<EOF,
333
+ sin announcement
334
+
335
+ Usage: sin announcement <id> [<options>]
336
+
337
+ Prints information about the announcement specified. Additional options may
338
+ be passed to include additional information:
339
+
340
+ --xml Print raw XML content
341
+ --all Print all possible details
342
+ EOF
343
+ "announcement-channel" => <<EOF,
344
+ sin content
345
+
346
+ Usage: sin announcement-channel <id> [<options>]
347
+
348
+ Prints information about the announcement channel specified. Additional
349
+ options may be passed to include additional information:
350
+
351
+ --announcements Print a summary of all announcements in this channel
352
+ --xml Print raw XML content
353
+ --all Print all possible details
330
354
  EOF
331
355
  }
332
356
 
@@ -2,7 +2,7 @@
2
2
  # SakaiInfo::Content library
3
3
  #
4
4
  # Created 2012-02-17 daveadams@gmail.com
5
- # Last updated 2012-04-21 daveadams@gmail.com
5
+ # Last updated 2012-05-10 daveadams@gmail.com
6
6
  #
7
7
  # https://github.com/daveadams/sakai-info
8
8
  #
@@ -145,6 +145,11 @@ module SakaiInfo
145
145
  class ContentResource < Content
146
146
  attr_reader :file_path, :uuid, :context, :resource_type_id, :dbrow
147
147
 
148
+ def self.clear_cache
149
+ @@cache = {}
150
+ end
151
+ clear_cache
152
+
148
153
  def initialize(dbrow)
149
154
  @dbrow = dbrow
150
155
 
@@ -160,7 +165,6 @@ module SakaiInfo
160
165
  @id_column = "resource_id"
161
166
  end
162
167
 
163
- @@cache = {}
164
168
  def self.find(id)
165
169
  if @@cache[id].nil?
166
170
  row = DB.connect[:content_resource].where(:resource_id => id).first
@@ -219,6 +223,11 @@ module SakaiInfo
219
223
  class ContentCollection < Content
220
224
  attr_reader :dbrow
221
225
 
226
+ def self.clear_cache
227
+ @@cache = {}
228
+ end
229
+ clear_cache
230
+
222
231
  def initialize(dbrow)
223
232
  @dbrow = dbrow
224
233
 
@@ -229,7 +238,6 @@ module SakaiInfo
229
238
  @id_column = "collection_id"
230
239
  end
231
240
 
232
- @@cache = {}
233
241
  def self.find(id)
234
242
  if id !~ /\/$/
235
243
  id += "/"
@@ -348,7 +356,11 @@ module SakaiInfo
348
356
  end
349
357
 
350
358
  class MissingContentCollection < ContentCollection
351
- @@cache = {}
359
+ def self.clear_cache
360
+ @@cache = {}
361
+ end
362
+ clear_cache
363
+
352
364
  def self.find(id)
353
365
  @@cache[id] ||= MissingContentCollection.new(id, nil)
354
366
  end
@@ -2,7 +2,7 @@
2
2
  # SakaiInfo::Forum library
3
3
  #
4
4
  # Created 2012-04-01 daveadams@gmail.com
5
- # Last updated 2012-04-01 daveadams@gmail.com
5
+ # Last updated 2012-05-10 daveadams@gmail.com
6
6
  #
7
7
  # https://github.com/daveadams/sakai-info
8
8
  #
@@ -11,7 +11,7 @@
11
11
 
12
12
  module SakaiInfo
13
13
  class Forum < SakaiObject
14
- attr_reader :id, :title, :dbrow
14
+ attr_reader :title, :dbrow
15
15
 
16
16
  include ModProps
17
17
  created_by_key :created_by
@@ -19,7 +19,11 @@ module SakaiInfo
19
19
  modified_by_key :modified_by
20
20
  modified_at_key :modified
21
21
 
22
- @@cache = {}
22
+ def self.clear_cache
23
+ @@cache = {}
24
+ end
25
+ clear_cache
26
+
23
27
  def self.find(id)
24
28
  if @@cache[id.to_s].nil?
25
29
  row = DB.connect[:mfr_open_forum_t].where(:id => id).first
@@ -118,7 +122,7 @@ module SakaiInfo
118
122
  end
119
123
 
120
124
  class ForumThread < GenericThread
121
- attr_reader :id, :title, :dbrow
125
+ attr_reader :title, :dbrow
122
126
 
123
127
  include ModProps
124
128
  created_by_key :created_by
@@ -126,7 +130,11 @@ module SakaiInfo
126
130
  modified_by_key :modified_by
127
131
  modified_at_key :modified
128
132
 
129
- @@cache = {}
133
+ def self.clear_cache
134
+ @@cache = {}
135
+ end
136
+ clear_cache
137
+
130
138
  def self.find(id)
131
139
  if @@cache[id.to_s].nil?
132
140
  row = DB.connect[:mfr_topic_t].where(:id => id, :topic_dtype => "DT").first
@@ -204,7 +212,11 @@ module SakaiInfo
204
212
  modified_by_key :modified_by
205
213
  modified_at_key :modified
206
214
 
207
- @@cache = {}
215
+ def self.clear_cache
216
+ @@cache = {}
217
+ end
218
+ clear_cache
219
+
208
220
  def self.find(id)
209
221
  if @@cache[id.to_s].nil?
210
222
  row = DB.connect[:mfr_message_t].where(:id => id, :message_dtype => "ME").first
@@ -2,7 +2,7 @@
2
2
  # SakaiInfo::Gradebook library
3
3
  #
4
4
  # Created 2012-02-17 daveadams@gmail.com
5
- # Last updated 2012-02-24 daveadams@gmail.com
5
+ # Last updated 2012-05-10 daveadams@gmail.com
6
6
  #
7
7
  # https://github.com/daveadams/sakai-info
8
8
  #
@@ -13,6 +13,12 @@ module SakaiInfo
13
13
  class Gradebook < SakaiObject
14
14
  attr_reader :version, :site, :name
15
15
 
16
+ def self.clear_cache
17
+ @@cache = {}
18
+ @@cache_by_site_id = {}
19
+ end
20
+ clear_cache
21
+
16
22
  def initialize(id, version, site, name)
17
23
  @id = id
18
24
  @version = version
@@ -20,8 +26,6 @@ module SakaiInfo
20
26
  @name = name
21
27
  end
22
28
 
23
- @@cache = {}
24
- @@cache_by_site_id = {}
25
29
  def self.find(id)
26
30
  if @@cache[id].nil?
27
31
  row = DB.connect.fetch("select version, gradebook_uid, name " +
@@ -72,6 +76,12 @@ module SakaiInfo
72
76
  attr_reader :id, :gradebook, :object_type, :version, :name
73
77
  attr_reader :points_possible, :due_date, :weight
74
78
 
79
+ def self.clear_cache
80
+ @@cache = {}
81
+ @@cache_by_gradebook_id = {}
82
+ end
83
+ clear_cache
84
+
75
85
  def initialize(id, gradebook, object_type, version, name,
76
86
  points_possible, due_date, weight)
77
87
  @id = id
@@ -84,7 +94,6 @@ module SakaiInfo
84
94
  @weight = weight
85
95
  end
86
96
 
87
- @@cache = {}
88
97
  def self.find(id)
89
98
  if @@cache[id].nil?
90
99
  row = DB.connect.fetch("select gradebook_id, object_type_id, version, " +
@@ -112,7 +121,6 @@ module SakaiInfo
112
121
  @@cache[id]
113
122
  end
114
123
 
115
- @@cache_by_gradebook_id = {}
116
124
  def self.find_by_gradebook_id(gradebook_id)
117
125
  if @@cache_by_gradebook_id[gradebook_id].nil?
118
126
  objects = []
@@ -2,7 +2,7 @@
2
2
  # SakaiInfo::Group library
3
3
  #
4
4
  # Created 2012-02-17 daveadams@gmail.com
5
- # Last updated 2012-04-22 daveadams@gmail.com
5
+ # Last updated 2012-05-10 daveadams@gmail.com
6
6
  #
7
7
  # https://github.com/daveadams/sakai-info
8
8
  #
@@ -13,6 +13,11 @@ module SakaiInfo
13
13
  class Group < SakaiObject
14
14
  attr_reader :site_id, :title, :dbrow
15
15
 
16
+ def self.clear_cache
17
+ @@cache = {}
18
+ end
19
+ clear_cache
20
+
16
21
  def initialize(dbrow)
17
22
  @dbrow = dbrow
18
23
 
@@ -25,7 +30,6 @@ module SakaiInfo
25
30
  @site ||= Site.find(@site_id)
26
31
  end
27
32
 
28
- @@cache = {}
29
33
  def self.find(id)
30
34
  if @@cache[id].nil?
31
35
  row = DB.connect[:sakai_site_group].filter(:group_id => id).first
@@ -2,7 +2,7 @@
2
2
  # SakaiInfo::Message library
3
3
  #
4
4
  # Created 2012-02-17 daveadams@gmail.com
5
- # Last updated 2012-02-24 daveadams@gmail.com
5
+ # Last updated 2012-05-10 daveadams@gmail.com
6
6
  #
7
7
  # https://github.com/daveadams/sakai-info
8
8
  #
@@ -63,13 +63,17 @@ module SakaiInfo
63
63
  class Forum < SakaiObject
64
64
  attr_reader :id, :title
65
65
 
66
+ def self.clear_cache
67
+ @@cache = {}
68
+ @@cache_by_site_id = {}
69
+ end
70
+ clear_cache
71
+
66
72
  def initialize(id, title)
67
73
  @id = id.to_i
68
74
  @title = title
69
75
  end
70
76
 
71
- @@cache = {}
72
-
73
77
  def self.count_by_site_id(site_id)
74
78
  DB.connect.fetch("select count(*) as count from mfr_open_forum_t " +
75
79
  "where surrogatekey = (select id from mfr_area_t " +
@@ -77,7 +81,6 @@ module SakaiInfo
77
81
  MessageTypeUUID::FORUM_POST, site_id).first[:count].to_i
78
82
  end
79
83
 
80
- @@cache_by_site_id = {}
81
84
  def self.find_by_site_id(site_id)
82
85
  if @@cache_by_site_id[site_id].nil?
83
86
  @@cache_by_site_id[site_id] = []
@@ -2,7 +2,7 @@
2
2
  # SakaiInfo::Page library
3
3
  #
4
4
  # Created 2012-03-08 daveadams@gmail.com
5
- # Last updated 2012-04-22 daveadams@gmail.com
5
+ # Last updated 2012-05-10 daveadams@gmail.com
6
6
  #
7
7
  # https://github.com/daveadams/sakai-info
8
8
  #
@@ -13,7 +13,11 @@ module SakaiInfo
13
13
  class Page < SakaiObject
14
14
  attr_reader :title, :order, :layout, :site_id, :dbrow
15
15
 
16
- @@cache = {}
16
+ def self.clear_cache
17
+ @@cache = {}
18
+ end
19
+ clear_cache
20
+
17
21
  def self.find(id)
18
22
  if @@cache[id].nil?
19
23
  row = DB.connect[:sakai_site_page].where(:page_id => id).first
@@ -2,7 +2,7 @@
2
2
  # SakaiInfo::QuestionPool library
3
3
  #
4
4
  # Created 2012-02-26 daveadams@gmail.com
5
- # Last updated 2012-02-26 daveadams@gmail.com
5
+ # Last updated 2012-05-10 daveadams@gmail.com
6
6
  #
7
7
  # https://github.com/daveadams/sakai-info
8
8
  #
@@ -19,6 +19,11 @@ module SakaiInfo
19
19
  modified_at_key :lastmodifieddate
20
20
  modified_by_key :lastmodifiedby
21
21
 
22
+ def self.clear_cache
23
+ @@cache = {}
24
+ end
25
+ clear_cache
26
+
22
27
  def initialize(dbrow)
23
28
  @dbrow = dbrow
24
29
 
@@ -30,7 +35,6 @@ module SakaiInfo
30
35
  @parent_pool_id = nil if @parent_pool_id == 0
31
36
  end
32
37
 
33
- @@cache = {}
34
38
  def self.find(id)
35
39
  if @@cache[id].nil?
36
40
  row = DB.connect[:sam_questionpool_t].filter(:questionpoolid => id).first
@@ -2,7 +2,7 @@
2
2
  # SakaiInfo::Quiz library
3
3
  #
4
4
  # Created 2012-02-17 daveadams@gmail.com
5
- # Last updated 2012-05-03 daveadams@gmail.com
5
+ # Last updated 2012-05-10 daveadams@gmail.com
6
6
  #
7
7
  # https://github.com/daveadams/sakai-info
8
8
  #
@@ -19,6 +19,11 @@ module SakaiInfo
19
19
  modified_by_key :lastmodifiedby
20
20
  modified_at_key :lastmodifieddate
21
21
 
22
+ def self.clear_cache
23
+ @@cache = {}
24
+ end
25
+ clear_cache
26
+
22
27
  # a note about quizzes:
23
28
  # they do not link directly back to sites
24
29
  # instead, they link back only via the sam_authzdata_t table
@@ -56,7 +61,6 @@ module SakaiInfo
56
61
  end
57
62
  end
58
63
 
59
- @@cache = {}
60
64
  def self.find(id)
61
65
  id = id.to_s
62
66
  if @@cache[id].nil?
@@ -171,7 +175,11 @@ module SakaiInfo
171
175
  end
172
176
 
173
177
  class PendingQuiz < Quiz
174
- @@cache = {}
178
+ def self.clear_cache
179
+ @@cache = {}
180
+ end
181
+ clear_cache
182
+
175
183
  def self.find(id)
176
184
  id = id.to_s
177
185
  if @@cache[id].nil?
@@ -212,7 +220,11 @@ module SakaiInfo
212
220
  end
213
221
 
214
222
  class PublishedQuiz < Quiz
215
- @@cache = {}
223
+ def self.clear_cache
224
+ @@cache = {}
225
+ end
226
+ clear_cache
227
+
216
228
  def self.find(id)
217
229
  id = id.to_s
218
230
  if @@cache[id].nil?
@@ -280,6 +292,11 @@ module SakaiInfo
280
292
  modified_by_key :lastmodifiedby
281
293
  modified_at_key :lastmodifieddate
282
294
 
295
+ def self.clear_cache
296
+ @@cache = {}
297
+ end
298
+ clear_cache
299
+
283
300
  def initialize(dbrow)
284
301
  @dbrow = dbrow
285
302
 
@@ -292,7 +309,6 @@ module SakaiInfo
292
309
  @status = dbrow[:status]
293
310
  end
294
311
 
295
- @@cache = {}
296
312
  def self.find(id)
297
313
  id = id.to_s
298
314
  if @@cache[id].nil?
@@ -387,7 +403,11 @@ module SakaiInfo
387
403
  end
388
404
 
389
405
  class PendingQuizSection < QuizSection
390
- @@cache = {}
406
+ def self.clear_cache
407
+ @@cache = {}
408
+ end
409
+ clear_cache
410
+
391
411
  def self.find(id)
392
412
  id = id.to_s
393
413
  if @@cache[id].nil?
@@ -407,7 +427,11 @@ module SakaiInfo
407
427
  end
408
428
 
409
429
  class PublishedQuizSection < QuizSection
410
- @@cache = {}
430
+ def self.clear_cache
431
+ @@cache = {}
432
+ end
433
+ clear_cache
434
+
411
435
  def self.find(id)
412
436
  id = id.to_s
413
437
  if @@cache[id].nil?
@@ -435,6 +459,11 @@ module SakaiInfo
435
459
  modified_by_key :lastmodifiedby
436
460
  modified_at_key :lastmodifieddate
437
461
 
462
+ def self.clear_cache
463
+ @@cache = {}
464
+ end
465
+ clear_cache
466
+
438
467
  def initialize(dbrow)
439
468
  @dbrow = dbrow
440
469
 
@@ -445,7 +474,6 @@ module SakaiInfo
445
474
  @typeid = dbrow[:typeid]
446
475
  end
447
476
 
448
- @@cache = {}
449
477
  def self.find(id)
450
478
  id = id.to_s
451
479
  if @@cache[id].nil?
@@ -540,7 +568,11 @@ module SakaiInfo
540
568
  end
541
569
 
542
570
  class PendingQuizItem < QuizItem
543
- @@cache = {}
571
+ def self.clear_cache
572
+ @@cache = {}
573
+ end
574
+ clear_cache
575
+
544
576
  def self.find(id)
545
577
  id = id.to_s
546
578
  if @@cache[id].nil?
@@ -560,7 +592,11 @@ module SakaiInfo
560
592
  end
561
593
 
562
594
  class PublishedQuizItem < QuizItem
563
- @@cache = {}
595
+ def self.clear_cache
596
+ @@cache = {}
597
+ end
598
+ clear_cache
599
+
564
600
  def self.find(id)
565
601
  id = id.to_s
566
602
  if @@cache[id].nil?
@@ -592,6 +628,11 @@ module SakaiInfo
592
628
  attr_reader :dbrow, :submitted_at, :total_auto_score, :status, :attempted_at
593
629
  attr_reader :time_elapsed, :comments, :user_id, :quiz_id
594
630
 
631
+ def self.clear_cache
632
+ @@cache = {}
633
+ end
634
+ clear_cache
635
+
595
636
  def initialize(dbrow)
596
637
  @dbrow = dbrow
597
638
 
@@ -608,7 +649,6 @@ module SakaiInfo
608
649
  @comments = dbrow[:comments]
609
650
  end
610
651
 
611
- @@cache = {}
612
652
  def self.find(id)
613
653
  id = id.to_s
614
654
  if @@cache[id].nil?
@@ -704,6 +744,11 @@ module SakaiInfo
704
744
  class QuizAttemptItem < SakaiObject
705
745
  attr_reader :dbrow, :submitted_at, :answer, :user_id, :item_id, :attempt_id
706
746
 
747
+ def self.clear_cache
748
+ @@cache = {}
749
+ end
750
+ clear_cache
751
+
707
752
  def initialize(dbrow)
708
753
  @dbrow = dbrow
709
754
 
@@ -727,7 +772,6 @@ module SakaiInfo
727
772
  @item ||= PublishedQuizItem.find(@item_id)
728
773
  end
729
774
 
730
- @@cache = {}
731
775
  def self.find(id)
732
776
  id = id.to_s
733
777
  if @@cache[id].nil?
@@ -766,7 +810,8 @@ module SakaiInfo
766
810
  "attempt" => self.attempt.serialize(:summary),
767
811
  "item" => self.item.serialize(:summary),
768
812
  "answer" => self.answer,
769
- "attachment_count" => self.attachments.length
813
+ "attachment_count" => self.attachments.length,
814
+ "submitted_at" => self.submitted_at,
770
815
  }
771
816
  end
772
817
 
@@ -775,14 +820,16 @@ module SakaiInfo
775
820
  "id" => self.id,
776
821
  "eid" => User.get_eid(self.user_id),
777
822
  "attempt_id" => self.attempt_id,
778
- "item_id" => self.item_id
823
+ "item_id" => self.item_id,
824
+ "submitted_at" => self.submitted_at,
779
825
  }
780
826
  end
781
827
 
782
828
  def attempt_summary_serialization
783
829
  {
784
830
  "id" => self.id,
785
- "item_id" => self.item_id
831
+ "item_id" => self.item_id,
832
+ "submitted_at" => self.submitted_at,
786
833
  }
787
834
  end
788
835
 
@@ -807,6 +854,11 @@ module SakaiInfo
807
854
  modified_by_key :lastmodifiedby
808
855
  modified_at_key :lastmodifieddate
809
856
 
857
+ def self.clear_cache
858
+ @@cache = {}
859
+ end
860
+ clear_cache
861
+
810
862
  def initialize(dbrow)
811
863
  @dbrow = dbrow
812
864
 
@@ -829,7 +881,6 @@ module SakaiInfo
829
881
  all.collect { |row| QuizAttemptItemAttachment.new(row) }
830
882
  end
831
883
 
832
- @@cache = {}
833
884
  def self.find(id)
834
885
  id = id.to_s
835
886
  if @@cache[id].nil?
@@ -2,7 +2,7 @@
2
2
  # SakaiInfo::SakaiObject
3
3
  #
4
4
  # Created 2012-02-15 daveadams@gmail.com
5
- # Last updated 2012-02-29 daveadams@gmail.com
5
+ # Last updated 2012-05-10 daveadams@gmail.com
6
6
  #
7
7
  # https://github.com/daveadams/sakai-info
8
8
  #
@@ -76,5 +76,10 @@ module SakaiInfo
76
76
  def self.all_serializations
77
77
  [:default]
78
78
  end
79
+
80
+ # keep track of descendants
81
+ def self.descendants
82
+ ObjectSpace.each_object(Class).select { |klass| klass < self }
83
+ end
79
84
  end
80
85
  end
@@ -2,7 +2,7 @@
2
2
  # SakaiInfo::Site library
3
3
  #
4
4
  # Created 2012-02-17 daveadams@gmail.com
5
- # Last updated 2012-04-22 daveadams@gmail.com
5
+ # Last updated 2012-05-10 daveadams@gmail.com
6
6
  #
7
7
  # https://github.com/daveadams/sakai-info
8
8
  #
@@ -19,7 +19,11 @@ module SakaiInfo
19
19
  modified_by_key :modifiedby
20
20
  modified_at_key :modifiedon
21
21
 
22
- @@cache = {}
22
+ def self.clear_cache
23
+ @@cache = {}
24
+ end
25
+ clear_cache
26
+
23
27
  def self.find(id)
24
28
  if @@cache[id].nil?
25
29
  row = DB.connect[:sakai_site].where(:site_id => id).first
@@ -275,7 +279,7 @@ module SakaiInfo
275
279
  "id" => self.id,
276
280
  "title" => self.title,
277
281
  "type" => self.type,
278
- "created_by" => self.created_by_id
282
+ "created_by" => self.created_by.eid
279
283
  }
280
284
  end
281
285
 
@@ -2,7 +2,7 @@
2
2
  # SakaiInfo::Tool library
3
3
  #
4
4
  # Created 2012-03-08 daveadams@gmail.com
5
- # Last updated 2012-04-22 daveadams@gmail.com
5
+ # Last updated 2012-05-10 daveadams@gmail.com
6
6
  #
7
7
  # https://github.com/daveadams/sakai-info
8
8
  #
@@ -13,7 +13,11 @@ module SakaiInfo
13
13
  class Tool < SakaiObject
14
14
  attr_reader :title, :registration, :order, :layout, :page_id, :site_id, :dbrow
15
15
 
16
- @@cache = {}
16
+ def self.clear_cache
17
+ @@cache = {}
18
+ end
19
+ clear_cache
20
+
17
21
  def self.find(id)
18
22
  if @@cache[id].nil?
19
23
  row = DB.connect[:sakai_site_tool].where(:tool_id => id).first
@@ -2,7 +2,7 @@
2
2
  # SakaiInfo::User library
3
3
  #
4
4
  # Created 2012-02-17 daveadams@gmail.com
5
- # Last updated 2012-04-22 daveadams@gmail.com
5
+ # Last updated 2012-05-10 daveadams@gmail.com
6
6
  #
7
7
  # https://github.com/daveadams/sakai-info
8
8
  #
@@ -19,7 +19,12 @@ module SakaiInfo
19
19
  modified_by_key :modifiedby
20
20
  modified_at_key :modifiedon
21
21
 
22
- @@cache = {}
22
+ def self.clear_cache
23
+ @@cache = {}
24
+ @@id_cache = {}
25
+ end
26
+ clear_cache
27
+
23
28
  def self.find(id)
24
29
  if @@cache[id].nil?
25
30
  eid = User.get_eid(id)
@@ -30,8 +35,8 @@ module SakaiInfo
30
35
 
31
36
  row = DB.connect[:sakai_user].where(:user_id => user_id).first
32
37
  if row.nil?
33
- #Has sakai_user_id_map record, but not sakai_user record. Provided account!
34
- #raise ObjectNotFoundException.new(User, id)
38
+ # Has sakai_user_id_map record, but not sakai_user record. Provided account!
39
+ # TODO: replace with a ProvidedUser subclass
35
40
  @@cache[eid] = @@cache[user_id] = User.new(user_id,'Provided')
36
41
  else
37
42
  @@cache[eid] = @@cache[user_id] = User.new(row)
@@ -40,7 +45,6 @@ module SakaiInfo
40
45
  @@cache[id]
41
46
  end
42
47
 
43
- @@id_cache = {}
44
48
  def self.get_ids(id)
45
49
  @@id_cache[id] ||=
46
50
  DB.connect[:sakai_user_id_map].where({:user_id => id, :eid => id}.sql_or).first
@@ -66,7 +70,7 @@ module SakaiInfo
66
70
  case args.size
67
71
  when 1
68
72
  dbrow = args[0]
69
- @dbrow = dbrow
73
+ @dbrow = dbrow
70
74
  @id = dbrow[:user_id]
71
75
  @eid = User.get_eid(@id)
72
76
  @email = dbrow[:email]
@@ -1,3 +1,3 @@
1
1
  module SakaiInfo
2
- VERSION = "0.4.2"
2
+ VERSION = "0.4.3"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sakai-info
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.2
4
+ version: 0.4.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-05-04 00:00:00.000000000 Z
12
+ date: 2012-05-10 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: sequel