Sha256: 6b100ae2bc1c068f8c8cdeb4081b3f9e30dea7c8b558b38dfc132f4175cd4918

Contents?: true

Size: 1.83 KB

Versions: 4

Compression:

Stored size: 1.83 KB

Contents

# frozen_string_literal: true

module MediaWiktory::Wikipedia
  module Actions
    # Get the usernames and other information for students enrolled in one or more courses.
    #
    # Usage:
    #
    # ```ruby
    # api.liststudents.courseids(value).perform # returns string with raw output
    # # or
    # api.liststudents.courseids(value).response # returns output parsed and wrapped into Response object
    # ```
    #
    # See {Base} for generic explanation of working with MediaWiki actions and
    # {MediaWiktory::Wikipedia::Response} for working with action responses.
    #
    # All action's parameters are documented as its public methods, see below.
    #
    class Liststudents < MediaWiktory::Wikipedia::Actions::Get

      # IDs of the courses.
      #
      # @param values [Array<Integer>]
      # @return [self]
      def courseids(*values)
        values.inject(self) { |res, val| res._courseids(val) }
      end

      # @private
      def _courseids(value)
        merge(courseids: value.to_s, replace: false)
      end

      # Which property to get for each student:
      #
      # @param value [String] One of "username" (The username of the student), "id" (The user ID of the student).
      # @return [self]
      def prop(value)
        _prop(value) or fail ArgumentError, "Unknown value for prop: #{value}"
      end

      # @private
      def _prop(value)
        defined?(super) && super || ["username", "id"].include?(value.to_s) && merge(prop: value.to_s)
      end

      # If given, the query will group students by course.
      #
      # @return [self]
      def group()
        merge(group: 'true')
      end

      # If given, the query will return usernames in CSV format, and it will return the articles assigned to those students.
      #
      # @return [self]
      def csv()
        merge(csv: 'true')
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
mediawiktory-0.1.3 lib/mediawiktory/wikipedia/actions/liststudents.rb
mediawiktory-0.1.2 lib/mediawiktory/wikipedia/actions/liststudents.rb
mediawiktory-0.1.1 lib/mediawiktory/wikipedia/actions/liststudents.rb
mediawiktory-0.1.0 lib/mediawiktory/wikipedia/actions/liststudents.rb