Class: Senkyoshi::OutcomeDefinition
- Includes:
- Senkyoshi
- Defined in:
- lib/senkyoshi/models/outcome_definition.rb
Constant Summary
Constants included from Senkyoshi
DIR_BASE, FILE_BASE, PRE_RESOURCE_TYPE, RESOURCE_TYPE, VERSION
Instance Attribute Summary collapse
-
#asidataid ⇒ Object
readonly
Returns the value of attribute asidataid.
-
#content_id ⇒ Object
readonly
Returns the value of attribute content_id.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#is_user_created ⇒ Object
readonly
Returns the value of attribute is_user_created.
Class Method Summary collapse
- .from(xml, category) ⇒ Object
-
.orphan?(outcome_def) ⇒ Boolean
Determine if an outcome definition is user created and linked to any other ‘CONTENT’ or assignments.
Instance Method Summary collapse
- #canvas_conversion(course, _ = nil) ⇒ Object
-
#initialize(category) ⇒ OutcomeDefinition
constructor
A new instance of OutcomeDefinition.
- #iterate_xml(xml) ⇒ Object
Methods included from Senkyoshi
build_file, build_heirarchy, cleanup, configure, connect_content, create_canvas_course, create_random_hex, get_attribute_value, get_description, get_single_pre_data, get_text, get_title, initialize_course, iterate_files, iterate_xml, iterator_master, parse, parse_and_process_single, parse_manifest, pre_iterator, read_file, reset, #true?
Methods inherited from Resource
#_find_directories, #_fix_path, #_matches_directory_xid?, #_search_and_replace, #cleanup, #fix_html, get_pre_data, #matches_xid?, #strip_xid
Constructor Details
#initialize(category) ⇒ OutcomeDefinition
Returns a new instance of OutcomeDefinition.
13 14 15 |
# File 'lib/senkyoshi/models/outcome_definition.rb', line 13 def initialize(category) @category = category end |
Instance Attribute Details
#asidataid ⇒ Object (readonly)
Returns the value of attribute asidataid.
7 8 9 |
# File 'lib/senkyoshi/models/outcome_definition.rb', line 7 def asidataid @asidataid end |
#content_id ⇒ Object (readonly)
Returns the value of attribute content_id.
7 8 9 |
# File 'lib/senkyoshi/models/outcome_definition.rb', line 7 def content_id @content_id end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
7 8 9 |
# File 'lib/senkyoshi/models/outcome_definition.rb', line 7 def id @id end |
#is_user_created ⇒ Object (readonly)
Returns the value of attribute is_user_created.
7 8 9 |
# File 'lib/senkyoshi/models/outcome_definition.rb', line 7 def is_user_created @is_user_created end |
Class Method Details
.from(xml, category) ⇒ Object
8 9 10 11 |
# File 'lib/senkyoshi/models/outcome_definition.rb', line 8 def self.from(xml, category) outcome_definition = OutcomeDefinition.new(category) outcome_definition.iterate_xml(xml) end |
.orphan?(outcome_def) ⇒ Boolean
Determine if an outcome definition is user created and linked to any other ‘CONTENT’ or assignments
31 32 33 34 35 |
# File 'lib/senkyoshi/models/outcome_definition.rb', line 31 def self.orphan?(outcome_def) outcome_def.content_id.empty? && outcome_def.asidataid.empty? && outcome_def.is_user_created end |
Instance Method Details
#canvas_conversion(course, _ = nil) ⇒ Object
37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/senkyoshi/models/outcome_definition.rb', line 37 def canvas_conversion(course, _ = nil) assignment_group = AssignmentGroup.find_or_create(course, @category) assignment = CanvasCc::CanvasCC::Models::Assignment.new assignment.identifier = Senkyoshi.create_random_hex assignment.assignment_group_identifier_ref = assignment_group.identifier assignment.title = @title assignment.position = 1 assignment.points_possible = @points_possible assignment.workflow_state = "published" assignment.grading_type = "points" course.assignments << assignment course end |
#iterate_xml(xml) ⇒ Object
17 18 19 20 21 22 23 24 25 |
# File 'lib/senkyoshi/models/outcome_definition.rb', line 17 def iterate_xml(xml) @content_id = xml.xpath("./CONTENTID/@value").text @asidataid = xml.xpath("./ASIDATAID/@value").text @id = xml.xpath("./@id").text @title = xml.xpath("./TITLE/@value").text @points_possible = xml.xpath("./POINTSPOSSIBLE/@value").text @is_user_created = true? xml.xpath("./ISUSERCREATED/@value").text self end |