Class: CommonCoreParser::BrokenDataCorrector
- Defined in:
- lib/common_core_parser/broken_data_corrector.rb
Class Method Summary collapse
- .load_corrections_from_yaml ⇒ Object
-
.patch_duplicated_parent_ref_ids(element, candidate_parent_ref_id) ⇒ Object
See comments on patch_duplicated_ref_ids() above.
-
.patch_duplicated_ref_ids(element, candidate_ref_id) ⇒ Object
There are a some cases where multiple items are sharing the same ref_id.
- .run ⇒ Object
Class Method Details
.load_corrections_from_yaml ⇒ Object
14 15 16 17 18 19 20 21 |
# File 'lib/common_core_parser/broken_data_corrector.rb', line 14 def load_corrections_from_yaml corrections_hash.keys.each do |refid| element = Master.instance.elements_hash[refid] corrections_hash[refid].keys.each do |attribute| element.instance_variable_set("@#{attribute}",corrections_hash[refid][attribute]) end end end |
.patch_duplicated_parent_ref_ids(element, candidate_parent_ref_id) ⇒ Object
See comments on patch_duplicated_ref_ids() above.
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 |
# File 'lib/common_core_parser/broken_data_corrector.rb', line 49 def patch_duplicated_parent_ref_ids(element,candidate_parent_ref_id) flagged_cluster_ref_ids = ['B1AC98EADE4145689E70EEEBD9B8CC18','834B17E279C64263AA83F7625F5D2993','91FABAB899814C55851003A0EE98F8FB'] if candidate_parent_ref_id == 'F053D3437D1E4338A2C18B25DACBED85' and element.is_a?(Component) return "Standard:DUPLICATEDREF_ID:#{candidate_parent_ref_id}" elsif candidate_parent_ref_id == 'F053D3437D1E4338A2C18B25DACBED85' and element.is_a?(Standard) return "Domain:DUPLICATEDREF_ID:#{candidate_parent_ref_id}" elsif flagged_cluster_ref_ids.include?(candidate_parent_ref_id) and element.is_a?(Standard) and element.code.match(/\.K\.G\./) return "Cluster:DUPLICATEDREF_ID:#{candidate_parent_ref_id}:Mathematics.K.G.1" elsif flagged_cluster_ref_ids.include?(candidate_parent_ref_id) and element.is_a?(Standard) and element.code == 'CCSS.Math.Content.K.MD.B.3' return "Cluster:DUPLICATEDREF_ID:#{candidate_parent_ref_id}:Mathematics.K.MD.2" elsif flagged_cluster_ref_ids.include?(candidate_parent_ref_id) and element.is_a?(Standard) and element.code.match(/\.3\.G\.A\./) return "Cluster:DUPLICATEDREF_ID:#{candidate_parent_ref_id}:Mathematics.3.G.1" elsif flagged_cluster_ref_ids.include?(candidate_parent_ref_id) and element.is_a?(Standard) and element.code == 'CCSS.Math.Content.6.NS.A.1' return "Cluster:DUPLICATEDREF_ID:#{candidate_parent_ref_id}:Mathematics.6.NS.1" elsif flagged_cluster_ref_ids.include?(candidate_parent_ref_id) and element.is_a?(Standard) and element.code.match(/\.3\.MD\.C\./) return "Cluster:DUPLICATEDREF_ID:#{candidate_parent_ref_id}:Mathematics.3.MD.3" elsif flagged_cluster_ref_ids.include?(candidate_parent_ref_id) and element.is_a?(Standard) and element.code.match(/\.6\.RP\.A\./) return "Cluster:DUPLICATEDREF_ID:#{candidate_parent_ref_id}:Mathematics.6.RP.1" else return candidate_parent_ref_id end end |
.patch_duplicated_ref_ids(element, candidate_ref_id) ⇒ Object
There are a some cases where multiple items are sharing the same ref_id.
-
Two cases of an ELA Standard and Domain having the same ref_id.
-
Three cases of pairs of clusters sharing the same ref_id.
-
Two standards that both have the same ref_id
This patch corrects the ref_ids to remove conflucts. See also patch_duplicated_parent_ref_ids()
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/common_core_parser/broken_data_corrector.rb', line 29 def patch_duplicated_ref_ids(element,candidate_ref_id) flagged_standard_domain_ref_ids = ['7CB154907B5743c7B97BFCFF452D7977','F053D3437D1E4338A2C18B25DACBED85'] flagged_cluster_ref_ids = ['B1AC98EADE4145689E70EEEBD9B8CC18','834B17E279C64263AA83F7625F5D2993','91FABAB899814C55851003A0EE98F8FB'] flagged_duplicated_stadard_ref_ids = ['FBCBB7C696FE475695920CA622B1C857'] if candidate_ref_id == 'F053D3437D1E4338A2C18B25DACBED85' and element.is_a?(Standard) return "Standard:DUPLICATEDREF_ID:#{candidate_ref_id}" elsif candidate_ref_id == 'F053D3437D1E4338A2C18B25DACBED85' and element.is_a?(Domain) return "Domain:DUPLICATEDREF_ID:#{candidate_ref_id}" elsif flagged_standard_domain_ref_ids.include?(candidate_ref_id) and element.is_a?(Standard) return "Standard:DUPLICATEDREF_ID:#{candidate_ref_id}" elsif flagged_cluster_ref_ids.include?(candidate_ref_id) and element.is_a?(Cluster) return "Cluster:DUPLICATEDREF_ID:#{candidate_ref_id}:#{element.code}" elsif flagged_duplicated_stadard_ref_ids.include?(candidate_ref_id) and element.is_a?(Standard) return "Standard:DUPLICATEDREF_ID:#{candidate_ref_id}:#{element.code}" else return candidate_ref_id end end |
.run ⇒ Object
5 6 7 8 9 10 11 12 |
# File 'lib/common_core_parser/broken_data_corrector.rb', line 5 def run load_corrections_from_yaml Master.instance.elements.each do |element| self.private_methods.select { |method_name| method_name.to_s.match(/^correct_/) }.each do |corrector_method| self.send(corrector_method,element) end end end |