Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Closes #691. Editing and removing annotations in GV.

This commit fixes editing/removing annotations in the grader view.
Specifically in the "Annotation Summary" tab.
  • Loading branch information...
commit 39eeaec5765d5425849ce17f91485eb0031c2ad7 1 parent cc5a330
@hansonywu hansonywu authored jerboaa committed
View
2  app/controllers/annotations_controller.rb
@@ -69,7 +69,7 @@ def destroy
end
def update_annotation
- return unless request.post?
+ return unless request.put?
@content = params[:annotation_text][:content]
@id = params[:annotation_text][:id]
@submission_file_id = params[:annotation_text][:submission_file_id]
View
18 app/views/results/marker/_annotation_summary.html.erb
@@ -5,16 +5,14 @@
<div class="annotationContent" id="annotation_text_content_display_<%=h(annot.annotation_text.id)%>">
<%= simple_format(h(annot.annotation_text.content)) %>
</div>
- <p class="manageAnnotations"><%= link_to_function I18n.t("edit"), "$('annotation_text_content_edit_#{annot.annotation_text.id}').show();$('annotation_text_content_display_#{annot.annotation_text.id}').hide();" %>
- &middot;
- <%= link_to I18n.t("remove"),
- :url => {:controller => "annotations",
- :action=>"destroy",
- :id=>annot.id,
- :submission_file_id => @submission_file_id},
- :confirm => I18n.t("marker.annotation.sure_to_remove"),
- :remote => true %>
- </p>
+
+ <%= link_to_function I18n.t("edit"),
+ "$('annotation_text_content_edit_#{annot.annotation_text.id}').show();$('annotation_text_content_display_#{annot.annotation_text.id}').hide();",
+ {:class => "float_left edit_remove_annotation_button"} %>
+ <%= button_to I18n.t("remove"),
+ annotations_path(:id => annot.id, :submission_file_id => @submission_file_id),
+ :method => :delete, :class => "edit_remove_annotation_button",
+ :confirm => I18n.t("marker.annotation.sure_to_remove"), :remote => true %>
<div id="annotation_text_content_edit_<%= annot.annotation_text.id %>" class="annotation_text_content_editor">
View
3  config/routes.rb
@@ -251,8 +251,9 @@
resources :annotations do
collection do
post 'add_existing_annotation'
- post 'update_annotation'
+ put 'update_annotation'
post 'update_comment'
+ delete 'destroy'
end
end
View
16 public/stylesheets/grader.css
@@ -27,8 +27,6 @@
padding: 0 0 0 10px;
}
-#annotation_summary_list form { margin: 0 0 10px 0; }
-
#student_selector {
-moz-border-radius: 5px;
background: #ECECEC;
@@ -91,6 +89,20 @@
margin: 0;
}
+.edit_remove_annotation_button {
+ background: #fff;
+ -moz-border-radius: 10px;
+ -webkit-border-radius: 10px;
+ border: 2px solid #ccc;
+ font-family: "Lucida Grande", Verdana, Arial, sans-serif;
+ font-weight: bold;
+ color: #464646;
+ margin: 5px;
+ font-size: 0.85em;
+ min-width: 0px;
+ padding: 3px 10px 3px 10px;
+}
+
li.annotation_category {
/* margin: 0 0 0 5px;*/
padding: 3px 5px;
View
14 test/functional/annotations_controller_test.rb
@@ -138,7 +138,7 @@ def setup
:line_start => 1, :line_end => 1,
:annotation_text_id => @annotation_text.id,
:submission_file_id => @submission_file.id})
- post_as @user, :update_annotation, :annotation_text => {
+ put_as @user, :update_annotation, :annotation_text => {
:id => @annotation_text.id, :content => @annotation_text.content,
:submission_file_id =>@submission_file.id}
assert_response :success
@@ -213,7 +213,7 @@ def setup
:line_start => 1, :line_end => 1,
:annotation_text_id => @annotation_text.id,
:submission_file_id => @submission_file.id})
- post_as @user, :update_annotation, :annotation_text => {
+ put_as @user, :update_annotation, :annotation_text => {
:id => @annotation_text.id, :content => @annotation_text.content,
:submission_file_id =>@submission_file.id}
assert_response :success
@@ -288,4 +288,14 @@ def setup
assert_response :not_found
end # End context :update_comment
end # End context Student POST
+
+ should "recognize action to update_annotation" do
+ assert_recognizes( {:action => "update_annotation", :controller => "annotations"},
+ {:path => "annotations/update_annotation", :method => "put"} )
+ end
+
+ should "recognize action to destroy" do
+ assert_recognizes( {:action => "destroy", :controller => "annotations"},
+ {:path => "annotations", :method => "delete"} )
+ end
end
Please sign in to comment.
Something went wrong with that request. Please try again.