Skip to content

Overview

The library module in the is designed to manage common library content across schools. This module includes models for handling access permissions (access.rb), assessment criteria and qualifiers (assessment_criterion.rb, assessment_qualifier.rb), categories (category.rb), curriculums (curriculum.rb), domains (domain.rb), goals (goal.rb), lesson plans (lesson_plan.rb, lesson_plan_subgoal.rb), materials and their associations (material.rb, material_entity.rb), measurement values and qualifiers (measurement_value.rb, measurement_qualifier.rb), performance indicators (performance_indicator.rb), user profiles (profile.rb), subgoals (subgoal.rb), tags and their associations (tag.rb, tagging.rb), templates (template.rb), and worksheets along with their related entities (worksheet.rb, worksheet_curriculum.rb, worksheet_domain.rb).

The models in this module collectively facilitate the organization, categorization, and management of library resources. They provide mechanisms for defining and associating goals, subgoals, and performance indicators with specific domains and curriculums. Additionally, the models support the creation and duplication of worksheets, tagging of materials, and tracking of user access permissions.


Library::Domain

Summary

The Library::Domain model represents domains in the library system, managing educational content and assessment criteria.

Fields/Columns

  • name: The name of the domain.
  • curriculum_id: The ID of the associated curriculum.

Relationships

  • has_many :categories, dependent: :destroy: Each domain can have many categories.
  • has_many :goals, through: :categories: Each domain can have many goals through categories.
  • has_many :subgoals, through: :goals: Each domain can have many subgoals through goals.
  • has_one :assessment_criterion, -> { order("created_at desc") }, class_name: Library::AssessmentCriterion.name, dependent: :destroy: Each domain can have one assessment criterion.
  • has_one :performance_indicator, -> { order("created_at desc") }, class_name: Library::PerformanceIndicator.name, dependent: :destroy: Each domain can have one performance indicator.
  • has_many :all_assessment_criteria, class_name: "Library::AssessmentCriterion", dependent: :destroy: Each domain can have many assessment criteria.
  • belongs_to :curriculum, optional: true: Each domain can optionally be associated with a curriculum.
  • has_many :material_entities, as: :entity, dependent: :destroy, class_name: "Library::MaterialEntity": Each domain can have many material entities.
  • has_many :materials, through: :material_entities: Each domain can have many materials through material entities.
  • has_many :worksheet_domains, class_name: Library::WorksheetDomain.name: Each domain can have many worksheet domains.
  • has_many :worksheets, through: :worksheet_domains: Each domain can have many worksheets through worksheet domains.

Library::Curriculum

Summary

The Library::Curriculum model represents curriculums in the library system, managing educational domains and their relationships.

Fields/Columns

  • name: The name of the curriculum.

Relationships

  • has_many :domains: Each curriculum can have many domains.
  • has_many :school_curriculums: Each curriculum can have many school curriculums.
  • has_many :schools, through: :school_curriculums: Each curriculum can have many schools through school curriculums.
  • has_many :categories, through: :domains: Each curriculum can have many categories through domains.
  • has_many :goals, through: :categories: Each curriculum can have many goals through categories.
  • has_many :subgoals, through: :goals: Each curriculum can have many subgoals through goals.
  • has_many :license_curriculums: Each curriculum can have many license curriculums.
  • has_many :licenses, through: :license_curriculums: Each curriculum can have many licenses through license curriculums.

Library::Category

Summary

The Library::Category model represents categories in the library system, organizing goals within domains.

Fields/Columns

  • name: The name of the category.
  • position: The position of the category within the domain.
  • domain_id: The ID of the associated domain.

Relationships

  • belongs_to :domain: Each category is associated with a domain.
  • has_many :goals, dependent: :destroy: Each category can have many goals.
  • has_many :subgoals, through: :goals: Each category can have many subgoals through goals.

Concerns Used

  • PositionHelper: Provides methods for managing the position of the category.

Library::AssessmentQualifier

Summary

The Library::AssessmentQualifier model represents qualifiers for assessments in the library system.

Fields/Columns

  • kind: The kind of qualifier (e.g., performance, testing).
  • value: The value of the qualifier.

Relationships

  • has_many :measurement_qualifiers, foreign_key: :qualifier_id, class_name: Library::MeasurementQualifier.name: Each assessment qualifier can have many measurement qualifiers.

Library::AssessmentCriterion

Summary

The Library::AssessmentCriterion model represents criteria for assessing performance in the library system.

Fields/Columns

  • total_attempts: The total number of attempts allowed.
  • successful_attempts: The number of successful attempts required.
  • kind: The type of assessment criterion (e.g., boolean, linear, percentile, makaton, qualifier).
  • domain_id: The ID of the associated domain.
  • goal_id: The ID of the associated goal.
  • copied_from_id: The ID of the assessment criterion it was copied from.

Relationships

  • belongs_to :domain, optional: true: Each assessment criterion can optionally be associated with a domain.
  • belongs_to :goal, optional: true: Each assessment criterion can optionally be associated with a goal.
  • belongs_to :copied_from, class_name: "Library::AssessmentCriterion", optional: true: Each assessment criterion can optionally be copied from another assessment criterion.
  • has_many :measurement_values, dependent: :destroy, inverse_of: :assessment_criterion: Each assessment criterion can have many measurement values.

Library::Access

Summary

The Library::Access model represents access permissions for profiles in the library system.

Fields/Columns

  • role: The role assigned to the profile (e.g., admin, content_creator).
  • profile_id: The ID of the associated profile.

Relationships

  • belongs_to :profile, class_name: "Library::Profile", foreign_key: :profile_id: Each access is associated with a profile.

Library::Profile

Summary

The Library::Profile model represents user profiles in the library system, managing access permissions and user-specific settings.

Fields/Columns

  • user_id: The ID of the associated user.

Relationships

  • has_many :accesses, dependent: :destroy, class_name: "Library::Access": Each profile can have many accesses.

Library::PerformanceIndicator

Summary

The Library::PerformanceIndicator model represents performance indicators in the library system, managing criteria for evaluating domain performance.

Fields/Columns

  • min_assessments_count: The minimum number of assessments required.
  • max_needs_help_percentage: The maximum percentage of students needing help.
  • min_excelling_percentage: The minimum percentage of students excelling.
  • domain_id: The ID of the associated domain.

Relationships

  • belongs_to :domain, class_name: Library::Domain.name: Each performance indicator is associated with a domain.

Library::MeasurementValue

Summary

The Library::MeasurementValue model represents measurement values in the library system, managing criteria for evaluating performance.

Fields/Columns

  • name: The name of the measurement value.
  • position: The position of the measurement value.
  • value: The value of the measurement.
  • success: A boolean indicating whether the measurement value represents success.
  • assessment_criterion_id: The ID of the associated assessment criterion.

Relationships

  • belongs_to :assessment_criterion, inverse_of: :measurement_values: Each measurement value is associated with an assessment criterion.
  • has_many :measurement_qualifiers, foreign_key: :measurement_id, dependent: :destroy, inverse_of: :measurement: Each measurement value can have many measurement qualifiers.
  • has_many :qualifiers, through: :measurement_qualifiers: Each measurement value can have many qualifiers through measurement qualifiers.

Concerns Used

  • None

Library::MeasurementQualifier

Summary

The Library::MeasurementQualifier model represents the association between measurement values and qualifiers in the library system.

Fields/Columns

  • measurement_id: The ID of the associated measurement value.
  • qualifier_id: The ID of the associated qualifier.

Relationships

  • belongs_to :qualifier, class_name: Library::AssessmentQualifier.name: Each measurement qualifier is associated with a qualifier.
  • belongs_to :measurement, class_name: Library::MeasurementValue.name: Each measurement qualifier is associated with a measurement value.

Library::Material

Summary

The Library::Material model represents educational materials in the library system, managing content and associated metadata.

Fields/Columns

  • text: The text content of the material.

Relationships

  • has_many :taggings, as: :taggable, dependent: :destroy, class_name: "Library::Tagging": Each material can have many taggings.
  • has_many :tags, through: :taggings, class_name: "Library::Tag": Each material can have many tags through taggings.
  • has_many :material_entities, dependent: :destroy: Each material can have many material entities.
  • has_many :goals, through: :material_entities, source: :entity, source_type: "Library::Goal": Each material can have many goals through material entities.
  • has_many :subgoals, through: :material_entities, source: :entity, source_type: "Library::Subgoal": Each material can have many subgoals through material entities.
  • has_many :domains, through: :material_entities, source: :entity, source_type: "Library::Domain": Each material can have many domains through material entities.
  • has_many :media, as: :record: Each material can have many media records.
  • has_one :medium, -> { where(kind: "primary") }, as: :record, dependent: :destroy: Each material can have one primary medium.
  • has_one :medium_secondary, -> { where(kind: "secondary") }, as: :record, dependent: :destroy, class_name: Medium.name: Each material can have one secondary medium.

Concerns Used

  • None

Library::MaterialEntity

Summary

The Library::MaterialEntity model represents the association between materials and entities in the library system.

Fields/Columns

  • material_id: The ID of the associated material.
  • entity_id: The ID of the associated entity.
  • entity_type: The type of the associated entity.

Relationships

  • belongs_to :material, class_name: "Library::Material": Each material entity is associated with a material.
  • belongs_to :entity, polymorphic: true: Each material entity is associated with a polymorphic entity.

Library::LessonPlan

Summary

The Library::LessonPlan model represents lesson plans in the library system, managing educational activities and associated metadata.

Fields/Columns

  • name: The name of the lesson plan.
  • age_range_kind: The kind of age range (e.g., year, month).
  • age_range_start: The start of the age range.
  • age_range_end: The end of the age range.
  • curriculum_id: The ID of the associated curriculum.

Relationships

  • belongs_to :curriculum: Each lesson plan is associated with a curriculum.
  • has_one :instruction_text, -> { where(kind: "instruction").order("created_at desc") }, class_name: "RichtextRecord", as: :owner, dependent: :destroy: Each lesson plan can have one instruction text.
  • has_one :notes_text, -> { where(kind: "notes").order("created_at desc") }, class_name: "RichtextRecord", as: :owner, dependent: :destroy: Each lesson plan can have one notes text.
  • has_one :item_required_text, -> { where(kind: "item_required").order("created_at desc") }, class_name: "RichtextRecord", as: :owner, dependent: :destroy: Each lesson plan can have one item required text.
  • has_many :lesson_plan_subgoals, class_name: Library::LessonPlanSubgoal.name: Each lesson plan can have many lesson plan subgoals.
  • has_many :subgoals, through: :lesson_plan_subgoals: Each lesson plan can have many subgoals through lesson plan subgoals.

Library::LessonPlanSubgoal

Summary

The Library::LessonPlanSubgoal model represents the association between lesson plans and subgoals in the library system.

Fields/Columns

  • lesson_plan_id: The ID of the associated lesson plan.
  • subgoal_id: The ID of the associated subgoal.

Relationships

  • belongs_to :lesson_plan, class_name: "Library::LessonPlan": Each lesson plan subgoal is associated with a lesson plan.
  • belongs_to :subgoal, class_name: "Library::Subgoal": Each lesson plan subgoal is associated with a subgoal.

Library::Goal

Summary

The Library::Goal model represents goals in the library system, managing educational objectives and their relationships.

Fields/Columns

  • title: The title of the goal.
  • position: The position of the goal within the category.
  • category_id: The ID of the associated category.

Relationships

  • belongs_to :category: Each goal is associated with a category.
  • has_many :subgoals, dependent: :destroy: Each goal can have many subgoals.
  • has_many :school_subgoals, class_name: "School::Subgoal": Each goal can have many school subgoals.
  • has_many :material_entities, as: :entity, dependent: :destroy, class_name: "Library::MaterialEntity": Each goal can have many material entities.
  • has_many :materials, through: :material_entities: Each goal can have many materials through material entities.
  • has_one :assessment_criterion, -> { order("created_at desc") }, class_name: "Library::AssessmentCriterion", dependent: :destroy: Each goal can have one assessment criterion.
  • has_many :all_assessment_criteria, class_name: "Library::AssessmentCriterion", dependent: :destroy: Each goal can have many assessment criteria.

Concerns Used

  • PositionHelper: Provides methods for managing the position of the goal.

Library::Worksheet

Summary

The Library::Worksheet model represents worksheets in the library system, managing educational activities and associated metadata.

Fields/Columns

  • title: The title of the worksheet.
  • purpose: The purpose of the worksheet (e.g., reading, writing).
  • created_by_id: The ID of the profile that created the worksheet.
  • status: The current status of the worksheet (e.g., draft, published).

Relationships

  • belongs_to :created_by, class_name: "Profile": Each worksheet is associated with a profile that created it.
  • has_many :custom_images, -> { where(kind: "custom_image").order("created_at desc") }, class_name: "Medium", as: :record, dependent: :destroy: Each worksheet can have many custom images.
  • has_one :preview_image, -> { where(kind: "preview_image").order("created_at desc") }, class_name: "Medium", as: :record, dependent: :destroy: Each worksheet can have one preview image.
  • has_one :pdf_document, -> { where(kind: "pdf_document").order("created_at desc") }, class_name: "Medium", as: :record, dependent: :destroy: Each worksheet can have one PDF document.
  • has_many :duplicated_sheets, class_name: Library::Worksheet.name, foreign_key: :duplicated_from_id, dependent: :nullify: Each worksheet can have many duplicated sheets.
  • belongs_to :original_sheet, class_name: Library::Worksheet.name, foreign_key: :duplicated_from_id, optional: true: Each worksheet can optionally be associated with an original sheet.
  • has_many :worksheet_curriculums, class_name: Library::WorksheetCurriculum.name, dependent: :destroy: Each worksheet can have many worksheet curriculums.
  • has_many :worksheet_domains, class_name: Library::WorksheetDomain.name, dependent: :destroy: Each worksheet can have many worksheet domains.
  • has_many :domains, through: :worksheet_domains: Each worksheet can have many domains through worksheet domains.
  • has_many :taggings, as: :taggable, dependent: :destroy, class_name: Library::Worksheet::Tagging.name: Each worksheet can have many taggings.
  • has_many :tags, through: :taggings, class_name: Library::Worksheet::Tag.name: Each worksheet can have many tags through taggings.

Concerns Used

  • AASM: Provides state machine functionality for the model.

Library::WorksheetDomain

Summary

The Library::WorksheetDomain model represents the association between worksheets and domains in the library system.

Fields/Columns

  • worksheet_id: The ID of the associated worksheet.
  • domain_id: The ID of the associated domain.

Relationships

  • belongs_to :worksheet, class_name: Library::Worksheet.name, foreign_key: :worksheet_id: Each worksheet domain is associated with a worksheet.
  • belongs_to :domain, class_name: Library::Domain.name, foreign_key: :domain_id: Each worksheet domain is associated with a domain.

Library::WorksheetCurriculum

Summary

The Library::WorksheetCurriculum model represents the association between worksheets and curriculums in the library system.

Fields/Columns

  • worksheet_id: The ID of the associated worksheet.
  • curriculum_id: The ID of the associated curriculum.

Relationships

  • belongs_to :worksheet, class_name: Library::Worksheet.name, foreign_key: :worksheet_id: Each worksheet curriculum is associated with a worksheet.
  • belongs_to :curriculum, class_name: Library::Curriculum.name, foreign_key: :curriculum_id: Each worksheet curriculum is associated with a curriculum.

Library::Template

Summary

The Library::Template model represents templates in the library system, managing reusable content for various purposes.

Fields/Columns

  • content: The content of the template.

Library::Tagging

Summary

The Library::Tagging model represents the association between tags and taggable entities in the library system.

Fields/Columns

  • tag_id: The ID of the associated tag.

Relationships

  • belongs_to :tag, class_name: "Library::Tag": Each tagging is associated with a tag.

Library::Tag

Summary

The Library::Tag model represents tags in the library system, managing the categorization and organization of various entities.

Fields/Columns

  • name: The name of the tag.

Relationships

  • has_many :taggings, dependent: :destroy, class_name: "Library::Tagging": Each tag can have many taggings.

Library::Subgoal

Summary

The Library::Subgoal model represents subgoals in the library system, managing specific objectives within goals and their relationships.

Fields/Columns

  • title: The title of the subgoal.
  • position: The position of the subgoal within the goal.
  • goal_id: The ID of the associated goal.
  • age_range_kind: The kind of age range (e.g., year, month).
  • age_range_start: The start of the age range.
  • age_range_end: The end of the age range.
  • archived_at: The timestamp when the subgoal was archived.

Relationships

  • belongs_to :goal: Each subgoal is associated with a goal.
  • has_many :material_entities, as: :entity, dependent: :destroy, class_name: "Library::MaterialEntity": Each subgoal can have many material entities.
  • has_many :materials, through: :material_entities: Each subgoal can have many materials through material entities.
  • has_many :lesson_plan_subgoals, class_name: Library::LessonPlanSubgoal.name: Each subgoal can have many lesson plan subgoals.
  • has_many :lesson_plans, through: :lesson_plan_subgoals: Each subgoal can have many lesson plans through lesson plan subgoals.

Concerns Used

  • PositionHelper: Provides methods for managing the position of the subgoal.