Class: SakaiInfo::Gradebook
Instance Attribute Summary collapse
Attributes inherited from SakaiObject
#id
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from SakaiObject
#dbrow_only_serialization, #dbrow_serialization, descendants, #object_type_serialization, #serialize, #shell_serialization, #to_csv, #to_json, #to_yaml
Constructor Details
#initialize(dbrow) ⇒ Gradebook
Returns a new instance of Gradebook.
21
22
23
24
25
26
27
28
|
# File 'lib/sakai-info/gradebook.rb', line 21
def initialize(dbrow)
@dbrow = dbrow
@id = @dbrow[:id].to_i
@version = @dbrow[:version].to_i
@site_id = @dbrow[:gradebook_uid]
@name = @dbrow[:name]
end
|
Instance Attribute Details
#name ⇒ Object
Returns the value of attribute name.
14
15
16
|
# File 'lib/sakai-info/gradebook.rb', line 14
def name
@name
end
|
#site_id ⇒ Object
Returns the value of attribute site_id.
14
15
16
|
# File 'lib/sakai-info/gradebook.rb', line 14
def site_id
@site_id
end
|
#version ⇒ Object
Returns the value of attribute version.
14
15
16
|
# File 'lib/sakai-info/gradebook.rb', line 14
def version
@version
end
|
Class Method Details
.all_serializations ⇒ Object
97
98
99
100
101
102
|
# File 'lib/sakai-info/gradebook.rb', line 97
def self.all_serializations
[
:default,
:items
]
end
|
.clear_cache ⇒ Object
16
17
18
|
# File 'lib/sakai-info/gradebook.rb', line 16
def self.clear_cache
@@cache = {}
end
|
.count_by_site_id(site_id) ⇒ Object
50
51
52
|
# File 'lib/sakai-info/gradebook.rb', line 50
def self.count_by_site_id(site_id)
Gradebook.query_by_site_id(site_id).count
end
|
.find(id) ⇒ Object
30
31
32
33
34
35
36
37
38
39
40
|
# File 'lib/sakai-info/gradebook.rb', line 30
def self.find(id)
if @@cache[id].nil?
row = DB.connect[:gb_gradebook_t].where(:id => id).first
if row.nil?
raise ObjectNotFoundException.new(Gradebook, id)
end
@@cache[id] = Gradebook.new(row)
end
@@cache[id]
end
|
.find_by_site_id(site_id) ⇒ Object
.query_by_site_id(site_id) ⇒ Object
46
47
48
|
# File 'lib/sakai-info/gradebook.rb', line 46
def self.query_by_site_id(site_id)
DB.connect[:gb_gradebook_t].where(:gradebook_uid => site_id)
end
|
Instance Method Details
#default_serialization ⇒ Object
66
67
68
69
70
71
72
73
74
|
# File 'lib/sakai-info/gradebook.rb', line 66
def default_serialization
{
"id" => self.id,
"name" => self.name,
"site" => self.site.serialize(:summary),
"version" => self.version,
"item_count" => self.item_count,
}
end
|
#items_serialization ⇒ Object
91
92
93
94
95
|
# File 'lib/sakai-info/gradebook.rb', line 91
def items_serialization
{
"items" => self.items.collect { |item| item.serialize(:summary) }
}
end
|
#site ⇒ Object
42
43
44
|
# File 'lib/sakai-info/gradebook.rb', line 42
def site
@site ||= Site.find(self.site_id)
end
|
#site_summary_serialization ⇒ Object
85
86
87
88
89
|
# File 'lib/sakai-info/gradebook.rb', line 85
def site_summary_serialization
{
"id" => self.id,
}
end
|
#summary_serialization ⇒ Object
76
77
78
79
80
81
82
83
|
# File 'lib/sakai-info/gradebook.rb', line 76
def summary_serialization
{
"id" => self.id,
"name" => self.name,
"site_id" => self.site_id,
"item_count" => self.item_count,
}
end
|