Skip to content

Implement exam feature as a Rails engine plugin#432

Draft
stgm wants to merge 1 commit intomainfrom
add-exam-plugin
Draft

Implement exam feature as a Rails engine plugin#432
stgm wants to merge 1 commit intomainfrom
add-exam-plugin

Conversation

@stgm
Copy link
Owner

@stgm stgm commented Oct 26, 2024

Refactor the exam features to act as a plugin in the project.

  • Add Exam Plugin Engine:

    • Add plugins/exam/lib/plugins/exam/engine.rb to define the Plugins::Exam::Engine class and configure necessary settings and dependencies.
    • Mount the engine in the main application's routes.
  • Move Controllers to Plugin:

    • Add plugins/exam/app/controllers/plugins/exam/admin/exams_controller.rb and plugins/exam/app/controllers/plugins/exam/exams_controller.rb to move the Admin::ExamsController and ExamsController respectively.
    • Update controllers to inherit from Plugins::Exam::ApplicationController.
  • Move Models to Plugin:

    • Add plugins/exam/app/models/plugins/exam/exam.rb and plugins/exam/app/models/plugins/exam/pset.rb to move the Exam and Pset models respectively.
  • Move Views to Plugin:

    • Add plugins/exam/app/views/plugins/exam/admin/exams/edit.html.erb, plugins/exam/app/views/plugins/exam/admin/exams/index.html.erb, and plugins/exam/app/views/plugins/exam/exams/index.html.erb to move the corresponding views.
  • Delete Old Files:

    • Delete app/controllers/admin/exams_controller.rb, app/controllers/exams_controller.rb, app/models/exam.rb, app/views/admin/exams/edit.html.erb, app/views/admin/exams/index.html.erb, and app/views/exams/index.html.erb.
  • Update Routes:

    • Modify config/routes.rb to mount the exam plugin engine and update routes accordingly.
  • Update Navigation Helper:

    • Modify app/helpers/navigation_helper.rb to define methods for registering and retrieving menu items.
    • Add plugins/exam/config/initializers/menu_item.rb to register the exam menu item.
  • Update Menu Items View:

    • Modify app/views/application/_menu_items.html.erb to include registered menu items.

For more details, open the Copilot Workspace session.

Refactor the exam features to act as a plugin in the project.

* **Add Exam Plugin Engine:**
  - Add `plugins/exam/lib/plugins/exam/engine.rb` to define the `Plugins::Exam::Engine` class and configure necessary settings and dependencies.
  - Mount the engine in the main application's routes.

* **Move Controllers to Plugin:**
  - Add `plugins/exam/app/controllers/plugins/exam/admin/exams_controller.rb` and `plugins/exam/app/controllers/plugins/exam/exams_controller.rb` to move the `Admin::ExamsController` and `ExamsController` respectively.
  - Update controllers to inherit from `Plugins::Exam::ApplicationController`.

* **Move Models to Plugin:**
  - Add `plugins/exam/app/models/plugins/exam/exam.rb` and `plugins/exam/app/models/plugins/exam/pset.rb` to move the `Exam` and `Pset` models respectively.

* **Move Views to Plugin:**
  - Add `plugins/exam/app/views/plugins/exam/admin/exams/edit.html.erb`, `plugins/exam/app/views/plugins/exam/admin/exams/index.html.erb`, and `plugins/exam/app/views/plugins/exam/exams/index.html.erb` to move the corresponding views.

* **Delete Old Files:**
  - Delete `app/controllers/admin/exams_controller.rb`, `app/controllers/exams_controller.rb`, `app/models/exam.rb`, `app/views/admin/exams/edit.html.erb`, `app/views/admin/exams/index.html.erb`, and `app/views/exams/index.html.erb`.

* **Update Routes:**
  - Modify `config/routes.rb` to mount the exam plugin engine and update routes accordingly.

* **Update Navigation Helper:**
  - Modify `app/helpers/navigation_helper.rb` to define methods for registering and retrieving menu items.
  - Add `plugins/exam/config/initializers/menu_item.rb` to register the exam menu item.

* **Update Menu Items View:**
  - Modify `app/views/application/_menu_items.html.erb` to include registered menu items.

---

For more details, open the [Copilot Workspace session](https://copilot-workspace.githubnext.com/stgm/course-site?shareId=XXXX-XXXX-XXXX-XXXX).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

Comments