Class: Course::Assessment::SubmissionQuestion

Inherits:
ApplicationRecord show all
Defined in:
app/models/course/assessment/submission_question.rb

Overview

TODO: Refactor to Course::Assessment::Answer, and refactor Answer to Attempt

Defined Under Namespace

Classes: CommentNotifier, CommentsController, Controller, SubmissionQuestionsController

Instance Method Summary collapse

Instance Method Details

#answersObject


31
32
33
34
# File 'app/models/course/assessment/submission_question.rb', line 31

def answers
  Course::Assessment::Answer.where('submission_id = ? AND question_id = ?',
                                   self.submission_id, self.question_id)
end

#notify(post) ⇒ Object


27
28
29
# File 'app/models/course/assessment/submission_question.rb', line 27

def notify(post)
  Course::Assessment::SubmissionQuestion::CommentNotifier.post_replied(post.creator, post)
end

#past_answers(answers_to_load) ⇒ Object

Loads the past answers of a specific question


37
38
39
# File 'app/models/course/assessment/submission_question.rb', line 37

def past_answers(answers_to_load)
  answers.unscope(:order).order(created_at: :desc).non_current_answers.first(answers_to_load)
end