Class: SakaiInfo::GradebookItem
- Inherits:
-
SakaiObject
- Object
- SakaiObject
- SakaiInfo::GradebookItem
- Defined in:
- lib/sakai-info/gradebook.rb
Instance Attribute Summary collapse
-
#due_date ⇒ Object
readonly
Returns the value of attribute due_date.
-
#gradebook_id ⇒ Object
readonly
Returns the value of attribute gradebook_id.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#object_type_id ⇒ Object
readonly
Returns the value of attribute object_type_id.
-
#points_possible ⇒ Object
readonly
Returns the value of attribute points_possible.
-
#version ⇒ Object
readonly
Returns the value of attribute version.
-
#weight ⇒ Object
readonly
Returns the value of attribute weight.
Attributes inherited from SakaiObject
Class Method Summary collapse
- .clear_cache ⇒ Object
- .count_by_gradebook_id(gradebook_id) ⇒ Object
- .find(id) ⇒ Object
- .find_by_gradebook_id(gradebook_id) ⇒ Object
- .query_by_gradebook_id(gradebook_id) ⇒ Object
Instance Method Summary collapse
- #default_serialization ⇒ Object
- #gradebook ⇒ Object
-
#initialize(dbrow) ⇒ GradebookItem
constructor
A new instance of GradebookItem.
- #summary_serialization ⇒ Object
Methods inherited from SakaiObject
all_serializations, #dbrow_only_serialization, #dbrow_serialization, descendants, #object_type_serialization, #serialize, #shell_serialization, #to_csv, #to_json, #to_yaml
Constructor Details
#initialize(dbrow) ⇒ GradebookItem
Returns a new instance of GradebookItem.
113 114 115 116 117 118 119 120 121 122 123 124 |
# File 'lib/sakai-info/gradebook.rb', line 113 def initialize(dbrow) @dbrow = dbrow @id = @dbrow[:id] @gradebook_id = @dbrow[:gradebook_id].to_i @object_type_id = @dbrow[:object_type_id].to_i @version = @dbrow[:version].to_i @name = @dbrow[:name] @points_possible = @dbrow[:points_possible].to_f @due_date = @dbrow[:due_date] @weight = @dbrow[:assignment_weighting].to_f end |
Instance Attribute Details
#due_date ⇒ Object (readonly)
Returns the value of attribute due_date.
106 107 108 |
# File 'lib/sakai-info/gradebook.rb', line 106 def due_date @due_date end |
#gradebook_id ⇒ Object (readonly)
Returns the value of attribute gradebook_id.
106 107 108 |
# File 'lib/sakai-info/gradebook.rb', line 106 def gradebook_id @gradebook_id end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
106 107 108 |
# File 'lib/sakai-info/gradebook.rb', line 106 def name @name end |
#object_type_id ⇒ Object (readonly)
Returns the value of attribute object_type_id.
106 107 108 |
# File 'lib/sakai-info/gradebook.rb', line 106 def object_type_id @object_type_id end |
#points_possible ⇒ Object (readonly)
Returns the value of attribute points_possible.
106 107 108 |
# File 'lib/sakai-info/gradebook.rb', line 106 def points_possible @points_possible end |
#version ⇒ Object (readonly)
Returns the value of attribute version.
106 107 108 |
# File 'lib/sakai-info/gradebook.rb', line 106 def version @version end |
#weight ⇒ Object (readonly)
Returns the value of attribute weight.
106 107 108 |
# File 'lib/sakai-info/gradebook.rb', line 106 def weight @weight end |
Class Method Details
.clear_cache ⇒ Object
108 109 110 |
# File 'lib/sakai-info/gradebook.rb', line 108 def self.clear_cache @@cache = {} end |
.count_by_gradebook_id(gradebook_id) ⇒ Object
145 146 147 |
# File 'lib/sakai-info/gradebook.rb', line 145 def self.count_by_gradebook_id(gradebook_id) GradebookItem.query_by_gradebook_id(gradebook_id).count end |
.find(id) ⇒ Object
126 127 128 129 130 131 132 133 134 135 |
# File 'lib/sakai-info/gradebook.rb', line 126 def self.find(id) if @@cache[id].nil? row = DB.connect[:gb_gradable_object_t].where(:id => id).first if row.nil? raise ObjectNotFoundException.new(GradebookItem, id) end @@cache[id] = GradebookItem.new(row) end @@cache[id] end |
.find_by_gradebook_id(gradebook_id) ⇒ Object
149 150 151 |
# File 'lib/sakai-info/gradebook.rb', line 149 def self.find_by_gradebook_id(gradebook_id) GradebookItem.query_by_gradebook_id(gradebook_id).all.collect { |row| GradebookItem.new(row) } end |
Instance Method Details
#default_serialization ⇒ Object
153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 |
# File 'lib/sakai-info/gradebook.rb', line 153 def default_serialization result = { "id" => self.id, "name" => self.name, "gradebook_id" => self.gradebook_id, "object_type_id" => self.object_type_id, "version" => self.version, "points_possible" => self.points_possible, "due_date" => self.due_date, "weight" => self.weight } if self.due_date.nil? result.delete("due_date") end result end |
#gradebook ⇒ Object
137 138 139 |
# File 'lib/sakai-info/gradebook.rb', line 137 def gradebook @gradebook = Gradebook.find(self.gradebook_id) end |
#summary_serialization ⇒ Object
170 171 172 173 174 175 176 177 178 179 180 181 |
# File 'lib/sakai-info/gradebook.rb', line 170 def summary_serialization result = { "id" => self.id, "name" => self.name, "points_possible" => self.points_possible, "due_date" => self.due_date } if self.due_date.nil? result.delete("due_date") end result end |