Class: Senkyoshi::OutcomeDefinition
- Includes:
- Senkyoshi
- Defined in:
- lib/senkyoshi/models/outcome_definition.rb
Constant Summary
Constants included from Senkyoshi
DIR_BASE, FILE_BASE, MAIN_CANVAS_MODULE, MASTER_MODULE, 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, id = nil) ⇒ 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, id, content_id = nil, asidataid = nil) ⇒ 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, initialize_course, iterate_files, iterate_xml, iterator_master, parse, parse_and_process_single, 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, id, content_id = nil, asidataid = nil) ⇒ OutcomeDefinition
Returns a new instance of OutcomeDefinition.
28 29 30 31 32 33 |
# File 'lib/senkyoshi/models/outcome_definition.rb', line 28 def initialize(category, id, content_id = nil, asidataid = nil) @id = id @content_id = content_id @asidataid = asidataid @category = category end |
Instance Attribute Details
#asidataid ⇒ Object (readonly)
Returns the value of attribute asidataid.
22 23 24 |
# File 'lib/senkyoshi/models/outcome_definition.rb', line 22 def asidataid @asidataid end |
#content_id ⇒ Object (readonly)
Returns the value of attribute content_id.
22 23 24 |
# File 'lib/senkyoshi/models/outcome_definition.rb', line 22 def content_id @content_id end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
22 23 24 |
# File 'lib/senkyoshi/models/outcome_definition.rb', line 22 def id @id end |
#is_user_created ⇒ Object (readonly)
Returns the value of attribute is_user_created.
22 23 24 |
# File 'lib/senkyoshi/models/outcome_definition.rb', line 22 def is_user_created @is_user_created end |
Class Method Details
.from(xml, category, id = nil) ⇒ Object
23 24 25 26 |
# File 'lib/senkyoshi/models/outcome_definition.rb', line 23 def self.from(xml, category, id = nil) outcome_definition = OutcomeDefinition.new(category, id) 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
51 52 53 54 55 |
# File 'lib/senkyoshi/models/outcome_definition.rb', line 51 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
57 58 59 60 61 62 63 64 65 66 67 68 69 70 |
# File 'lib/senkyoshi/models/outcome_definition.rb', line 57 def canvas_conversion(course, _ = nil) assignment_group = AssignmentGroup.find_or_create(course, @category) assignment = CanvasCc::CanvasCC::Models::Assignment.new assignment.identifier = @id 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
35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/senkyoshi/models/outcome_definition.rb', line 35 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 = Senkyoshi.true?( xml.xpath("./ISUSERCREATED/@value").text, ) self end |