Module: Moodle::Service::User

Included in:
Client
Defined in:
lib/moodle/services/user.rb

Instance Method Summary collapse

Instance Method Details

#core_user_get_users(criteria) ⇒ Object

Search for users matching the criteria


22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/moodle/services/user.rb', line 22

def core_user_get_users(criteria)
  params = {}

  counter = 0
  criteria.each do |key,value|
    params['criteria[' + counter.to_s + '][key]'] = key.to_s
    params['criteria[' + counter.to_s + '][value]'] = value
    counter = counter + 1
  end

  response = request(params)

  if response['users']
    users = response['users'].map { |user| Hashie::Mash.new(user) }
  end
end

#core_user_get_users_by_field(field, values) ⇒ Object

Get users by field


5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/moodle/services/user.rb', line 5

def core_user_get_users_by_field(field, values)
  params = {
    :field => field
  }

  # Add all the userids as array params
  counter = 0
  values.each do |id|
    params['values[' + counter.to_s + ']'] = id
    counter = counter + 1
  end

  response = request(params)
  Hashie::Mash.new *response
end