0

I am creating a learning management system, where admins can create Curriculums and assign it to users. A Curriculum has_many Courses, and users mark courses as complete.

Now, I want to extend this feature and add a Document model, where the admin can upload a document and assign it to users. Users will then have to come to the platform and mark the document as completed, similar to how they interact with courses.

I know I should have started off with a model such as AssignableMaterial and made Curriculums and Document inherit from AssignableMaterial, but I didn't think I would be adding Documents. What would be the best way to add Documents and still use the "assign" feature from Curriculum, and "mark as complete" feature from Course?

Could Document inherit from Curriculums, or would I either have to move all the methods tied to Curriculums/Courses into a parent model AssignableMaterial, and then inherit Document from that parent model?

kibaekr
  • 1,279
  • 1
  • 18
  • 36
  • Are the documents related to the curriculum assigned to the user? – Paul Richter Aug 19 '14 at 00:13
  • No the documents aren't related to the curriculum at all, but Users interact with it similar to Curriculums. Users get assigned, and they complete them. Although Documents and Curriculums aren't directly related, I would like to find the completion rate of a user's assignments. (i.e. if user gets assigned 1 doc and 1 curriculum, and completes the doc, user.overall_completion_rate_of_tasks would return 50%) – kibaekr Aug 19 '14 at 00:16

1 Answers1

0

Probably the best strategy would be to extract the common features of Document and Curriculum into a "concern" -- Document and Curriculum would remain separate classes inheriting directly from ActiveRecord::Base, with separate tables in the database, but the common behavior between them would live in a single module that both include.

See this question for an overview: How to use concerns in Rails 4

Community
  • 1
  • 1
scottb
  • 955
  • 9
  • 15