Skip to content

Commit

Permalink
Closes #691. Editing and removing annotations in GV.
Browse files Browse the repository at this point in the history
This commit fixes editing/removing annotations in the grader view.
Specifically in the "Annotation Summary" tab.
  • Loading branch information
hansonywu authored and jerboaa committed Mar 14, 2012
1 parent cc5a330 commit 39eeaec
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 16 deletions.
2 changes: 1 addition & 1 deletion app/controllers/annotations_controller.rb
Expand Up @@ -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]
Expand Down
18 changes: 8 additions & 10 deletions app/views/results/marker/_annotation_summary.html.erb
Expand Up @@ -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">

Expand Down
3 changes: 2 additions & 1 deletion config/routes.rb
Expand Up @@ -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

Expand Down
16 changes: 14 additions & 2 deletions public/stylesheets/grader.css
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
14 changes: 12 additions & 2 deletions test/functional/annotations_controller_test.rb
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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

0 comments on commit 39eeaec

Please sign in to comment.