Last active
February 2, 2021 08:53
-
-
Save samuels410/8f0bec9eb7bdf7b845dfc9fcab14c7c9 to your computer and use it in GitHub Desktop.
update_section_enrollment
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sections_not_found = [] | |
course_ids = [1910,1911,1912,1913,1914,1915,1916,1917,1919,1920,1923,1926,1929,1930,1933,1934,1937,1938,1939,1940,1941,1942,1944,1945,1947,1948,1949,1957,1959,1961,1965,1966,1967,1968,1971,1972,1973,1974,1977,1978,1979,1984,1986,1989,1990,1992,1993,1996,1997,1998,1999,2001,2003,2004,2006,2007,2011,2012,2017,2018,2019,2020,2023,2024,2025,2026,2028,2029,2072,2073,2478,2479,2481,2482,2483,2484,2485,2486,2487,2488,2489,3472,3473,3474,3475,3477,3478,3479,3480,3481,3482,3483,3484,3485,3487,3488,3563,3721,3722,5064,5065,5066,5067,5068,5069,5071,5072,5738,5739,7233,7234,7235,7236,7330,7336,7337,7340,7343,7344,7345,7346,7347,7348,7349,7350,7351,7352,7353,7354,7355,7356,7357,7358,7359,7360,7361,7362,7363,7364,7365,7366,7368,7369,7371,8105,11068,11070,11071,11072,11074,11075,11076,11077,11078,11080,11081,11082,11083,11084,11085,11086,11087,11088,11089,11090,11091,11092,11093,11375,11858,11859,11860,11861,11862,11863,11864,11865,11866,11867,11868,11869,11870,11871,11872,11873,11874,11875,11876,11877,11878,11879,11880,11881,11882,11883,11884,11885,11886,11887,11888,11889,11890,11891,11892,11893,11894,12022] | |
section_ids = [12640,13168,13167,12641,13169,12644,12646,12648,12650,12651,12630,12638,12657,12658,12686,12688,12710,12711,12706,12726,12727,12729,12616,12617,12622,12621,12625,12628,12629,12633,12661,12662,12663,12664,12666,12667,12668,12669,12671,12672,12670,12675,12679,12690,12691,12818,12697,12701,12702,12703,12704,12713,12730,12733,12723,12725,12740,12743,12762,12774,12775,12776,12764,12763,12766,12770,12767,12687,12714,12715,12618,12680,12692,12698,12716,12717,12718,12719,12753,12754,12778,12623,12615,12649,12660,12642,12677,12685,12656,12741,12632,12673,12708,12699,12619,12676,12645,12756,12757,12696,12720,12731,12734,12736,12750,12777,12779,12744,12748,12653,12654,12693,12759,12627,12747,12737,12614,12635,12639,12643,12647,12655,12659,12631,12682,12678,12681,12689,12695,12707,12709,12712,12721,12732,12735,12722,12751,12746,12745,12755,12752,12758,12761,12768,12626,12749,12620,12613,12624,12637,12652,12634,12780,12738,12772,12769,12773,12771,12765,12760,12724,12728,12705,12700,12694,12684,12674,12665,12238,12781,12782,12783,12784,12785,12786,12787,12788,12789,12790,12791,12792,12793,12794,12795,12796,12797,12798,12799,12800,12801,12802,12803,12804,12805,12806,12807,12808,12809,12810,12811,12812,12813,12814,12815,12816,12817,12966] | |
section_name = '2019 JULY-DEC' | |
zipped_data = course_ids.zip section_ids | |
zipped_data.each do |course_id, section_id| | |
course_section = CourseSection.where(id: section_id).first | |
if course_section.name == section_name | |
enrollments = Enrollment.where(course_id: course_id, course_section_id: section_id) | |
enrollments.each do |enrollment| | |
enrollment.workflow_state = 'inactive' | |
enrollment.save! | |
puts "Enrollment updated course##{course_id}, Section id ##{section_id}, User_id ##{enrollment.user_id}" | |
end | |
else | |
sections_not_found << section_id | |
end | |
end | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment