woople-theme 0.3.04 → 0.3.5

Sign up to get free protection for your applications and to get access to all the features.
@@ -56,7 +56,7 @@
56
56
  padding-top: 12px;
57
57
  }
58
58
 
59
- .badge {
59
+ .badge-unanswered {
60
60
  background-color: @yellow;
61
61
  }
62
62
 
@@ -77,6 +77,22 @@
77
77
  }
78
78
  }
79
79
 
80
+ #assessment.results {
81
+ .span12.return {
82
+ text-align: right;
83
+ }
84
+
85
+ input {
86
+ margin-right: 0;
87
+ }
88
+ }
89
+
90
+ .assessment_result_status {
91
+ .alert {
92
+ margin: 10px;
93
+ }
94
+ }
95
+
80
96
  @media (max-width: 480px) {
81
97
  #assessment {
82
98
  .fieldset {
@@ -116,4 +132,10 @@
116
132
  margin-right: @assessment-fieldset-padding / 4;
117
133
  }
118
134
  }
119
- }
135
+
136
+ #assessment.results {
137
+ .span12.return {
138
+ text-align: center;
139
+ }
140
+ }
141
+ }
@@ -83,6 +83,12 @@
83
83
  transition: transform .4s ease-in-out;
84
84
  }
85
85
 
86
+ .front.completed {
87
+ background-image:url(/assets/woople-theme/completed-triangle.png);
88
+ background-position:top right;
89
+ background-repeat:no-repeat;
90
+ }
91
+
86
92
  &.flip .back {
87
93
  z-index:1000;
88
94
  -webkit-transform: rotateY(0deg);
@@ -114,7 +120,6 @@
114
120
  -moz-transition: -moz-transform .4s ease-in-out;
115
121
  -webkit-transition: -webkit-transform .4s ease-in-out;
116
122
  transition: transform .4s ease-in-out;
117
-
118
123
  }
119
124
 
120
125
  .assessment-pad {
@@ -0,0 +1,7 @@
1
+ module AssessmentHelper
2
+ def assessment_form(presenter, options = { submitted?: false })
3
+ form_presenter = options[:submitted?] ? SubmittedAssessmentFormPresenter : AssessmentFormPresenter
4
+
5
+ render partial: 'woople-theme/assessment_form', object: ThemePresentation.wrap(presenter, form_presenter)
6
+ end
7
+ end
@@ -48,19 +48,16 @@ module ThemeHelper
48
48
  render partial: 'woople-theme/results_header', locals: { title: title, path: path }
49
49
  end
50
50
 
51
- def assessment_form assessment_form
52
- render partial: 'woople-theme/assessment_form', object: ThemePresentation.wrap(assessment_form, AssessmentFormPresenter)
53
- end
54
-
55
51
  def impersonation_banner
56
52
  if !respond_to?(WoopleTheme.configuration.impersonation_banner_helper)
57
53
  raise "#{WoopleTheme.configuration.impersonation_banner_helper} helper_method does not exist. WoopleTheme.configuration.impersonation_banner_helper must point to a valid helper_method."
58
54
  end
59
-
55
+
60
56
  model = ThemePresentation.wrap(send(WoopleTheme.configuration.impersonation_banner_helper))
61
57
 
62
58
  return unless model.impersonating?
63
59
 
64
60
  render 'woople-theme/impersonation_banner', impersonation: model
65
61
  end
62
+
66
63
  end
@@ -1,19 +1,39 @@
1
1
  require 'explicit_delegator'
2
2
 
3
3
  class AssessmentFormPresenter < ExplicitDelegator
4
-
5
4
  enforce_definitions :description, # Short description of assessment
6
5
  :course_path, # url to go to when assessment cancelled
7
6
  :copyright, # copyright notice for assessment
8
7
  :submit_path, # path for assessment form to submit to
9
8
  :questions # set of questions in the assessment
10
9
 
11
- def render_copyright
12
- yield if copyright.present?
10
+ def title
11
+ I18n.t('woople_theme.assessment.name')
12
+ end
13
+
14
+ def css_classes
15
+ nil
13
16
  end
14
17
 
15
18
  def questions
16
19
  ThemePresentation.wrap_collection(__getobj__.questions, WoopleTheme::QuestionPresenter)
17
20
  end
18
21
 
22
+ def render_result_status
23
+ nil
24
+ end
25
+
26
+ def render_copyright
27
+ yield if copyright.present?
28
+ end
29
+
30
+ def footer_partial
31
+ 'woople-theme/assessment_form_submission'
32
+ end
33
+
34
+ private
35
+
36
+ def assessment_result
37
+ __getobj__
38
+ end
19
39
  end
@@ -3,10 +3,15 @@ require 'delegate'
3
3
  require 'action_view'
4
4
  require 'active_support/core_ext/object/blank'
5
5
  require 'woople_theme_i18n'
6
+ require 'explicit_delegator'
6
7
 
7
- class OutlineAssessmentPresenter < SimpleDelegator
8
- include ActionView::Helpers::TagHelper
8
+ class OutlineAssessmentPresenter < ExplicitDelegator
9
9
  include ActionView::Helpers::FormTagHelper
10
+ include ActionView::Helpers::NumberHelper
11
+ include ActionView::Helpers::TagHelper
12
+
13
+ enforce_definitions :completed?,
14
+ :enabled?
10
15
 
11
16
  def render
12
17
  yield if enabled?
@@ -53,12 +58,16 @@ class OutlineAssessmentPresenter < SimpleDelegator
53
58
  end
54
59
  end
55
60
 
61
+ def completed_class
62
+ "completed" if completed?
63
+ end
64
+
56
65
  private
57
66
 
58
67
  def normalize history_item
59
68
  OpenStruct.new(
60
69
  date: WoopleThemeI18n.l(history_item.completed_at.to_date),
61
- score: "#{history_item.score}%",
70
+ score: number_to_percentage(history_item.score, :precision => 0),
62
71
  result_name: history_item.passed ? I18n.t('woople_theme.assessment.pass') : I18n.t('woople_theme.assessment.fail'),
63
72
  url: history_item.url
64
73
  )
@@ -0,0 +1,57 @@
1
+ require 'action_view'
2
+ require 'woople_theme_i18n'
3
+
4
+ class SubmittedAssessmentFormPresenter < AssessmentFormPresenter
5
+ include ActionView::Helpers::NumberHelper
6
+ include ActionView::Helpers::TagHelper
7
+
8
+ enforce_definitions :completed_at,
9
+ :passed?,
10
+ :correct_questions,
11
+ :score
12
+
13
+ def title
14
+ I18n.t('woople_theme.assessment.result')
15
+ end
16
+
17
+ def css_classes
18
+ [:results]
19
+ end
20
+
21
+ def questions
22
+ ThemePresentation.wrap_collection(__getobj__.questions, WoopleTheme::SubmittedQuestionPresenter)
23
+ end
24
+
25
+ def render_result_status
26
+ status_message = I18n.t('woople_theme.assessment.result_status', {
27
+ completed_at: WoopleThemeI18n.l(completed_at.to_date),
28
+ status: status,
29
+ correct_questions: correct_questions,
30
+ total_questions: total_questions,
31
+ score: number_to_percentage(score, :precision => 0),
32
+ count: total_questions
33
+ })
34
+
35
+ yield OpenStruct.new(message: status_message, classes: result_status_classes)
36
+ end
37
+
38
+ def footer_partial
39
+ 'woople-theme/assessment_form_return'
40
+ end
41
+
42
+ def result_status_classes
43
+ classes = [:alert, :fade, :in]
44
+ classes << 'alert-success' if passed?
45
+ classes << 'alert-error' if !passed?
46
+
47
+ classes
48
+ end
49
+
50
+ def status
51
+ passed? ? I18n.t('woople_theme.assessment.passed') : I18n.t('woople_theme.assessment.failed')
52
+ end
53
+
54
+ def total_questions
55
+ questions.length
56
+ end
57
+ end
@@ -4,6 +4,21 @@ module WoopleTheme
4
4
  class AnswerPresenter < ExplicitDelegator
5
5
  enforce_definitions :index, # ID of the option to be used in the form
6
6
  :text # Text of the option/answer
7
+
8
+ def correct_badge
9
+ nil
10
+ end
11
+
12
+ def incorrect_badge
13
+ nil
14
+ end
15
+
16
+ def radio_disabled
17
+ nil
18
+ end
19
+
20
+ def radio_checked
21
+ nil
22
+ end
7
23
  end
8
24
  end
9
-
@@ -0,0 +1,27 @@
1
+ require 'action_view'
2
+
3
+ module WoopleTheme
4
+ class SubmittedAnswerPresenter < WoopleTheme::AnswerPresenter
5
+ include ActionView::Helpers::TagHelper
6
+
7
+ enforce_definitions :correct?,
8
+ :incorrect?,
9
+ :checked?
10
+
11
+ def correct_badge
12
+ content_tag(:span, I18n.t('woople_theme.assessment.correct'), class: "badge badge-success") if correct?
13
+ end
14
+
15
+ def incorrect_badge
16
+ content_tag(:span, I18n.t('woople_theme.assessment.incorrect'), class: "badge badge-important") if incorrect?
17
+ end
18
+
19
+ def radio_disabled
20
+ 'disabled="disabled"'
21
+ end
22
+
23
+ def radio_checked
24
+ 'checked="checked"' if checked?
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,7 @@
1
+ module WoopleTheme
2
+ class SubmittedQuestionPresenter < WoopleTheme::QuestionPresenter
3
+ def answers
4
+ ThemePresentation.wrap_collection(__getobj__.answers, WoopleTheme::SubmittedAnswerPresenter)
5
+ end
6
+ end
7
+ end
@@ -1,20 +1,16 @@
1
- <%= page_header title: 'Assessment', description: assessment_form.description %>
2
-
3
-
4
- <%= form_tag(assessment_form.submit_path, { id: "assessment", method: :put }) do %>
1
+ <%= page_header title: assessment_form.title, description: assessment_form.description %>
2
+ <% assessment_form.render_result_status do |result| %>
3
+ <div class="row-fluid assessment_result_status <%= cycle 'odd', 'even' %>">
4
+ <%= content_tag(:div, result.message, class: result.classes) %>
5
+ </div>
6
+ <% end %>
5
7
 
8
+ <%= form_tag(assessment_form.submit_path, method: :put, id: "assessment", class: assessment_form.css_classes) do %>
6
9
  <%= render partial: 'woople-theme/assessment_form_question', collection: assessment_form.questions %>
7
10
 
8
11
  <div class="fieldset <%= cycle 'odd', 'even' %>">
9
12
  <div class="row-fluid">
10
- <div class="span4"><span class="badge"><%= t 'woople_theme.assessment_form.unanswered_questions', count: assessment_form.questions.count %></span></div>
11
- <div class="span8">
12
- <input type="button"
13
- value="<%= I18n.t('woople_theme.cancel') %>"
14
- class="btn btn-large"
15
- data-course-path="<%= assessment_form.course_path %>" />
16
- <%= submit_tag(I18n.t('woople_theme.assessment_form.submit_assessment'), {class: "btn btn-primary btn-large", disabled: "disabled"}) %>
17
- </div>
13
+ <%= render partial: assessment_form.footer_partial, locals: { data: assessment_form } %>
18
14
  </div>
19
15
  </div>
20
16
  <% assessment_form.render_copyright do %>
@@ -3,7 +3,11 @@
3
3
  <input type="radio"
4
4
  id="<%= input_id %>"
5
5
  name="response[<%= response_id %>]"
6
- value="<%= assessment_form_answer.index %>"/>
6
+ value="<%= assessment_form_answer.index %>"
7
+ <%= assessment_form_answer.radio_disabled %>
8
+ <%= assessment_form_answer.radio_checked %> />
7
9
 
10
+ <%= assessment_form_answer.correct_badge %>
11
+ <%= assessment_form_answer.incorrect_badge %>
8
12
  <%= assessment_form_answer.text %>
9
- </label>
13
+ </label>
@@ -0,0 +1,6 @@
1
+ <div class="span12 return">
2
+ <input type="button"
3
+ value="<%= I18n.t('woople_theme.return_to_course') %>"
4
+ class="btn btn-large"
5
+ data-course-path="<%= data.course_path %>" />
6
+ </div>
@@ -0,0 +1,8 @@
1
+ <div class="span4"><span class="badge badge-unanswered"><%= t 'woople_theme.assessment_form.unanswered_questions', count: data.questions.count %></span></div>
2
+ <div class="span8">
3
+ <input type="button"
4
+ value="<%= I18n.t('woople_theme.cancel') %>"
5
+ class="btn btn-large"
6
+ data-course-path="<%= data.course_path %>" />
7
+ <%= submit_tag(I18n.t('woople_theme.assessment_form.submit_assessment'), {class: "btn btn-primary btn-large", disabled: "disabled"}) %>
8
+ </div>
@@ -1,6 +1,6 @@
1
1
  <% assessment.render do %>
2
2
  <div id="assessment-<%= assessment.assessment_id %>" class="assessment">
3
- <div class="front">
3
+ <div class="front <%= assessment.completed_class %>">
4
4
  <div class="assessment-pad">
5
5
  <div class="flip-action pull-right">
6
6
  <%= assessment.history_link_tag %>
@@ -34,12 +34,20 @@ en:
34
34
  result_title: Result
35
35
  pass: Pass
36
36
  fail: Fail
37
+ passed: passed
38
+ failed: failed
37
39
  pass_alert:
38
40
  heading: Passed!
39
41
  message: Congratulations, you've passed! You may review your history to see your scores and results. You may also retake the assessment to achieve a better result.
40
42
  fail_alert:
41
43
  heading: Failed!
42
44
  message: Thank you for completing the assessment. You may review your history to see your scores and results. You may also retake the assessment to achieve a better result. You must rewatch the required relearnings below before retaking the assessment.
45
+ result: Assessment Result
46
+ result_status:
47
+ one: On %{completed_at} you %{status} this assessment by answering %{correct_questions}/%{total_questions} question correctly for a %{score} score.
48
+ other: On %{completed_at} you %{status} this assessment by answering %{correct_questions}/%{total_questions} questions correctly for a %{score} score.
49
+ correct: Correct
50
+ incorrect: Incorrect
43
51
  assessment_form:
44
52
  unanswered_questions:
45
53
  one: 1 unanswered question
@@ -49,6 +57,7 @@ en:
49
57
  logged_in_as: Logged in as
50
58
  impersonating: impersonating
51
59
  cancel: Cancel
60
+ return_to_course: Return to Course
52
61
  date:
53
62
  formats:
54
- default: ! '%b %d %Y'
63
+ default: ! '%b %d %Y'
@@ -1,3 +1,3 @@
1
1
  module WoopleTheme
2
- VERSION = '0.3.04'
2
+ VERSION = '0.3.5'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: woople-theme
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.04
4
+ version: 0.3.5
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-07-12 00:00:00.000000000 Z
12
+ date: 2012-07-17 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails
16
- requirement: &70157500146880 !ruby/object:Gem::Requirement
16
+ requirement: &70284694912860 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ~>
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: 3.2.5
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70157500146880
24
+ version_requirements: *70284694912860
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: less-rails-bootstrap
27
- requirement: &70157500146340 !ruby/object:Gem::Requirement
27
+ requirement: &70284694912280 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - =
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: 2.0.13
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *70157500146340
35
+ version_requirements: *70284694912280
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: therubyracer
38
- requirement: &70157500145940 !ruby/object:Gem::Requirement
38
+ requirement: &70284694911900 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ! '>='
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: '0'
44
44
  type: :runtime
45
45
  prerelease: false
46
- version_requirements: *70157500145940
46
+ version_requirements: *70284694911900
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: bundler
49
- requirement: &70157500145180 !ruby/object:Gem::Requirement
49
+ requirement: &70284694911420 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ! '>='
@@ -54,10 +54,10 @@ dependencies:
54
54
  version: '0'
55
55
  type: :development
56
56
  prerelease: false
57
- version_requirements: *70157500145180
57
+ version_requirements: *70284694911420
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: sqlite3
60
- requirement: &70157500144320 !ruby/object:Gem::Requirement
60
+ requirement: &70284694947240 !ruby/object:Gem::Requirement
61
61
  none: false
62
62
  requirements:
63
63
  - - ! '>='
@@ -65,10 +65,10 @@ dependencies:
65
65
  version: '0'
66
66
  type: :development
67
67
  prerelease: false
68
- version_requirements: *70157500144320
68
+ version_requirements: *70284694947240
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: rspec-rails
71
- requirement: &70157500143300 !ruby/object:Gem::Requirement
71
+ requirement: &70284694946660 !ruby/object:Gem::Requirement
72
72
  none: false
73
73
  requirements:
74
74
  - - =
@@ -76,10 +76,10 @@ dependencies:
76
76
  version: 2.11.0
77
77
  type: :development
78
78
  prerelease: false
79
- version_requirements: *70157500143300
79
+ version_requirements: *70284694946660
80
80
  - !ruby/object:Gem::Dependency
81
81
  name: capybara
82
- requirement: &70157500142680 !ruby/object:Gem::Requirement
82
+ requirement: &70284694946180 !ruby/object:Gem::Requirement
83
83
  none: false
84
84
  requirements:
85
85
  - - ! '>='
@@ -87,7 +87,7 @@ dependencies:
87
87
  version: '0'
88
88
  type: :development
89
89
  prerelease: false
90
- version_requirements: *70157500142680
90
+ version_requirements: *70284694946180
91
91
  description: All Front-End all the Time
92
92
  email:
93
93
  - developers@bigbangtechnology.com
@@ -152,6 +152,7 @@ files:
152
152
  - app/assets/stylesheets/woople-theme/theme-retina.css
153
153
  - app/assets/stylesheets/woople-theme/theme.css
154
154
  - app/assets/stylesheets/woople-theme/variables.css.less
155
+ - app/helpers/assessment_helper.rb
155
156
  - app/helpers/javascript_helper.rb
156
157
  - app/helpers/theme_helper.rb
157
158
  - app/presenters/assessment_form_presenter.rb
@@ -166,13 +167,18 @@ files:
166
167
  - app/presenters/outline_video_presenter.rb
167
168
  - app/presenters/page_header_presenter.rb
168
169
  - app/presenters/profile_presenter.rb
170
+ - app/presenters/submitted_assessment_form_presenter.rb
169
171
  - app/presenters/theme_presentation.rb
170
172
  - app/presenters/woople_theme/answer_presenter.rb
171
173
  - app/presenters/woople_theme/question_presenter.rb
174
+ - app/presenters/woople_theme/submitted_answer_presenter.rb
175
+ - app/presenters/woople_theme/submitted_question_presenter.rb
172
176
  - app/views/layouts/theme.html.erb
173
177
  - app/views/woople-theme/_assessment_form.html.erb
174
178
  - app/views/woople-theme/_assessment_form_answer.html.erb
175
179
  - app/views/woople-theme/_assessment_form_question.html.erb
180
+ - app/views/woople-theme/_assessment_form_return.html.erb
181
+ - app/views/woople-theme/_assessment_form_submission.html.erb
176
182
  - app/views/woople-theme/_content_item.html.erb
177
183
  - app/views/woople-theme/_content_item_header.html.erb
178
184
  - app/views/woople-theme/_impersonation_banner.html.erb
@@ -225,7 +231,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
225
231
  version: '0'
226
232
  requirements: []
227
233
  rubyforge_project:
228
- rubygems_version: 1.8.10
234
+ rubygems_version: 1.8.16
229
235
  signing_key:
230
236
  specification_version: 3
231
237
  summary: Our Front-End CSS Framework/Theme