O
O
O Di2015-06-16 23:53:08
Ruby on Rails
O Di, 2015-06-16 23:53:08

What models and associations should be added to account for attendance?

There are 4 models:
1. Teacher (can lead several courses, or can lead more than one, teacher table)

class Teacher < ActiveRecord::Base  
  has_and_belongs_to_many :courses
end

2. Course (table courses)
class Course < ActiveRecord::Base
  has_and_belongs_to_many :teachers
  has_many  :groups
end

3. Course groups (groups table)
class Group < ActiveRecord::Base
  belongs_to              :course
  has_many                :bids
end

4. Applications to these groups (bids table)
class Bid < ActiveRecord::Base
  belongs_to  :group
end

Now it is necessary to implement a page for the teacher, where he will mark the attendance of students (full names of students are taken from applications - bids) - the page will contain the name of the Course, group number and a table with dates, full names and status - was / was not.
My thoughts on this:
- add the Attendance model (the table will have a :status field - was / was not)
- add the Lessons model (the table will contain the dates of group classes)
- somehow tie everything together (there is no understanding yet - how)
PS :
Maybe someone will advise you to read on this topic, I will be grateful.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
T
thepry, 2015-06-17
@insiki

Well, look:
Classes are held at some rate for some group. Attendance refers to a particular student, and a particular class. The teacher will be able to choose a specific lesson and indicate who from the group attended and who did not.
Hence:

class Lesson < ActiveRecord::Base
  belongs_to :course
  belongs_to :group
end

class Attendance < ActiveRecord::Base
  belongs_to :lesson
  belongs_to :bid
end

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question