class Mumuki::Domain::Workspace

Attributes

area[RW]
user[RW]

Public Class Methods

new(user, area) click to toggle source

area is a organization-like or course-like object that can be converted into slugs, has content and access-rules information

# File lib/mumuki/domain/workspace.rb, line 6
def initialize(user, area)
  @user = user
  @area = area
end

Public Instance Methods

annonymous?() click to toggle source
# File lib/mumuki/domain/workspace.rb, line 11
def annonymous?
  user.nil?
end
enabled_containers(sequence) click to toggle source

Takes a didactic sequence of containers and retuns the enabled containers for this user in this workspace.

This method does not check the user is actually member of the area, you should check that before sending this message

# File lib/mumuki/domain/workspace.rb, line 25
def enabled_containers(sequence)
  return sequence if annonymous? || teacher?

  # TODO refactor when introducing access rules
  if area.progressive_display_lookahead
    user.completed_containers_with_lookahead(
      sequence,
      area.to_organization,
      lookahead: area.progressive_display_lookahead)
  else
    sequence
  end
end
teacher?() click to toggle source
# File lib/mumuki/domain/workspace.rb, line 15
def teacher?
  user.teacher_of? area
end