我正在建立一个在线考试应用程序,应用程序的目的是,它可以让教师创建课程,课程主题和问题(每个问题都有标记),教师可以为学生和学生创建考试在线做考试。由于我将使用多个单词examination
和examinations
,因此我将其称为exam
和exams
更短。
关于我的应用的业务:
general exam
,它会从question bank
获得一系列问题。general exam
开始,教师将生成与number of exams
相对应的number of students
需要参加课程考试。考试将在生成后自动分配给学生。生成的考试将有不同的number of questions
,但每次考试中的total mark of questions
都是相同的。例如,在生成考试后:
Student A take exam with 20 questions, student B take exam only has 10 questions, it means maybe every question in exam of student A only has mark is 1, but questions in exam of student B has mark is 2.
所以20 = 10 x 2,这就是我的意思total mark of questions in every examination will be the same.
我为:
设计了表格当学生参加考试时,我认为它会有表格:
这是我认为我将为general examination
创建的表格:
但现在我不知道如何在用户(学生),问题,考试,普通考试之间建立联系。总结协会:
general exam
有许多问题,来自问题库,但每次考试都会从general exam
生成问题。general examination
,用于生成它们。我如何设置这些关联?
答案 0 :(得分:3)
Course has_many :topics belongs_to :teacher
Topic has_many :questions belongs_to :course belongs_to :teacher
Question belongs_to :teacher belongs_to :topic has_and_belongs_to_many :general_exams has_and_belongs_to_many :exams
GeneralExam belongs_to :teacher belongs_to :course has_many :exams has_and_belongs_to_many :questions
Exam belongs_to :general_exam belongs_to :student has_and_belongs_to_many :questions has_one :exam_result
Student has_many :exams has_many :exam_results, :through => :exams
ExamResult belongs_to :exam belongs_to :teacher
class QuestionBank < ActiveRecord::Base
belongs_to :course
def questions
Question.where("topic_id IN (?)", course.topic_ids)
end
end
答案 1 :(得分:1)
我正在研究something similar,随时学习,分叉和贡献。