Module: Course::Assessment::Submission::SubmissionsAutogradedHelper

Included in:
SubmissionsHelper
Defined in:
app/helpers/course/assessment/submission/submissions_autograded_helper.rb

Instance Method Summary collapse

Instance Method Details

#current_stepObject

The step that current user is on.


21
22
23
24
25
# File 'app/helpers/course/assessment/submission/submissions_autograded_helper.rb', line 21

def current_step
  @current_step ||= begin
    @current_question ? @assessment.questions.index(@current_question) + 1 : nil
  end
end

#max_stepObject

The maximum step that current user can attempt.


4
5
6
7
8
9
10
11
12
13
14
# File 'app/helpers/course/assessment/submission/submissions_autograded_helper.rb', line 4

def max_step
  @max_step ||= begin
    question = next_unanswered_question
    if question && !@assessment.skippable && cannot?(:manage, @assessment)
      @assessment.questions.index(question) + 1
    else
      # All questions have been answered or assessment is skippable or user is a staff.
      @assessment.questions.length
    end
  end
end

Highlight current step and grey out un-accessible steps.


28
29
30
31
32
# File 'app/helpers/course/assessment/submission/submissions_autograded_helper.rb', line 28

def nav_class(step)
  return 'active' if step == current_step
  return 'disabled' if step > max_step
  return 'completed' if step <= max_step
end

#next_unanswered_questionObject


16
17
18
# File 'app/helpers/course/assessment/submission/submissions_autograded_helper.rb', line 16

def next_unanswered_question
  @next_unanswered_question ||= @assessment.questions.next_unanswered(@submission)
end