sakai-info 0.2.1 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -2,7 +2,7 @@
2
2
  # SakaiInfo::SakaiObject
3
3
  #
4
4
  # Created 2012-02-15 daveadams@gmail.com
5
- # Last updated 2012-02-18 daveadams@gmail.com
5
+ # Last updated 2012-02-26 daveadams@gmail.com
6
6
  #
7
7
  # https://github.com/daveadams/sakai-info
8
8
  #
@@ -26,11 +26,8 @@ module SakaiInfo
26
26
  serialization = {}
27
27
  q.each do |sub|
28
28
  sub_method_name = (sub.to_s + "_serialization").to_sym
29
- begin
30
- sub_method = self.method(sub_method_name)
31
- serialization = serialization.merge(sub_method.call)
32
- rescue NameError
33
- # ignore any missing serialization patterns
29
+ if self.respond_to? sub_method_name
30
+ serialization = serialization.merge(self.method(sub_method_name).call)
34
31
  end
35
32
  end
36
33
 
@@ -43,6 +40,16 @@ module SakaiInfo
43
40
  }
44
41
  end
45
42
 
43
+ def dbrow_serialization
44
+ if self.respond_to? :dbrow
45
+ {
46
+ "dbrow" => self.dbrow
47
+ }
48
+ else
49
+ {}
50
+ end
51
+ end
52
+
46
53
  def default_serialization
47
54
  object_type_serialization
48
55
  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-02-24 daveadams@gmail.com
5
+ # Last updated 2012-02-26 daveadams@gmail.com
6
6
  #
7
7
  # https://github.com/daveadams/sakai-info
8
8
  #
@@ -323,11 +323,11 @@ module SakaiInfo
323
323
  end
324
324
  if self.pending_quiz_count > 0
325
325
  result["quizzes"]["pending"] =
326
- self.pending_quizzes.collect { |pq| pq.serialize(:summary) }
326
+ self.pending_quizzes.collect { |pq| pq.serialize(:site_summary) }
327
327
  end
328
328
  if self.published_quiz_count > 0
329
329
  result["quizzes"]["published"] =
330
- self.published_quizzes.collect { |pq| pq.serialize(:summary) }
330
+ self.published_quizzes.collect { |pq| pq.serialize(:site_summary) }
331
331
  end
332
332
  result
333
333
  end
@@ -2,7 +2,7 @@
2
2
  # SakaiInfo::User 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-02-26 daveadams@gmail.com
6
6
  #
7
7
  # https://github.com/daveadams/sakai-info
8
8
  #
@@ -84,11 +84,7 @@ module SakaiInfo
84
84
  end
85
85
 
86
86
  def question_pool_count
87
- if @question_pools.nil?
88
- QuestionPool.count_by_user_id(@id)
89
- else
90
- @question_pools.length
91
- end
87
+ @question_pool_count ||= QuestionPool.count_by_user_id(@id)
92
88
  end
93
89
 
94
90
  def assignment_submissions
@@ -1,3 +1,3 @@
1
1
  module SakaiInfo
2
- VERSION = "0.2.1"
2
+ VERSION = "0.3.0"
3
3
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sakai-info
3
3
  version: !ruby/object:Gem::Version
4
- hash: 21
4
+ hash: 19
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
- - 2
9
- - 1
10
- version: 0.2.1
8
+ - 3
9
+ - 0
10
+ version: 0.3.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - David Adams
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2012-02-25 00:00:00 -06:00
18
+ date: 2012-02-26 00:00:00 -06:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -57,18 +57,20 @@ extra_rdoc_files: []
57
57
  files:
58
58
  - lib/sakai-info.rb
59
59
  - lib/sakai-info/group.rb
60
- - lib/sakai-info/samigo.rb
61
60
  - lib/sakai-info/cli/help.rb
62
61
  - lib/sakai-info/site.rb
63
62
  - lib/sakai-info/assignment.rb
64
63
  - lib/sakai-info/authz.rb
65
64
  - lib/sakai-info/gradebook.rb
65
+ - lib/sakai-info/mod_props.rb
66
66
  - lib/sakai-info/sakai_object.rb
67
+ - lib/sakai-info/quiz.rb
67
68
  - lib/sakai-info/user.rb
68
69
  - lib/sakai-info/version.rb
69
70
  - lib/sakai-info/announcement.rb
70
71
  - lib/sakai-info/database.rb
71
72
  - lib/sakai-info/cli.rb
73
+ - lib/sakai-info/question_pool.rb
72
74
  - lib/sakai-info/message.rb
73
75
  - lib/sakai-info/content.rb
74
76
  - lib/sakai-info/sakai_xml_entity.rb
@@ -1,196 +0,0 @@
1
- # sakai-info/samigo.rb
2
- # SakaiInfo::Samigo library
3
- #
4
- # Created 2012-02-17 daveadams@gmail.com
5
- # Last updated 2012-02-25 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 PendingQuiz < SakaiObject
14
- attr_reader :title, :site
15
-
16
- def initialize(id, title, site)
17
- @id = id
18
- @title = title
19
- @site = site
20
- end
21
-
22
- @@cache = {}
23
- def self.find(id)
24
- if @@cache[id].nil?
25
- row = DB.connect[:sam_assessmentbase_t].filter(:id => id).first
26
- if row.nil?
27
- raise ObjectNotFoundException.new(PendingQuiz, id)
28
- end
29
- @@cache[id] = PendingQuiz.new(id, row[0], Site.find(row[1]))
30
- end
31
- @@cache[id]
32
- end
33
-
34
- def self.find_by_site_id(site_id)
35
- results = []
36
- site = Site.find(site_id)
37
- DB.connect.fetch("select id, title from sam_assessmentbase_t " +
38
- "where id in (select qualifierid from sam_authzdata_t " +
39
- "where agentid=? and functionid='EDIT_ASSESSMENT')",
40
- site_id) do |row|
41
- @@cache[row[:id]] = PendingQuiz.new(row[:id].to_i, row[:title], site)
42
- results << @@cache[row[:id]]
43
- end
44
- results
45
- end
46
-
47
- def self.count_by_site_id(site_id)
48
- DB.connect.fetch("select count(*) as count from sam_assessmentbase_t " +
49
- "where id in (select qualifierid from sam_authzdata_t " +
50
- "where agentid=? and functionid='EDIT_ASSESSMENT')",
51
- site_id).first[:count].to_i
52
- end
53
-
54
- def default_serialization
55
- {
56
- "id" => self.id,
57
- "title" => self.title,
58
- "site_id" => self.site.id
59
- }
60
- end
61
-
62
- def summary_serialization
63
- {
64
- "id" => self.id,
65
- "title" => self.title
66
- }
67
- end
68
- end
69
-
70
- class PublishedQuiz < SakaiObject
71
- attr_reader :title, :site
72
-
73
- def initialize(id, title, site)
74
- @id = id
75
- @title = title
76
- @site = site
77
- end
78
-
79
- @@cache = {}
80
- def self.find(id)
81
- if @@cache[id].nil?
82
- row = DB.connect[:sam_publishedassessment_t].filter(:id => id).first
83
- if row.nil?
84
- raise ObjectNotFoundException.new(PublishedQuiz, id)
85
- end
86
-
87
- @@cache[id] = PublishedQuiz.new(id, row[:title], Site.find(row[:agent_id]))
88
- end
89
- @@cache[id]
90
- end
91
-
92
- def self.find_by_site_id(site_id)
93
- results = []
94
- site = Site.find(site_id)
95
- DB.connect.fetch("select id, title from sam_publishedassessment_t " +
96
- "where id in (select qualifierid from sam_authzdata_t " +
97
- "where agentid=? and functionid='OWN_PUBLISHED_ASSESSMENT')",
98
- site_id) do |row|
99
- @@cache[row[:id]] = PublishedQuiz.new(row[:id].to_i, row[:title], site)
100
- results << @@cache[row[:id]]
101
- end
102
- results
103
- end
104
-
105
- def self.count_by_site_id(site_id)
106
- DB.connect.fetch("select count(*) as count from sam_publishedassessment_t " +
107
- "where id in (select qualifierid from sam_authzdata_t " +
108
- "where agentid=? and functionid='OWN_PUBLISHED_ASSESSMENT')",
109
- site_id).first[:count].to_i
110
- end
111
-
112
- def default_serialization
113
- {
114
- "id" => self.id,
115
- "title" => self.title,
116
- "site_id" => self.site.id
117
- }
118
- end
119
-
120
- def summary_serialization
121
- {
122
- "id" => self.id,
123
- "title" => self.title
124
- }
125
- end
126
- end
127
-
128
- class QuestionPool < SakaiObject
129
- attr_reader :title, :owner
130
-
131
- def initialize(id, title, owner)
132
- @id = id
133
- @title = title
134
- @owner = owner
135
- end
136
-
137
- @@cache = {}
138
- def self.find(id)
139
- if @@cache[id].nil?
140
- row = DB.connect[:sam_questionpool_t].filter(:id => id).first
141
- if row.nil?
142
- raise ObjectNotFoundException.new(QuestionPool, id)
143
- end
144
- @@cache[id] = QuestionPool.new(id, row[:title], User.find(row[:owner_id]))
145
- end
146
- @@cache[id]
147
- end
148
-
149
- def self.find_by_user_id(user_id)
150
- results = []
151
- user = User.find(user_id)
152
- DB.connect[:sam_questionpool_t].filter(:ownerid => user_id).all.each do |row|
153
- @@cache[row[:questionpoolid]] =
154
- QuestionPool.new(row[:questionpoolid].to_i, row[:title], user)
155
- results << @@cache[row[:questionpoolid]]
156
- end
157
- results
158
- end
159
-
160
- def self.count_by_user_id(user_id)
161
- DB.connect[:sam_questionpool_t].filter(:ownerid => user_id).count
162
- end
163
-
164
- def item_count
165
- @item_count ||=
166
- DB.connect[:sam_questionpoolitem_t].filter(:questionpoolid => @id).count
167
- end
168
-
169
- # serialization
170
- def default_serialization
171
- {
172
- "id" => self.id,
173
- "title" => self.title,
174
- "owner" => self.owner.serialize(:summary),
175
- "item_count" => self.item_count
176
- }
177
- end
178
-
179
- def summary_serialization
180
- {
181
- "id" => self.id,
182
- "title" => self.title,
183
- "owner_eid" => self.owner.eid,
184
- "item_count" => self.item_count
185
- }
186
- end
187
-
188
- def user_summary_serialization
189
- {
190
- "id" => self.id,
191
- "title" => self.title,
192
- "item_count" => self.item_count
193
- }
194
- end
195
- end
196
- end