{
  "clusterId": "02_CORE_CourseContent",
  "featureFocus": "Course Creation, Structure, Content Items (Rich Text, Documents), Enrollment, and Progress Tracking",
  "documentationReport": "{\n  \"title\": \"Course Management, Enrollment, and Learner Progress System Documentation\",\n  \"functional_domain\": \"Learning Management System (LMS) Core Features\",\n  \"description\": \"This report synthesizes documentation for a merged software cluster, providing a comprehensive overview of the Course Management, Enrollment, and Learner Progress System. It integrates insights from foundational documentation with additional components, highlighting the full scope of functionality for defining courses, managing content, handling user enrollment, tracking learner progress, and providing administrative oversight.\",\n  \"sections\": [\n    {\n      \"title\": \"1. Course Definition and Content Management\",\n      \"content\": \"This section details the processes and components involved in defining courses, structuring their content, and managing various types of learning materials.\",\n      \"sub_sections\": [\n        {\n          \"title\": \"1.1 Course Creation and Metadata\",\n          \"content\": \"Course metadata, including title, course code, abstract, description, target groups, and learning goals, is primarily managed through the `Admin::CourseForm` (app/forms/admin/course_form.rb). This form also handles critical attributes such as `status`, `lang`, `channel_id`, and various feature flags like `roa_enabled`, `cop_enabled`, `pinboard_enabled`, and `invite_only`. Course visuals and stage visuals are managed via uploads, processed by the `Course::Visual::Store` operation (app/operations/course/visual/store.rb), which facilitates S3 interactions for images and teaser videos, including subtitles. Course classifiers are also managed through this form, with built-in validation for format and uniqueness.\"\n        },\n        {\n          \"title\": \"1.2 Course Structure (Sections)\",\n          \"content\": \"Course sections, which organize content, are managed by the `SectionsController` (app/controllers/sections_controller.rb). Teachers can perform CRUD operations (create, update, destroy) and reorder sections. The controller interacts with the `Xikolo::Course::Section` microservice client to persist these changes. For courses not yet migrated to a new content tree, a `load_raw_sections` method is used to load sections and their items. The frontend UI (app/assets/teacher/sections/sections.js) provides functionality to toggle UUIDs and manage delete restrictions. Implicit tags for pinboards are automatically created when a section is saved. The `SectionPresenter` (app/presenters/section_presenter.rb) is used to display section details, including item availability and alternative sections.\"\n        },\n        {\n          \"title\": \"1.3 Content Item Management\",\n          \"content\": \"Content items within sections are managed by the `ItemsController` (app/controllers/items_controller.rb), supporting diverse content types including `video`, `rich_text`, `quiz`, and `lti_exercise`.\\n\\n*   **Creation**: The `Item::Create` operation (app/operations/item/create.rb) orchestrates the creation of an item and its associated content resource, ensuring content validity, setting `content_id` and `section_id`, and creating implicit pinboard tags.\\n*   **Rich Text**: `Course::Richtext` content is processed by `Course::Richtext::Store` (app/operations/course/richtext/store.rb), which handles text processing, S3 uploads for embedded files, and manages file references. Frontend logic (`handleRichTextType` in app/assets/teacher/items/rich-text.ts) dynamically adjusts the item creation/edit form for rich text content.\\n*   **Video**: Video items utilize `Video::Video` and `Video::Store` (app/operations/course/visual/store.rb) for managing video streams, subtitles, slides, and reading materials.\\n*   **Quiz**: Quiz items interact with `Xikolo::Quiz::Quiz` and its associated question types.\\n*   **LTI Exercise**: LTI exercises leverage `Lti::Exercise` and `Lti::Provider`.\\n\\nThe `ItemsController` also facilitates moving items within or between sections, accommodating both legacy and tree-based course structures. Item deletion involves removing the item via the `course_api` and, for most content types, destroying the associated content resource.\"\n        },\n        {\n          \"title\": \"1.4 Documents\",\n          \"content\": \"Course documents are managed by `Course::DocumentsController` (app/controllers/course/documents_controller.rb) and `DocumentHelper` (app/helpers/document_helper.rb). These components interact with the `course_api` to list, show, create, update, and delete documents and their localizations. File uploads for documents are handled via `FileUpload` with a `course_document` purpose.\"\n        },\n        {\n          \"title\": \"1.5 Poll Management\",\n          \"content\": \"The system includes administrative capabilities for managing interactive elements. `Admin::PollOptionsController` (Admin::PollOptionsController) is responsible for managing the options available for polls, suggesting a configurable system for integrating polling features within courses or as standalone engagement tools.\"\n        },\n        {\n          \"title\": \"1.6 Course Context and Access Control\",\n          \"content\": \"`CourseContextHelper` (app/helpers/course_context_helper.rb) and `ItemContextHelper` (app/helpers/item_context_helper.rb) provide shared logic for course and item-related pages. The `inside_course` method sets a course-specific layout and enforces `check_course_eligibility` to ensure users have appropriate permissions or enrollment status. Similarly, `inside_item` ensures the item belongs to the course and loads necessary presenters.\"\n        }\n      ]\n    },\n    {\n      \"title\": \"2. Enrollment Lifecycle Management\",\n      \"content\": \"This section covers the entire lifecycle of user enrollment in courses, from initial registration to unenrollment and reactivation, including administrative policies and statistics.\",\n      \"sub_sections\": [\n        {\n          \"title\": \"2.1 Enrollment and Unenrollment\",\n          \"content\": \"User enrollment is managed by the `Course::EnrollmentsController` (app/controllers/course/enrollments_controller.rb). The `create` action attempts to enroll a user via a `POST` request to `course_api.rel(:enrollments)`, handling various error scenarios like `access_restricted` or `prerequisites_unfulfilled`. Users already enrolled are redirected to the course resume path. The `destroy` action allows unenrollment via a `DELETE` request to the enrollment's `self` relation via the `course_api`.\"\n        },\n        {\n          \"title\": \"2.2 Course Launch and Reactivation\",\n          \"content\": \"The `Course::LaunchController` (app/controllers/course/launch_controller.rb) handles initial course access, redirecting unauthenticated users to login or authenticated users to enrollment, storing the intended course location in the session. `Course::FreeReactivationsController` (app/controllers/course/free_reactivations_controller.rb) enables users to reactivate courses under specific conditions, interacting with the `course_api` to check prerequisites and create new reactivations. The platform's `course_reactivation` feature flipper and course configuration determine if reactivation is enabled. Presenters like `CourseInfoPresenter` (app/presenters/course_info_presenter.rb) and `CourseLargePreviewPresenter` (app/presenters/course_large_preview_presenter.rb) expose logic for checking course reactivation eligibility.\"\n        },\n        {\n          \"title\": \"2.3 Enrollment Policies and Statistics\",\n          \"content\": \"Administrative control over enrollment rules is facilitated by `Course::EnrollmentPolicyForm` (Course::EnrollmentPolicyForm), allowing for the definition and management of enrollment policies. `Course::EnrollmentStatistics` (Course::EnrollmentStatistics) provides aggregated data and insights into enrollment trends and user participation, crucial for reporting and course management.\"\n        }\n      ]\n    },\n    {\n      \"title\": \"3. Learner Progress and Engagement\",\n      \"content\": \"This section details how learner progress is tracked, displayed, and how users navigate and engage with course content, including achievements and dashboard integrations.\",\n      \"sub_sections\": [\n        {\n          \"title\": \"3.1 Progress Tracking and Visualization\",\n          \"content\": \"The `Course::ProgressController` (app/controllers/course/progress_controller.rb) displays a user's progress, fetching data from `course_api.rel(:progresses)` for the current user or a specified user (with teaching permissions). The `ProgressHelper` (app/helpers/progress_helper.rb) provides the `calc_progress` method to compute percentage progress. Visual representation of progress is enhanced by `Course::CircularProgress` (Course::CircularProgress), likely a UI component for displaying progress in a user-friendly circular format.\"\n        },\n        {\n          \"title\": \"3.2 Syllabus and Content Access\",\n          \"content\": \"The `Course::SyllabusController` (app/controllers/course/syllabus_controller.rb) provides an overview of course content, including a progress summary, and handles open mode access for previewable items. The `ItemPresenter` (app/presenters/item_presenter.rb) is central for displaying individual items, providing status (locked, visited, active), type labels, and time effort. It also determines item previewability based on `open_mode` and content type (currently restricted to video). The `ItemContextHelper` (app/helpers/item_context_helper.rb) includes `create_visit!` to record user visits to items, excluding quizzes or masquerading sessions.\"\n        },\n        {\n          \"title\": \"3.3 Certificates and Achievements\",\n          \"content\": \"`DocumentsPresenter` (app/presenters/documents_presenter.rb) is responsible for presenting available certificates (Confirmation of Participation, Record of Achievement, Certificate, Transcript of Records) and open badges. It checks for template existence and user eligibility (e.g., passing proctoring for certificates) based on enrollment and course configuration.\"\n        },\n        {\n          \"title\": \"3.4 Course Navigation\",\n          \"content\": \"`CourseNav` (app/presenters/course_nav.rb) defines the primary navigation items for learners (sections, discussions, progress, certificates, documents). `CourseTeacherNav` (app/presenters/course_teacher_nav.rb) provides navigation for teachers (dashboards, content management, settings, enrollments, grading).\"\n        },\n        {\n          \"title\": \"3.5 Dashboard and Calendar Integration\",\n          \"content\": \"The system supports dashboard functionalities and integrations. `Dashboard::IcalFeed` (Dashboard::IcalFeed) enables the generation of iCal feeds, allowing users to integrate course schedules, deadlines, and events into their personal calendars, enhancing overall course management and engagement.\"\n        }\n      ]\n    }\n  ],\n  \"components_overview\": {\n    \"frontend_application\": \"xi-web (Ruby on Rails)\",\n    \"microservices\": [\n      \"Xikolo::CourseService (core course data)\",\n      \"Xikolo::QuizService (quiz content)\",\n      \"Xikolo::S3 (file storage)\"\n    ],\n    \"key_controllers\": [\n      \"SectionsController\",\n      \"ItemsController\",\n      \"Course::DocumentsController\",\n      \"Course::EnrollmentsController\",\n      \"Course::LaunchController\",\n      \"Course::FreeReactivationsController\",\n      \"Course::ProgressController\",\n      \"Course::SyllabusController\",\n      \"Admin::PollOptionsController\"\n    ],\n    \"key_forms\": [\n      \"Admin::CourseForm\",\n      \"Course::EnrollmentPolicyForm\"\n    ],\n    \"key_operations\": [\n      \"Course::Visual::Store\",\n      \"Item::Create\",\n      \"Course::Richtext::Store\"\n    ],\n    \"key_presenters\": [\n      \"SectionPresenter\",\n      \"ItemPresenter\",\n      \"CourseInfoPresenter\",\n      \"CourseLargePreviewPresenter\",\n      \"DocumentsPresenter\",\n      \"CourseNav\",\n      \"CourseTeacherNav\"\n    ],\n    \"key_helpers\": [\n      \"DocumentHelper\",\n      \"CourseContextHelper\",\n      \"ItemContextHelper\",\n      \"ProgressHelper\"\n    ],\n    \"other_components\": [\n      \"Course::CircularProgress\",\n      \"Course::EnrollmentStatistics\",\n      \"Dashboard::IcalFeed\"\n    ]\n  }\n}",
  "componentMapPatch": {
    "components": {
      "Admin::CourseForm": {
        "type": "Form",
        "description": "Handles the creation and editing of course metadata and configuration in the admin interface. It defines attributes for course title, code, abstract, description, dates, status, and various feature flags like ROA, COP, pinboard, and invite-only. It also manages course classifiers and validates input.",
        "interactions": {
          "interaction_0": "Interacts with the underlying Course model (via microservice) for persistence.",
          "interaction_1": "Uses `ChannelHelper` for image dimension constants.",
          "interaction_2": "Validates course status, code, title, language, description, and classifier formats."
        },
        "techDebt": [],
        "provenance": {
          "sources": [
            "app/forms/admin/course_form.rb",
            "app/helpers/channel_helper.rb"
          ]
        }
      },
      "SectionsController": {
        "type": "Controller",
        "description": "Manages course sections, allowing teachers to view, create, update, destroy, and reorder them. It handles both legacy and tree-based course structures.",
        "interactions": {
          "interaction_0": "Uses `CourseContextHelper` for course context and eligibility checks.",
          "interaction_1": "Interacts with `Xikolo::Course::Section` microservice client for section data.",
          "interaction_2": "Interacts with `Course::Course` model to determine legacy status.",
          "interaction_3": "Creates `Xikolo::Pinboard::ImplicitTag` when a section is created.",
          "interaction_4": "Redirects to `course_item_path` or `course_resume_path` after section show action."
        },
        "techDebt": [
          "TODO@JG: null values in section_params for dates.",
          "TODO: the redirect should differentiate between logged in and anonymous users in `show` action."
        ],
        "provenance": {
          "sources": [
            "app/controllers/sections_controller.rb",
            "app/helpers/course_context_helper.rb"
          ]
        },
        "codeImplementation": {
          "confidence": 0.95,
          "codeBlocks": [
            {
              "startLine": 3,
              "endLine": 17,
              "code": "class SectionsController < Abstract::FrontendController   include CourseContextHelper    before_action :ensure_content_editor, only: %i[index create destroy move update]   before_action :load_section_nav, only: [:show]   before_action :set_no_cache_headers   inside_course   respond_to :json    before_action(only: :create) do     next if section_params[:alternative_state] != 'child'     next if current_user.feature?('alternative_sections.create')      raise AbstractController::ActionNotFound   end",
              "source": "app/controllers/sections_controller.rb"
            },
            {
              "startLine": 19,
              "endLine": 32,
              "code": "  def index     @course_presenter = CoursePresenter.create(the_course, current_user)      course = Course::Course.find(the_course.id)      if course.legacy?       @legacy = true       @sections = load_raw_sections(the_course)     else       course.node.preload_tree!       @sections = course.node.children     end      Acfs.run     @new_section = Xikolo::Course::Section.new   end",
              "source": "app/controllers/sections_controller.rb"
            },
            {
              "startLine": 3,
              "endLine": 7,
              "code": "class SectionsController < ApplicationController   responders Responders::ApiResponder,     Responders::DecorateResponder,     Responders::HttpCacheResponder,     Responders::PaginateResponder    respond_to :json",
              "source": "app/controllers/sections_controller.rb"
            },
            {
              "startLine": 8,
              "endLine": 26,
              "code": "  def index     sections = Section.all     sections.where! course_id: params[:course_id] unless params[:course_id].nil?     sections.where! published: params[:published] unless params[:published].nil?     sections = sections.available unless params[:available].nil?     sections.where! id: params[:id] if params[:id]     sections.where! position: params[:position] if params[:position]     if params[:parent_id]       sections.where! parent_id: params[:parent_id]     elsif !params[:include_alternatives]       sections = sections.not_alternative     end     sections.includes! :course      respond_with sections   end",
              "source": "app/controllers/sections_controller.rb"
            },
            {
              "startLine": 28,
              "endLine": 34,
              "code": "  def show     respond_with Section.find params[:id]   end    def create     section = Section.create section_params     if params[:pare...",
              "source": "app/controllers/sections_controller.rb"
            }
          ],
          "sourceFiles": [
            {
              "path": "app/controllers/sections_controller.rb",
              "relevance": 24
            },
            {
              "path": "services/course/app/controllers/sections_controller.rb",
              "relevance": 24
            },
            {
              "path": "app/controllers/abstract/ajax_controller.rb",
              "relevance": 5
            }
          ]
        }
      },
      "ItemsController": {
        "type": "Controller",
        "description": "Manages course content items (videos, rich text, quizzes, LTI exercises). Provides actions for viewing, creating, editing, moving, and destroying items.",
        "interactions": {
          "interaction_0": "Uses `CourseContextHelper` and `ItemContextHelper` for context and eligibility.",
          "interaction_1": "Interacts with `Xikolo::Course::Item` microservice client for item data.",
          "interaction_2": "Interacts with `Video::Video`, `Course::Richtext`, `Xikolo::Quiz::Quiz`, `Lti::Exercise` for content-specific data.",
          "interaction_3": "Utilizes `Item::Create` operation for item creation.",
          "interaction_4": "Uses `Video::Store`, `Course::Richtext::Store`, `Lti::Exercise::Store` for content persistence.",
          "interaction_5": "Creates `Xikolo::Course::Visit` records for item views.",
          "interaction_6": "Loads `Lti::Provider` for LTI exercises.",
          "interaction_7": "Redirects based on content type after creation or update."
        },
        "techDebt": [
          "Error handling inconsistencies between content types for inline vs. flash messages.",
          "TODO: reuse passed in upload ids in `create_video_uploads!`."
        ],
        "provenance": {
          "sources": [
            "app/controllers/items_controller.rb",
            "app/helpers/course_context_helper.rb",
            "app/helpers/item_context_helper.rb",
            "app/operations/item/create.rb",
            "app/operations/course/richtext/store.rb",
            "docs/app/development/implementation/course_items_form.md"
          ]
        },
        "codeImplementation": {
          "confidence": 0.95,
          "codeBlocks": [
            {
              "startLine": 1,
              "endLine": 20,
              "code": "# frozen_string_literal: true\n\nclass ItemsController < Abstract::FrontendController\n  include CourseContextHelper\n  include ItemContextHelper\n\n  before_action :set_no_cache_headers\n\n  include Interruptible\n\n  before_action :ensure_content_editor, except: :show\n  before_action :load_user_preferences, only: :show, if: proc {|_| current_user.authenticated? }\n\n  inside_course\n  inside_item only: :show\n  before_action :load_section_nav, except: :destroy\n\n  respond_to :json, :xml\n\n  def request_section\n    if params[:action] == 'show'\n      course_api.rel(:section).get({id: UUID(item['section_id'])})\n    else\n      super\n    end\n  end\n\n  def request_item\n    return nil unless params[:id]\n    raise Status::NotFound if (uuid = UUID4.try_convert(params[:id])).nil?\n\n    get_params = {id: uuid.to_s}.tap do |p|\n      # Authorized users (e.g., course admins) can always access items, but\n      # for regular learners the user-specific access is verified.\n      p[:user_id] = current_user.id unless cur...",
              "source": "app/controllers/items_controller.rb"
            },
            {
              "startLine": 1,
              "endLine": 35,
              "code": "# frozen_string_literal: true\n\nclass ItemsController < ApplicationController\n  responders Responders::ApiResponder,\n    Responders::DecorateResponder,\n    Responders::HttpCacheResponder,\n    Responders::PaginateResponder\n  include PointsProcessor\n\n  respond_to :json\n\n  def index\n    items = Item.all\n    items.where! content_type: params[:content_type] if params[:content_type]\n    if params[:exercise_type]\n      case params[:exercise_type]\n        when ::ActionController::Parameters\n          items.where! exercise_type: params[:exercise_type].values\n        when String\n          items.where! exercise_type: params[:exercise_type].split(',')\n        else\n          items.where! exercise_type: params[:exercise_type]\n      end\n    end\n    items.where! section_id: params[:section_id] unless params[:section_id].nil?\n    items.where! content_id: params[:content_id] unless params[:content_id].nil?\n    items.where! id: params[:id] unless params[:id].nil?\n    # NOTE: This will also return availabl...",
              "source": "app/controllers/items_controller.rb"
            },
            {
              "startLine": 1,
              "endLine": 41,
              "code": "# frozen_string_literal: true\n\nclass ItemsController < RESTController\n  respond_to :json\n\n  has_scope :section_id do |_controller, scope, value|\n    scope.for_section value.to_s\n  end\n\n  has_scope :course_id do |_controller, scope, value|\n    scope.for_course value.to_s\n  end\n\n  rfc6570_params index: %i[section_id course_id]\n\n  def index\n    respond_with collection\n  end\n\n  def create\n    item = Item.create item_params\n\n    respond_with item\n  end\n\n  def show\n    respond_with resource\n  end\n\n  def overwrite_time_effort\n    if params[:time_effort].blank?\n      return render status: :unprocessable_content, json: {errors: 'time_effort_required'}\n    end\n\n    item = Item.find(params.require(:item_id))\n    overwrite_for!(item, params[:time_effort])\n\n    head :no_content\n  rescue Errors::OverwriteTimeEffortError => e\n    render status: :unprocessable_content, json: {errors: e.reason}\n  rescue Restify::ClientError => e\n    render status: :unprocessable_content, json: {errors: e.errors}\n  end",
              "source": "app/controllers/items_controller.rb"
            }
          ],
          "sourceFiles": [
            {
              "path": "app/controllers/items_controller.rb",
              "relevance": 24
            },
            {
              "path": "services/course/app/controllers/items_controller.rb",
              "relevance": 24
            },
            {
              "path": "services/timeeffort/app/controllers/items_controller.rb",
              "relevance": 24
            }
          ]
        }
      },
      "Course::DocumentsController": {
        "type": "Controller",
        "description": "Manages course documents, allowing users to view lists of documents and individual documents. Access is restricted by a beta feature flag.",
        "interactions": {
          "interaction_0": "Uses `CourseContextHelper` for course context.",
          "interaction_1": "Uses `DocumentHelper` for document-related actions and helpers.",
          "interaction_2": "Interacts with `course_api` (Xikolo::CourseService) to fetch document lists and individual documents."
        },
        "techDebt": [],
        "provenance": {
          "sources": [
            "app/controllers/course/documents_controller.rb",
            "app/helpers/course_context_helper.rb",
            "app/helpers/document_helper.rb"
          ]
        },
        "codeImplementation": {
          "confidence": 0.95,
          "codeBlocks": [
            {
              "startLine": 1,
              "endLine": 35,
              "code": "# frozen_string_literal: true\n\nclass DocumentsController < ApplicationController\n  responders Responders::ApiResponder,\n    Responders::DecorateResponder,\n    Responders::HttpCacheResponder,\n    Responders::PaginateResponder\n  respond_to :json\n\n  rfc6570_params index: %i[course_id item_id language tag]\n  def index\n    documents = Document.all.not_deleted\n\n    # Filter by course\n    if params[:course_id].present?\n      documents = documents.joins(:courses_documents)\n        .where(courses_documents: {course_id: params[:course_id]})\n    end\n\n    # Filter by items\n    if params[:item_id].present?\n      documents = documents.joins(:documents_items)\n        .where(documents_items: {item_id: params[:item_id]})\n    end\n\n    # Filter by language\n    if params[:language].present?\n      documents = documents.joins(:localizations)\n        .where(document_localizations: {language: params[:language]})\n    end\n\n    # Filter by tag\n    documents = documents.tagged_with(params[:tag]) if params[:tag].p...\n",
              "source": "services/course/app/controllers/documents_controller.rb"
            }
          ],
          "sourceFiles": [
            {
              "path": "services/course/app/controllers/documents_controller.rb",
              "relevance": 27
            },
            {
              "path": "app/controllers/admin/ajax/courses_controller.rb",
              "relevance": 12
            },
            {
              "path": "app/controllers/bridges/chatbot/courses_controller.rb",
              "relevance": 12
            }
          ]
        }
      },
      "Course::EnrollmentsController": {
        "type": "Controller",
        "description": "Handles user enrollment and unenrollment in courses. It manages the creation and deletion of enrollments, checking for course restrictions, user permissions, and prerequisites.",
        "interactions": {
          "interaction_0": "Communicates with `Xikolo.api(:course)` (specifically `Xikolo::CourseService`) for enrollment creation, retrieval, and deletion.",
          "interaction_1": "Checks `current_user.allowed?('course.content.access')` for invite-only courses.",
          "interaction_2": "Handles `Restify::UnprocessableEntity` exceptions for various enrollment restrictions (e.g., access restricted, prerequisites unfulfilled).",
          "interaction_3": "Redirects to `course_resume_path`, `course_path`, or `dashboard_path` based on action outcome."
        },
        "techDebt": [],
        "provenance": {
          "sources": [
            "app/controllers/course/enrollments_controller.rb"
          ]
        },
        "codeImplementation": {
          "confidence": 0.95,
          "codeBlocks": [
            {
              "startLine": 3,
              "endLine": 7,
              "code": "class EnrollmentsController < ApplicationController\n  responders Responders::ApiResponder,\n    Responders::DecorateResponder,\n    Responders::HttpCacheResponder,\n    Responders::PaginateResponder",
              "source": "app/controllers/portal_api/enrollments_controller.rb"
            },
            {
              "startLine": 9,
              "endLine": 9,
              "code": "  respond_to :json",
              "source": "app/controllers/portal_api/enrollments_controller.rb"
            },
            {
              "startLine": 12,
              "endLine": 21,
              "code": "  rfc6570_params index: %i[\n    course_id\n    user_id\n    learning_evaluation\n    deleted\n    current_course\n    per_page\n    proctored\n  ]",
              "source": "app/controllers/portal_api/enrollments_controller.rb"
            },
            {
              "startLine": 22,
              "endLine": 41,
              "code": "  def index\n    enrollments = Enrollment.all\n\n    # eliminate enrollments from deleted courses\n    enrollments = enrollments.left_joins(:course).where({courses: {deleted: false}})\n\n    enrollments = enrollments.active unless params[:deleted] == 'true'\n\n    if params[:course_id].present?\n      enrollments.where! course_id: course.id\n    end\n\n    enrollments.where! user_id: params[:user_id] if params[:user_id].present?\n\n    if params[:proctored].present?\n      enrollments.where! proctored: params[:proctored]\n    end\n\n    if params[:completed].present?\n    ...",
              "source": "app/controllers/portal_api/enrollments_controller.rb"
            }
          ],
          "sourceFiles": [
            {
              "path": "app/controllers/portal_api/enrollments_controller.rb",
              "relevance": 28
            },
            {
              "path": "services/course/app/controllers/enrollments_controller.rb",
              "relevance": 27
            },
            {
              "path": "app/controllers/admin/ajax/courses_controller.rb",
              "relevance": 12
            }
          ]
        }
      },
      "Course::LaunchController": {
        "type": "Controller",
        "description": "Manages the initial launch flow for a course, redirecting users to enrollment or login based on their authentication status.",
        "interactions": {
          "interaction_0": "Fetches course details from `Xikolo.api(:course)`.",
          "interaction_1": "Redirects to `create_enrollment_path` if authenticated.",
          "interaction_2": "Redirects to `login_url` if anonymous and no `auth` parameter is present.",
          "interaction_3": "Stores the intended course location for post-login redirection."
        },
        "techDebt": [],
        "provenance": {
          "sources": [
            "app/controllers/course/launch_controller.rb"
          ]
        }
      },
      "Course::FreeReactivationsController": {
        "type": "Controller",
        "description": "Allows users to reactivate courses for which they have a 'free reactivation' prerequisite. It interacts with the `Xikolo::CourseService` to verify eligibility and perform the reactivation.",
        "interactions": {
          "interaction_0": "Communicates with `Xikolo.api(:course)` to fetch prerequisite status and post reactivation requests.",
          "interaction_1": "Uses `CourseReactivation.config('period')` to determine the duration of the reactivation period.",
          "interaction_2": "Handles `Restify::UnprocessableEntity` for failed reactivation attempts."
        },
        "techDebt": [],
        "provenance": {
          "sources": [
            "app/controllers/course/free_reactivations_controller.rb"
          ]
        }
      },
      "Course::ProgressController": {
        "type": "Controller",
        "description": "Displays the progress of a user within a specific course. It can show progress for the `current_user` or, with appropriate permissions, for other users.",
        "interactions": {
          "interaction_0": "Uses `CourseContextHelper` to establish the course context.",
          "interaction_1": "Fetches user details from `Xikolo::Account::User` if an admin is viewing another user's progress.",
          "interaction_2": "Instantiates `Course::DocumentsPresenter` and uses `Acfs.run` to fetch course documents.",
          "interaction_3": "Communicates with `Xikolo.api(:course)` to retrieve course progress data.",
          "interaction_4": "Sets the page title using `set_page_title`."
        },
        "techDebt": [
          "The `current_user` is passed to `Course::DocumentsPresenter` to check for features, even when an admin is monitoring another user's progress. This indicates a potential design flaw or area for refactoring the user object interface. [Source: app/controllers/course/progress_controller.rb]"
        ],
        "provenance": {
          "sources": [
            "app/controllers/course/progress_controller.rb"
          ]
        }
      },
      "Course::SyllabusController": {
        "type": "Controller",
        "description": "Displays the course syllabus and an overview of course progress. Overrides standard course eligibility checks to support 'open mode' for previewable content.",
        "interactions": {
          "interaction_0": "Uses `CourseContextHelper` for course context.",
          "interaction_1": "Loads section navigation (`load_section_nav`).",
          "interaction_2": "Uses `Course::ProgressPresenter` to build progress data.",
          "interaction_3": "Interacts with `Xikolo.api(:course)` to fetch previewable items for open mode."
        },
        "techDebt": [],
        "provenance": {
          "sources": [
            "app/controllers/course/syllabus_controller.rb",
            "app/helpers/course_context_helper.rb"
          ]
        }
      },
      "CourseContextHelper": {
        "type": "Helper",
        "description": "Provides common functionality and lifecycle hooks for course-related controllers. Defines `inside_course` to set layout and enforce course eligibility checks.",
        "interactions": {
          "interaction_0": "Defines `inside_course` which calls `layout` and `before_action :check_course_eligibility`.",
          "interaction_1": "The `check_course_eligibility` method checks user permissions, course availability, and enrollment status.",
          "interaction_2": "Provides `the_course`, `the_section`, `the_item` promises for lazy loading resources.",
          "interaction_3": "Loads section navigation using `Navigation::TableOfContents`."
        },
        "techDebt": [
          "TODO: improve checks in `check_course_eligibility`."
        ],
        "provenance": {
          "sources": [
            "app/helpers/course_context_helper.rb",
            "docs/app/development/implementation/helper_inside_course.md"
          ]
        },
        "codeImplementation": {
          "confidence": 0.95,
          "codeBlocks": [
            {
              "startLine": 4,
              "endLine": 6,
              "code": "  def course_layout     @course_layout ||= Course::LayoutPresenter.new(the_course, current_user)   end",
              "source": "app/helpers/course_context_helper.rb"
            },
            {
              "startLine": 8,
              "endLine": 13,
              "code": "  def the_table_of_content     if promises.key? :table_of_content       promises[:table_of_content]     else       raise 'Table of content not loaded!'     end   end",
              "source": "app/helpers/course_context_helper.rb"
            },
            {
              "startLine": 15,
              "endLine": 28,
              "code": "  def self.included(base_controller)     # for some reason some other module seems to want to include this     return unless base_controller.respond_to? :before_action      base_controller.helper_method :course_layout     base_controller.helper_method :hide_course_nav?      class << base_controller       def inside_course(**)         layout('course_area', **)         before_action(:check_course_eligibility, **)       end     end   end",
              "source": "app/helpers/course_context_helper.rb"
            },
            {
              "startLine": 30,
              "endLine": 36,
              "code": "  def check_course_eligibility     return if current_user.allowed?('course.content.access')      # TODO: improve checks     if !the_course.was_available?       unless the_course.published?         Rails.logger.debug 'NOT FOUND: cou...",
              "source": "app/helpers/course_context_helper.rb"
            }
          ],
          "sourceFiles": [
            {
              "path": "app/helpers/course_context_helper.rb",
              "relevance": 19
            }
          ]
        }
      },
      "ItemContextHelper": {
        "type": "Helper",
        "description": "Provides common functionality and lifecycle hooks for course item-related controllers. Defines `inside_item` to set layout, load navigation, and create presenters.",
        "interactions": {
          "interaction_0": "Defines `inside_item` which calls `layout`, `before_action :load_section_nav`, `before_action :create_position_presenter!`, `before_action :create_item_presenter!`, and `before_action :check_course_path`.",
          "interaction_1": "Creates `Course::PositionPresenter` and `ItemPresenter` instances.",
          "interaction_2": "Records user visits to items via `Xikolo::Course::Visit.create`."
        },
        "techDebt": [],
        "provenance": {
          "sources": [
            "app/helpers/item_context_helper.rb",
            "docs/app/development/implementation/helper_inside_course.md"
          ]
        },
        "codeImplementation": {
          "confidence": 0.95,
          "codeBlocks": [
            {
              "startLine": 4,
              "endLine": 19,
              "code": "module ItemContextHelper   def self.included(base_controller)     # for some reason some other module seems to want to include this     return unless base_controller.respond_to? :before_action      # disabled when_course_loaded would be called to early     # (would try to access user):     class << base_controller       def inside_item(**)         layout('course_area_two_cols', **)         before_action(:load_section_nav, **)         before_action(:create_position_presenter!, **)         before_action(:create_item_presenter!, **)         before_action(:check_course_path, **)       end     end   end",
              "source": "app/helpers/item_context_helper.rb"
            },
            {
              "startLine": 23,
              "endLine": 30,
              "code": "  def check_course_path     # Ensure that the requested item belongs to the given course     Acfs.on the_course do |course|       if the_section.value!['course_id'] != course.id         raise Status::NotFound       end     end   end",
              "source": "app/helpers/item_context_helper.rb"
            },
            {
              "startLine": 32,
              "endLine": 35,
              "code": "  def create_position_presenter!     Acfs.on the_course do |course|       @inner_course_position = Course::PositionPr...   end",
              "source": "app/helpers/item_context_helper.rb"
            }
          ],
          "sourceFiles": [
            {
              "path": "app/helpers/item_context_helper.rb",
              "relevance": 19
            }
          ]
        }
      },
      "DocumentHelper": {
        "type": "Helper",
        "description": "Provides helper methods for managing course documents and their localizations, including creation, updates, and deletions. Handles file uploads to S3.",
        "interactions": {
          "interaction_0": "Interacts with `Xikolo.api(:course)` (CourseService) for document and localization CRUD operations.",
          "interaction_1": "Uses `FileUpload` for S3 uploads of document files.",
          "interaction_2": "Handles error messages for document creation."
        },
        "techDebt": [
          "TODO: Get rid of `Rails/HelperInstanceVariable`."
        ],
        "provenance": {
          "sources": [
            "app/helpers/document_helper.rb"
          ]
        },
        "codeImplementation": {
          "confidence": 0.95,
          "codeBlocks": [
            {
              "startLine": 5,
              "endLine": 5,
              "code": "module DocumentHelper",
              "source": "app/helpers/document_helper.rb"
            },
            {
              "startLine": 6,
              "endLine": 22,
              "code": "  Document = Struct.new(:title, :description, :tags, :course_ids, :public, :id, :language, :localizations) do\n    include ActiveModel::Validations\n    include ActiveModel::Conversion\n    extend ActiveModel::Naming\n\n    def persisted?\n      true\n    end\n\n    def tag_array\n      tags&.join(',')\n    end\n  end",
              "source": "app/helpers/document_helper.rb"
            },
            {
              "startLine": 24,
              "endLine": 34,
              "code": "  Localization = Struct.new(:title, :description, :file_url, :language, :deleted, :document_id, :id) do\n    include ActiveModel::Validations\n    include ActiveModel::Conversion\n    extend ActiveModel::Naming\n\n    def persisted?\n      true\n    end\n  end",
              "source": "app/helpers/document_helper.rb"
            },
            {
              "startLine": 36,
              "endLine": 43,
              "code": "  def add_localization(document = nil)\n    document ||= Xikolo.api(:course).value!.rel(:document).get({\n      id: params[:document_id],\n    }).value!\n    document.rel(:localizations).post(create_localization_params).value!\n    redirect_to documents_path\n  end",
              "source": "app/helpers/document_helper.rb"
            },
            {
              "startLine": 45,
              "endLine": 46,
              "code": "  def update_localization\n    update_params =...",
              "source": "app/helpers/document_helper.rb"
            }
          ],
          "sourceFiles": [
            {
              "path": "app/helpers/document_helper.rb",
              "relevance": 19
            }
          ]
        }
      },
      "ProgressHelper": {
        "type": "Helper",
        "description": "Provides a utility method `calc_progress` to calculate a percentage progress, ensuring it's capped at 100% and handles edge cases like zero total points.",
        "interactions": {
          "interaction_0": "Used by views or other components to display calculated progress percentages."
        },
        "techDebt": [],
        "provenance": {
          "sources": [
            "app/helpers/progress_helper.rb"
          ]
        },
        "codeImplementation": {
          "confidence": 0.95,
          "codeBlocks": [
            {
              "startLine": 1,
              "endLine": 10,
              "code": "# frozen_string_literal: true\n\nmodule ProgressHelper\n  def calc_progress(user_points, total_points)\n    return 0 if user_points.blank? || total_points.blank?\n\n    if total_points.zero?\n      0\n    else\n      [user_points.fdiv(total_points) * 100, 100].min.floor\n    end\n  end\nend",
              "source": "app/helpers/progress_helper.rb"
            }
          ],
          "sourceFiles": [
            {
              "path": "app/helpers/progress_helper.rb",
              "relevance": 19
            },
            {
              "path": "spec/helpers/progress_helper_spec.rb",
              "relevance": 19
            }
          ]
        }
      },
      "Course::Metadata::Store": {
        "type": "Operation",
        "description": "Handles the storage and validation of course metadata, particularly for skills, educational alignment, and licenses, by processing S3 file uploads.",
        "interactions": {
          "interaction_0": "Interacts with `Xikolo::S3::SingleFileUpload` to manage uploaded files.",
          "interaction_1": "Parses and validates JSON data from uploaded files against a schema.",
          "interaction_2": "Persists metadata to the `Metadata` ActiveRecord model within a transaction.",
          "interaction_3": "Captures errors with `Mnemosyne` and `Sentry`."
        },
        "techDebt": [],
        "provenance": {
          "sources": [
            "app/operations/course/metadata/store.rb"
          ]
        },
        "codeImplementation": {
          "confidence": 0.95,
          "codeBlocks": [
            {
              "startLine": 1,
              "endLine": 15,
              "code": "# frozen_string_literal: true\n\nmodule Course\n  class Metadata\n    class Store < ApplicationOperation\n      def initialize(metadata, params)\n        super()\n\n        @metadata = metadata\n        @params = params\n        @metadata_types = [\n          Metadata::TYPE::SKILLS,\n          Metadata::TYPE::EDUCATIONAL_ALIGNMENT,\n          Metadata::TYPE::LICENSE,\n        ]\n      end",
              "source": "app/operations/course/metadata/store.rb"
            },
            {
              "startLine": 17,
              "endLine": 28,
              "code": "      Success = Struct.new(:metadata)\n      Error = Struct.new(:metadata)\n\n      def call\n        @metadata_types.each do |metadata_type|\n          process_upload(metadata_type, @params.fetch(:%\"#{metadata_type}_upload_id\", nil))\n        end\n\n        if @metadata.errors.any?\n          return result Error.new(@metadata)\n        end\n\n        result Success.new(@metadata)\n      end",
              "source": "app/operations/course/metadata/store.rb"
            },
            {
              "startLine": 30,
              "endLine": 41,
              "code": "      def process_upload(metadata_type, upload_id)\n        return if upload_id.nil?\n\n        upload = Xikolo::S3::SingleFileUpload.new(\n          upload_id,\n          purpose: 'course_metadata'\n        )\n\n        return if upload.empty?\n\n  ...\n",
              "source": "app/operations/course/metadata/store.rb"
            }
          ],
          "sourceFiles": [
            {
              "path": "app/operations/course/metadata/store.rb",
              "relevance": 44
            },
            {
              "path": "app/operations/course/richtext/store.rb",
              "relevance": 37
            },
            {
              "path": "app/operations/course/visual/store.rb",
              "relevance": 37
            }
          ]
        }
      },
      "Course::Richtext::Store": {
        "type": "Operation",
        "description": "Processes and stores rich text content for course items, including handling embedded file uploads to S3 and managing file references.",
        "interactions": {
          "interaction_0": "Uses `Xikolo::S3::TextWithUploadsProcessor` to parse and manage text with embedded uploads.",
          "interaction_1": "Interacts with `S3FileDeletionJob` for asynchronous deletion of obsolete S3 files.",
          "interaction_2": "Persists rich text content to the `Course::Richtext` model."
        },
        "techDebt": [],
        "provenance": {
          "sources": [
            "app/operations/course/richtext/store.rb"
          ]
        },
        "codeImplementation": {
          "confidence": 0.95,
          "codeBlocks": [
            {
              "startLine": 6,
              "endLine": 11,
              "code": "      def initialize(richtext, params)\n        super()\n\n        @richtext = richtext\n        @params = params\n      end",
              "source": "app/operations/course/richtext/store.rb"
            },
            {
              "startLine": 13,
              "endLine": 29,
              "code": "      def call\n        if @params[:text].blank?\n          @richtext.errors.add :text, :blank\n        else\n          text = @params.delete(:text)\n          @richtext.assign_attributes @params\n          configure_processor! text\n          process_text\n        end\n        if @richtext.errors.blank? && @richtext.save\n          remove_replaced_files!\n        else\n          @processor&.rollback!\n        end\n        @richtext\n      end",
              "source": "app/operations/course/richtext/store.rb"
            },
            {
              "startLine": 33,
              "endLine": 43,
              "code": "      def configure_processor!(text)\n        @processor = Xikolo::S3::TextWithUploadsProcessor.new \\\n          bucket: :course,\n          purpose: 'course_richtext',\n          current: @richtext.text,\n          text:,\n          valid_refs: @richtext.text&.file_refs || []\n        @processor.on_new do |upload|\n          cid = UUI...\n",
              "source": "app/operations/course/richtext/store.rb"
            },
            {
              "startLine": 45,
              "endLine": 49,
              "code": "      def process_text\n        @richtext.text = @processor.process!\n        @processor.added_files.each { |upload| add_file_to_richtext!(upload) }\n      end",
              "source": "app/operations/course/richtext/store.rb"
            },
            {
              "startLine": 51,
              "endLine": 55,
              "code": "      def remove_replaced_files!\n        @processor.removed_files.each do |upload|\n          @richtext.richtext_files.find_by(content_id: upload.content_id)&.destroy!\n        end\n      end",
              "source": "app/operations/course/richtext/store.rb"
            },
            {
              "startLine": 57,
              "endLine": 60,
              "code": "      def add_file_to_richtext!(upload)\n        @richtext.richtext_files.create! upload_id: upload.upload_id,\n                                          content_id: upload.content_id,\n                                          filename: upload.filename\n      end",
              "source": "app/operations/course/richtext/store.rb"
            }
          ],
          "sourceFiles": [
            {
              "path": "app/operations/course/richtext/store.rb",
              "relevance": 44
            },
            {
              "path": "app/operations/course/metadata/store.rb",
              "relevance": 37
            },
            {
              "path": "app/operations/course/visual/store.rb",
              "relevance": 37
            }
          ]
        }
      },
      "Course::Visual::Store": {
        "type": "Operation",
        "description": "Manages the storage of course visuals (images) and teaser videos, including associated subtitles. Handles S3 uploads and updates to the `Course::Visual` and `Video::Video` models.",
        "interactions": {
          "interaction_0": "Interacts with `Xikolo::S3::SingleFileUpload` and `Xikolo::S3::UploadByUri` for S3 file management.",
          "interaction_1": "Persists visual data to `Course::Visual` and video data to `Video::Video`.",
          "interaction_2": "Uses `S3FileDeletionJob` for asynchronous deletion of old S3 files.",
          "interaction_3": "Captures errors with `Mnemosyne`."
        },
        "techDebt": [
          "TODO: Improve generic error handling for more helpful inline messages."
        ],
        "provenance": {
          "sources": [
            "app/operations/course/visual/store.rb"
          ]
        },
        "codeImplementation": {
          "confidence": 0.95,
          "codeBlocks": [
            {
              "startLine": 1,
              "endLine": 30,
              "code": "# frozen_string_literal: true\n\nmodule Course\n  class Visual\n    class Store < ApplicationOperation\n      class OperationError < StandardError; end\n\n      # @param visual [Course::Visual]\n      # @param params [Hash] a hash of params (with symbol keys!)\n      def initialize(visual, params)\n        super()\n\n        @visual = visual\n        @params = params\n\n        @upload_errors = {}\n        @new_uris = []\n      end\n\n      Success = Struct.new(:message)\n      Error = Struct.new(:message)\n\n      def call\n        begin\n          ActiveRecord::Base.transaction do\n            ##\n            # 1. Process the visual image upload and handle possible errors.\n            # If the provided value is `nil`, e.g. because the image is removed,\n            # the upload actions will be skipped(see the implementation).\n            if @params.key?(:image_uri)\n              upload_via_uri('image', @params[:image_uri], 'course_course_image')\n              # Please note: Deleting replaced or removed (S3) im...",
              "source": "app/operations/course/visual/store.rb"
            }
          ],
          "sourceFiles": [
            {
              "path": "app/operations/course/visual/store.rb",
              "relevance": 44
            },
            {
              "path": "app/operations/course/metadata/store.rb",
              "relevance": 37
            },
            {
              "path": "app/operations/course/richtext/store.rb",
              "relevance": 37
            }
          ]
        }
      },
      "Item::Create": {
        "type": "Operation",
        "description": "Orchestrates the creation of a course item and its associated content resource (e.g., video, rich text, quiz). Ensures content validity and handles rollback if item creation fails.",
        "interactions": {
          "interaction_0": "Validates and saves the content resource (`@content`).",
          "interaction_1": "Sets `content_id` and `section_id` on the item.",
          "interaction_2": "Saves the item resource (`@item`).",
          "interaction_3": "Creates `Xikolo::Pinboard::ImplicitTag` for the new item.",
          "interaction_4": "Handles `Restify::ClientError`, `Acfs::InvalidResource`, and `Acfs::ErroneousResponse` for content and item creation."
        },
        "techDebt": [],
        "provenance": {
          "sources": [
            "app/operations/item/create.rb"
          ]
        },
        "codeImplementation": {
          "confidence": 0.95,
          "codeBlocks": [
            {
              "startLine": 4,
              "endLine": 31,
              "code": "      class CreateComment < Gamification::Rules::Base\n        def create_score!\n          # Do not award points for comments in the \"Technical issues\" sections\n          return if @payload.fetch(:technical)\n\n          super\n        end\n\n        private\n\n        def name\n          :create_comment\n        end\n\n        def checksum\n          @payload.fetch :id\n        end\n\n        def data\n          {comment_id: @payload.fetch(:id)}\n        end\n\n        def required_keys\n          %i[course_id id user_id]\n        end\n      end",
              "source": "app/models/gamification/rules/pinboard/create_comment.rb"
            },
            {
              "startLine": 4,
              "endLine": 31,
              "code": "      class CreateQuestion < Gamification::Rules::Base\n        def create_score!\n          # Do not award points for questions in the \"Technical issues\" sections\n          return if @payload.fetch(:technical)\n\n          super\n        end\n\n        private\n\n        def name\n          :create_question\n        end\n\n        def checksum\n          @payload.fetch :id\n        end\n\n        def data\n          {question_id: @payload.fetch(:id)}\n        end\n\n        def required_keys\n          %i[course_id id user_id]\n        end\n      end",
              "source": "app/models/gamification/rules/pinboard/create_comment.rb"
            },
            {
              "startLine": 4,
              "endLine": 14,
              "code": "  def change\n    create_table :content_tests, id: :uuid do |t|\n      t.uuid :course_id\n      t.uuid :groups, array: true, default: []\n\n      t.timestamps\n    end\n\n    add_foreign_key :content_tests, :courses\n  end",
              "source": "app/models/gamification/rules/pinboard/create_comment.rb"
            }
          ],
          "sourceFiles": [
            {
              "path": "app/models/gamification/rules/pinboard/create_comment.rb",
              "relevance": 30
            },
            {
              "path": "app/models/gamification/rules/pinboard/create_question.rb",
              "relevance": 30
            },
            {
              "path": "db/migrate/20211012081627_create_content_tests.rb",
              "relevance": 30
            }
          ]
        }
      },
      "Home::CourseCard": {
        "type": "ViewComponent",
        "description": "A UI component for displaying a course card on the homepage or course lists. It shows course details, visuals, dates, and actions.",
        "interactions": {
          "interaction_0": "Receives `course`, `enrollment`, `user`, and `type` as initialization parameters.",
          "interaction_1": "Renders actions and conditional buttons based on user features (e.g., `course_reactivation`).",
          "interaction_2": "Uses `Imagecrop` for visual resizing and `Xikolo::S3` for course visuals.",
          "interaction_3": "Fetches `Course::Cluster` data for classifiers.",
          "interaction_4": "Determines subtitle information from `Course::Course`."
        },
        "techDebt": [],
        "provenance": {
          "sources": [
            "app/components/home/course_card.rb"
          ]
        },
        "codeImplementation": {
          "confidence": 0.95,
          "codeBlocks": [
            {
              "startLine": 1,
              "endLine": 46,
              "code": "# frozen_string_literal: true\n\nmodule Home\n  class CourseCard < ApplicationComponent\n    def initialize(course, enrollment: nil, user: nil, type: nil)\n      @course = course\n      @enrollment = enrollment\n      @user = user\n      @type = type\n    end\n\n    renders_many :actions\n\n    private\n\n    def card_type\n      if %w[expandable compact].include? @type\n        @type\n      else\n        'expandable'\n      end\n    end\n\n    def compact_card?\n      card_type == 'compact'\n    end\n\n    def css_modifiers\n      card_type\n    end\n\n    def data_attributes\n      card_type == 'expandable' ? {behavior: 'expandable'} : {}\n    end\n\n    def actions_dropdown?\n      actions.present? || (compact_card? && show_reactivation_button?)\n    end\n\n    def show_additional_buttons?\n      @user.present?\n    end\n\n    def show_reactivation_button?\n      @user&.feature?('course_reactivation') &&\n        CourseReactivation.enabled? &&\n        !@enrollment&.reactivated? &&\n        @course.reactivation_possible?\n    end",
              "source": "app/components/home/course_card.rb"
            },
            {
              "startLine": 1,
              "endLine": 27,
              "code": "# frozen_string_literal: true\n\nmodule Home\n  # @label Course cards\n  class CourseCardPreview < ViewComponent::Preview\n    # Needed for previews with course reactivation button\n    Xikolo.config.voucher['enabled'] = true\n\n    # Appears collapsed on default, expands on hover.\n    #\n    # Contains basic metadata of a course in collapsed state.\n    # In the hovered state it includes teachers, course abstract and action buttons.\n    #\n    # @label Expandable\n    def expandable\n      render Home::CourseCard.new(active_course)\n    end\n\n    # Passing an enrollment object for the user has effects on the available buttons\n    #\n    # @label Expandable with enrolled user\n    def expandable_with_enrolled_user\n      render Home::CourseCard.new(ended_course_with_reactivation, user: registered_user, enrollment:)\n    end\n\n    # A card with actions moves the 'Details' button in a dropdown where more links can be added\n    #\n    # @label With actions\n    def with_actions\n      render Home::CourseCard.ne...",
              "source": "app/components/home/course_card.rb"
            }
          ],
          "sourceFiles": [
            {
              "path": "app/components/home/course_card.rb",
              "relevance": 26
            },
            {
              "path": "app/components/home/course_card_preview.rb",
              "relevance": 26
            },
            {
              "path": "app/components/home/category.rb",
              "relevance": 7
            }
          ]
        }
      },
      "Navigation::CoursesMenu": {
        "type": "ViewComponent",
        "description": "A UI component for the main navigation menu that displays a list of current, upcoming, and archived courses. It's only rendered if the `course_list` feature is enabled for the user.",
        "interactions": {
          "interaction_0": "Fetches course data from `Catalog::Course` (released, for global list, for guests).",
          "interaction_1": "Caches course lists for 30 minutes.",
          "interaction_2": "Checks `user.feature?('course_list')` to determine rendering."
        },
        "techDebt": [],
        "provenance": {
          "sources": [
            "app/components/navigation/courses_menu.rb"
          ]
        },
        "codeImplementation": {
          "confidence": 0.95,
          "codeBlocks": [
            {
              "startLine": 4,
              "endLine": 6,
              "code": "    def initialize(user:)\n      @user = user\n    end",
              "source": "app/components/navigation/courses_menu.rb"
            },
            {
              "startLine": 10,
              "endLine": 12,
              "code": "    def render?\n      @user.feature?('course_list')\n    end",
              "source": "app/components/navigation/courses_menu.rb"
            },
            {
              "startLine": 15,
              "endLine": 22,
              "code": "    def courses\n      Rails.cache.fetch(\n        'nav/courses_megamenu',\n        expires_in: 30.minutes\n      ) do\n        load_courses\n      end\n    end",
              "source": "app/components/navigation/courses_menu.rb"
            },
            {
              "startLine": 24,
              "endLine": 34,
              "code": "    def load_courses\n      Catalog::Course.released.for_global_list.for_guests.then do |courses|\n        {\n          current: courses.current.limit(5),\n          upcoming: courses.upcoming.limit(5),\n          archive: courses.self_paced.limit(5),\n        }.delete_if {|_, crs| crs.load.empty? }.transform_values do |crs|\n          crs.pluck(:course_code, :title).map {|c| {'course_code' => c[0], 'title' => c[1]} }\n        end\n      end\n    end",
              "source": "app/components/navigation/courses_menu.rb"
            }
          ],
          "sourceFiles": [
            {
              "path": "app/components/navigation/courses_menu.rb",
              "relevance": 26
            },
            {
              "path": "app/components/dashboard/navigation.rb",
              "relevance": 7
            },
            {
              "path": "app/components/navigation/bar.rb",
              "relevance": 7
            }
          ]
        }
      },
      "BasicCoursePresenter": {
        "type": "Presenter",
        "description": "A basic presenter for course information, providing common attributes and methods related to course identity, certificates, and proctoring status.",
        "interactions": {
          "interaction_0": "Wraps a course hash (`@course`).",
          "interaction_1": "Checks for `Certificate::Template` and `Certificate::OpenBadgeTemplate` existence for certificate availability."
        },
        "techDebt": [],
        "provenance": {
          "sources": [
            "app/presenters/basic_course_presenter.rb"
          ]
        },
        "codeImplementation": {
          "confidence": 0.95,
          "codeBlocks": [
            {
              "startLine": 1,
              "endLine": 45,
              "code": "# frozen_string_literal: true\n\nclass BasicCoursePresenter\n  def initialize(course)\n    @course = course\n  end\n\n  def id\n    @course['id']\n  end\n\n  def title\n    @course['title']\n  end\n\n  def course_code\n    @course['course_code']\n  end\n\n  def stage_visual_url\n    @course['stage_visual_url']\n  end\n\n  def visual_url\n    @course['visual_url']\n  end\n\n  def roa_enabled?\n    @course['roa_enabled']\n  end\n\n  def cop_enabled?\n    @course['cop_enabled']\n  end\n\n  def tor_enabled?\n    Xikolo.config.certificate['transcript_of_records'].present?\n  end\n\n  def tor_available?\n    tor_enabled? && tor_template?\n  end\n\n  def roa_threshold_percentage\n    @course['roa_threshold_percentage']\n  end\n\n  def cop_threshold_percentage\n    @course['cop_threshold_percentage']\n  end\n\n  def proctored?\n    @course['proctored']\n  end\n\n  def certificates_enabled?\n    roa_enabled? || cop_enabled? || tor_available?\n  end\n\n  def open_badge_enabled?\n    certificates_enabled? && open_badge_template?\n  end\n\n  def certificates_...",
              "source": "app/presenters/basic_course_presenter.rb"
            }
          ],
          "sourceFiles": [
            {
              "path": "app/presenters/basic_course_presenter.rb",
              "relevance": 24
            },
            {
              "path": "app/presenters/abuse_report_presenter.rb",
              "relevance": 5
            },
            {
              "path": "app/presenters/account/policy_presenter.rb",
              "relevance": 5
            }
          ]
        }
      },
      "CourseInfoPresenter": {
        "type": "Presenter",
        "description": "Presents detailed course information for public display, including abstract, description, dates, classifiers, and enrollment status. It handles markdown rendering and external URLs.",
        "interactions": {
          "interaction_0": "Delegates attributes to the `@course` object (Restify resource).",
          "interaction_1": "Renders markdown for abstract and description.",
          "interaction_2": "Determines `date_label` based on start/end dates.",
          "interaction_3": "Checks `user.feature?` for `course_details.learning_goals`, `course_reactivation`, `certificate_requirements`, `course_rating`.",
          "interaction_4": "Interacts with `Course::Visual` for visual URLs.",
          "interaction_5": "Uses `BasicCoursePresenter` for shared certificate logic."
        },
        "techDebt": [],
        "provenance": {
          "sources": [
            "app/presenters/course_info_presenter.rb"
          ]
        },
        "codeImplementation": {
          "confidence": 0.95,
          "codeBlocks": [
            {
              "startLine": 3,
              "endLine": 6,
              "code": "class CourseInfoPresenter < PrivatePresenter\n  include Rails.application.routes.url_helpers\n  include ActionView::Helpers::AssetUrlHelper\n  include MarkdownHelper",
              "source": "app/presenters/course_info_presenter.rb"
            },
            {
              "startLine": 8,
              "endLine": 26,
              "code": "  def_restify_delegators :@course, :id,\n    :course_code,\n    :title,\n    :abstract,\n    :available?,\n    :was_available?,\n    :lang,\n    :classifiers,\n    :alternative_teacher_text,\n    :external_course_url,\n    :hidden,\n    :fullstate,\n    :pinboard_enabled,\n    :rating_stars,\n    :rating_votes,\n    :proctored,\n    :learning_goals,\n    :target_groups",
              "source": "app/presenters/course_info_presenter.rb"
            },
            {
              "startLine": 28,
              "endLine": 30,
              "code": "  def self.build(course, user, enrollments = nil)\n    new(course:, user:, enrollments:)\n  end",
              "source": "app/presenters/course_info_presenter.rb"
            },
            {
              "startLine": 32,
              "endLine": 35,
              "code": "  def start_date\n    return if @course['start_date'].blank?\n\n    ::DateTime.iso8601 @course['start_date']\n  }",
              "source": "app/presenters/course_info_presenter.rb"
            }
          ],
          "sourceFiles": [
            {
              "path": "app/presenters/course_info_presenter.rb",
              "relevance": 24
            },
            {
              "path": "app/presenters/abuse_report_presenter.rb",
              "relevance": 5
            },
            {
              "path": "app/presenters/account/policy_presenter.rb",
              "relevance": 5
            }
          ]
        }
      },
      "CourseLargePreviewPresenter": {
        "type": "Presenter",
        "description": "Extends `CourseInfoPresenter` to provide additional information relevant for a large course preview, including teaser video, unenrollment options, and proctoring context.",
        "interactions": {
          "interaction_0": "Initializes a `VideoPresenter` if a teaser video exists.",
          "interaction_1": "Determines `unenrollment_enabled?` based on `invite_only` and `external_registration_url`.",
          "interaction_2": "Initializes `Proctoring::CourseContext` for proctoring status.",
          "interaction_3": "Checks `user.feature?('proctoring')`."
        },
        "techDebt": [],
        "provenance": {
          "sources": [
            "app/presenters/course_large_preview_presenter.rb"
          ]
        },
        "codeImplementation": {
          "confidence": 0.95,
          "codeBlocks": [
            {
              "startLine": 1,
              "endLine": 32,
              "code": "# frozen_string_literal: true\n\nclass CourseLargePreviewPresenter < CourseInfoPresenter\n  attr_reader :video\n\n  def self.build(course, user, enrollments = nil)\n    new(course:, user:, enrollments:).tap(&:video!)\n  end\n\n  def video!\n    return unless visual&.video\n\n    @video = VideoPresenter.new(\n      video: visual.video,\n      user: @user\n    )\n  end\n\n  def unenrollment_enabled?\n    # unenrollment is enabled for non-invite-only courses\n    return true unless @course.invite_only\n\n    # unenrollment is disabled if the course is invite-only\n    # and has an external_registration_url\n    @course.external_registration_url.blank?\n  end\n\n  def access_allowed?\n    # is always visible if user is allowed to preview content\n    return true if @user.allowed? 'course.content.access'\n    # is always hidden if user is not logged in\n    return false if @user.anonymous?\n\n    # hide course nav for upcoming courses\n    @course.was_available? && @course.external_course_url.blank?\n  end\n\n  def proctoring_...",
              "source": "app/presenters/course_large_preview_presenter.rb"
            }
          ],
          "sourceFiles": [
            {
              "path": "app/presenters/course_large_preview_presenter.rb",
              "relevance": 24
            },
            {
              "path": "app/presenters/abuse_report_presenter.rb",
              "relevance": 5
            },
            {
              "path": "app/presenters/account/policy_presenter.rb",
              "relevance": 5
            }
          ]
        }
      },
      "CourseNav": {
        "type": "Presenter",
        "description": "Defines the navigation menu items for learners within a course, including links to sections, discussions, progress, certificates, and announcements.",
        "interactions": {
          "interaction_0": "Uses `MenuWithPermissions` for permission-based item visibility.",
          "interaction_1": "Checks `course.pinboard_enabled` and `Xikolo.config.beta_features['documents']` for item visibility.",
          "interaction_2": "Determines active state based on controller name."
        },
        "techDebt": [
          "FIXME: `user.feature?('quiz_recap') && course.was_available?` should not use `was_available?` for quiz recap."
        ],
        "provenance": {
          "sources": [
            "app/presenters/course_nav.rb"
          ]
        },
        "codeImplementation": {
          "confidence": 0.95,
          "codeBlocks": [
            {
              "startLine": 1,
              "endLine": 35,
              "code": "# frozen_string_literal: true\n\nclass CourseNav < MenuWithPermissions\n  # Learnings\n  item 'courses.nav.sections', 'lamp-desk',\n    active: lambda {|request|\n      controller_name = request.filtered_parameters['controller']\n      %w[items quiz_submission].include?(controller_name)\n    },\n    route: :course_resume\n\n  # Pinboard\n  item 'courses.nav.discussions', 'comments',\n    if: ->(_user, course) { course.pinboard_enabled },\n    active: lambda {|request|\n      controller_name = request.filtered_parameters['controller']\n      pinboard_controller = %w[pinboard question answer pinboard_comment].include? controller_name\n\n      pinboard_controller\n    },\n    route: :course_pinboard_index\n\n  # Progress\n  item 'courses.nav.progress', 'chart-mixed',\n    route: :course_progress\n\n  # Certificates\n  item 'courses.nav.certificates', 'medal',\n    route: :course_certificates\n\n  # Course Details\n  item 'courses.nav.info', 'circle-info',\n    route: :course\n\n  # Documents\n  item 'courses.nav.knowledge_...",
              "source": "app/presenters/course_nav.rb"
            }
          ],
          "sourceFiles": [
            {
              "path": "app/presenters/course_nav.rb",
              "relevance": 19
            }
          ]
        }
      },
      "CoursePresenter": {
        "type": "Presenter",
        "description": "Extends `CourseInfoPresenter` with additional methods for course administration and feed generation, such as classifier titles, item/section collections, and recalculation status.",
        "interactions": {
          "interaction_0": "Delegates attributes to the `@course` object.",
          "interaction_1": "Fetches item and section collections from `Course::Course`.",
          "interaction_2": "Checks `user.allowed?('course.course.recalculate')` and `the_course.needs_recalculation?` for recalculation features."
        },
        "techDebt": [],
        "provenance": {
          "sources": [
            "app/presenters/course_presenter.rb"
          ]
        },
        "codeImplementation": {
          "confidence": 0.95,
          "codeBlocks": [
            {
              "startLine": 1,
              "endLine": 9,
              "code": "# frozen_string_literal: true\n\nclass CoursePresenter < CourseInfoPresenter\n  include ActionView::Helpers::TagHelper\n  include ActionView::Context\n\n  def_delegators :course, :id, :course_code, :classifiers, :lang, :title, :abstract, :forum_is_locked,\n    :start_date, :end_date, :display_start_date, :was_available?, :available?, :status, :hidden,\n    :alternative_teacher_text, :fullstate",
              "source": "app/presenters/course_presenter.rb"
            },
            {
              "startLine": 11,
              "endLine": 22,
              "code": "  attr_accessor :course, :enrollments\n\n  def self.create(course, user, enrollments = nil)\n    new(course:, user:, enrollments:)\n  end\n\n  def self.build_collection(*, **)\n    # This presenter does not use `#build` for mapping attributes, but\n    # `#create`. Therefore, we must build collections with a different\n    # method than the default:\n    super(*, **, &method(:create))\n  end",
              "source": "app/presenters/course_presenter.rb"
            },
            {
              "startLine": 24,
              "endLine": 29,
              "code": "  def classifier_titles\n    course.classifiers\n      .slice('category', 'topic')\n      .flat_map {|_, v| v }\n      .sort\n      .uniq\n  end",
              "source": "app/presenters/course_presenter.rb"
            },
            {
              "startLine": 31,
              "endLine": 31,
              "code": "  def item_collection\n    @item_collection ||= ::Course::Course.find(course.id).secti...",
              "source": "app/presenters/course_presenter.rb"
            }
          ],
          "sourceFiles": [
            {
              "path": "app/presenters/course_presenter.rb",
              "relevance": 24
            },
            {
              "path": "app/presenters/abuse_report_presenter.rb",
              "relevance": 5
            },
            {
              "path": "app/presenters/account/policy_presenter.rb",
              "relevance": 5
            }
          ]
        }
      },
      "CourseTeacherNav": {
        "type": "Presenter",
        "description": "Defines the navigation menu items for teachers within a course, including links to dashboards, content management, settings, enrollments, and grading.",
        "interactions": {
          "interaction_0": "Uses `MenuWithPermissions` for permission-based item visibility.",
          "interaction_1": "Checks `user.allowed?` for various course-related permissions (e.g., `course.dashboard.view`, `course.content.edit`).",
          "interaction_2": "Checks `Xikolo.config.beta_features['teaching_team_pinboard_activity']` and `Transpipe.enabled?` for specific features."
        },
        "techDebt": [],
        "provenance": {
          "sources": [
            "app/presenters/course_teacher_nav.rb"
          ]
        },
        "codeImplementation": {
          "confidence": 0.95,
          "codeBlocks": [
            {
              "startLine": 1,
              "endLine": 26,
              "code": "# frozen_string_literal: true\n\nclass CourseTeacherNav < MenuWithPermissions\n  item(\n    'courses.nav.teacher.dashboard', 'chart-mixed',\n    if: ->(user, _course) { user.allowed? 'course.dashboard.view' },\n    route: :course_dashboard\n  ) do\n    item 'courses.nav.teacher.item_visits', '',\n      if: ->(user, _course) { user.allowed? 'course.dashboard.view' },\n      route: :course_statistics_item_visits\n\n    item 'courses.nav.teacher.videos', '',\n      if: ->(user, _course) { user.allowed? 'course.dashboard.view' },\n      route: :course_statistics_videos\n\n    item 'courses.nav.teacher.downloads', '',\n      if: ->(user, _course) { user.allowed? 'course.dashboard.view' },\n      route: :course_statistics_downloads\n\n    item 'courses.nav.teacher.item_details', '',\n      if: ->(user, _course) { user.allowed? 'course.item_stats.show' },\n      route: :course_statistics_item_details\n\n    item 'courses.nav.teacher.forum_stats', '',\n      if: lambda {|user, _course|\n        user.allowed?('course.da...",
              "source": "app/presenters/course_teacher_nav.rb"
            }
          ],
          "sourceFiles": [
            {
              "path": "app/presenters/course_teacher_nav.rb",
              "relevance": 19
            }
          ]
        }
      },
      "DocumentsListPresenter": {
        "type": "Presenter",
        "description": "Presents a list of course documents, including filtering options by language and tags. It also handles pagination information.",
        "interactions": {
          "interaction_0": "Wraps a collection of document resources.",
          "interaction_1": "Extracts unique languages from document localizations.",
          "interaction_2": "Creates `DocumentListFilter` instances for filtering UI.",
          "interaction_3": "Delegates to `DocumentPresenter` for individual document display."
        },
        "techDebt": [],
        "provenance": {
          "sources": [
            "app/presenters/documents_list_presenter.rb"
          ]
        },
        "codeImplementation": {
          "confidence": 0.95,
          "codeBlocks": [
            {
              "startLine": 3,
              "endLine": 3,
              "code": "class DocumentsListPresenter < PrivatePresenter",
              "source": "app/presenters/documents_list_presenter.rb"
            },
            {
              "startLine": 4,
              "endLine": 4,
              "code": "  def_delegators :@documents, :empty?",
              "source": "app/presenters/documents_list_presenter.rb"
            },
            {
              "startLine": 6,
              "endLine": 14,
              "code": "  def self.build(documents, courses, tags, params, helpers)\n    new(\n      documents:,\n      courses:,\n      tags:,\n      params:,\n      helpers:\n    )\n  end",
              "source": "app/presenters/documents_list_presenter.rb"
            },
            {
              "startLine": 16,
              "endLine": 23,
              "code": "  def initialize(*)\n    super\n\n    @languages = @documents.flat_map do |document|\n      document['localizations'].pluck('language')\n    end.uniq\n  end",
              "source": "app/presenters/documents_list_presenter.rb"
            },
            {
              "startLine": 25,
              "endLine": 29,
              "code": "  def each\n    @documents.each do |document|\n      yield DocumentPresenter.new(document:, courses: @courses)\n    end\n  end",
              "source": "app/presenters/documents_list_presenter.rb"
            },
            {
              "startLine": 31,
              "endLine": 33,
              "code": "  def filters?\n    !filters.empty?\n  end",
              "source": "app/presenters/documents_list_presenter.rb"
            },
            {
              "startLine": 35,
              "endLine": 37,
              "code": "  def filtered?\n    !@params.empty?\n  end",
              "source": "app/presenters/documents_list_presenter.rb"
            },
            {
              "startLine": 39,
              "endLine": 41,
              "code": "  def tag_list\n    @tags.to_h {|t| [t, t] }\n  end",
              "source": "app/presenters/documents_list_presenter.rb"
            },
            {
              "startLine": 43,
              "endLine": 45,
              "code": "  def language_list\n    @languages.to_h {|l| [l, l] }\n  end",
              "source": "app/presenters/documents_list_presenter.rb"
            },
            {
              "startLine": 47,
              "endLine": 49,
              "code": "  def total_pages\n    @documents.response.headers['X_TOTAL_PAGES'].to_i\n  end",
              "source": "app/presenters/documents_list_presenter.rb"
            },
            {
              "startLine": 51,
              "endLine": 53,
              "code": "  def current_page\n    @documents.response.headers['X_CURRENT_PAGE'].to_i\n  end",
              "source": "app/presenters/documents_list_presenter.rb"
            },
            {
              "startLine": 55,
              "endLine": 58,
              "code": "  def filters\n    @filters ||= [].tap do |filters|\n      unless @languages.empty?\n        ...",
              "source": "app/presenters/documents_list_presenter.rb"
            }
          ],
          "sourceFiles": [
            {
              "path": "app/presenters/documents_list_presenter.rb",
              "relevance": 24
            },
            {
              "path": "app/presenters/abuse_report_presenter.rb",
              "relevance": 5
            },
            {
              "path": "app/presenters/account/policy_presenter.rb",
              "relevance": 5
            }
          ]
        }
      },
      "DocumentsListPresenter::DocumentPresenter": {
        "type": "Presenter",
        "description": "Presents details of a single document within a list, including its title, description, tags, and associated courses and localizations.",
        "interactions": {
          "interaction_0": "Wraps a document resource and a collection of courses.",
          "interaction_1": "Maps course IDs to course titles.",
          "interaction_2": "Uses `I18nData` to translate localization languages."
        },
        "techDebt": [],
        "provenance": {
          "sources": [
            "app/presenters/documents_list_presenter.rb"
          ]
        },
        "codeImplementation": {
          "confidence": 0.85,
          "codeBlocks": [
            {
              "startLine": 1,
              "endLine": 26,
              "code": "# frozen_string_literal: true\n\nclass DocumentsListPresenter < PrivatePresenter\n  def_delegators :@documents, :empty?\n\n  def self.build(documents, courses, tags, params, helpers)\n    new(\n      documents:,\n      courses:,\n      tags:,\n      params:,\n      helpers:\n    )\n  end\n\n  def initialize(*)\n    super\n\n    @languages = @documents.flat_map do |document|\n      document['localizations'].pluck('language')\n    end.uniq\n  end\n\n  def each\n    @documents.each do |document|\n      yield DocumentPresenter.new(document:, courses: @courses)\n    end\n  end",
              "source": "app/presenters/documents_list_presenter.rb"
            }
          ],
          "sourceFiles": [
            {
              "path": "app/presenters/documents_list_presenter.rb",
              "relevance": 28
            },
            {
              "path": "app/presenters/abuse_report_presenter.rb",
              "relevance": 5
            },
            {
              "path": "app/presenters/account/policy_presenter.rb",
              "relevance": 5
            }
          ]
        }
      },
      "DocumentsPresenter": {
        "type": "Presenter",
        "description": "Presents a user's certificates and documents related to their enrollment in a course. Determines availability of COP, ROA, Open Badge, Certificate, and TOR.",
        "interactions": {
          "interaction_0": "Fetches course details via `course_api` and wraps them in `BasicCoursePresenter`.",
          "interaction_1": "Finds `Certificate::Template` and `Certificate::OpenBadgeTemplate` based on course and certificate type.",
          "interaction_2": "Checks `enrollment.certificates` and `user.feature?('proctoring')`.",
          "interaction_3": "Interacts with `Proctoring::SmowlAdapter` to check if user passed proctoring."
        },
        "techDebt": [],
        "provenance": {
          "sources": [
            "app/presenters/documents_presenter.rb"
          ]
        },
        "codeImplementation": {
          "confidence": 0.95,
          "codeBlocks": [
            {
              "startLine": 3,
              "endLine": 4,
              "code": "class DocumentsPresenter < Presenter\n  attr_accessor :enrollment, :course, :user",
              "source": "app/presenters/documents_presenter.rb"
            },
            {
              "startLine": 6,
              "endLine": 10,
              "code": "  def self.create(enrollment, user)\n    new(enrollment:, user:).tap do |presenter|\n      presenter.course!\n      presenter.templates!\n    end",
              "source": "app/presenters/documents_presenter.rb"
            },
            {
              "startLine": 12,
              "endLine": 16,
              "code": "  def course!\n    @course = course_api.rel(:course).get({id: enrollment.course_id}).then do |course|\n      BasicCoursePresenter.new(course)\n    end.value!\n  end",
              "source": "app/presenters/documents_presenter.rb"
            },
            {
              "startLine": 18,
              "endLine": 30,
              "code": "  def templates!\n    @templates ||= {}.tap do |templates|\n      if enrollment.certificates[:confirmation_of_participation]\n        templates[:confirmation_of_participation] = template_for(type: Certificate::Record::COP)\n      end\n\n      if enrollment.certificates[:record_of_achievement]\n        templates[:record_of_achievement] = template_for(type: Certificate::Record::ROA)\n        templates[:open_badge] = Certificate::OpenBadgeTemplate.find_by(course_id: enrollment.course_id)\n      end\n\n      if enrollment.certificates[:transcript_of_records]\n        templates[:transcr...",
              "source": "app/presenters/documents_presenter.rb"
            }
          ],
          "sourceFiles": [
            {
              "path": "app/presenters/documents_presenter.rb",
              "relevance": 24
            },
            {
              "path": "app/presenters/abuse_report_presenter.rb",
              "relevance": 5
            },
            {
              "path": "app/presenters/account/policy_presenter.rb",
              "relevance": 5
            }
          ]
        }
      },
      "FeaturedItemPresenter": {
        "type": "Presenter",
        "description": "A factory presenter for featured course items. Currently supports only video items.",
        "interactions": {
          "interaction_0": "Builds `FeaturedVideoItem` for video content types.",
          "interaction_1": "Raises an error for unsupported content types."
        },
        "techDebt": [],
        "provenance": {
          "sources": [
            "app/presenters/featured_item_presenter.rb"
          ]
        },
        "codeImplementation": {
          "confidence": 0.95,
          "codeBlocks": [
            {
              "startLine": 3,
              "endLine": 28,
              "code": "class FeaturedItemPresenter\n  def self.build(item, course)\n    if item.content_type != 'video'\n      raise \"Featured items of type #{item.content_type} are not yet supported\"\n    end\n\n    FeaturedVideoItem.new(item, course)\n  end\n\n  class FeaturedVideoItem\n    def initialize(item, course)\n      @item = item\n      @course = course\n      @video = Video::Video.find item.content_id\n    end\n\n    def featured_image\n      @video.thumbnail\n    end\n\n    extend Forwardable\n\n    def_delegators :@item, :id, :title\n    def_delegators :@course, :course_code\n  end\nend",
              "source": "app/presenters/featured_item_presenter.rb"
            }
          ],
          "sourceFiles": [
            {
              "path": "app/presenters/featured_item_presenter.rb",
              "relevance": 24
            },
            {
              "path": "app/presenters/abuse_report_presenter.rb",
              "relevance": 5
            },
            {
              "path": "app/presenters/account/policy_presenter.rb",
              "relevance": 5
            }
          ]
        }
      },
      "ItemPresenter": {
        "type": "Presenter",
        "description": "A base presenter for course content items, providing common attributes and methods like title, points, status (locked, visited, active), type labels, and time effort.",
        "interactions": {
          "interaction_0": "Delegates attributes to the `@item` and `@course` objects.",
          "interaction_1": "Determines `partial_name` and `layout` based on content type.",
          "interaction_2": "Checks `Course::RequiredItemPresenter` for item requirements.",
          "interaction_3": "Uses `Course::Item::Icon` for icon classes.",
          "interaction_4": "Checks `user.feature?('time_effort')` for time effort display.",
          "interaction_5": "Determines `locked?` status based on user permissions, item availability, and open mode."
        },
        "techDebt": [],
        "provenance": {
          "sources": [
            "app/presenters/item_presenter.rb"
          ]
        },
        "codeImplementation": {
          "confidence": 0.95,
          "codeBlocks": [
            {
              "startLine": 1,
              "endLine": 15,
              "code": "# frozen_string_literal: true\n\nclass ItemPresenter < PrivatePresenter\n  def_restify_delegators :@item, :id, :content_id, :title,\n    :max_points,\n    :optional, :position,\n    :section_id, :featured, :public_description,\n    :open_mode, :time_effort,\n    :required_item_ids, :published,\n    :content_type, :exercise_type\n  def_delegator :@course, :id, :course_id\n  def_delegator :@course, :course_code, :course_code\n  def_delegator :@course, :title, :course_title\n  def_delegator :@course, :pinboard_enabled, :course_pinboard?\n  def_delegator :@course, :forum_is_locked, :course_pinboard_closed?\n  def_delegator :@course, :lang, :lang",
              "source": "app/presenters/item_presenter.rb"
            },
            {
              "startLine": 17,
              "endLine": 26,
              "code": "  class << self\n    def lookup(item)\n      \"#{item['content_type']}_item_presenter\".camelize.constantize\n    rescue NameError\n      UnsupportedItemPresenter\n    end\n\n    def for(item, course: nil, user: nil)\n      lookup(item).new(item:, course:, user:)\n    end\n  end",
              "source": "app/presenters/item_presenter.rb"
            },
            {
              "startLine": 28,
              "endLine": 30,
              "code": "  def partial_name\n    \"items/#{content_type}/show_item_#{content_type}\"\n  end",
              "source": "app/presenters/item_presenter.rb"
            }
          ],
          "sourceFiles": [
            {
              "path": "app/presenters/item_presenter.rb",
              "relevance": 24
            },
            {
              "path": "app/presenters/abuse_report_presenter.rb",
              "relevance": 5
            },
            {
              "path": "app/presenters/account/policy_presenter.rb",
              "relevance": 5
            }
          ]
        }
      },
      "RichTextItemPresenter": {
        "type": "Presenter",
        "description": "Presents rich text course items, rendering their markdown content to HTML.",
        "interactions": {
          "interaction_0": "Extends `ItemPresenter`.",
          "interaction_1": "Finds the associated `Course::Richtext` content.",
          "interaction_2": "Uses `MarkdownHelper` to render the rich text content."
        },
        "techDebt": [],
        "provenance": {
          "sources": [
            "app/presenters/rich_text_item_presenter.rb"
          ]
        },
        "codeImplementation": {
          "confidence": 0.95,
          "codeBlocks": [
            {
              "startLine": 1,
              "endLine": 10,
              "code": "# frozen_string_literal: true\n\nclass RichTextItemPresenter < ItemPresenter\n  include MarkdownHelper\n\n  def self.build(item, course, user, **)\n    richtext = Course::Richtext.find(item['content_id'])\n    new item:, richtext:, course:, user:\n  end\n\n  def text_html\n    render_markdown(@richtext.text&.external, allow_tables: true, escape_html: false)\n  end\nend",
              "source": "app/presenters/rich_text_item_presenter.rb"
            }
          ],
          "sourceFiles": [
            {
              "path": "app/presenters/rich_text_item_presenter.rb",
              "relevance": 24
            },
            {
              "path": "app/presenters/abuse_report_presenter.rb",
              "relevance": 5
            },
            {
              "path": "app/presenters/account/policy_presenter.rb",
              "relevance": 5
            }
          ]
        }
      },
      "SectionPresenter": {
        "type": "Presenter",
        "description": "Presents course section details, including title, published status, description, and item availability. It also handles alternative sections and section choices.",
        "interactions": {
          "interaction_0": "Delegates attributes to the `@section` object.",
          "interaction_1": "Fetches items for the section from `Xikolo.api(:course)`.",
          "interaction_2": "Determines `unlocked?` status based on start/end dates.",
          "interaction_3": "Fetches `Xikolo::Course::SectionChoice` and `Course::Section` for alternative sections.",
          "interaction_4": "Enqueues implicit tags for pinboards."
        },
        "techDebt": [],
        "provenance": {
          "sources": [
            "app/presenters/section_presenter.rb"
          ]
        },
        "codeImplementation": {
          "confidence": 0.95,
          "codeBlocks": [
            {
              "startLine": 1,
              "endLine": 32,
              "code": "# frozen_string_literal: true\n\nclass SectionPresenter < PrivatePresenter\n  def_restify_delegators :@section, :id, :title, :published, :alternative_state,\n    :description, :required_section_ids, :course_id, :course_archived\n\n  def items\n    Xikolo.api(:course).value!.rel(:items).get({section_id: id}).value!.map do |item_resource|\n      ItemPresenter.new(item: item_resource, user: @user)\n    end\n  end\n\n  def to_param\n    UUID(id).to_param\n  end\n\n  def available?\n    unlocked? && published\n  end\n\n  def end_date\n    Time.zone.parse(@section['end_date'].to_s) if @section['end_date'].present?\n  end\n\n  def start_date\n    Time.zone.parse(@section['start_date'].to_s) if @section['start_date'].present?\n  end\n\n  def effective_start_date\n    Time.zone.parse(@section['effective_start_date'].to_s) if @section['effective_start_date'].present?\n  end\n\n  def effective_end_date\n    Time.zone.parse(@section['effective_end_date'].to_s) if @section['effective_end_date'].present?\n  end\n\n  def unlocked?\n    ...",
              "source": "app/presenters/section_presenter.rb"
            }
          ],
          "sourceFiles": [
            {
              "path": "app/presenters/section_presenter.rb",
              "relevance": 24
            },
            {
              "path": "app/presenters/abuse_report_presenter.rb",
              "relevance": 5
            },
            {
              "path": "app/presenters/account/policy_presenter.rb",
              "relevance": 5
            }
          ]
        }
      },
      "StageItemPresenter": {
        "type": "Presenter",
        "description": "Presents content for the course stage (e.g., a promotional banner or statement). It parses statements to extract quotes and renders markdown.",
        "interactions": {
          "interaction_0": "Uses `MarkdownHelper` to render statements.",
          "interaction_1": "Parses the statement string to extract `quote_by`."
        },
        "techDebt": [],
        "provenance": {
          "sources": [
            "app/presenters/stage_item_presenter.rb"
          ]
        },
        "codeImplementation": {
          "confidence": 0.95,
          "codeBlocks": [
            {
              "startLine": 1,
              "endLine": 30,
              "code": "# frozen_string_literal: true\n\nclass StageItemPresenter < PrivatePresenter\n  include MarkdownHelper\n  include Rails.application.routes.url_helpers\n\n  attr_reader :quote_by, :course_path, :visual_url\n\n  def self.build(visual, statement, course_path: nil)\n    new(visual_url: visual, statement:, course_path:).tap do |presenter|\n      presenter.parse_statement! unless statement.nil?\n    end\n  end\n\n  def parse_statement!\n    @quote_by = @statement[/(.*)###(.*)/m, 2]\n    unless @quote_by.nil?\n      @quote_by.strip!\n      @statement = @statement.split('###')[0]\n    end\n    @statement&.strip!\n  end\n\n  def render_statement\n    render_markdown @statement\n  end\n\n  def statement?\n    @statement.present?\n  end\nend",
              "source": "app/presenters/stage_item_presenter.rb"
            }
          ],
          "sourceFiles": [
            {
              "path": "app/presenters/stage_item_presenter.rb",
              "relevance": 24
            },
            {
              "path": "app/presenters/abuse_report_presenter.rb",
              "relevance": 5
            },
            {
              "path": "app/presenters/account/policy_presenter.rb",
              "relevance": 5
            }
          ]
        }
      },
      "UnsupportedItemPresenter": {
        "type": "Presenter",
        "description": "A fallback presenter for course items with unsupported content types. It displays a generic unsupported item view.",
        "interactions": {
          "interaction_0": "Extends `ItemPresenter`.",
          "interaction_1": "Sets `partial_name` to `items/show_unsupported_item`."
        },
        "techDebt": [],
        "provenance": {
          "sources": [
            "app/presenters/unsupported_item_presenter.rb"
          ]
        },
        "codeImplementation": {
          "confidence": 0.95,
          "codeBlocks": [
            {
              "startLine": 1,
              "endLine": 10,
              "code": "# frozen_string_literal: true\n\nrequire 'addressable'\n\nclass UnsupportedItemPresenter < ItemPresenter\n  def self.build(item, course, user, **)\n    new(item:, user:, course:)\n  end\n\n  def partial_name\n    'items/show_unsupported_item'\n  end\nend",
              "source": "app/presenters/unsupported_item_presenter.rb"
            }
          ],
          "sourceFiles": [
            {
              "path": "app/presenters/unsupported_item_presenter.rb",
              "relevance": 24
            },
            {
              "path": "app/presenters/abuse_report_presenter.rb",
              "relevance": 5
            },
            {
              "path": "app/presenters/account/policy_presenter.rb",
              "relevance": 5
            }
          ]
        }
      },
      "handleRichTextType": {
        "type": "Frontend Script",
        "description": "A TypeScript function that dynamically adjusts the visibility of form inputs in the course item creation/edit form when the content type is 'rich text'. It hides fields irrelevant to rich text content.",
        "interactions": {
          "interaction_0": "Modifies DOM elements using `setVisibility`, `hidePublicDescription`, and `hideAndUncheckSwitch` helpers.",
          "interaction_1": "Called when the content type selection changes to 'rich text'."
        },
        "techDebt": [],
        "provenance": {
          "sources": [
            "app/assets/teacher/items/rich-text.ts",
            "docs/app/development/implementation/course_items_form.md"
          ]
        }
      },
      "sections.js": {
        "type": "Frontend Script",
        "description": "A JavaScript file that provides client-side functionality for managing course sections, including saving/restoring scroll position and handling delete restrictions.",
        "interactions": {
          "interaction_0": "Uses `toggleUuids` to show/hide section UUIDs.",
          "interaction_1": "Attaches event listeners to 'new item' and 'delete section' buttons.",
          "interaction_2": "Uses `sessionStorage` to preserve scroll position.",
          "interaction_3": "Displays `swal` (SweetAlert2) for delete forbidden messages."
        },
        "techDebt": [],
        "provenance": {
          "sources": [
            "app/assets/teacher/sections/sections.js"
          ]
        }
      },
      "Xikolo::Course::Course": {
        "type": "Microservice Client",
        "description": "A client-side representation of the Course resource from the `Xikolo::CourseService` microservice. It is used to fetch course details, manage enrollments, and access related resources like sections and items.",
        "interactions": {
          "interaction_0": "Used by `Course::CoursesController`, `CourseContextHelper`, `CourseInfoPresenter`, `CoursePresenter`, `Home::CourseCard` and others to fetch course data.",
          "interaction_1": "Provides methods for checking course availability (`was_available?`, `published?`).",
          "interaction_2": "Exposes relations like `sections`, `items`, `enrollments`."
        },
        "techDebt": [],
        "provenance": {
          "sources": [
            "app/controllers/course/courses_controller.rb",
            "app/helpers/course_context_helper.rb",
            "services/course/README.md"
          ]
        },
        "codeImplementation": {
          "confidence": 0.95,
          "codeBlocks": [
            {
              "startLine": 1,
              "endLine": 23,
              "code": "# frozen_string_literal: true\n\nmodule Xikolo\n  module Model\n    class CourseRepository\n      def courses_for(user, course_id)\n        courses = course_api.rel(:courses).get({\n          per_page: 100,\n          user_id: user.id,\n        }).value!\n        if course_id.present?\n          courses.select {|c| c['id'] == course_id }\n        else\n          courses\n        end\n      end\n\n      private\n\n      def course_api\n        @course_api ||= Xikolo.api(:course).value!\n      end\n    end\n  end\nend",
              "source": "api/xikolo/entities/course_date.rb"
            },
            {
              "startLine": 1,
              "endLine": 19,
              "code": "# frozen_string_literal: true\n\nmodule Xikolo\n  module V2\n    class CourseAPI < Grape::API::Instance\n      namespace 'courses' do\n        route_param :course_id, type: String, desc: 'The course UUID' do\n          namespace 'time_effort' do\n            mount Endpoint::GetCourseTimeEffort\n          end\n        end\n      end\n\n      namespace 'next_dates' do\n        mount Endpoint::ListNextDates\n      end\n    end\n  end\nend",
              "source": "api/xikolo/entities/course_date.rb"
            }
          ],
          "sourceFiles": [
            {
              "path": "api/xikolo/entities/course_date.rb",
              "relevance": 44
            },
            {
              "path": "api/xikolo/model/course_repository.rb",
              "relevance": 44
            },
            {
              "path": "api/xikolo/v2/course_api.rb",
              "relevance": 44
            }
          ]
        }
      },
      "Xikolo::Course::Section": {
        "type": "Microservice Client",
        "description": "A client-side representation of the Section resource from the `Xikolo::CourseService` microservice. Used to manage course sections and their properties.",
        "interactions": {
          "interaction_0": "Used by `SectionsController` for CRUD operations on sections.",
          "interaction_1": "Used by `CourseContextHelper` to fetch the current section.",
          "interaction_2": "Used by `Item::Create` to associate items with sections."
        },
        "techDebt": [],
        "provenance": {
          "sources": [
            "app/controllers/sections_controller.rb",
            "app/helpers/course_context_helper.rb",
            "app/operations/item/create.rb"
          ]
        },
        "codeImplementation": {
          "confidence": 0.95,
          "codeBlocks": [
            {
              "startLine": 3,
              "endLine": 29,
              "code": "module Xikolo   module V2::Courses     class SectionProgresses < Xikolo::Endpoint::CollectionEndpoint       entity do         type 'section-progresses'          id {|progress|           progress['resource_id']         }          attribute('title') {           description 'The section\\'s title'           type :string         }          attribute('description') {           description 'A text describing the section\\'s content'           type :string         }          attribute('position') {           description 'The sections\\'s position within its course'           type :integer         }          attribute('available') {           description 'Whether the section was unlocked yet'           type :boolean         }          attribute('parent') {           description 'Whether the section is a parent section'           type :boolean         }          attribute('main_exercises') {           description 'The sections\\'s main exercise statistics for user'",
              "source": "api/xikolo/v2/courses/section_progresses.rb"
            },
            {
              "startLine": 3,
              "endLine": 33,
              "code": "module Xikolo   module V2::Courses     class Sections < Xikolo::Endpoint::CollectionEndpoint       entity do         type 'course-sections'          attribute('title') {           description 'The section\\'s title'           type :string         }          attribute('description') {           description 'A text describing the section\\'s content'           type :string         }          attribute('position') {           description 'The sections\\'s position within its course'           type :integer         }          attribute('start_at') {           description 'The date when this section becomes available'           type :datetime           alias_for 'effective_start_date'         }          attribute('end_at') {           description 'The date when access to this section is closed'           type :datetime           alias_for 'effective_end_date'         }          attribute('accessible') {           description 'Whether the section\\'s content can be...",
              "source": "api/xikolo/v2/courses/section_progresses.rb"
            },
            {
              "startLine": 3,
              "endLine": 9,
              "code": "module Xikolo::Course::Concerns   module Section     extend ActiveSupport::Concern      included do       validates :title, :course_id, presence: true     end   end end",
              "source": "api/xikolo/v2/courses/section_progresses.rb"
            }
          ],
          "sourceFiles": [
            {
              "path": "api/xikolo/v2/courses/section_progresses.rb",
              "relevance": 40
            },
            {
              "path": "api/xikolo/v2/courses/sections.rb",
              "relevance": 40
            },
            {
              "path": "clients/xikolo-course/lib/xikolo/course/concerns/section.rb",
              "relevance": 40
            }
          ]
        }
      },
      "Xikolo::Course::Item": {
        "type": "Microservice Client",
        "description": "A client-side representation of the Item resource from the `Xikolo::CourseService` microservice. Used to manage course content items of various types.",
        "interactions": {
          "interaction_0": "Used by `ItemsController` for CRUD operations on items.",
          "interaction_1": "Used by `CourseContextHelper` to fetch the current item.",
          "interaction_2": "Used by `Item::Create` to create new items.",
          "interaction_3": "Provides attributes like `content_type`, `content_id`, `open_mode`, `featured`."
        },
        "techDebt": [],
        "provenance": {
          "sources": [
            "app/controllers/items_controller.rb",
            "app/helpers/course_context_helper.rb",
            "app/operations/item/create.rb"
          ]
        },
        "codeImplementation": {
          "confidence": 0.95,
          "codeBlocks": [
            {
              "startLine": 6,
              "endLine": 30,
              "code": "      entity do\n        type 'course-items'\n\n        attribute('title') {\n          description 'The item\\'s title'\n          type :string\n        }\n\n        attribute('position') {\n          description 'The item\\'s position within its section'\n          type :integer\n        }\n\n        attribute('deadline') {\n          description 'The date at which the item must have been finished by the user'\n          type :datetime\n          alias_for 'submission_deadline'\n        }\n\n        attribute('content_type') {\n          description 'The type of item: one of quiz, video, rich_text, lti_exercise'\n          type :string\n        }\n\n        attribute('icon') {\n          version max: 4\n          description 'The icon for this item (reflecting the icon in the xikolo-font)'\n          type :string\n          reading {|item|\n            case item['content_type']",
              "source": "api/xikolo/v2/courses/items.rb"
            },
            {
              "startLine": 3,
              "endLine": 9,
              "code": "module Xikolo::Course::Concerns\n  module Item\n    extend ActiveSupport::Concern\n\n    included do\n      validates :title, :content_type, :content_id, :section_id, presence: true\n    end\n  end\nend",
              "source": "api/xikolo/v2/courses/items.rb"
            },
            {
              "startLine": 3,
              "endLine": 31,
              "code": "module Xikolo::Course\n  class Item < Acfs::Resource\n    service Xikolo::Course::Client, path: 'items'\n\n    attribute :id, :uuid\n    attribute :title, :string\n    attribute :start_date, :date_time\n    attribute :end_date, :date_time\n    attribute :content_type, :string\n    attribute :content_id, :uuid\n    attribute :section_id, :uuid\n    attribute :published, :boolean\n    attribute :exercise_type, :string\n    attribute :max_points, :float\n    attribute :submission_deadline, :date_time\n    attribute :submission_publishing_date, :date_time\n    attribute :show_in_nav, :boolean\n    attribute :position, :integer\n    attribute :next_item_id, :uuid\n    attribute :prev_item_id, :uuid\n    attribute :effective_start_date, :date_time\n    attribute :effective_end_date, :date_time\n    attribute :course_archived, :boolean\n    attribute :user_state, :string\n    attribute :proctored, :boolean\n    attribute :optional, :boolean, default: false\n    attribute :icon_type, :str...",
              "source": "api/xikolo/v2/courses/items.rb"
            }
          ],
          "sourceFiles": [
            {
              "path": "api/xikolo/v2/courses/items.rb",
              "relevance": 40
            },
            {
              "path": "clients/xikolo-course/lib/xikolo/course/concerns/item.rb",
              "relevance": 40
            },
            {
              "path": "clients/xikolo-course/lib/xikolo/course/item.rb",
              "relevance": 40
            }
          ]
        }
      },
      "Xikolo::Course::Visit": {
        "type": "Microservice Client",
        "description": "A client-side representation of the Visit resource from the `Xikolo::CourseService` microservice. Used to record user visits to course items for progress tracking.",
        "interactions": {
          "interaction_0": "Created by `ItemContextHelper#create_visit!` when a user views an item."
        },
        "techDebt": [],
        "provenance": {
          "sources": [
            "app/helpers/item_context_helper.rb"
          ]
        },
        "codeImplementation": {
          "confidence": 0.95,
          "codeBlocks": [
            {
              "startLine": 4,
              "endLine": 10,
              "code": "  class Visit < Acfs::SingletonResource\n    service Xikolo::Course::Client, path: '/items/:item_id/users/:user_id/visit'\n\n    attribute :item_id, :uuid\n    attribute :user_id, :uuid\n  end",
              "source": "clients/xikolo-course/lib/xikolo/course/visit.rb"
            }
          ],
          "sourceFiles": [
            {
              "path": "clients/xikolo-course/lib/xikolo/course/visit.rb",
              "relevance": 40
            },
            {
              "path": "app/models/course/visit.rb",
              "relevance": 37
            },
            {
              "path": "app/models/gamification/rules/course/visited_item.rb",
              "relevance": 37
            }
          ]
        }
      },
      "Xikolo::Quiz::Quiz": {
        "type": "Microservice Client",
        "description": "A client-side representation of the Quiz resource from the `Xikolo::QuizService` microservice. Used to manage quiz content for course items.",
        "interactions": {
          "interaction_0": "Used by `ItemsController` when creating or editing quiz items.",
          "interaction_1": "Provides attributes like `allowed_attempts`, `time_limit_seconds`, `instructions`."
        },
        "techDebt": [],
        "provenance": {
          "sources": [
            "app/controllers/items_controller.rb"
          ]
        },
        "codeImplementation": {
          "confidence": 0.95,
          "codeBlocks": [
            {
              "startLine": 5,
              "endLine": 34,
              "code": "module Xikolo\n  module V2::Quiz\n    class Quizzes < Xikolo::Endpoint::CollectionEndpoint\n      entity do\n        type 'quizzes'\n\n        attribute('instructions') {\n          description 'Textual instructions for the quiz taker in Markdown format'\n          type :string\n        }\n\n        attribute('time_limit') {\n          description 'The time (in seconds) that the user can take to finish the quiz, or zero if unlimited'\n          type :integer\n          reading {|quiz|\n            quiz['unlimited_time'] ? 0 : quiz['time_limit_seconds']\n          }\n        }\n\n        attribute('allowed_attempts') {\n          description 'The number of allowed attempts the user has to finish the quiz, or zero if unlimited'\n          type :integer\n          reading {|quiz|\n            quiz['unlimited_attempts'] ? 0 : quiz['allowed_attempts']\n          }\n        }\n\n        link('self') {|quiz| \"/api/v2/quizzes/#{quiz['id']}\" }\n\n        includable has_many('...\n",
              "source": "api/xikolo/v2/quiz/quizzes.rb"
            },
            {
              "startLine": 5,
              "endLine": 9,
              "code": "module Xikolo\n  module Quiz\n    require 'xikolo/quiz/client'\n  end\nend",
              "source": "api/xikolo/v2/quiz/quizzes.rb"
            }
          ],
          "sourceFiles": [
            {
              "path": "api/xikolo/v2/quiz/quizzes.rb",
              "relevance": 44
            },
            {
              "path": "clients/xikolo-quiz/lib/xikolo/quiz.rb",
              "relevance": 44
            },
            {
              "path": "clients/xikolo-submission/lib/xikolo/submission/quiz_submission.rb",
              "relevance": 44
            }
          ]
        }
      },
      "Lti::Exercise": {
        "type": "Model",
        "description": "An ActiveRecord model representing an LTI exercise, used as a content type for course items. It stores details like custom fields, instructions, and LTI provider ID.",
        "interactions": {
          "interaction_0": "Used by `ItemsController` when creating or editing LTI exercise items.",
          "interaction_1": "Interacts with `Lti::Exercise::Store` for persistence."
        },
        "techDebt": [],
        "provenance": {
          "sources": [
            "app/controllers/items_controller.rb"
          ]
        },
        "codeImplementation": {
          "confidence": 0.98,
          "codeBlocks": [
            {
              "startLine": 1,
              "endLine": 38,
              "code": "# frozen_string_literal: true\n\nmodule Lti\n  class Exercise < ::ApplicationRecord\n    self.table_name = 'lti_exercises'\n\n    DEFAULT_WEIGHT = 1\n\n    attribute :instructions, Xikolo::S3::Markup.new(\n      uploads: {purpose: 'lti_exercise_instructions', content_type: 'image/*'}\n    )\n\n    validates :lti_provider_id, presence: true\n\n    belongs_to :provider,\n      optional: true,\n      class_name: 'Lti::Provider',\n      foreign_key: :lti_provider_id,\n      inverse_of: :exercises\n\n    has_one :item,\n      class_name: 'Course::Item',\n      as: :content,\n      dependent: :restrict_with_exception\n\n    has_many :gradebooks,\n      class_name: 'Lti::Gradebook',\n      dependent: :destroy,\n      foreign_key: :lti_exercise_id,\n      inverse_of: :exercise\n\n    def score_for(user_id)\n      gradebooks.find_by(user_id:).try(:highest_grade).try(:score)\n    end\n\n    def deleted_provider?\n      persisted? && reload_provider.nil?\n    end\n\n    def weight\n      self[:weight] || DEFAULT_WEIGHT\n    end",
              "source": "app/models/lti/exercise.rb"
            },
            {
              "startLine": 1,
              "endLine": 33,
              "code": "# frozen_string_literal: true\n\nmodule Lti\n  class Exercise\n    class Store < ApplicationOperation\n      def initialize(exercise, params)\n        super()\n\n        @exercise = exercise\n        @params = params\n      end\n\n      def call\n        if @params[:instructions]\n          instructions = @params.delete(:instructions)\n          @exercise.assign_attributes @params\n          configure_processor! instructions\n          process_instructions_and_save\n        else\n          @exercise.update @params\n        end\n        @exercise\n      end\n\n      private\n\n      def configure_processor!(input)\n        @processor = Xikolo::S3::TextWithUploadsProcessor.new \\\n          bucket: :lti,\n          purpose: 'lti_exercise_instructions',\n          current: @exercise.instructions,\n          text: input,\n          valid_refs: @exercise.instructions&.file_refs || []\n        @processor.on_new do |upload|\n          eid = UUID4(@exercise.id).to_s(format: :base62)\n          {",
              "source": "app/models/lti/exercise.rb"
            },
            {
              "startLine": 4,
              "endLine": 28,
              "code": "    class LtiExercises < Xikolo::Endpoint::CollectionEndpoint\n      entity do\n        type 'lti-exercises'\n\n        attribute('instructions') {\n          description 'A text with detailed explanation what this task will entail'\n          type :string\n        }\n\n        attribute('weight') {\n          description 'A multiplier (integer) for the LTI score (a number between 0 and 1) to achieve the final score for this exercise'\n          type :integer\n        }\n\n        attribute('allowed_attempts') {\n          description 'The maximum number of attempts allowed per user (0 is infinite)'\n          type :integer\n        }\n\n        attribute('launch_url') {\n          description 'URL to launch the LTI tool'\n          type :string\n          reading {|exercise|\n            next unless exercise.lti_provider_id\n\n            item = ::Course::Item.find_by(content_id: exercise.id)\n            course_id = item&.section&.course_id",
              "source": "app/models/lti/exercise.rb"
            }
          ],
          "sourceFiles": [
            {
              "path": "app/models/lti/exercise.rb",
              "relevance": 37
            },
            {
              "path": "app/operations/lti/exercise/store.rb",
              "relevance": 29
            },
            {
              "path": "api/xikolo/v2/course_items/lti_exercises.rb",
              "relevance": 18
            }
          ]
        }
      },
      "Video::Video": {
        "type": "Model",
        "description": "An ActiveRecord model representing a video, used as a content type for course items and for course teaser visuals. It stores stream IDs, titles, and references to associated files (subtitles, slides, etc.).",
        "interactions": {
          "interaction_0": "Used by `ItemsController` when creating or editing video items.",
          "interaction_1": "Used by `Course::Visual::Store` for managing teaser videos.",
          "interaction_2": "Interacts with `Video::Store` for persistence and file management."
        },
        "techDebt": [],
        "provenance": {
          "sources": [
            "app/controllers/items_controller.rb",
            "app/operations/course/visual/store.rb"
          ]
        },
        "codeImplementation": {
          "confidence": 0.95,
          "codeBlocks": [
            {
              "startLine": 6,
              "endLine": 25,
              "code": "      entity do\n        type 'videos'\n\n        attribute('summary') {\n          description 'A short description of the video contents'\n          alias_for 'description'\n          type :string\n        }\n\n        attribute('duration') {\n          description 'The video\\'s duration in seconds, if known'\n          type :integer\n        }\n\n        attribute('single_stream') {\n          description 'Media info about the single stream (picture-in-picture), if it exists. Clients can choose to use this version instead of combining the lecturer and slides streams.'\n          type :hash, of: Xikolo::V2::VideoStream.schema\n          reading {|video|\n            next if video['pip_stream_id'].blank?\n\n            stream = ::Video::Stream.find video['pip_stream_id']\n            Xikolo::V2::VideoStream.data stream, video['id']\n          }\n        }",
              "source": "api/xikolo/v2/course_items/videos.rb"
            },
            {
              "startLine": 7,
              "endLine": 25,
              "code": "        def schema\n          {\n            hd_url: :string,\n            sd_url: :string,\n            hls_url: :string,\n            hd_size: :integer,\n            sd_size: :integer,\n            thumbnail_url: :string,\n          }\n        }\n\n        def data(stream, video_id = nil)\n          {\n            hd_url: stream.hd_url,\n            sd_url: stream.sd_url,\n            hls_url: stream.hls_url.present? ? Xikolo::V2::URL.playlist_url(id: stream.id, format: 'm3u8', embed_subtitles_for_video: video_id) : nil,\n            hd_size: stream.hd_size || 0,\n            sd_size: stream.sd_size || 0,\n            thumbnail_url: stream.poster,\n          }\n        }",
              "source": "api/xikolo/v2/course_items/videos.rb"
            },
            {
              "startLine": 5,
              "endLine": 11,
              "code": "    def self.compatible?(video)\n      provider_types = %w[vimeo kaltura]\n\n      [video.lecturer_stream, video.slides_stream, video.pip_stream, video.subtitled_stream].compact.all? do |stream|\n        provider_types.include? stream.provider.provider_type\n      end\n    }",
              "source": "api/xikolo/v2/course_items/videos.rb"
            },
            {
              "startLine": 26,
              "endLine": 37,
              "code": "    private\n\n    def streams\n      if @video.lecturer_stream && @video.slides_stream\n        [\n          render_stream(@video.lecturer_stream, 'primary'),\n          render_stream(@video.slides_stream, 'secondary'),\n          tag.xm_presentation('', reference: 'primary,secondary', name: 'dual',\n            label: t(:'video_player.dual_stream_mode')),\n        ]\n      elsif @video.pip_stream\n        [\n          render_stream(@video.pip_stream, 'p...",
              "source": "api/xikolo/v2/course_items/videos.rb"
            }
          ],
          "sourceFiles": [
            {
              "path": "api/xikolo/v2/course_items/videos.rb",
              "relevance": 37
            },
            {
              "path": "api/xikolo/v2/video_stream.rb",
              "relevance": 37
            },
            {
              "path": "app/components/video/video_player.rb",
              "relevance": 37
            }
          ]
        }
      },
      "Course::Richtext": {
        "type": "Model",
        "description": "An ActiveRecord model representing rich text content, used as a content type for course items. It stores the rich text content and handles file references.",
        "interactions": {
          "interaction_0": "Used by `ItemsController` when creating or editing rich text items.",
          "interaction_1": "Interacts with `Course::Richtext::Store` for persistence and file management."
        },
        "techDebt": [],
        "provenance": {
          "sources": [
            "app/controllers/items_controller.rb",
            "app/operations/course/richtext/store.rb"
          ]
        },
        "codeImplementation": {
          "confidence": 0.95,
          "codeBlocks": [
            {
              "startLine": 1,
              "endLine": 17,
              "code": "# frozen_string_literal: true\n\nmodule Course\n  class Richtext < ApplicationRecord\n    attribute :text, Xikolo::S3::Markup.new(\n      uploads: {purpose: 'course_richtext'}\n    )\n\n    belongs_to :course, class_name: 'Course::Course'\n    has_one :item,\n      class_name: 'Course::Item',\n      as: :content,\n      dependent: :restrict_with_exception\n\n    after_commit :delete_s3_objects!, on: :destroy\n\n    def self.referenced?(uri)\n      ::Course::Course.exists?(['description LIKE ?', \"%#{uri}%\"]) ||\n        ::Course::Richtext.exists?(['text LIKE ?', \"%#{uri}%\"])\n    end\n\n    def as_api_v2\n      @api_v2 ||= ::Course::Richtext::APIV2.new(self).as_json # rubocop:disable Naming/MemoizedInstanceVariableName\n    end",
              "source": "app/models/course/richtext.rb"
            },
            {
              "startLine": 1,
              "endLine": 12,
              "code": "# frozen_string_literal: true\n\nclass RichtextsController < ApplicationController\n  responders Responders::ApiResponder,\n    Responders::DecorateResponder,\n    Responders::HttpCacheResponder\n\n  respond_to :json\n\n  def show\n    respond_with Richtext.find params[:id]\n  end\nend",
              "source": "app/models/course/richtext.rb"
            },
            {
              "startLine": 1,
              "endLine": 20,
              "code": "# frozen_string_literal: true\n\nclass RichtextDecorator < ApplicationDecorator\n  delegate :errors\n\n  def fields\n    {\n      id: object.id,\n      text:,\n    }\n  end\n\n  def as_api_v1(_opts)\n    fields.as_json\n  end\n\n  def as_event(_opts)\n    fields.as_json\n  end\n\n  def text\n    Xikolo::S3.externalize_file_refs(object.text, public: true)\n  end\nend",
              "source": "app/models/course/richtext.rb"
            }
          ],
          "sourceFiles": [
            {
              "path": "app/models/course/richtext.rb",
              "relevance": 37
            },
            {
              "path": "services/course/app/controllers/richtexts_controller.rb",
              "relevance": 33
            },
            {
              "path": "services/course/app/decorators/richtext_decorator.rb",
              "relevance": 33
            }
          ]
        }
      },
      "Course::CircularProgress": {
        "type": "ViewComponent",
        "description": "Displays a circular progress indicator with a given value and label. Supports a 'small' size modifier for visual adjustments.",
        "interactions": {
          "interaction_0": "Rendered by other views or components (e.g., `ItemPresenter` or `Course::SectionProgressPresenter`) to visualize user progress."
        },
        "techDebt": [],
        "provenance": {
          "sources": [
            "app/components/course/circular_progress.rb",
            "app/components/course/circular_progress.html.slim",
            "app/components/course/circular_progress_preview.rb"
          ]
        },
        "codeImplementation": {
          "confidence": 0.95,
          "codeBlocks": [
            {
              "startLine": 1,
              "endLine": 18,
              "code": "# frozen_string_literal: true\n\nmodule Course\n  class CircularProgress < ApplicationComponent\n    def initialize(value, label, size = nil)\n      @value = value\n      @label = label\n      @size = size\n    end\n\n    def css_modifiers\n      [].tap do |modifiers|\n        modifiers << 'circular-progress--small' if @size == :small\n        modifiers << 'circular-progress--small__label' if @size == :small\n      end.join(' ')\n    end\n  end\nend",
              "source": "app/components/course/circular_progress.rb"
            },
            {
              "startLine": 1,
              "endLine": 35,
              "code": "# frozen_string_literal: true\n\nmodule Course\n  class CircularProgressPreview < ViewComponent::Preview\n    # @!group\n    # @label\n    def optimum\n      render ::Course::CircularProgress.new(100, '100%')\n    end\n\n    # @label\n    def optimal\n      render ::Course::CircularProgress.new(90, '90%')\n    end\n\n    # @label\n    def sub_optimal\n      render ::Course::CircularProgress.new(50, '50%')\n    end\n\n    # @label\n    def sub_sub_optimal\n      render ::Course::CircularProgress.new(25, '25%')\n    end\n\n    # @label\n    def empty\n      render ::Course::CircularProgress.new(0, '0%')\n    end\n\n    # @!endgroup\n    def small\n      render ::Course::CircularProgress.new(100, '100%', :small)\n    end\n  end\nend",
              "source": "app/components/course/circular_progress.rb"
            }
          ],
          "sourceFiles": [
            {
              "path": "app/components/course/circular_progress.rb",
              "relevance": 26
            },
            {
              "path": "app/components/course/circular_progress_preview.rb",
              "relevance": 26
            },
            {
              "path": "api/xikolo/entities/course_date.rb",
              "relevance": 7
            }
          ]
        }
      },
      "Course::EnrollmentPolicyForm": {
        "type": "ViewComponent",
        "description": "Renders a form for users to accept a course's enrollment policy. It retrieves course details like title, course code, and policy URL, and submits enrollment requests.",
        "interactions": {
          "interaction_0": "Interacts with `Course::Course` model to fetch course details using `by_identifier`.",
          "interaction_1": "Submits enrollment data to `Course::EnrollmentsController#create` via `enrollments_path`.",
          "interaction_2": "Uses `Translations` utility for policy URL localization."
        },
        "techDebt": [],
        "provenance": {
          "sources": [
            "app/components/course/enrollment_policy_form.rb",
            "app/components/course/enrollment_policy_form.html.slim",
            "app/components/course/enrollment_policy_form_preview.rb"
          ]
        },
        "codeImplementation": {
          "confidence": 0.95,
          "codeBlocks": [
            {
              "startLine": 1,
              "endLine": 21,
              "code": "# frozen_string_literal: true\n\nmodule Course\n  class EnrollmentPolicyForm < ApplicationComponent\n    def initialize(course_identifier)\n      @course = ::Course::Course.by_identifier(course_identifier).take!\n    end\n\n    def course_title\n      @course.title\n    end\n\n    def course_code\n      @course.course_code\n    end\n\n    def enrollment_policy_url\n      Translations.new(@course.policy_url).to_s\n    end\n  end\nend",
              "source": "app/components/course/enrollment_policy_form.rb"
            },
            {
              "startLine": 1,
              "endLine": 9,
              "code": "# frozen_string_literal: true\n\nmodule Course\n  class EnrollmentPolicyFormPreview < ViewComponent::Preview\n    def default\n      render ::Course::EnrollmentPolicyForm.new('content-ab')\n    end\n  end\nend",
              "source": "app/components/course/enrollment_policy_form.rb"
            }
          ],
          "sourceFiles": [
            {
              "path": "app/components/course/enrollment_policy_form.rb",
              "relevance": 26
            },
            {
              "path": "app/components/course/enrollment_policy_form_preview.rb",
              "relevance": 26
            },
            {
              "path": "app/forms/course/admin/announcement_form.rb",
              "relevance": 12
            }
          ]
        }
      },
      "Course::EnrollmentStatistics": {
        "type": "ViewComponent",
        "description": "Displays enrollment statistics for a course, including current, at start, and at end counts. It conditionally shows total enrollment count based on a threshold or user permissions.",
        "interactions": {
          "interaction_0": "Interacts with `Course::Course` to get course details and `Course::EnrollmentsStatistics` to retrieve enrollment counts.",
          "interaction_1": "Checks `user.allowed?('course.enrollment_counter.view')` for permission to display the count.",
          "interaction_2": "Uses `I18n` for localization and `number_with_delimiter` for count formatting."
        },
        "techDebt": [],
        "provenance": {
          "sources": [
            "app/components/course/enrollment_statistics.rb",
            "app/components/course/enrollment_statistics.html.slim"
          ]
        },
        "codeImplementation": {
          "confidence": 0.95,
          "codeBlocks": [
            {
              "startLine": 1,
              "endLine": 31,
              "code": "# frozen_string_literal: true\n\nmodule Course\n  class EnrollmentStatistics < ApplicationComponent\n    MIN_ENROLLMENTS = 500\n\n    def initialize(course, user:)\n      @course = course\n      @user = user\n      @stats = ::Course::Course.find(@course.id).stats.enrollments\n    end\n\n    def enrollment_statistics\n      return unless @course.end_date&.past?\n\n      @enrollment_statistics ||= [].tap do |stats|\n        stats << {\n          type: 'current',\n          count: readable_count(@stats.current),\n          date: I18n.t(:'course.courses.enrollment_statistics.current.date'),\n        }\n        if @stats.at_end.present?\n          stats << {\n            type: 'course_end',\n            count: readable_count(@stats.at_end),\n            date: I18n.l(@course.end_date.in_time_zone.to_date, format: :short),\n          }\n        end\n        if @stats.at_start.present?\n          stats << {\n            type: 'course_start',\n            count: readable_count(@stats.at_start),\n            date: I18n.l(@cour...",
              "source": "app/components/course/enrollment_statistics.rb"
            }
          ],
          "sourceFiles": [
            {
              "path": "app/components/course/enrollment_statistics.rb",
              "relevance": 26
            },
            {
              "path": "api/xikolo/entities/course_date.rb",
              "relevance": 7
            },
            {
              "path": "api/xikolo/model/course_repository.rb",
              "relevance": 7
            }
          ]
        }
      },
      "Dashboard::IcalFeed": {
        "type": "ViewComponent",
        "description": "Renders a widget that provides a user-specific iCal feed URL for upcoming course dates. It only renders if the 'ical_feed' feature is enabled for the user.",
        "interactions": {
          "interaction_0": "Checks `user.feature?('ical_feed')` to determine if it should render.",
          "interaction_1": "Uses `IcalHelper#ical_url` to generate the iCal feed URL.",
          "interaction_2": "Renders `Global::DisclosureWidget` and `Global::CopyToClipboard` for UI presentation."
        },
        "techDebt": [],
        "provenance": {
          "sources": [
            "app/components/dashboard/ical_feed.rb",
            "app/components/dashboard/ical_feed.html.slim",
            "app/components/dashboard/ical_feed_preview.rb"
          ]
        },
        "codeImplementation": {
          "confidence": 0.95,
          "codeBlocks": [
            {
              "startLine": 1,
              "endLine": 17,
              "code": "# frozen_string_literal: true\n\nmodule Dashboard\n  include IcalHelper\n\n  class IcalFeed < ApplicationComponent\n    def initialize(user:)\n      @user = user\n    end\n\n    def render?\n      @user.feature?('ical_feed')\n    end\n\n    def url\n      helpers.ical_url(@user, full_path: true)\n    end\n  end\nend",
              "source": "app/components/dashboard/ical_feed.rb"
            },
            {
              "startLine": 1,
              "endLine": 18,
              "code": "# frozen_string_literal: true\n\nmodule Dashboard\n  class IcalFeedPreview < ViewComponent::Preview\n    def default\n      render Dashboard::IcalFeed.new(user: user)\n    end\n\n    private\n\n    def user\n      Xikolo::Common::Auth::CurrentUser.from_session({'features' => {'ical_feed' => true},\n                                                       'user_id' => SecureRandom.uuid,\n                                                       'user' => {'anonymous' => false}})\n    end\n  end\nend",
              "source": "app/components/dashboard/ical_feed.rb"
            }
          ],
          "sourceFiles": [
            {
              "path": "app/components/dashboard/ical_feed.rb",
              "relevance": 26
            },
            {
              "path": "app/components/dashboard/ical_feed_preview.rb",
              "relevance": 26
            },
            {
              "path": "app/components/dashboard/gamification_badge.rb",
              "relevance": 7
            }
          ]
        }
      },
      "Admin::PollOptionsController": {
        "type": "Controller",
        "description": "Manages poll options for administrators. Provides endpoints for creating and destroying options for a specific poll. Requires 'helpdesk.polls.manage' permission.",
        "interactions": {
          "interaction_0": "Interacts with `Poll::Poll` model to find polls and add/delete options.",
          "interaction_1": "Renders the `admin/polls/options_form` partial to update the options list."
        },
        "techDebt": [],
        "provenance": {
          "sources": [
            "app/controllers/admin/poll_options_controller.rb"
          ]
        }
      },
      "Admin::PollsController": {
        "type": "Controller",
        "description": "Provides CRUD operations for polls within the admin interface. Allows administrators to list, create, edit, update, and delete polls. Requires 'helpdesk.polls.manage' permission.",
        "interactions": {
          "interaction_0": "Interacts with `Poll::Poll` model for all CRUD operations.",
          "interaction_1": "Uses `add_flash_message` for user feedback on operations.",
          "interaction_2": "Redirects to `edit_admin_poll_path` or `admin_polls_path` after actions."
        },
        "techDebt": [
          "TODO: Implement pagination for the poll listing [Source: app/controllers/admin/polls_controller.rb]"
        ],
        "provenance": {
          "sources": [
            "app/controllers/admin/polls_controller.rb"
          ]
        }
      },
      "CourseSubscriptionsController": {
        "type": "Controller",
        "description": "Manages user subscriptions to course pinboards. Provides actions for users to subscribe and unsubscribe from a course's pinboard.",
        "interactions": {
          "interaction_0": "Uses `CourseContextHelper` to get the course context.",
          "interaction_1": "Communicates with `Xikolo.api(:pinboard)` to create or delete course subscriptions.",
          "interaction_2": "Redirects back to `course_pinboard_index_path` after actions."
        },
        "techDebt": [],
        "provenance": {
          "sources": [
            "app/controllers/course_subscriptions_controller.rb"
          ]
        },
        "codeImplementation": {
          "confidence": 0.95,
          "codeBlocks": [
            {
              "startLine": 3,
              "endLine": 6,
              "code": "class CourseSubscriptionsController < ApplicationController\n  include CourseContextHelper\n  before_action :ensure_logged_in",
              "source": "app/controllers/course_subscriptions_controller.rb"
            },
            {
              "startLine": 8,
              "endLine": 13,
              "code": "  def create\n    Xikolo.api(:pinboard).value!\n      .rel(:course_subscriptions)\n      .post({user_id: current_user.id, course_id: params[:course_id]}).value!\n\n    redirect_back(fallback_location: course_pinboard_index_path(the_course.course_code))\n  end",
              "source": "app/controllers/course_subscriptions_controller.rb"
            },
            {
              "startLine": 15,
              "endLine": 20,
              "code": "  def destroy\n    Xikolo.api(:pinboard).value!\n      .rel(:course_subscription)\n      .delete({id: params[:id]}).value!\n\n    redirect_back(fallback_location: course_pinboard_index_path(the_course.course_code))\n  end",
              "source": "app/controllers/course_subscriptions_controller.rb"
            },
            {
              "startLine": 3,
              "endLine": 8,
              "code": "class CourseSubscriptionsController < ApplicationController\n  responders Responders::DecorateResponder,\n    Responders::HttpCacheResponder,\n    Responders::PaginateResponder\n\n  respond_to :json",
              "source": "app/controllers/course_subscriptions_controller.rb"
            },
            {
              "startLine": 10,
              "endLine": 10,
              "code": "  before_action :set_course_subscription, only: %i[show update destroy]",
              "source": "app/controllers/course_subscriptions_controller.rb"
            },
            {
              "startLine": 12,
              "endLine": 15,
              "code": "  def index\n    course_subscriptions = CourseSubscription.where index_params\n    respond_with course_subscriptions\n  end",
              "source": "app/controllers/course_subscriptions_controller.rb"
            },
            {
              "startLine": 17,
              "endLine": 19,
              "code": "  def show\n    respond_with(@course_subscription)\n  end",
              "source": "app/controllers/course_subscriptions_controller.rb"
            },
            {
              "startLine": 21,
              "endLine": 27,
              "code": "  def create\n    @course_subscription = CourseSubscription.create_or_find_by!(\n      user_id: course_subscription_params[:user_id],\n      course_id: course_subscription_params[:course_id]\n    )\n\n    respond_with(@course_subscription)\n  end",
              "source": "app/controllers/course_subscriptions_controller.rb"
            },
            {
              "startLine": 29,
              "endLine": 31,
              "code": "  def update\n    @course_subscription.update(course_subscription_params)\n    respond_with(@course_subscription)\n  end",
              "source": "app/controllers/course_subscriptions_controller.rb"
            },
            {
              "startLine": 33,
              "endLine": 35,
              "code": "  def destroy\n    @course_subscription.destroy\n    respond_with(@course_subscription)\n  end",
              "source": "app/controllers/course_subscriptions_controller.rb"
            },
            {
              "startLine": 39,
              "endLine": 40,
              "code": "  def set_course_subscription\n    @course_subscription = C...",
              "source": "app/controllers/course_subscriptions_controller.rb"
            },
            {
              "startLine": 11,
              "endLine": 14,
              "code": "    def ensure_logged_in\n      return true if current_user.logged_in?\n\n      head :forbidden\n    end",
              "source": "app/controllers/course_subscriptions_controller.rb"
            }
          ],
          "sourceFiles": [
            {
              "path": "app/controllers/course_subscriptions_controller.rb",
              "relevance": 24
            },
            {
              "path": "services/pinboard/app/controllers/course_subscriptions_controller.rb",
              "relevance": 24
            },
            {
              "path": "app/controllers/abstract/ajax_controller.rb",
              "relevance": 5
            }
          ]
        }
      },
      "DashboardController": {
        "type": "Controller",
        "description": "Serves the main user dashboard, displaying categorized courses (current, upcoming, completed), upcoming dates, promoted courses, gamification achievements, and user documents/certificates.",
        "interactions": {
          "interaction_0": "Redirects `index` action to `dashboard`.",
          "interaction_1": "Fetches `Xikolo::Account::Authorization` if an authorization parameter is present (e.g., after SSO signup).",
          "interaction_2": "Loads sidebar content, including promoted courses and next dates, using `Xikolo.api(:course)`.",
          "interaction_3": "Retrieves user enrollments from `Course::Enrollment.active` and categorizes `Catalog::Course.released` courses.",
          "interaction_4": "Renders `Home::CourseCard` components for courses.",
          "interaction_5": "For achievements, uses `Gamification::DashboardPresenter` with `Account::User` data.",
          "interaction_6": "For documents, iterates `Xikolo::Course::Enrollment` to find certificates and uses `DocumentsPresenter` and `Xikolo::Account::Preferences`.",
          "interaction_7": "Utilizes `Acfs.run` for concurrent API calls.",
          "interaction_8": "Requires the 'gamification' feature for achievements."
        },
        "techDebt": [
          "TODO: Show some fancy notice to set a password when a new user account is created on-the-fly via SSO. [Source: app/controllers/dashboard_controller.rb]",
          "A commented-out line for filtering `next_dates` by date range suggests a potential incomplete feature or a change in requirements. [Source: app/controllers/dashboard_controller.rb]"
        ],
        "provenance": {
          "sources": [
            "app/controllers/dashboard_controller.rb",
            "app/views/dashboard/dashboard.html.slim",
            "app/views/dashboard/_overview_sidebar.html.slim",
            "app/views/dashboard/achievements.html.slim",
            "app/views/dashboard/documents.html.slim"
          ]
        },
        "codeImplementation": {
          "confidence": 0.95,
          "codeBlocks": [
            {
              "startLine": 1,
              "endLine": 27,
              "code": "# frozen_string_literal: true\n\nmodule Course\n  module Admin\n    class DashboardController < Abstract::FrontendController\n      include CourseContextHelper\n\n      before_action :set_no_cache_headers\n\n      inside_course\n\n      def show\n        authorize! 'course.dashboard.view'\n\n        @course = the_course\n        Acfs.run # wait for course context promises\n      end\n\n      def hide_course_nav?\n        true\n      end\n\n      private\n\n      def auth_context\n        the_course.context_id\n      end\n\n      # fix course receiving\n      def request_course\n        Xikolo::Course::Course.find(params[:id])\n      end\n    end\n  end\nend",
              "source": "app/controllers/course/admin/dashboard_controller.rb"
            },
            {
              "startLine": 1,
              "endLine": 28,
              "code": "# frozen_string_literal: true\n\nclass DashboardController < Abstract::FrontendController\n  include ActionView::Helpers::TranslationHelper\n\n  require_feature 'gamification', only: :achievements\n\n  before_action :set_no_cache_headers\n  before_action :ensure_logged_in\n\n  include Interruptible\n\n  def index\n    redirect_to action: :dashboard\n  end\n\n  ### Dashboard ###\n\n  def dashboard\n    if params[:authorization]\n      # You get a authorization parameter when a user has signed up with\n      # e.g. company SSO and a new user account was created on-the-fly.\n      # TODO: Show some fancy notice to set a password\n      @authorization = Xikolo::Account::Authorization.find params[:authorization]\n    end\n\n    load_sidebar_content!\n    Acfs.run\n\n    # Load all of the user's enrollments into a hash (keyed by course ID) so that\n    # they can be looked up and passed into each course's card component.\n    # This is needed for action buttons on the cards being rendered depending on\n    # whether an enr...",
              "source": "app/controllers/course/admin/dashboard_controller.rb"
            },
            {
              "startLine": 11,
              "endLine": 15,
              "code": "    private\n\n    def ensure_logged_in\n      return true if current_user.logged_in?\n\n      head :forbidden\n    end",
              "source": "app/controllers/course/admin/dashboard_controller.rb"
            }
          ],
          "sourceFiles": [
            {
              "path": "app/controllers/course/admin/dashboard_controller.rb",
              "relevance": 24
            },
            {
              "path": "app/controllers/dashboard_controller.rb",
              "relevance": 24
            },
            {
              "path": "app/controllers/abstract/ajax_controller.rb",
              "relevance": 5
            }
          ]
        }
      },
      "IcalController": {
        "type": "Controller",
        "description": "Generates an iCal feed for a specific user's upcoming course dates. It requires a user UUID and a security hash for authentication.",
        "interactions": {
          "interaction_0": "Requires the 'ical_feed' feature to be enabled.",
          "interaction_1": "Uses `IcalHelper` for generating the authentication hash and URL.",
          "interaction_2": "Fetches `NextDate` events from `Xikolo.api(:course).rel(:next_dates)`.",
          "interaction_3": "Finds `User` from `Xikolo::Account` to set the user's locale for event descriptions.",
          "interaction_4": "Uses the `Icalendar` gem to construct the iCal calendar.",
          "interaction_5": "Uses `Course::NextDatePresenter` to format event details for the calendar."
        },
        "techDebt": [],
        "provenance": {
          "sources": [
            "app/controllers/ical_controller.rb"
          ]
        },
        "codeImplementation": {
          "confidence": 0.95,
          "codeBlocks": [
            {
              "startLine": 3,
              "endLine": 10,
              "code": "class IcalController < ApplicationController\n  require 'icalendar'\n  require 'icalendar/tzinfo'\n  require 'digest'\n\n  include Xikolo::Account\n  include IcalHelper\n\n  before_action :set_no_cache_headers",
              "source": "app/controllers/ical_controller.rb"
            },
            {
              "startLine": 12,
              "endLine": 32,
              "code": "  def index\n    if %i[u h].all? {|k| params[k].present? }\n      begin\n        uuid = UUID params[:u]\n      rescue TypeError\n        raise Status::NotFound\n      end\n\n      events = Xikolo.api(:course).value!.rel(:next_dates).get({user_id: uuid.to_s}).value!\n\n      User.find(uuid.to_s) do |user|\n        I18n.locale = user.language if user.language.present?\n        if params[:h] == ical_hash(user)\n          cal = Icalendar::Calendar.new\n          tz = TZInfo::Timezone.get 'UTC'\n          cal.add_timezone tz.ical_timezone(Time.zone.now)\n          events.each do |next_date|\n            cal.event do |e|\n              next_date_presenter = Course::NextDatePresenter.new next_date\n              if next_date_presenter.id == 'item_subm...'",
              "source": "app/controllers/ical_controller.rb"
            }
          ],
          "sourceFiles": [
            {
              "path": "app/controllers/ical_controller.rb",
              "relevance": 24
            },
            {
              "path": "app/controllers/abstract/ajax_controller.rb",
              "relevance": 5
            },
            {
              "path": "app/controllers/abstract/bridge_api_controller.rb",
              "relevance": 5
            }
          ]
        }
      },
      "PollsController": {
        "type": "Controller",
        "description": "Handles user interactions with polls, including viewing an archive of past polls, fetching the next available poll, and submitting votes.",
        "interactions": {
          "interaction_0": "Interacts with `Poll::Poll` model to retrieve polls, check for upcoming polls, and record votes.",
          "interaction_1": "Uses `PollArchivePresenter` for formatting archived polls.",
          "interaction_2": "Renders `Dashboard::Poll::Widget` and its content components (e.g., `Dashboard::Poll::Question`, `Dashboard::Poll::Thanks`)."
        },
        "techDebt": [],
        "provenance": {
          "sources": [
            "app/controllers/polls_controller.rb"
          ]
        },
        "codeImplementation": {
          "confidence": 0.95,
          "codeBlocks": [
            {
              "startLine": 3,
              "endLine": 30,
              "code": "class PollsController < Abstract::FrontendController   before_action :set_no_cache_headers   before_action :ensure_logged_in    def archive     @polls = Poll::Poll.includes(:options).started.latest_first.take(20)       .map { PollArchivePresenter.new(it, current_user) }   end    def next     poll = Poll::Poll.upcoming_for_user(current_user.id).first!      render Dashboard::Poll::Widget.new(poll).with_content(       Dashboard::Poll::Question.vote(poll).render_in(view_context)     ), layout: false   rescue ActiveRecord::RecordNotFound     head :no_content   end    def vote     poll = Poll::Poll.find(params[:id])     response = poll.vote! choices, user_id: current_user.id      has_next_poll = Poll::Poll.upcoming_for_user(current_user.id).exists?      render Dashboard::Poll::Widget.new(poll).with_content(       Dashboard::Poll::Thanks.new(         poll,         choices: response.choices,         stats: poll.reveal_results? ? poll.stats : nil,         next_pol...",
              "source": "app/controllers/polls_controller.rb"
            },
            {
              "startLine": 13,
              "endLine": 17,
              "code": "    def ensure_logged_in       return true if current_user.logged_in?        head :forbidden     end",
              "source": "app/controllers/polls_controller.rb"
            }
          ],
          "sourceFiles": [
            {
              "path": "app/controllers/polls_controller.rb",
              "relevance": 24
            },
            {
              "path": "app/controllers/abstract/ajax_controller.rb",
              "relevance": 5
            },
            {
              "path": "app/controllers/abstract/bridge_api_controller.rb",
              "relevance": 5
            }
          ]
        }
      },
      "User::SubscriptionsController": {
        "type": "Controller",
        "description": "Manages user subscriptions to pinboard questions. Provides an action for users to unsubscribe from a question.",
        "interactions": {
          "interaction_0": "Finds `Xikolo::Pinboard::Subscription` based on `user_id` and `question_id`.",
          "interaction_1": "Deletes the found subscription.",
          "interaction_2": "Redirects to `preferences_path` after the operation."
        },
        "techDebt": [],
        "provenance": {
          "sources": [
            "app/controllers/user/subscriptions_controller.rb"
          ]
        },
        "codeImplementation": {
          "confidence": 0.95,
          "codeBlocks": [
            {
              "startLine": 1,
              "endLine": 23,
              "code": "# frozen_string_literal: true\n\nmodule User\n  class SubscriptionsController < ApplicationController\n    before_action :ensure_logged_in\n\n    def destroy\n      subscription = Xikolo::Pinboard::Subscription.find_by!(\n        user_id: current_user.id,\n        question_id: params[:question_id]\n      )\n      Acfs.run\n\n      if subscription.delete\n        add_flash_message :success, t(:'flash.success.subscription_canceled')\n      else\n        add_flash_message :error, t(:'flash.error.subscription_not_canceled')\n      end\n\n      redirect_to preferences_path\n    rescue Acfs::ResourceNotFound\n      # It's already gone\n      redirect_to preferences_path\n    end\n  end\nend",
              "source": "app/controllers/user/subscriptions_controller.rb"
            }
          ],
          "sourceFiles": [
            {
              "path": "app/controllers/user/subscriptions_controller.rb",
              "relevance": 31
            },
            {
              "path": "app/controllers/subscriptions_controller.rb",
              "relevance": 24
            },
            {
              "path": "services/pinboard/app/controllers/subscriptions_controller.rb",
              "relevance": 24
            }
          ]
        }
      },
      "IcalHelper": {
        "type": "Helper",
        "description": "Provides utility methods for generating secure iCal feed hashes and constructing iCal feed URLs.",
        "interactions": {
          "interaction_0": "Interacts with `Xikolo::Account::Token` to create a security token for the user.",
          "interaction_1": "Uses `Digest::SHA256` for hashing user ID and token.",
          "interaction_2": "Uses `UUID` for user ID formatting and `Xikolo.base_url` for URL construction."
        },
        "techDebt": [],
        "provenance": {
          "sources": [
            "app/helpers/ical_helper.rb"
          ]
        },
        "codeImplementation": {
          "confidence": 0.95,
          "codeBlocks": [
            {
              "startLine": 4,
              "endLine": 10,
              "code": "  # Build a hash from token and userID., can handle a user id or a user object\n  def ical_hash(user)\n    user_id = user.is_a?(String) ? user : user.id\n    token = Xikolo::Account::Token.create(user_id:)\n    Acfs.run\n    dig = Digest::SHA256.hexdigest [user_id, token.token].join\n    dig[10..20]\n  end",
              "source": "app/helpers/ical_helper.rb"
            },
            {
              "startLine": 12,
              "endLine": 18,
              "code": "  def ical_url(user, full_path: false)\n    path = \"ical.ical?u=#{UUID(user.id).to_param}&h=#{ical_hash(user)}\"\n    if full_path\n      Xikolo.base_url.join(path).to_s\n    else\n      \"/#{path}\"\n    end\n  end",
              "source": "app/helpers/ical_helper.rb"
            }
          ],
          "sourceFiles": [
            {
              "path": "app/helpers/ical_helper.rb",
              "relevance": 19
            }
          ]
        }
      },
      "CourseReactivation": {
        "type": "Utility Module",
        "description": "Provides configuration and logic for the course reactivation feature. It checks if reactivation is enabled (dependent on voucher feature) and provides locale-specific store URLs for purchasing reactivation vouchers.",
        "interactions": {
          "interaction_0": "Reads configuration from `Xikolo.config.course_reactivation` and `Xikolo.config.voucher`.",
          "interaction_1": "Used by `Course::FreeReactivationsController` to determine the reactivation period."
        },
        "techDebt": [],
        "provenance": {
          "sources": [
            "app/lib/course_reactivation.rb",
            "config/xikolo.yml"
          ]
        },
        "codeImplementation": {
          "confidence": 0.95,
          "codeBlocks": [
            {
              "startLine": 3,
              "endLine": 24,
              "code": "module CourseReactivation\n  class << self\n    def config(key)\n      Xikolo.config.course_reactivation[key]\n    end\n\n    def enabled?\n      # Course reactivations can only be booked using vouchers;\n      # require this feature to be enabled.\n      Xikolo.config.voucher['enabled'] &&\n        Xikolo.config.course_reactivation.present?\n    end\n\n    def store_url\n      configured_url = config 'store_url'\n\n      # If the config is a string, that's our URL and we're done\n      return configured_url if configured_url.respond_to? :to_str\n\n      # Otherwise, we assume one URL per locale, and fall back to English\n      configured_url[I18n.locale.to_s] || configured_url['en']\n    end\n  end\nend",
              "source": "app/lib/course_reactivation.rb"
            }
          ],
          "sourceFiles": [
            {
              "path": "app/lib/course_reactivation.rb",
              "relevance": 19
            }
          ]
        }
      },
      "Course::Enrollment": {
        "type": "Model (ActiveRecord)",
        "description": "Represents a user's enrollment in a course. It tracks the course association, active status, reactivation status, and proctoring information.",
        "interactions": {
          "interaction_0": "Belongs to `Course`.",
          "interaction_1": "Provides a scope `active` to filter non-deleted enrollments.",
          "interaction_2": "Checks `forced_submission_date` to determine if an enrollment is `reactivated?`.",
          "interaction_3": "Instantiates a `Proctoring` service if the enrollment is proctored.",
          "interaction_4": "Used by `DashboardController` to fetch active and completed enrollments.",
          "interaction_5": "Used by `Course::EnrollmentsStatistics` for counting enrollments."
        },
        "techDebt": [],
        "provenance": {
          "sources": [
            "app/models/course/enrollment.rb"
          ]
        },
        "codeImplementation": {
          "confidence": 0.95,
          "codeBlocks": [
            {
              "startLine": 1,
              "endLine": 19,
              "code": "# frozen_string_literal: true\n\nmodule Course\n  class EnrollmentPolicyForm < ApplicationComponent\n    def initialize(course_identifier)\n      @course = ::Course::Course.by_identifier(course_identifier).take!\n    end\n\n    def course_title\n      @course.title\n    end\n\n    def course_code\n      @course.course_code\n    end\n\n    def enrollment_policy_url\n      Translations.new(@course.policy_url).to_s\n    end\n  end\nend",
              "source": "app/components/course/enrollment_policy_form.rb"
            },
            {
              "startLine": 1,
              "endLine": 28,
              "code": "# frozen_string_literal: true\n\nmodule Course\n  class EnrollmentStatistics < ApplicationComponent\n    MIN_ENROLLMENTS = 500\n\n    def initialize(course, user:)\n      @course = course\n      @user = user\n      @stats = ::Course::Course.find(@course.id).stats.enrollments\n    end\n\n    def enrollment_statistics\n      return unless @course.end_date&.past?\n\n      @enrollment_statistics ||= [].tap do |stats|\n        stats << {\n          type: 'current',\n          count: readable_count(@stats.current),\n          date: I18n.t(:'course.courses.enrollment_statistics.current.date'),\n        }\n        if @stats.at_end.present?\n          stats << {\n            type: 'course_end',\n            count: readable_count(@stats.at_end),\n            date: I18n.l(@course.end_date.in_time_zone.to_date, format: :short),\n          }\n        end\n        if @stats.at_start.present?\n          stats << {\n            type: 'course_start',\n            count: readable_count(@stats.at_start),\n            date: I18n.l(@cour...",
              "source": "app/components/course/enrollment_policy_form.rb"
            }
          ],
          "sourceFiles": [
            {
              "path": "app/components/course/enrollment_policy_form.rb",
              "relevance": 37
            },
            {
              "path": "app/components/course/enrollment_policy_form_preview.rb",
              "relevance": 37
            },
            {
              "path": "app/components/course/enrollment_statistics.rb",
              "relevance": 37
            }
          ]
        }
      },
      "Course::EnrollmentsStatistics": {
        "type": "Service Object / Utility",
        "description": "Calculates various enrollment statistics for a given course, including current, at start date, and at end date enrollments, accounting for any `enrollment_delta`.",
        "interactions": {
          "interaction_0": "Initialized with a `Course::Course` object.",
          "interaction_1": "Queries `course.enrollments` and uses `course.enrollment_delta` for calculations.",
          "interaction_2": "Used by `Course::EnrollmentStatistics` ViewComponent to display data."
        },
        "techDebt": [],
        "provenance": {
          "sources": [
            "app/models/course/enrollments_statistics.rb"
          ]
        },
        "codeImplementation": {
          "confidence": 0.95,
          "codeBlocks": [
            {
              "startLine": 1,
              "endLine": 31,
              "code": "# frozen_string_literal: true\n\nmodule Course\n  class EnrollmentsStatistics\n    # @param course [Course::Course]\n    def initialize(course:)\n      @course = course\n      @enrollments = course.enrollments.unscope(:order)\n    end\n\n    def current\n      @enrollments.count + @course.enrollment_delta\n    end\n\n    def at_start\n      return unless @course.start_date&.past?\n\n      enrollments = created_by(@enrollments, date: @course.start_date)\n      enrollments.count + @course.enrollment_delta\n    end\n\n    def at_end\n      return unless @course.end_date&.past?\n\n      enrollments = created_by(@enrollments, date: @course.end_date)\n      enrollments.count + @course.enrollment_delta\n    end\n\n    private\n\n    def created_by(scope, date:)\n      scope.where(created_at: ..date)\n    end\n  end\nend",
              "source": "app/models/course/enrollments_statistics.rb"
            }
          ],
          "sourceFiles": [
            {
              "path": "app/models/course/enrollments_statistics.rb",
              "relevance": 26
            },
            {
              "path": "api/xikolo/entities/course_date.rb",
              "relevance": 7
            },
            {
              "path": "api/xikolo/model/course_repository.rb",
              "relevance": 7
            }
          ]
        }
      },
      "Admin::SubscriptionListPresenter": {
        "type": "Presenter",
        "description": "Presents a list of subscriptions, providing pagination capabilities for administrative views.",
        "interactions": {
          "interaction_0": "Wraps a collection of subscriptions (likely `Xikolo::Pinboard::Subscription` resources).",
          "interaction_1": "Uses `RestifyPaginationCollection` for pagination."
        },
        "techDebt": [],
        "provenance": {
          "sources": [
            "app/presenters/admin/subscription_list_presenter.rb"
          ]
        }
      },
      "Course::DashboardPresenter": {
        "type": "Presenter",
        "description": "Provides static methods for transforming course dashboard statistics (enrollments, forum activity) into chart-friendly formats and for calculating historic date labels and vertical lines.",
        "interactions": {
          "interaction_0": "Provides data transformation logic for charting.",
          "interaction_1": "Uses `I18n` for localized labels.",
          "interaction_2": "Processes `Course` objects to determine start/end dates for historic lines."
        },
        "techDebt": [],
        "provenance": {
          "sources": [
            "app/presenters/course/dashboard_presenter.rb"
          ]
        },
        "codeImplementation": {
          "confidence": 0.9,
          "codeBlocks": [
            {
              "startLine": 1,
              "endLine": 30,
              "code": "# frozen_string_literal: true\n\nmodule Gamification\n  class DashboardPresenter\n    # @param user [Account::User]\n    def initialize(user)\n      @user = user\n    end\n\n    def badges\n      @badges ||= begin\n        gained = @user.gamification_badges\n          .unscope(:order)\n          .group(:name, :user_id, :course_id)\n          .select('COUNT(id), name, user_id, course_id, MAX(level) as level')\n          .to_a\n\n        missing = Badge.types.keys - gained.map(&:name)\n\n        gained + missing.map do |name|\n          Badge.new(name:, user: @user, level: Badge.types[name]['levels'].keys.first)\n        end\n      end\n    end\n\n    def scores\n      @scores ||= Gamification::ScoresPresenter.new(@user)\n    end\n  end\nend",
              "source": "app/presenters/gamification/dashboard_presenter.rb"
            }
          ],
          "sourceFiles": [
            {
              "path": "app/presenters/gamification/dashboard_presenter.rb",
              "relevance": 24
            },
            {
              "path": "app/presenters/course/admin/metadata_edit_presenter.rb",
              "relevance": 12
            },
            {
              "path": "app/presenters/course/admin/visual_edit_presenter.rb",
              "relevance": 12
            }
          ]
        }
      },
      "Course::DeadlinesPresenter": {
        "type": "Presenter",
        "description": "Presents upcoming deadlines for a user within a specific course. It fetches `NextDate` resources from the `Xikolo::CourseService` and wraps them in `Deadline` objects, indicating urgency.",
        "interactions": {
          "interaction_0": "Communicates with `Xikolo.api(:course).rel(:next_dates)` to fetch deadline data.",
          "interaction_1": "Uses `ActionView::Helpers::DateHelper` for time formatting.",
          "interaction_2": "Uses `Rails.application.routes.url_helpers` to generate URLs for specific deadlines.",
          "interaction_3": "Relies on the `NextDate` resource structure and visibility rules from the Course Service. [Source: services/course/app/models/next_date.rb]"
        },
        "techDebt": [],
        "provenance": {
          "sources": [
            "app/presenters/course/deadlines_presenter.rb",
            "services/course/app/models/next_date.rb"
          ]
        },
        "codeImplementation": {
          "confidence": 0.98,
          "codeBlocks": [
            {
              "startLine": 1,
              "endLine": 42,
              "code": "# frozen_string_literal: true\n\nmodule Course\n  ##\n  # Used in the course area to present upcoming deadlines, in this course,\n  # for the current user.\n  #\n  class DeadlinesPresenter\n    def initialize(user, course)\n      @user = user\n\n      return if @user.anonymous?\n\n      course_api = Xikolo.api(:course).value\n      return unless course_api&.rel?(:next_dates)\n\n      @promise = course_api.rel(:next_dates).get({\n        course_id: course.id,\n        user_id: @user.id,\n        all: true,\n        type: 'item_submission_deadline,on_demand_expires',\n      })\n    end\n\n    def show?\n      @user.logged_in?\n    end\n\n    def any?\n      deadlines.present?\n    end\n\n    def count\n      deadlines.count\n    end\n\n    def state\n      deadlines.any?(&:urgent?) ? 'urgent' : 'uncritical'\n    end\n\n    def each\n      deadlines.each { yield it }\n    end\n\n    private\n\n    def deadlines\n      @deadlines ||= if @promise&.value\n                       @promise.value.map { Deadline.new it }\n                     e...\n",
              "source": "app/presenters/course/deadlines_presenter.rb"
            }
          ],
          "sourceFiles": [
            {
              "path": "app/presenters/course/deadlines_presenter.rb",
              "relevance": 31
            },
            {
              "path": "app/presenters/course/admin/metadata_edit_presenter.rb",
              "relevance": 12
            },
            {
              "path": "app/presenters/course/admin/visual_edit_presenter.rb",
              "relevance": 12
            }
          ]
        }
      },
      "Course::ProgressPresenter": {
        "type": "Presenter",
        "description": "Presents a user's overall and section-level progress within a course. It fetches progress data and delegates to `Course::SectionProgressPresenter` for detailed section information. It also determines if the course is in 'open mode'.",
        "interactions": {
          "interaction_0": "Fetches `Xikolo::Course::Progress` records for the user and course.",
          "interaction_1": "Uses `Acfs.on` for concurrent data fetching.",
          "interaction_2": "Delegates to `Course::SectionProgressPresenter` for rendering section-specific progress.",
          "interaction_3": "Checks `user.allowed_any?` to determine 'open mode' access."
        },
        "techDebt": [
          "The presenter handles two types of user objects (`Xikolo::Common::Auth::CurrentUser` or `Xikolo::Account::User`), requiring `respond_to?` checks for methods like `allowed_any?`, indicating a potential type inconsistency or need for a unified interface. [Source: app/presenters/course/progress_presenter.rb]"
        ],
        "provenance": {
          "sources": [
            "app/presenters/course/progress_presenter.rb"
          ]
        }
      },
      "Course::SectionProgressPresenter": {
        "type": "Presenter",
        "description": "Presents the progress for a specific course section, including its availability, optional status, description, and the items contained within it. It delegates to `ItemPresenter` for individual item details.",
        "interactions": {
          "interaction_0": "Wraps a section object (likely a `Xikolo::Course::Section` resource).",
          "interaction_1": "Iterates through `section.items` and uses `ItemPresenter.for` to present each item.",
          "interaction_2": "Relies on `Xikolo::Course::Item` for item details."
        },
        "techDebt": [],
        "provenance": {
          "sources": [
            "app/presenters/course/section_progress_presenter.rb"
          ]
        }
      }
    },
    "microservices": {},
    "interactions": {
      "interaction_0": "Interacts with the underlying Course model (via microservice) for persistence.",
      "interaction_1": "Uses `ChannelHelper` for image dimension constants.",
      "interaction_2": "Validates course status, code, title, language, description, and classifier formats.",
      "interaction_3": "Uses `CourseContextHelper` for course context and eligibility checks.",
      "interaction_4": "Interacts with `Xikolo::Course::Section` microservice client for section data.",
      "interaction_5": "Interacts with `Course::Course` model to determine legacy status.",
      "interaction_6": "Creates `Xikolo::Pinboard::ImplicitTag` when a section is created.",
      "interaction_7": "Redirects to `course_item_path` or `course_resume_path` after section show action.",
      "interaction_8": "Uses `CourseContextHelper` and `ItemContextHelper` for context and eligibility.",
      "interaction_9": "Interacts with `Xikolo::Course::Item` microservice client for item data.",
      "interaction_10": "Interacts with `Video::Video`, `Course::Richtext`, `Xikolo::Quiz::Quiz`, `Lti::Exercise` for content-specific data.",
      "interaction_11": "Utilizes `Item::Create` operation for item creation.",
      "interaction_12": "Uses `Video::Store`, `Course::Richtext::Store`, `Lti::Exercise::Store` for content persistence.",
      "interaction_13": "Creates `Xikolo::Course::Visit` records for item views.",
      "interaction_14": "Loads `Lti::Provider` for LTI exercises.",
      "interaction_15": "Redirects based on content type after creation or update.",
      "interaction_16": "Uses `CourseContextHelper` for course context.",
      "interaction_17": "Uses `DocumentHelper` for document-related actions and helpers.",
      "interaction_18": "Interacts with `course_api` (Xikolo::CourseService) to fetch document lists and individual documents.",
      "interaction_19": "Requires user to be logged in (`ensure_logged_in`).",
      "interaction_20": "Interacts with `course_api` (Xikolo::CourseService) to check existing enrollments, create new ones, and destroy them.",
      "interaction_21": "Handles `Restify::UnprocessableEntity` errors for access restrictions and unfulfilled prerequisites.",
      "interaction_22": "Fetches course details from `Xikolo.api(:course)`.",
      "interaction_23": "Redirects to `create_enrollment_path` if authenticated.",
      "interaction_24": "Redirects to `login_url` if anonymous and no `auth` parameter is present.",
      "interaction_25": "Stores the intended course location for post-login redirection.",
      "interaction_26": "Requires user to be logged in (`ensure_logged_in`).",
      "interaction_27": "Interacts with `course_api` to fetch course prerequisites and create new enrollments/reactivations.",
      "interaction_28": "Responds with JSON status codes for success or failure.",
      "interaction_29": "Uses `CourseContextHelper` for course context.",
      "interaction_30": "Requires user to be logged in (`ensure_logged_in`).",
      "interaction_31": "Fetches user details from `Xikolo::Account::User` if a specific user ID is provided.",
      "interaction_32": "Interacts with `course_api` (Xikolo::CourseService) to retrieve progress data.",
      "interaction_33": "Uses `Course::DocumentsPresenter` to display course documents and certificates.",
      "interaction_34": "Uses `CourseContextHelper` for course context.",
      "interaction_35": "Loads section navigation (`load_section_nav`).",
      "interaction_36": "Uses `Course::ProgressPresenter` to build progress data.",
      "interaction_37": "Interacts with `Xikolo.api(:course)` to fetch previewable items for open mode.",
      "interaction_38": "Defines `inside_course` which calls `layout` and `before_action :check_course_eligibility`.",
      "interaction_39": "The `check_course_eligibility` method checks user permissions, course availability, and enrollment status.",
      "interaction_40": "Provides `the_course`, `the_section`, `the_item` promises for lazy loading resources.",
      "interaction_41": "Loads section navigation using `Navigation::TableOfContents`.",
      "interaction_42": "Defines `inside_item` which calls `layout`, `before_action :load_section_nav`, `before_action :create_position_presenter!`, `before_action :create_item_presenter!`, and `before_action :check_course_path`.",
      "interaction_43": "Creates `Course::PositionPresenter` and `ItemPresenter` instances.",
      "interaction_44": "Records user visits to items via `Xikolo::Course::Visit.create`.",
      "interaction_45": "Interacts with `Xikolo.api(:course)` (CourseService) for document and localization CRUD operations.",
      "interaction_46": "Uses `FileUpload` for S3 uploads of document files.",
      "interaction_47": "Handles error messages for document creation.",
      "interaction_48": "Interacts with `Xikolo::S3::SingleFileUpload` to manage uploaded files.",
      "interaction_49": "Parses and validates JSON data from uploaded files against a schema.",
      "interaction_50": "Persists metadata to the `Metadata` ActiveRecord model within a transaction.",
      "interaction_51": "Captures errors with `Mnemosyne` and `Sentry`.",
      "interaction_52": "Uses `Xikolo::S3::TextWithUploadsProcessor` to parse and manage text with embedded uploads.",
      "interaction_53": "Interacts with `S3FileDeletionJob` for asynchronous deletion of obsolete S3 files.",
      "interaction_54": "Persists rich text content to the `Course::Richtext` model.",
      "interaction_55": "Interacts with `Xikolo::S3::SingleFileUpload` and `Xikolo::S3::UploadByUri` for S3 file management.",
      "interaction_56": "Persists visual data to `Course::Visual` and video data to `Video::Video`.",
      "interaction_57": "Uses `S3FileDeletionJob` for asynchronous deletion of old S3 files.",
      "interaction_58": "Captures errors with `Mnemosyne`.",
      "interaction_59": "Validates and saves the content resource (`@content`).",
      "interaction_60": "Sets `content_id` and `section_id` on the item.",
      "interaction_61": "Saves the item resource (`@item`).",
      "interaction_62": "Creates `Xikolo::Pinboard::ImplicitTag` for the new item.",
      "interaction_63": "Handles `Restify::ClientError`, `Acfs::InvalidResource`, and `Acfs::ErroneousResponse` for content and item creation.",
      "interaction_64": "Receives `course`, `enrollment`, `user`, and `type` as initialization parameters.",
      "interaction_65": "Renders actions and conditional buttons based on user features (e.g., `course_reactivation`).",
      "interaction_66": "Uses `Imagecrop` for visual resizing and `Xikolo::S3` for course visuals.",
      "interaction_67": "Fetches `Course::Cluster` data for classifiers.",
      "interaction_68": "Determines subtitle information from `Course::Course`.",
      "interaction_69": "Fetches course data from `Catalog::Course` (released, for global list, for guests).",
      "interaction_70": "Caches course lists for 30 minutes.",
      "interaction_71": "Checks `user.feature?('course_list')` to determine rendering.",
      "interaction_72": "Wraps a course hash (`@course`).",
      "interaction_73": "Checks for `Certificate::Template` and `Certificate::OpenBadgeTemplate` existence for certificate availability.",
      "interaction_74": "Delegates attributes to the `@course` object (Restify resource).",
      "interaction_75": "Renders markdown for abstract and description.",
      "interaction_76": "Determines `date_label` based on start/end dates.",
      "interaction_77": "Checks `user.feature?` for `course_details.learning_goals`, `course_reactivation`, `certificate_requirements`, `course_rating`.",
      "interaction_78": "Interacts with `Course::Visual` for visual URLs.",
      "interaction_79": "Uses `BasicCoursePresenter` for shared certificate logic.",
      "interaction_80": "Initializes a `VideoPresenter` if a teaser video exists.",
      "interaction_81": "Determines `unenrollment_enabled?` based on `invite_only` and `external_registration_url`.",
      "interaction_82": "Initializes `Proctoring::CourseContext` for proctoring status.",
      "interaction_83": "Checks `user.feature?('proctoring')`.",
      "interaction_84": "Uses `MenuWithPermissions` for permission-based item visibility.",
      "interaction_85": "Checks `course.pinboard_enabled` and `Xikolo.config.beta_features['documents']` for item visibility.",
      "interaction_86": "Determines active state based on controller name.",
      "interaction_87": "Delegates attributes to the `@course` object.",
      "interaction_88": "Fetches item and section collections from `Course::Course`.",
      "interaction_89": "Checks `user.allowed?('course.course.recalculate')` and `the_course.needs_recalculation?` for recalculation features.",
      "interaction_90": "Uses `MenuWithPermissions` for permission-based item visibility.",
      "interaction_91": "Checks `user.allowed?` for various course-related permissions (e.g., `course.dashboard.view`, `course.content.edit`).",
      "interaction_92": "Checks `Xikolo.config.beta_features['teaching_team_pinboard_activity']` and `Transpipe.enabled?` for specific features.",
      "interaction_93": "Wraps a collection of document resources.",
      "interaction_94": "Extracts unique languages from document localizations.",
      "interaction_95": "Creates `DocumentListFilter` instances for filtering UI.",
      "interaction_96": "Delegates to `DocumentPresenter` for individual document display.",
      "interaction_97": "Wraps a document resource and a collection of courses.",
      "interaction_98": "Maps course IDs to course titles.",
      "interaction_99": "Uses `I18nData` to translate localization languages.",
      "interaction_100": "Fetches course details via `course_api` and wraps them in `BasicCoursePresenter`.",
      "interaction_101": "Finds `Certificate::Template` and `Certificate::OpenBadgeTemplate` based on course and certificate type.",
      "interaction_102": "Checks `enrollment.certificates` and `user.feature?('proctoring')`.",
      "interaction_103": "Interacts with `Proctoring::SmowlAdapter` to check if user passed proctoring.",
      "interaction_104": "Builds `FeaturedVideoItem` for video content types.",
      "interaction_105": "Raises an error for unsupported content types.",
      "interaction_106": "Delegates attributes to the `@item` and `@course` objects.",
      "interaction_107": "Determines `partial_name` and `layout` based on content type.",
      "interaction_108": "Checks `Course::RequiredItemPresenter` for item requirements.",
      "interaction_109": "Uses `Course::Item::Icon` for icon classes.",
      "interaction_110": "Checks `user.feature?('time_effort')` for time effort display.",
      "interaction_111": "Determines `locked?` status based on user permissions, item availability, and open mode.",
      "interaction_112": "Extends `ItemPresenter`.",
      "interaction_113": "Finds the associated `Course::Richtext` content.",
      "interaction_114": "Uses `MarkdownHelper` to render the rich text content.",
      "interaction_115": "Delegates attributes to the `@section` object.",
      "interaction_116": "Fetches items for the section from `Xikolo.api(:course)`.",
      "interaction_117": "Determines `unlocked?` status based on start/end dates.",
      "interaction_118": "Fetches `Xikolo::Course::SectionChoice` and `Course::Section` for alternative sections.",
      "interaction_119": "Enqueues implicit tags for pinboards.",
      "interaction_120": "Uses `MarkdownHelper` to render statements.",
      "interaction_121": "Parses the statement string to extract `quote_by`.",
      "interaction_122": "Extends `ItemPresenter`.",
      "interaction_123": "Sets `partial_name` to `items/show_unsupported_item`.",
      "interaction_124": "Modifies DOM elements using `setVisibility`, `hidePublicDescription`, and `hideAndUncheckSwitch` helpers.",
      "interaction_125": "Called when the content type selection changes to 'rich text'.",
      "interaction_126": "Uses `toggleUuids` to show/hide section UUIDs.",
      "interaction_127": "Attaches event listeners to 'new item' and 'delete section' buttons.",
      "interaction_128": "Uses `sessionStorage` to preserve scroll position.",
      "interaction_129": "Displays `swal` (SweetAlert2) for delete forbidden messages.",
      "interaction_130": "Used by `Course::CoursesController`, `CourseContextHelper`, `CourseInfoPresenter`, `CoursePresenter`, `Home::CourseCard` and others to fetch course data.",
      "interaction_131": "Provides methods for checking course availability (`was_available?`, `published?`).",
      "interaction_132": "Exposes relations like `sections`, `items`, `enrollments`.",
      "interaction_133": "Used by `SectionsController` for CRUD operations on sections.",
      "interaction_134": "Used by `CourseContextHelper` to fetch the current section.",
      "interaction_135": "Used by `Item::Create` to associate items with sections.",
      "interaction_136": "Used by `ItemsController` for CRUD operations on items.",
      "interaction_137": "Used by `CourseContextHelper` to fetch the current item.",
      "interaction_138": "Used by `Item::Create` to create new items.",
      "interaction_139": "Provides attributes like `content_type`, `content_id`, `open_mode`, `featured`.",
      "interaction_140": "Created by `ItemContextHelper#create_visit!` when a user views an item.",
      "interaction_141": "Used by `ItemsController` when creating or editing quiz items.",
      "interaction_142": "Provides attributes like `allowed_attempts`, `time_limit_seconds`, `instructions`.",
      "interaction_143": "Used by `ItemsController` when creating or editing LTI exercise items.",
      "interaction_144": "Interacts with `Lti::Exercise::Store` for persistence.",
      "interaction_145": "Used by `ItemsController` when creating or editing video items.",
      "interaction_146": "Used by `Course::Visual::Store` for managing teaser videos.",
      "interaction_147": "Interacts with `Video::Store` for persistence and file management.",
      "interaction_148": "Used by `ItemsController` when creating or editing rich text items.",
      "interaction_149": "Interacts with `Course::Richtext::Store` for persistence and file management.",
      "interaction_150": "Rendered by other views or components (e.g., `ItemPresenter` or `Course::SectionProgressPresenter`) to visualize user progress.",
      "interaction_151": "Interacts with `Course::Course` model to fetch course details using `by_identifier`.",
      "interaction_152": "Submits enrollment data to `Course::EnrollmentsController#create` via `enrollments_path`.",
      "interaction_153": "Uses `Translations` utility for policy URL localization.",
      "interaction_154": "Interacts with `Course::Course` to get course details and `Course::EnrollmentsStatistics` to retrieve enrollment counts.",
      "interaction_155": "Checks `user.allowed?('course.enrollment_counter.view')` for permission to display the count.",
      "interaction_156": "Uses `I18n` for localization and `number_with_delimiter` for count formatting.",
      "interaction_157": "Checks `user.feature?('ical_feed')` to determine if it should render.",
      "interaction_158": "Uses `IcalHelper#ical_url` to generate the iCal feed URL.",
      "interaction_159": "Renders `Global::DisclosureWidget` and `Global::CopyToClipboard` for UI presentation.",
      "interaction_160": "Interacts with `Poll::Poll` model to find polls and add/delete options.",
      "interaction_161": "Renders the `admin/polls/options_form` partial to update the options list.",
      "interaction_162": "Interacts with `Poll::Poll` model for all CRUD operations.",
      "interaction_163": "Uses `add_flash_message` for user feedback on operations.",
      "interaction_164": "Redirects to `edit_admin_poll_path` or `admin_polls_path` after actions.",
      "interaction_165": "Communicates with `Xikolo.api(:course)` (specifically `Xikolo::CourseService`) for enrollment creation, retrieval, and deletion.",
      "interaction_166": "Checks `current_user.allowed?('course.content.access')` for invite-only courses.",
      "interaction_167": "Handles `Restify::UnprocessableEntity` exceptions for various enrollment restrictions (e.g., access restricted, prerequisites unfulfilled).",
      "interaction_168": "Redirects to `course_resume_path`, `course_path`, or `dashboard_path` based on action outcome.",
      "interaction_169": "Communicates with `Xikolo.api(:course)` to fetch prerequisite status and post reactivation requests.",
      "interaction_170": "Uses `CourseReactivation.config('period')` to determine the duration of the reactivation period.",
      "interaction_171": "Handles `Restify::UnprocessableEntity` for failed reactivation attempts.",
      "interaction_172": "Uses `CourseContextHelper` to establish the course context.",
      "interaction_173": "Fetches user details from `Xikolo::Account::User` if an admin is viewing another user's progress.",
      "interaction_174": "Instantiates `Course::DocumentsPresenter` and uses `Acfs.run` to fetch course documents.",
      "interaction_175": "Communicates with `Xikolo.api(:course)` to retrieve course progress data.",
      "interaction_176": "Sets the page title using `set_page_title`.",
      "interaction_177": "Uses `CourseContextHelper` to get the course context.",
      "interaction_178": "Communicates with `Xikolo.api(:pinboard)` to create or delete course subscriptions.",
      "interaction_179": "Redirects back to `course_pinboard_index_path` after actions.",
      "interaction_180": "Redirects `index` action to `dashboard`.",
      "interaction_181": "Fetches `Xikolo::Account::Authorization` if an authorization parameter is present (e.g., after SSO signup).",
      "interaction_182": "Loads sidebar content, including promoted courses and next dates, using `Xikolo.api(:course)`.",
      "interaction_183": "Retrieves user enrollments from `Course::Enrollment.active` and categorizes `Catalog::Course.released` courses.",
      "interaction_184": "Renders `Home::CourseCard` components for courses.",
      "interaction_185": "For achievements, uses `Gamification::DashboardPresenter` with `Account::User` data.",
      "interaction_186": "For documents, iterates `Xikolo::Course::Enrollment` to find certificates and uses `DocumentsPresenter` and `Xikolo::Account::Preferences`.",
      "interaction_187": "Utilizes `Acfs.run` for concurrent API calls.",
      "interaction_188": "Requires the 'gamification' feature for achievements.",
      "interaction_189": "Requires the 'ical_feed' feature to be enabled.",
      "interaction_190": "Uses `IcalHelper` for generating the authentication hash and URL.",
      "interaction_191": "Fetches `NextDate` events from `Xikolo.api(:course).rel(:next_dates)`.",
      "interaction_192": "Finds `User` from `Xikolo::Account` to set the user's locale for event descriptions.",
      "interaction_193": "Uses the `Icalendar` gem to construct the iCal calendar.",
      "interaction_194": "Uses `Course::NextDatePresenter` to format event details for the calendar.",
      "interaction_195": "Interacts with `Poll::Poll` model to retrieve polls, check for upcoming polls, and record votes.",
      "interaction_196": "Uses `PollArchivePresenter` for formatting archived polls.",
      "interaction_197": "Renders `Dashboard::Poll::Widget` and its content components (e.g., `Dashboard::Poll::Question`, `Dashboard::Poll::Thanks`).",
      "interaction_198": "Finds `Xikolo::Pinboard::Subscription` based on `user_id` and `question_id`.",
      "interaction_199": "Deletes the found subscription.",
      "interaction_200": "Redirects to `preferences_path` after the operation.",
      "interaction_201": "Interacts with `Xikolo::Account::Token` to create a security token for the user.",
      "interaction_202": "Uses `Digest::SHA256` for hashing user ID and token.",
      "interaction_203": "Uses `UUID` for user ID formatting and `Xikolo.base_url` for URL construction.",
      "interaction_204": "Used by views or other components to display calculated progress percentages.",
      "interaction_205": "Reads configuration from `Xikolo.config.course_reactivation` and `Xikolo.config.voucher`.",
      "interaction_206": "Used by `Course::FreeReactivationsController` to determine the reactivation period.",
      "interaction_207": "Belongs to `Course`.",
      "interaction_208": "Provides a scope `active` to filter non-deleted enrollments.",
      "interaction_209": "Checks `forced_submission_date` to determine if an enrollment is `reactivated?`.",
      "interaction_210": "Instantiates a `Proctoring` service if the enrollment is proctored.",
      "interaction_211": "Used by `DashboardController` to fetch active and completed enrollments.",
      "interaction_212": "Used by `Course::EnrollmentsStatistics` for counting enrollments.",
      "interaction_213": "Initialized with a `Course::Course` object.",
      "interaction_214": "Queries `course.enrollments` and uses `course.enrollment_delta` for calculations.",
      "interaction_215": "Used by `Course::EnrollmentStatistics` ViewComponent to display data.",
      "interaction_216": "Wraps a collection of subscriptions (likely `Xikolo::Pinboard::Subscription` resources).",
      "interaction_217": "Uses `RestifyPaginationCollection` for pagination.",
      "interaction_218": "Provides data transformation logic for charting.",
      "interaction_219": "Uses `I18n` for localized labels.",
      "interaction_220": "Processes `Course` objects to determine start/end dates for historic lines.",
      "interaction_221": "Communicates with `Xikolo.api(:course).rel(:next_dates)` to fetch deadline data.",
      "interaction_222": "Uses `ActionView::Helpers::DateHelper` for time formatting.",
      "interaction_223": "Uses `Rails.application.routes.url_helpers` to generate URLs for specific deadlines.",
      "interaction_224": "Relies on the `NextDate` resource structure and visibility rules from the Course Service. [Source: services/course/app/models/next_date.rb]",
      "interaction_225": "Fetches `Xikolo::Course::Progress` records for the user and course.",
      "interaction_226": "Uses `Acfs.on` for concurrent data fetching.",
      "interaction_227": "Delegates to `Course::SectionProgressPresenter` for rendering section-specific progress.",
      "interaction_228": "Checks `user.allowed_any?` to determine 'open mode' access.",
      "interaction_229": "Wraps a section object (likely a `Xikolo::Course::Section` resource).",
      "interaction_230": "Iterates through `section.items` and uses `ItemPresenter.for` to present each item.",
      "interaction_231": "Relies on `Xikolo::Course::Item` for item details."
    },
    "technicalDebt": [
      "TODO@JG: null values in section_params for dates.",
      "TODO: the redirect should differentiate between logged in and anonymous users in `show` action.",
      "Error handling inconsistencies between content types for inline vs. flash messages.",
      "TODO: reuse passed in upload ids in `create_video_uploads!`.",
      "The `current_user` passed to `Course::DocumentsPresenter` might be an admin/teacher, not the actual user whose progress is being monitored, which needs refactoring.",
      "TODO: improve checks in `check_course_eligibility`.",
      "TODO: Get rid of `Rails/HelperInstanceVariable`.",
      "TODO: Improve generic error handling for more helpful inline messages.",
      "FIXME: `user.feature?('quiz_recap') && course.was_available?` should not use `was_available?` for quiz recap.",
      "TODO: Implement pagination for the poll listing [Source: app/controllers/admin/polls_controller.rb]",
      "The `current_user` is passed to `Course::DocumentsPresenter` to check for features, even when an admin is monitoring another user's progress. This indicates a potential design flaw or area for refactoring the user object interface. [Source: app/controllers/course/progress_controller.rb]",
      "TODO: Show some fancy notice to set a password when a new user account is created on-the-fly via SSO. [Source: app/controllers/dashboard_controller.rb]",
      "A commented-out line for filtering `next_dates` by date range suggests a potential incomplete feature or a change in requirements. [Source: app/controllers/dashboard_controller.rb]",
      "The presenter handles two types of user objects (`Xikolo::Common::Auth::CurrentUser` or `Xikolo::Account::User`), requiring `respond_to?` checks for methods like `allowed_any?`, indicating a potential type inconsistency or need for a unified interface. [Source: app/presenters/course/progress_presenter.rb]"
    ]
  }
}