d2l_sdk 0.1.13 → 0.1.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +5 -5
- data/.vscode/settings.json +1 -2
- data/example_scripts/adjusted_courses.txt +44446 -0
- data/lib/d2l_sdk/calendar.rb +44 -32
- data/lib/d2l_sdk/config_variables.rb +9 -5
- data/lib/d2l_sdk/course_content.rb +54 -34
- data/lib/d2l_sdk/demographics.rb +21 -18
- data/lib/d2l_sdk/discussions.rb +7 -5
- data/lib/d2l_sdk/enroll.rb +20 -14
- data/lib/d2l_sdk/grades.rb +21 -18
- data/lib/d2l_sdk/logging.rb +25 -21
- data/lib/d2l_sdk/org_unit.rb +19 -13
- data/lib/d2l_sdk/user.rb +6 -4
- data/lib/d2l_sdk/version.rb +1 -1
- metadata +9 -6
- data/example_scripts/add_to_201708.rb +0 -15
- data/example_scripts/enroll_users.rb +0 -22
- data/example_scripts/find_201708_courses.rb +0 -16
    
        data/lib/d2l_sdk/logging.rb
    CHANGED
    
    | @@ -11,17 +11,19 @@ require_relative 'requests' | |
| 11 11 | 
             
            def get_all_logs(date_range_start, date_range_end, search = '', log_level = '',
         | 
| 12 12 | 
             
                             logger_assembly = '', user_id = 0, message_group_id = 0,
         | 
| 13 13 | 
             
                             include_traces = nil, org_unit_id = 0, bookmark = '')
         | 
| 14 | 
            -
                path = "/d2l/api/lp/#{$lp_ver}/logging | 
| 15 | 
            -
                 | 
| 16 | 
            -
                 | 
| 17 | 
            -
                 | 
| 18 | 
            -
                 | 
| 19 | 
            -
                 | 
| 20 | 
            -
                 | 
| 21 | 
            -
                 | 
| 22 | 
            -
                 | 
| 23 | 
            -
                 | 
| 24 | 
            -
                 | 
| 14 | 
            +
                path = "/d2l/api/lp/#{$lp_ver}/logging/?"
         | 
| 15 | 
            +
                params = []
         | 
| 16 | 
            +
                params << "dateRangeStart=#{date_range_start}"
         | 
| 17 | 
            +
                params << "dateRangeEnd=#{date_range_end}"
         | 
| 18 | 
            +
                params << "search=#{search}" if search != ''
         | 
| 19 | 
            +
                params << "logLevel=#{log_level}" if log_level != ''
         | 
| 20 | 
            +
                params << "loggerAssembly=#{logger_assembly}" if logger_assembly != ''
         | 
| 21 | 
            +
                params << "userId=#{user_id}" if user_id != 0
         | 
| 22 | 
            +
                params << "messageGroupId=#{message_group_id}" if message_group_id != 0
         | 
| 23 | 
            +
                params << "includeTraces=#{include_traces}" unless include_traces.nil?
         | 
| 24 | 
            +
                params << "orgUnitId=#{org_unit_id}" if org_unit_id != 0
         | 
| 25 | 
            +
                params << "bookmark=#{bookmark}" if bookmark != ''
         | 
| 26 | 
            +
                path = path + params.join('&')
         | 
| 25 27 | 
             
                ap path
         | 
| 26 28 | 
             
                _get(path)
         | 
| 27 29 | 
             
                # returns paged result set of Message data blocks
         | 
| @@ -34,16 +36,18 @@ def get_all_message_group_logs(date_range_start, date_range_end, search = '', | |
| 34 36 | 
             
                                           log_level = '', logger_assembly = '', user_id = 0,
         | 
| 35 37 | 
             
                                           message_group_id = 0, org_unit_id = 0,
         | 
| 36 38 | 
             
                                           bookmark = '')
         | 
| 37 | 
            -
                path = "/d2l/api/lp/#{$lp_ver}/logging/grouped | 
| 38 | 
            -
                 | 
| 39 | 
            -
                 | 
| 40 | 
            -
                 | 
| 41 | 
            -
                 | 
| 42 | 
            -
                 | 
| 43 | 
            -
                 | 
| 44 | 
            -
                 | 
| 45 | 
            -
                 | 
| 46 | 
            -
                 | 
| 39 | 
            +
                path = "/d2l/api/lp/#{$lp_ver}/logging/grouped/?"
         | 
| 40 | 
            +
                params = []
         | 
| 41 | 
            +
                params << "dateRangeStart=#{date_range_start}"
         | 
| 42 | 
            +
                params << "dateRangeEnd=#{date_range_end}"
         | 
| 43 | 
            +
                params << "search=#{search}" if search != ''
         | 
| 44 | 
            +
                params << "logLevel=#{log_level}" if log_level != ''
         | 
| 45 | 
            +
                params << "loggerAssembly=#{logger_assembly}" if logger_assembly != ''
         | 
| 46 | 
            +
                params << "userId=#{user_id}" if user_id != 0
         | 
| 47 | 
            +
                params << "messageGroupId=#{message_group_id}" if message_group_id != 0
         | 
| 48 | 
            +
                params << "orgUnitId=#{org_unit_id}" if org_unit_id != 0
         | 
| 49 | 
            +
                params << "bookmark=#{bookmark}" if bookmark != ''
         | 
| 50 | 
            +
                path = path + params.join('&')
         | 
| 47 51 | 
             
                _get(path)
         | 
| 48 52 | 
             
                # returns paged result set of MessageGroupSummary data blocks
         | 
| 49 53 | 
             
            end
         | 
    
        data/lib/d2l_sdk/org_unit.rb
    CHANGED
    
    | @@ -35,11 +35,13 @@ end | |
| 35 35 |  | 
| 36 36 | 
             
            def get_properties_of_all_org_units(org_unit_type = '', org_unit_code = '', org_unit_name = '',
         | 
| 37 37 | 
             
                                                bookmark = '')
         | 
| 38 | 
            -
                path = "/d2l/api/lp/#{$lp_ver}/orgstructure | 
| 39 | 
            -
                 | 
| 40 | 
            -
                 | 
| 41 | 
            -
                 | 
| 42 | 
            -
                 | 
| 38 | 
            +
                path = "/d2l/api/lp/#{$lp_ver}/orgstructure/?"
         | 
| 39 | 
            +
                params = []
         | 
| 40 | 
            +
                params << "orgUnitType=#{org_unit_type}" if org_unit_type != ''
         | 
| 41 | 
            +
                params << "orgUnitCode=#{org_unit_code}" if org_unit_code != ''
         | 
| 42 | 
            +
                params << "orgUnitName=#{org_unit_name}" if org_unit_name != ''
         | 
| 43 | 
            +
                params << "bookmark=#{bookmark}" if bookmark != ''
         | 
| 44 | 
            +
                path = path + params.join('&')
         | 
| 43 45 | 
             
                _get(path)
         | 
| 44 46 | 
             
                # ONLY RETRIEVES FIRST 100 after bookmark
         | 
| 45 47 | 
             
                # returns: paged result of OrgUnitProperties blocks
         | 
| @@ -62,11 +64,13 @@ end | |
| 62 64 | 
             
            # return: JSON array of childless org units.
         | 
| 63 65 | 
             
            def get_all_childless_org_units(org_unit_type = '', org_unit_code = '', org_unit_name = '',
         | 
| 64 66 | 
             
                                            bookmark = '')
         | 
| 65 | 
            -
                path = "/d2l/api/lp/#{$lp_ver}/orgstructure/childless | 
| 66 | 
            -
                 | 
| 67 | 
            -
                 | 
| 68 | 
            -
                 | 
| 69 | 
            -
                 | 
| 67 | 
            +
                path = "/d2l/api/lp/#{$lp_ver}/orgstructure/childless/?"
         | 
| 68 | 
            +
                params = []
         | 
| 69 | 
            +
                params << "orgUnitType=#{org_unit_type}" if org_unit_type != ''
         | 
| 70 | 
            +
                params << "orgUnitCode=#{org_unit_code}" if org_unit_code != ''
         | 
| 71 | 
            +
                params << "orgUnitName=#{org_unit_name}" if org_unit_name != ''
         | 
| 72 | 
            +
                params << "bookmark=#{bookmark}" if bookmark != ''
         | 
| 73 | 
            +
                path = path + params.join('&')
         | 
| 70 74 | 
             
                _get(path)
         | 
| 71 75 | 
             
                # ONLY RETRIEVES FIRST 100
         | 
| 72 76 | 
             
            end
         | 
| @@ -136,9 +140,11 @@ end | |
| 136 140 | 
             
            #
         | 
| 137 141 | 
             
            # return: JSON array of org unit descendants (paged)
         | 
| 138 142 | 
             
            def get_paged_org_unit_descendants(org_unit_id, ou_type_id = 0, bookmark = '')
         | 
| 139 | 
            -
                path = "/d2l/api/lp/#{$lp_ver}/orgstructure/#{org_unit_id}/descendants/paged | 
| 140 | 
            -
                 | 
| 141 | 
            -
                 | 
| 143 | 
            +
                path = "/d2l/api/lp/#{$lp_ver}/orgstructure/#{org_unit_id}/descendants/paged/?"
         | 
| 144 | 
            +
                params = []
         | 
| 145 | 
            +
                params << "ouTypeId=#{ou_type_id}" if ou_type_id != 0
         | 
| 146 | 
            +
                params << "bookmark=#{bookmark}" if bookmark != ''
         | 
| 147 | 
            +
                path = path + params.join('&')
         | 
| 142 148 | 
             
                _get(path)
         | 
| 143 149 | 
             
                # return paged json of org_unit descendants
         | 
| 144 150 | 
             
            end
         | 
    
        data/lib/d2l_sdk/user.rb
    CHANGED
    
    | @@ -74,10 +74,12 @@ end | |
| 74 74 | 
             
            #
         | 
| 75 75 | 
             
            # Returns: JSON of all users matching the parameters given.
         | 
| 76 76 | 
             
            def get_users(org_defined_id = '', username = '', bookmark = '')
         | 
| 77 | 
            -
                path = "/d2l/api/lp/#{$lp_ver}/users | 
| 78 | 
            -
                 | 
| 79 | 
            -
                 | 
| 80 | 
            -
                 | 
| 77 | 
            +
                path = "/d2l/api/lp/#{$lp_ver}/users/?"
         | 
| 78 | 
            +
                params = []
         | 
| 79 | 
            +
                params << "orgDefinedId=#{org_defined_id}" if org_defined_id != ''
         | 
| 80 | 
            +
                params << "userName=#{username}" if username != ''
         | 
| 81 | 
            +
                params << "bookmark=#{bookmark}" if bookmark != ''
         | 
| 82 | 
            +
                path = path + params.join('&')
         | 
| 81 83 | 
             
                _get(path)
         | 
| 82 84 | 
             
                # If- username is defined, this RETURNS a single UserData JSON block
         | 
| 83 85 | 
             
                # else if- org_defined_id is defined, this returns a UserData JSON array
         | 
    
        data/lib/d2l_sdk/version.rb
    CHANGED
    
    
    
        metadata
    CHANGED
    
    | @@ -1,14 +1,14 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification
         | 
| 2 2 | 
             
            name: d2l_sdk
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            -
              version: 0.1. | 
| 4 | 
            +
              version: 0.1.15
         | 
| 5 5 | 
             
            platform: ruby
         | 
| 6 6 | 
             
            authors:
         | 
| 7 7 | 
             
            - Andrew Kulpa
         | 
| 8 8 | 
             
            autorequire: 
         | 
| 9 9 | 
             
            bindir: exe
         | 
| 10 10 | 
             
            cert_chain: []
         | 
| 11 | 
            -
            date:  | 
| 11 | 
            +
            date: 2018-08-29 00:00:00.000000000 Z
         | 
| 12 12 | 
             
            dependencies:
         | 
| 13 13 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 14 14 | 
             
              name: bundler
         | 
| @@ -160,11 +160,14 @@ files: | |
| 160 160 | 
             
            - bin/console
         | 
| 161 161 | 
             
            - bin/setup
         | 
| 162 162 | 
             
            - d2l_sdk.gemspec
         | 
| 163 | 
            -
            - example_scripts/ | 
| 164 | 
            -
            - example_scripts/enroll_users.rb
         | 
| 165 | 
            -
            - example_scripts/find_201708_courses.rb
         | 
| 163 | 
            +
            - example_scripts/adjusted_courses.txt
         | 
| 166 164 | 
             
            - example_scripts/fix_201708_courses.rb
         | 
| 167 165 | 
             
            - example_scripts/update_enddates.rb
         | 
| 166 | 
            +
            - example_tests/multithread_test.rb
         | 
| 167 | 
            +
            - example_tests/test3.rb
         | 
| 168 | 
            +
            - example_tests/testCSV.rb
         | 
| 169 | 
            +
            - example_tests/test_course_search.rb
         | 
| 170 | 
            +
            - example_tests/unit_tests.rb
         | 
| 168 171 | 
             
            - lib/d2l_sdk.rb
         | 
| 169 172 | 
             
            - lib/d2l_sdk/auth.rb
         | 
| 170 173 | 
             
            - lib/d2l_sdk/calendar.rb
         | 
| @@ -231,7 +234,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement | |
| 231 234 | 
             
                  version: '0'
         | 
| 232 235 | 
             
            requirements: []
         | 
| 233 236 | 
             
            rubyforge_project: 
         | 
| 234 | 
            -
            rubygems_version: 2.6 | 
| 237 | 
            +
            rubygems_version: 2.7.6
         | 
| 235 238 | 
             
            signing_key: 
         | 
| 236 239 | 
             
            specification_version: 4
         | 
| 237 240 | 
             
            summary: Simple Ruby Gem to utilize the Valence/D2L API
         | 
| @@ -1,15 +0,0 @@ | |
| 1 | 
            -
            require_relative "lib/d2l_sdk"
         | 
| 2 | 
            -
             | 
| 3 | 
            -
            file = "NoSemester.out"
         | 
| 4 | 
            -
            # get all courses coded as 201708 but not in a semester
         | 
| 5 | 
            -
            courses = [] # fill this array with course ID's stored in the referenced file.
         | 
| 6 | 
            -
            File.readlines(file).each{ |line| courses.push(line.chomp) unless line.chomp.empty? }
         | 
| 7 | 
            -
             | 
| 8 | 
            -
            semester_201708_id = "111723" # Fall '17 semester recieved through line of code above
         | 
| 9 | 
            -
            courses_done = 0
         | 
| 10 | 
            -
            courses.each do |course_id| # for each of these 201708 courses
         | 
| 11 | 
            -
              # print out progress thus far
         | 
| 12 | 
            -
              puts "Progress: #{courses_done}/#{courses.length} (#{(courses_done / courses.length).round(2)}%)" if courses_done % 10 == 0
         | 
| 13 | 
            -
              add_parent_to_org_unit(semester_201708_id, course_id) # add the semester as the parent
         | 
| 14 | 
            -
              courses_done += 1
         | 
| 15 | 
            -
            end
         | 
| @@ -1,22 +0,0 @@ | |
| 1 | 
            -
            require "d2l_sdk"
         | 
| 2 | 
            -
             | 
| 3 | 
            -
            semester = 201708
         | 
| 4 | 
            -
            starnum = 32835
         | 
| 5 | 
            -
            sect_code = create_section_code(starnum, semester)
         | 
| 6 | 
            -
            section = get_section_by_section_code(x)
         | 
| 7 | 
            -
            org_unit_id = section["Identifier"]
         | 
| 8 | 
            -
             | 
| 9 | 
            -
            # user_ids is each D2L user ID for each student
         | 
| 10 | 
            -
            # user["Identifier"]
         | 
| 11 | 
            -
            user_ids = []
         | 
| 12 | 
            -
            role_id = 104
         | 
| 13 | 
            -
             | 
| 14 | 
            -
             | 
| 15 | 
            -
            user_ids.each do |user_id|
         | 
| 16 | 
            -
                  enrollments_data = {
         | 
| 17 | 
            -
                        'OrgUnitId' => org_unit_id.to_s, # String
         | 
| 18 | 
            -
                        'UserId' => user_id.to_s, # String
         | 
| 19 | 
            -
                        'RoleId' => role_id.to_s, # String
         | 
| 20 | 
            -
                  }
         | 
| 21 | 
            -
            end
         | 
| 22 | 
            -
            create_user_enrollment(course_enrollment_data)
         | 
| @@ -1,16 +0,0 @@ | |
| 1 | 
            -
            require_relative "lib/d2l_sdk"
         | 
| 2 | 
            -
             | 
| 3 | 
            -
            courses = get_courses_by_code(201708) # get all courses coded as 201708
         | 
| 4 | 
            -
            courses_done = 0
         | 
| 5 | 
            -
            courses.each do |course| # for each of these 201708 courses
         | 
| 6 | 
            -
              # print out progress thus far
         | 
| 7 | 
            -
              puts "Progress: #{courses_done}/#{courses.length} (#{(courses_done/courses.length).to_i})" if courses_done % 10 == 0
         | 
| 8 | 
            -
              course_id = course["Identifier"] # get their identifier
         | 
| 9 | 
            -
              course_data = get_course_by_id(course_id)
         | 
| 10 | 
            -
              if course_data["Semester"] == nil
         | 
| 11 | 
            -
                open('NoSemester.out', 'a') do |file|
         | 
| 12 | 
            -
                    file << "#{course_id}\n"
         | 
| 13 | 
            -
                end
         | 
| 14 | 
            -
              end
         | 
| 15 | 
            -
              courses_done += 1
         | 
| 16 | 
            -
            end
         |