Class: Senkyoshi::Gradebook
Instance Attribute Summary collapse
Attributes inherited from FileResource
#id
Class Method Summary
collapse
Instance Method Summary
collapse
#create_module, from
Methods inherited from Resource
#_find_directories, #_fix_path, #_matches_directory_xid?, #_search_and_replace, #cleanup, #fix_html, #matches_xid?, #strip_xid
Constructor Details
#initialize(resource_id = nil, categories = [], outcome_definitions = []) ⇒ Gradebook
Returns a new instance of Gradebook.
23
24
25
26
27
|
# File 'lib/senkyoshi/models/gradebook.rb', line 23
def initialize(resource_id = nil, categories = [], outcome_definitions = [])
super(resource_id)
@categories = categories
@outcome_definitions = outcome_definitions
end
|
Instance Attribute Details
#categories ⇒ Object
Returns the value of attribute categories.
21
22
23
|
# File 'lib/senkyoshi/models/gradebook.rb', line 21
def categories
@categories
end
|
#outcome_definitions ⇒ Object
Returns the value of attribute outcome_definitions.
21
22
23
|
# File 'lib/senkyoshi/models/gradebook.rb', line 21
def outcome_definitions
@outcome_definitions
end
|
Class Method Details
.get_categories(data) ⇒ Object
49
50
51
52
53
54
55
56
57
|
# File 'lib/senkyoshi/models/gradebook.rb', line 49
def self.get_categories(data)
data.at("CATEGORIES").children.
each_with_object({}) do |category, categories|
id = category.attributes["id"].value
title = category.at("TITLE").
attributes["value"].value.gsub(".name", "")
categories[id] = title
end
end
|
.get_pre_data(data, _) ⇒ Object
35
36
37
38
39
40
41
42
43
44
45
46
47
|
# File 'lib/senkyoshi/models/gradebook.rb', line 35
def self.get_pre_data(data, _)
categories = get_categories(data)
data.search("OUTCOMEDEFINITIONS").children.map do |outcome|
category_id = outcome.at("CATEGORYID").attributes["value"].value
{
category: categories[category_id],
points: outcome.at("POINTSPOSSIBLE").attributes["value"].value,
content_id: outcome.at("CONTENTID").attributes["value"].value,
assignment_id: outcome.at("ASIDATAID").attributes["value"].value,
due_at: outcome.at("DUE").attributes["value"].value,
}
end
end
|
Instance Method Details
#canvas_conversion(course, resources = nil) ⇒ Object
81
82
83
84
85
86
87
|
# File 'lib/senkyoshi/models/gradebook.rb', line 81
def canvas_conversion(course, resources = nil)
convert_categories(course)
@outcome_definitions.
select { |outcome_def| OutcomeDefinition.orphan? outcome_def }.
each { |outcome_def| outcome_def.canvas_conversion course, resources }
course
end
|
#convert_categories(course) ⇒ Object
#find_outcome_def(outcome_def_id) ⇒ Object
75
76
77
78
79
|
# File 'lib/senkyoshi/models/gradebook.rb', line 75
def find_outcome_def(outcome_def_id)
@outcome_definitions.detect do |outcome_def|
outcome_def.id == outcome_def_id
end
end
|
#get_outcome_definitions(xml) ⇒ Object
59
60
61
62
63
64
|
# File 'lib/senkyoshi/models/gradebook.rb', line 59
def get_outcome_definitions(xml)
xml.xpath("//OUTCOMEDEFINITION").map do |outcome_def|
category_id = outcome_def.xpath("CATEGORYID/@value").first.value
OutcomeDefinition.from(outcome_def, @categories[category_id])
end
end
|
#iterate_xml(xml_data, _) ⇒ Object
29
30
31
32
33
|
# File 'lib/senkyoshi/models/gradebook.rb', line 29
def iterate_xml(xml_data, _)
@categories = Gradebook.get_categories(xml_data)
@outcome_definitions = get_outcome_definitions(xml_data).compact
self
end
|