Class: Course::Assessment::Question::MultipleResponse

Inherits:
ApplicationRecord
  • Object
show all
Defined in:
app/models/course/assessment/question/multiple_response.rb

Instance Method Summary collapse

Instance Method Details

#attempt(submission, last_attempt = nil) ⇒ Object


29
30
31
32
33
34
35
36
37
# File 'app/models/course/assessment/question/multiple_response.rb', line 29

def attempt(submission, last_attempt = nil)
  answer =
    Course::Assessment::Answer::MultipleResponse.new(submission: submission, question: question)
  last_attempt&.answer_options&.each do |answer_option|
    answer.answer_options.build(option_id: answer_option.option_id)
  end

  answer.acting_as
end

#auto_gradable?Boolean


21
22
23
# File 'app/models/course/assessment/question/multiple_response.rb', line 21

def auto_gradable?
  true
end

#auto_graderObject


25
26
27
# File 'app/models/course/assessment/question/multiple_response.rb', line 25

def auto_grader
  Course::Assessment::Answer::MultipleResponseAutoGradingService.new
end

#initialize_duplicate(duplicator, other) ⇒ Object


39
40
41
42
43
44
# File 'app/models/course/assessment/question/multiple_response.rb', line 39

def initialize_duplicate(duplicator, other)
  copy_attributes(other)
  associate_duplicated_skills(duplicator, other)

  self.options = duplicator.duplicate(other.options)
end

#question_typeObject

returns the type of question as multiple response or multiple choice


47
48
49
50
51
52
53
# File 'app/models/course/assessment/question/multiple_response.rb', line 47

def question_type
  if multiple_choice?
    I18n.t('course.assessment.question.multiple_responses.question_type.multiple_choice')
  else
    I18n.t('course.assessment.question.multiple_responses.question_type.multiple_response')
  end
end