0

私は数学の練習アプリを構築しています。問題を演習に分けて保存したいのですが、各演習は別のセクションに属しています。また、学年ごとに複数のセクションがあります(全12学年)。

ユーザーの回答 (アクション) を追跡するにはどうすればよいですか? たとえば、ユーザーがアプリを閲覧し、グレード「Pre-K」のセクション「G」の演習「G1」の質問 7 に回答することを決定し、正解を提供します。これを追跡し、将来的に統計を提供したいと考えています。彼のパフォーマンスについて。

現在、私の User モデルと質問の間にはつながりがありません。これに取り組むための最も効率的な方法について、他の人から聞きたいと思いました (現在のモデルは完全に間違っている可能性があります)。

これは、has_many、belongs_to 関係を使用した現在のモデル図です ('the_question':string と 'answer':string を後で質問モデルに追加します): ここに画像の説明を入力

4

1 に答える 1

1

Answer欠けているのは、ユーザーに接続されているモデルだけだと思います。

必要に応じて、「親」の関係を定義することもできますQuestion

class Grade < ActiveRecord::Base
  has_many :users, :through => :sections # optional. i.e. 'users that have answers in this grade'
end

class Section < ActiveRecord::Base
  has_many :users, :through => :exercises # optional
end

class Exercise < ActiveRecord::Base
  has_many :users, :through => :questions # optional
end

class Question < ActiveRecord::Base
  has_many :answers
  has_many :users, :through => :answers # optional
end

class Answer < ActiveRecord::Base
  belongs_to :question
  belongs_to :user
end

class User < ActiveRecord::Base
  has_many :answers
end

更新:あなたの説明を読み直して、私はCorrectAnswerよりも適していると思いますAnswer

于 2012-10-25T01:23:12.930 に答える