Created
November 11, 2012 14:55
-
-
Save benjaminvialle/4055130 to your computer and use it in GitHub Desktop.
Diff from RB for issue 745_2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/app/controllers/flexible_criteria_controller.rb b/app/controllers/flexible_criteria_controller.rb | |
index c75c06016778f55d51030db8087e2e53f6d052a0..1958912880b6ece459d368f4d05ec1f4f2ec66ec 100644 | |
--- a/app/controllers/flexible_criteria_controller.rb | |
+++ b/app/controllers/flexible_criteria_controller.rb | |
@@ -25,31 +25,31 @@ class FlexibleCriteriaController < ApplicationController | |
def new | |
@assignment = Assignment.find(params[:assignment_id]) | |
- if !request.post? | |
- return | |
+ @criterion = FlexibleCriterion.new | |
+ end | |
+ | |
+ def create | |
+ @assignment = Assignment.find(params[:assignment_id]) | |
+ @criteria = @assignment.flexible_criteria | |
+ if @criteria.length > 0 | |
+ new_position = @criteria.last.position + 1 | |
else | |
- @criteria = @assignment.flexible_criteria | |
- if @criteria.length > 0 | |
- new_position = @criteria.last.position + 1 | |
- else | |
- new_position = 1 | |
- end | |
- @criterion = FlexibleCriterion.new | |
- @criterion.assignment = @assignment | |
- @criterion.max = FlexibleCriterion::DEFAULT_MAX | |
- @criterion.position = new_position | |
- if !@criterion.update_attributes(params[:flexible_criterion]) | |
- @errors = @criterion.errors | |
- render :add_criterion_error | |
- return | |
- end | |
- @criteria.reload | |
- render :create_and_edit | |
+ new_position = 1 | |
end | |
+ @criterion = FlexibleCriterion.new | |
+ @criterion.assignment = @assignment | |
+ @criterion.max = FlexibleCriterion::DEFAULT_MAX | |
+ @criterion.position = new_position | |
+ if !@criterion.update_attributes(params[:flexible_criterion]) | |
+ @errors = @criterion.errors | |
+ render :add_criterion_error | |
+ return | |
+ end | |
+ @criteria.reload | |
+ render :create_and_edit | |
end | |
def destroy | |
- return unless request.delete? | |
@criterion = FlexibleCriterion.find(params[:id]) | |
@assignment = @criterion.assignment | |
@criteria = @assignment.flexible_criteria | |
@@ -57,7 +57,6 @@ class FlexibleCriteriaController < ApplicationController | |
# Will be possible when Mark gets its association with FlexibleCriterion. | |
@criterion.destroy | |
flash.now[:success] = I18n.t('criterion_deleted_success') | |
- redirect_to :action => 'index', :id => @assignment | |
end | |
def download | |
diff --git a/app/views/flexible_criteria/_criterion_editor.html.erb b/app/views/flexible_criteria/_criterion_editor.html.erb | |
index f55a688207af3010205f0604d885d2b125214d7b..bec2b62ab9e317634fd6567da2457daf5c1329e5 100644 | |
--- a/app/views/flexible_criteria/_criterion_editor.html.erb | |
+++ b/app/views/flexible_criteria/_criterion_editor.html.erb | |
@@ -6,9 +6,8 @@ | |
<%= form_for criterion, | |
:as => :flexible_criterion, | |
- :url => {:action => 'update', | |
- :id => criterion.id}, | |
- :remote => true do |f| %> | |
+ :url => {:action => 'update', :id => criterion.id}, | |
+ :html => {:remote => true} do |f| %> | |
<h2> | |
<span id="selected_criterion_name"> | |
@@ -21,16 +20,6 @@ | |
<div class="main_flexible_criteria_edit"> | |
- <div class="float_right"> | |
- <%= link_to I18n.t(:delete), | |
- :method => 'delete', | |
- :url => {:action => 'delete', :id => criterion.id}, | |
- :html => {:class => 'delete', | |
- :title => I18n.t(:remove_criteria_title)}, | |
- :confirm => I18n.t(:remove_criteria_message), | |
- :remote => true %> | |
- </div> | |
- | |
<span id="<%="criterion_inputs_#{criterion.id}"%>"> | |
<%= f.label :flexible_criterion_name, I18n.t(:criterion)%> | |
<%= f.text_field :flexible_criterion_name %> | |
@@ -60,3 +49,13 @@ | |
</div> | |
</div> | |
<% end %> | |
+ | |
+<div class="float_right"> | |
+ <%= button_to I18n.t(:delete), | |
+ assignment_flexible_criterium_path(:id => criterion.id), | |
+ :confirm => I18n.t(:remove_criteria_message), | |
+ :method => :delete, | |
+ :class => 'delete', | |
+ :title => I18n.t(:remove_criteria_title), | |
+ :remote => true %> | |
+</div> | |
\ No newline at end of file | |
diff --git a/app/views/flexible_criteria/_flexible_criteria_pane.html.erb b/app/views/flexible_criteria/_flexible_criteria_pane.html.erb | |
index 6109def55ce08762c7c25f30c8cd6b5679da75cc..d0e51fdcfb5647f1a1ac6e47149a369c66d46bb5 100644 | |
--- a/app/views/flexible_criteria/_flexible_criteria_pane.html.erb | |
+++ b/app/views/flexible_criteria/_flexible_criteria_pane.html.erb | |
@@ -22,5 +22,5 @@ | |
</ul> | |
</div> | |
<%= sortable_element("flexible_criteria_pane_list", | |
- :url => {:action => "update_positions", | |
- :assignment_id => @assignment.id}) %> | |
+ :url => update_positions_assignment_flexible_criteria_path( | |
+ @assignment)) %> | |
diff --git a/app/views/flexible_criteria/_flexible_criterion.html.erb b/app/views/flexible_criteria/_flexible_criterion.html.erb | |
index 959f9f213fce23aa700b5c5ce179614c84c86c0a..84bfa3c47cd636632b23d2737ca25749935b2b6b 100644 | |
--- a/app/views/flexible_criteria/_flexible_criterion.html.erb | |
+++ b/app/views/flexible_criteria/_flexible_criterion.html.erb | |
@@ -3,13 +3,10 @@ | |
<%= image_tag "handle.png" %> | |
</span> | |
<span class="criterion_title_div link"> | |
- <%= link_to h(truncate(criterion.flexible_criterion_name, | |
- :length => 30, | |
- :omission => '...')), | |
- :url => {:action => 'edit', | |
- :id => criterion.id}, | |
- :html => {:id => "criterion_title_#{criterion.id}"}, | |
- :remote => true %> | |
+ <%= link_to h(truncate(criterion.flexible_criterion_name, :length => 30, :omission => '...')), | |
+ {:action => 'edit', :id => criterion.id}, | |
+ {:id => "criterion_title_#{criterion.id}", | |
+ :remote => true} %> | |
</span> | |
<span class="criterion_arrow"> | |
<% if location != :first and location != :single %> | |
diff --git a/app/views/flexible_criteria/_new_flexible_criterion.html.erb b/app/views/flexible_criteria/_new_flexible_criterion.html.erb | |
index f727216bdb02f7cea92436b9a34021e10526cc15..5b94aadc312f7a2c10fa6118ea8e61003e1d5952 100644 | |
--- a/app/views/flexible_criteria/_new_flexible_criterion.html.erb | |
+++ b/app/views/flexible_criteria/_new_flexible_criterion.html.erb | |
@@ -1,8 +1,6 @@ | |
<li id="new_flexible_criterion"> | |
- <%= form_for :flexible_criterion, | |
- :url => {:action => 'new', | |
- :id => assignment.id}, | |
- :remote => true do |f| %> | |
+ <%= form_for @criterion, | |
+ :url => assignment_flexible_criteria_path(@assignment), :html => {:remote => true} do |f| %> | |
<div id="new_flexible_criterion_errors" style="display:none;" class="error"></div> | |
<%= label_tag 'new_flexible_criterion_prompt', | |
t("flexible_criteria.name") %><br /> | |
@@ -10,5 +8,5 @@ | |
:size => 15, | |
:id => 'new_flexible_criterion_prompt' %><br /> | |
<%= f.submit t("flexible_criteria.save")%> | |
- <% end %> | |
+ <% end %> | |
</li> | |
diff --git a/app/views/flexible_criteria/create_and_edit.rjs b/app/views/flexible_criteria/create_and_edit.rjs | |
index f54dcded0d68918c52e25ab248f8a2c906d6c0c9..609aab047a43e1286e04ffdfa4dc4b1f1e1f5a6d 100644 | |
--- a/app/views/flexible_criteria/create_and_edit.rjs | |
+++ b/app/views/flexible_criteria/create_and_edit.rjs | |
@@ -27,4 +27,4 @@ page.replace_html 'flexible_edition_pane_menu', | |
page.replace_html "criteria_total_mark", @criterion.assignment.total_mark | |
page.sortable 'flexible_criteria_pane_list', | |
:constraint => :vertical, | |
- :url => {:action => :update_positions, :assignment_id => @criterion.assignment.id} | |
+ :url => {:action => :update_positions, :aid => @criterion.assignment.id} | |
diff --git a/app/views/flexible_criteria/destroy.rjs b/app/views/flexible_criteria/destroy.rjs | |
new file mode 100644 | |
index 0000000000000000000000000000000000000000..3fba4ceaa924b07f885901012a19230d28123820 | |
--- /dev/null | |
+++ b/app/views/flexible_criteria/destroy.rjs | |
@@ -0,0 +1,2 @@ | |
+page.replace_html "flexible_criteria_pane", :partial => "flexible_criteria/flexible_criteria_pane" | |
+page.replace_html "flexible_edition_pane_menu", :partial => "flexible_criteria_manager_help" | |
diff --git a/app/views/flexible_criteria/index.html.erb b/app/views/flexible_criteria/index.html.erb | |
index 05babb14d009e0d5e052babead6da03b3426d55f..08dab9f4fdf284facf1522eafa49bfe813798c53 100644 | |
--- a/app/views/flexible_criteria/index.html.erb | |
+++ b/app/views/flexible_criteria/index.html.erb | |
@@ -5,7 +5,9 @@ | |
<% # UI LIBRARIES %> | |
<%= javascript_include_tag "livepipe/livepipe.js", | |
"livepipe/window.js", | |
- "livepipe/tabs.js" %> | |
+ "livepipe/tabs.js" , | |
+ "effects.js", | |
+ "dragdrop.js" %> | |
<script type="text/javascript"> | |
//<![CDATA[ | |
@@ -52,8 +54,9 @@ | |
<div id="title_bar"> | |
<h1><%= I18n.t("flexible_criteria.criteria_management", :identifier => h(@assignment.short_identifier)) %> | |
- | |
- <%= link_to_function t("add_criterion"), %| if($('new_flexible_criterion') != null) { | |
+ </h1> | |
+ <div class="headingButtons"> | |
+ <%= link_to_function t("add_criterion"), %| if($('new_flexible_criterion') != null) { | |
$('flexible_criterion_flexible_criterion_name').select(); | |
$('flexible_criterion_flexible_criterion_name').focus(); | |
} else { | |
@@ -63,7 +66,7 @@ | |
<%= button_to_function I18n.t("upload"), "upload_criteria();"%> | |
<span class="menu_bar" >|</span> | |
<%= button_to_function I18n.t("download"), "download_criteria();"%> | |
- </h1> | |
+ </div> | |
</div><!-- Title bar--> | |
<div class="wrapLeft"> | |
@@ -122,7 +125,8 @@ | |
<p><%= t('flexible_criteria.download.prompt') %></p> | |
<ul> | |
- <li><%= link_to t('flexible_criteria.download.link'), {:controller=>"flexible_criteria", :action=>"download", :id=> @assignment.id}%></li> | |
+ <li><%= link_to t('flexible_criteria.download.link'), | |
+ {:controller=>"flexible_criteria", :action=>"download", :id=> @assignment.id}%></li> | |
</ul> | |
<input type="reset" value="<%= t(:cancel) %>" onclick="modalDownload.close();"> | |
diff --git a/app/views/flexible_criteria/update.rjs b/app/views/flexible_criteria/update.rjs | |
index 0987d1ae87fbd5af7fa1d910d6bad2d9a9ea9bbf..cbb513df2895c8eb3b4296a9c679e9d8049b1171 100644 | |
--- a/app/views/flexible_criteria/update.rjs | |
+++ b/app/views/flexible_criteria/update.rjs | |
@@ -1,4 +1,4 @@ | |
page.replace_html "criterion_title_#{@criterion.id}", @criterion.flexible_criterion_name | |
page.replace_html "criterion_max_#{@criterion.id}", @criterion.max | |
-page.replace_html "criteria_total_mark", @criterion.assignment.total_criteria_weight | |
+page.replace_html "criteria_total_mark", @criterion.assignment.total_mark | |
page.replace_html "flexible_edition_pane_menu", :partial => 'criterion_editor', :locals => {:criterion => @criterion} | |
diff --git a/app/views/rubrics/_criterion_editor.html.erb b/app/views/rubrics/_criterion_editor.html.erb | |
index 524d59b12c33dde9871ebc76509df82271ca91df..2ea711b3e484e8caf8f6623e854d2d283ef6afb0 100644 | |
--- a/app/views/rubrics/_criterion_editor.html.erb | |
+++ b/app/views/rubrics/_criterion_editor.html.erb | |
@@ -1,3 +1,9 @@ | |
+<% if !flash[:success].nil? %> | |
+ <div class="success"> | |
+ <%= flash[:success] %> | |
+ </div> | |
+<% end %> | |
+ | |
<%= remote_form_for criterion, | |
:as => :rubric_criterion, | |
:url => {:action => 'update', | |
@@ -38,10 +44,10 @@ | |
<div class="float_right"> | |
<%= button_to I18n.t(:delete), | |
- assignment_rubric_path(:id => criterion.id), | |
- :confirm => I18n.t(:remove_criteria_message), | |
- :method => :delete, | |
- :class => 'delete', | |
- :title => I18n.t(:remove_criteria_title), | |
- :remote => true %> | |
+ assignment_rubric_path(:id => criterion.id), | |
+ :confirm => I18n.t(:remove_criteria_message), | |
+ :method => :delete, | |
+ :class => 'delete', | |
+ :title => I18n.t(:remove_criteria_title), | |
+ :remote => true %> | |
</div> | |
diff --git a/app/views/rubrics/create_and_edit.rjs b/app/views/rubrics/create_and_edit.rjs | |
index a4dd931a06e9510288593859ecda31ce83592305..9dd216c1e26464e575e07dc9fdb1c15d9a1de590 100644 | |
--- a/app/views/rubrics/create_and_edit.rjs | |
+++ b/app/views/rubrics/create_and_edit.rjs | |
@@ -2,28 +2,23 @@ if @criteria.count > 2 | |
page.insert_html :bottom, | |
'rubric_criteria_pane_list', | |
:partial => 'rubric_criterion', | |
- :locals => {:criterion => @criterion, | |
- :location => :last } | |
+ :locals => {:criterion => @criterion, :location => :last } | |
page.replace "criterion_#{@criteria[-2].id}", | |
:partial => 'rubric_criterion', | |
- :locals => {:criterion => @criteria[-2], | |
- :location => :middle } | |
+ :locals => {:criterion => @criteria[-2], :location => :middle } | |
elsif @criteria.count == 2 | |
page.insert_html :bottom, | |
'rubric_criteria_pane_list', | |
- :partial => 'rubric_criterion', | |
- :locals => {:criterion => @criterion, | |
- :location => :last } | |
+ :partial => 'rubric_criterion', | |
+ :locals => {:criterion => @criterion, :location => :last } | |
page.replace "criterion_#{@criteria.first.id}", | |
:partial => 'rubric_criterion', | |
- :locals => {:criterion => @criteria.first, | |
- :location => :first } | |
+ :locals => {:criterion => @criteria.first, :location => :first } | |
else | |
page.insert_html :bottom, | |
'rubric_criteria_pane_list', | |
:partial => 'rubric_criterion', | |
- :locals => {:criterion => @criterion, | |
- :location => :single } | |
+ :locals => {:criterion => @criterion, :location => :single } | |
end | |
page.remove 'new_rubric_criterion' | |
page.replace_html 'rubric_levels_pane_menu', :partial => 'criterion_editor', :locals => {:criterion => @criterion} | |
diff --git a/app/views/rubrics/index.html.erb b/app/views/rubrics/index.html.erb | |
index 9a6e6419d403a7dd5191675f97a2f0c234484fb3..f68c53ac37e37f66c554c3d6a0513ddb6407f24d 100644 | |
--- a/app/views/rubrics/index.html.erb | |
+++ b/app/views/rubrics/index.html.erb | |
@@ -62,11 +62,10 @@ | |
#{remote_function :url => new_assignment_rubric_path(@assignment), | |
:method => 'get'} | |
}|%> | |
- <span class="menu_bar" >|</span> | |
+ <span class="menu_bar" >|</span> | |
<%= button_to_function I18n.t("upload"), "upload_criteria();"%> | |
- <span class="menu_bar" >|</span> | |
+ <span class="menu_bar" >|</span> | |
<%= button_to_function I18n.t("download"), "download_criteria();"%> | |
- | |
</div> | |
</div><!-- Title bar--> | |
diff --git a/config/routes.rb b/config/routes.rb | |
index fd1e267cca9ab65cde803ffeba85032dd61e16f2..50d6ca3336a564e9d59c454ee8db2aeae01d3ec2 100644 | |
--- a/config/routes.rb | |
+++ b/config/routes.rb | |
@@ -58,6 +58,10 @@ Markus::Application.routes.draw do | |
end | |
resources :flexible_criteria do | |
+ member do | |
+ delete 'destroy' | |
+ end | |
+ | |
collection do | |
post 'upload' | |
get 'update_positions' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment