Sha256: f9595973ec00bb50169bad4613c0b842a887dfc759e9fba9136749260c341b3f

Contents?: true

Size: 1.78 KB

Versions: 2

Compression:

Stored size: 1.78 KB

Contents

module Mumuki::Domain
  class IncognitoClass

    def incognito?
      true
    end

    # ============
    # Permissions
    # ============

    def ensure_enabled!
    end

    def has_student_granted_organizations?
      false
    end

    def teacher_here?
      false
    end

    def teacher_of?(*)
      false
    end

    def profile_completed?
      true
    end

    def writer?
      false
    end

    def moderator_here?
      false
    end

    def can_discuss_here?
      false
    end

    # ========
    # Visiting
    # ========

    def visit!(*)
    end

    # ========
    # Progress
    # ========

    def next_exercise_at(guide)
      guide.exercises.first
    end

    # def completed_containers_with_lookahead(*)
    #   raise 'Unsupported operation. Userless mode and progressive display modes are incompatible'
    # end

    def progress_at(content, organization)
      Indicator.new content: content, organization: organization
    end

    def build_assignment(exercise, organization)
      Assignment.new exercise: exercise, organization: organization, submitter: self
    end

    def pending_siblings_at(content)
      []
    end

    # ============
    # ActiveRecord
    # ============

    def id
      '<incognito>'
    end

    def is_a?(other)
      other.is_a?(Class) && other.name == 'User' || super
    end

    def _read_attribute(key)
      return id if key == 'id'
      raise "unknown attribute #{key}"
    end

    def self.primary_key
      'id'
    end

    # ==========
    # Evaluation
    # ==========

    def interpolations
      []
    end

    def run_submission!(submission, assignment, evaluation)
      results = submission.dry_run! assignment, evaluation
      assignment.assign_attributes results
      results
    end

  end

  Incognito = IncognitoClass.new
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
mumuki-domain-7.8.1 lib/mumuki/domain/incognito.rb
mumuki-domain-7.8.0 lib/mumuki/domain/incognito.rb