Skip to content

Commit

Permalink
lml#347: Integrate unconfirm gem.
Browse files Browse the repository at this point in the history
- Add gem dependency.
- Add configuration file for unconfirm.
- Include JS and HTML.
- Add migrations.
- Modify free response and multiple choice submissions
  to use unconfirm.
  • Loading branch information
navilan committed Jun 23, 2014
1 parent 2c65099 commit 6cb2290
Show file tree
Hide file tree
Showing 10 changed files with 68 additions and 12 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,4 @@ brakeman.html
cucumber_rerun.txt
rspec.failures
vendor/cache
.sass-cache
2 changes: 2 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ gem 'remotipart', '~> 1.0'
gem 'babbler', '~> 1.0.0'
gem 'sketchily', '~> 1.5.0'

gem 'unconfirm', path: '../unconfirm'

gem 'on_the_spot', git: 'https://github.com/kevinburleigh75/on_the_spot.git', ref: '67a423a'

gem 'fine_print', git: 'https://github.com/jpslav/fine_print.git', ref: '3146ce934e337'
Expand Down
11 changes: 11 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,14 @@ GIT
on_the_spot (1.0.2)
json_pure (>= 1.4.6)

PATH
remote: ../unconfirm
specs:
unconfirm (0.0.1)
activerecord-typedstore
jquery-rails
rails (~> 3.2.17)

GEM
remote: https://rubygems.org/
specs:
Expand All @@ -48,6 +56,8 @@ GEM
activesupport (= 3.2.17)
arel (~> 3.0.2)
tzinfo (~> 0.3.29)
activerecord-typedstore (0.4.3)
activerecord (>= 3.2)
activeresource (3.2.17)
activemodel (= 3.2.17)
activesupport (= 3.2.17)
Expand Down Expand Up @@ -396,6 +406,7 @@ DEPENDENCIES
thin (~> 1.4.1)
timecop (~> 0.3.5)
uglifier (>= 1.0.3)
unconfirm!
whenever
will_paginate (~> 3.0.3)
yaml_db
3 changes: 2 additions & 1 deletion app/assets/javascripts/application.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
//= require raphael-min
//= require_tree .
//= require on_the_spot
//= require unconfirm
// Loads Bootstrap javascripts for accordions; note loading everything breaks other existing CSS/JS
//= require bootstrap-transition
//= require bootstrap-collapse
Expand Down Expand Up @@ -80,4 +81,4 @@ $(document).ready(function() {
return false;
}
});
});
});
2 changes: 2 additions & 0 deletions app/views/layouts/application.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -333,6 +333,8 @@

</div>

<%= include_unconfirm %>
<%= unconfirm_tag %>
<%= yield :javascript %>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,13 +75,12 @@
</div>

<center>

<div class="actions" style="padding-top:10px">
<%= f.submit "Turn in my answer",
<%= f.submit "Turn in my answer",
:name => "save_and_lock",
:class => 'link_button',
:confirm => "After you turn in your answer, you can no longer change it. " +
"Are you sure you want to turn in your answer?" %>
:class => 'link_button unconfirm',
:data => data_with_unconfirm('skip_answer_submitted_confirmation_dialog') %>
</div>

</center>
Expand Down
9 changes: 4 additions & 5 deletions app/views/student_exercises/_multiple_choice_form.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,9 @@

<center>
<div class="actions">
<%= f.submit "Turn in my choice",
:class => 'link_button',
:confirm => "After you turn in your selected answer, you can no longer change it. " +
"Are you sure you want to turn it in?" %>
<%= f.submit "Turn in my choice",
:class => 'link_button unconfirm',
:data => data_with_unconfirm('skip_answer_submitted_confirmation_dialog') %>
</div>
</center>
<% end %>
Expand All @@ -53,4 +52,4 @@
});
})
</script>
<% end %>
<% end %>
20 changes: 20 additions & 0 deletions config/unconfirm/student_user_settings.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
category: student
description: >
This category contains the settings for confirmation messages
when you are viewing the OST application as a student.
settings:
skip_answer_submitted_confirmation_dialog:
description: >
This setting controls if you are shown a confirmation dialog
before you submit a free response or a multiple choice answer.
message: >
After you turn in your answer, you can no longer change it.
Are you sure you want to turn in your answer?
message_title: >
Are you sure?
dont_show_text: Don't show this message again.
continue_text: Continue
cancel_text: Cancel


Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# This migration comes from unconfirm_engine (originally 20140613110759)
class CreateUnconfirmUserSettings < ActiveRecord::Migration
def change
create_table(:unconfirm_user_settings) do |t|
t.integer :user_id, :null => false
t.text :settings
t.timestamps
end

add_index :unconfirm_user_settings, :user_id
end
end
11 changes: 10 additions & 1 deletion db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#
# It's strongly recommended to check this file into your version control system.

ActiveRecord::Schema.define(:version => 20140218235334) do
ActiveRecord::Schema.define(:version => 20140622221005) do

create_table "assignment_coworkers", :force => true do |t|
t.integer "student_assignment_id"
Expand Down Expand Up @@ -588,6 +588,15 @@
add_index "topics", ["name", "learning_plan_id"], :name => "index_topics_on_name_scoped", :unique => true
add_index "topics", ["number", "learning_plan_id"], :name => "index_topics_on_number_scoped", :unique => true

create_table "unconfirm_user_settings", :force => true do |t|
t.integer "user_id", :null => false
t.text "settings"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
end

add_index "unconfirm_user_settings", ["user_id"], :name => "index_unconfirm_user_settings_on_user_id"

create_table "users", :force => true do |t|
t.string "email", :null => false
t.string "encrypted_password", :default => "", :null => false
Expand Down

0 comments on commit 6cb2290

Please sign in to comment.