Class: SubmittedAssessmentFormPresenter

Inherits:
AssessmentFormPresenter show all
Includes:
ActionView::Helpers::NumberHelper, ActionView::Helpers::TagHelper
Defined in:
app/presenters/submitted_assessment_form_presenter.rb

Instance Method Summary collapse

Methods inherited from AssessmentFormPresenter

#render_copyright

Methods inherited from ExplicitDelegator

enforce_definitions, #enforced_methods, #ensure_defined, #initialize

Constructor Details

This class inherits a constructor from ExplicitDelegator

Instance Method Details

#css_classesObject



17
18
19
# File 'app/presenters/submitted_assessment_form_presenter.rb', line 17

def css_classes
  [:results]
end


38
39
40
# File 'app/presenters/submitted_assessment_form_presenter.rb', line 38

def footer_partial
  'woople-theme/assessment_form_return'
end

#questionsObject



21
22
23
# File 'app/presenters/submitted_assessment_form_presenter.rb', line 21

def questions
  ThemePresentation.wrap_collection(@delegate.questions, WoopleTheme::SubmittedQuestionPresenter)
end

#render_result_status {|OpenStruct.new(message: status_message, classes: result_status_classes)| ... } ⇒ Object

Yields:



25
26
27
28
29
30
31
32
33
34
35
36
# File 'app/presenters/submitted_assessment_form_presenter.rb', line 25

def render_result_status
  status_message = I18n.t('woople_theme.assessment.result_status', {
    completed_at: WoopleThemeI18n.l(completed_at.to_date),
    status: status,
    correct_questions: correct_questions,
    total_questions: total_questions,
    score: number_to_percentage(score, :precision => 0),
    count: total_questions
  })

  yield OpenStruct.new(message: status_message, classes: result_status_classes)
end

#result_status_classesObject



42
43
44
45
# File 'app/presenters/submitted_assessment_form_presenter.rb', line 42

def result_status_classes
  css_classes = [:alert]
  css_classes << (passed? ? 'alert-success' : 'alert-error')
end

#statusObject



47
48
49
# File 'app/presenters/submitted_assessment_form_presenter.rb', line 47

def status
  passed? ? I18n.t('woople_theme.assessment.passed') : I18n.t('woople_theme.assessment.failed')
end

#titleObject



13
14
15
# File 'app/presenters/submitted_assessment_form_presenter.rb', line 13

def title
  I18n.t('woople_theme.assessment.result')
end

#total_questionsObject



51
52
53
# File 'app/presenters/submitted_assessment_form_presenter.rb', line 51

def total_questions
  questions.length
end