Module: Course::Assessment::Submission::SubmissionsHelper

Includes:
Answer::ProgrammingTestCaseHelper, SubmissionsAutogradedHelper
Defined in:
app/helpers/course/assessment/submission/submissions_helper.rb

Instance Method Summary collapse

Methods included from Answer::ProgrammingTestCaseHelper

#get_failed_test_cases_by_type, #get_hint, #get_output, #get_test_cases_and_results

Methods included from SubmissionsAutogradedHelper

#current_step, #max_step, #nav_class, #next_unanswered_question

Instance Method Details

#comments_container_id(submission_question) ⇒ String

Gets the ID for the given submission_question's comments container.

Parameters:

Returns:

  • (String)

    The ID for the given submission_question's comments container.


11
12
13
# File 'app/helpers/course/assessment/submission/submissions_helper.rb', line 11

def comments_container_id(submission_question)
  "course_assessment_submission_question_#{submission_question.id}_comments"
end

#last_attempt(answer) ⇒ Course::Assessment::Answer

Return the last non-current attempt if the submission is being attempted, or the current_answer if it's in other states. If there are no non-current attempts, just return the current attempt.

The last non-current attempt contains the most recent autograding result if the submission is being attempted. When the submission is finalised, current_answer contains the autograding result.


24
25
26
27
28
29
30
31
32
33
34
# File 'app/helpers/course/assessment/submission/submissions_helper.rb', line 24

def last_attempt(answer)
  submission = answer.submission

  attempts = submission.answers.from_question(answer.question_id)
  last_non_current_answer = attempts.reject(&:current_answer?).last
  current_answer = attempts.find(&:current_answer?)
  # Fallback to last attempt if none of the attempts have been autograded.
  latest_attempt = last_non_current_answer || attempts.last

  submission.attempting? ? latest_attempt : current_answer
end