Class: Meibo::Enrollment

Inherits:
Object
  • Object
show all
Defined in:
lib/meibo/enrollment.rb

Direct Known Subclasses

JapanProfile::Enrollment

Constant Summary collapse

ROLES =
{
  administrator: "administrator",
  proctor: "proctor",
  student: "student",
  teacher: "teacher"
}.freeze

Instance Method Summary collapse

Constructor Details

#initialize(sourced_id:, class_sourced_id:, school_sourced_id:, user_sourced_id:, role:, status: nil, date_last_modified: nil, primary: nil, begin_date: nil, end_date: nil, **extension_fields) ⇒ Enrollment

Returns a new instance of Enrollment.



36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/meibo/enrollment.rb', line 36

def initialize(sourced_id:, class_sourced_id:, school_sourced_id:, user_sourced_id:, role:, status: nil,
               date_last_modified: nil, primary: nil, begin_date: nil, end_date: nil, **extension_fields)
  @sourced_id = sourced_id
  @status = status
  @date_last_modified = date_last_modified
  @primary = primary
  @class_sourced_id = class_sourced_id
  @school_sourced_id = school_sourced_id
  @user_sourced_id = user_sourced_id
  @role = role
  @begin_date = begin_date
  @end_date = end_date
  @extension_fields = extension_fields
end

Instance Method Details

#administrator?Boolean

Returns:

  • (Boolean)


55
56
57
# File 'lib/meibo/enrollment.rb', line 55

def administrator?
  role == ROLES[:administrator]
end

#classroomObject



71
72
73
# File 'lib/meibo/enrollment.rb', line 71

def classroom
  Meibo.current_roster.classes.find(class_sourced_id)
end

#collectionObject



51
52
53
# File 'lib/meibo/enrollment.rb', line 51

def collection
  Meibo.current_roster.enrollments
end

#proctor?Boolean

Returns:

  • (Boolean)


59
60
61
# File 'lib/meibo/enrollment.rb', line 59

def proctor?
  role == ROLES[:proctor]
end

#schoolObject



75
76
77
# File 'lib/meibo/enrollment.rb', line 75

def school
  Meibo.current_roster.organizations.find(school_sourced_id)
end

#student?Boolean

Returns:

  • (Boolean)


63
64
65
# File 'lib/meibo/enrollment.rb', line 63

def student?
  role == ROLES[:student]
end

#teacher?Boolean

Returns:

  • (Boolean)


67
68
69
# File 'lib/meibo/enrollment.rb', line 67

def teacher?
  role == ROLES[:teacher]
end

#userObject



79
80
81
# File 'lib/meibo/enrollment.rb', line 79

def user
  Meibo.current_roster.users.find(user_sourced_id)
end