class AnnotationsController

Public Instance Methods

add_existing_annotation() click to toggle source
# File app/controllers/annotations_controller.rb, line 5
def add_existing_annotation
  return unless request.post?
  @text = AnnotationText.find(params[:annotation_text_id])
  @submission_file_id = params[:submission_file_id]
  @submission_file = SubmissionFile.find(@submission_file_id)
  submission= @submission_file.submission
  is_remark = submission.has_remark?
  if params[:annotation_type] == 'image'
    @annotation = ImageAnnotation.new
    @annotation.update_attributes({
      :x1 => Integer(params[:x1]), :x2 => Integer(params[:x2]),
      :y1 => Integer(params[:y1]), :y2 => Integer(params[:y2]),
      :submission_file_id => params[:submission_file_id],
      :is_remark => is_remark,
      :annotation_number => submission.annotations.count + 1
    })
  else
    @annotation = TextAnnotation.new
    @annotation.update_attributes({
      :line_start => params[:line_start],
      :line_end => params[:line_end],
      :submission_file_id => params[:submission_file_id],
      :is_remark => is_remark,
      :annotation_number => submission.annotations.count + 1
    })
  end
  @annotation.annotation_text = @text
  @annotation.save
  @submission = @submission_file.submission
  @annotations = @submission.annotations
end
create() click to toggle source
# File app/controllers/annotations_controller.rb, line 37
def create
  @text = AnnotationText.create({
    :content => params[:content],
    :annotation_category_id => params[:category_id]
  })
  @submission_file_id = params[:submission_file_id]
  @submission_file = SubmissionFile.find(@submission_file_id)
  submission= @submission_file.submission
  is_remark = submission.has_remark?
  case params[:annotation_type]
    when 'text'
      @annotation = TextAnnotation.create({
        :line_start => params[:line_start],
        :line_end => params[:line_end],
        :annotation_text_id => @text.id,
        :submission_file_id => params[:submission_file_id],
        :is_remark => is_remark,
        :annotation_number => submission.annotations.count + 1
      })
    when 'image'
      @annotation = ImageAnnotation.create({
        :annotation_text_id => @text.id,
        :submission_file_id => params[:submission_file_id],
        :x1 => Integer(params[:x1]), :x2 => Integer(params[:x2]),
        :y1 => Integer(params[:y1]), :y2 => Integer(params[:y2]),
        :is_remark => is_remark,
        :annotation_number => submission.annotations.count + 1
      })
  end
  @submission = @submission_file.submission
  @annotations = @submission.annotations
end
destroy() click to toggle source
# File app/controllers/annotations_controller.rb, line 70
def destroy
  @annotation = Annotation.find(params[:id])
  @old_annotation = @annotation.destroy
  @submission_file_id = params[:submission_file_id]
  @submission_file = SubmissionFile.find(@submission_file_id)
  @submission = @submission_file.submission
  @annotations = @submission.annotations
  @annotations.each do |annot|
    if annot.annotation_number > @old_annotation.annotation_number
      annot.annotation_number -= 1
      annot.save
    end
  end

end
update_annotation() click to toggle source
# File app/controllers/annotations_controller.rb, line 86
def update_annotation
  return unless request.put?
  @content = params[:annotation_text][:content]
  @id = params[:annotation_text][:id]
  @submission_file_id = params[:annotation_text][:submission_file_id]
  @annotation_text = AnnotationText.find(@id)
  @annotation_text.content = @content
  @annotation_text.save
  @submission_file = SubmissionFile.find(@submission_file_id)
  @submission = @submission_file.submission
  @annotations = @submission.annotations
end
update_comment() click to toggle source

Updates the overall comment from the annotations tab

# File app/controllers/annotations_controller.rb, line 100
def update_comment
  return unless request.post?
  result = Result.find(params[:result_id])
  result.overall_comment = params[:overall_comment]
  result.save
  render :update do |page|
  end
end
update_marking_state() click to toggle source

Updates the marking state

# File lib/benchmarking/submission_files/annotations_controller.rb, line 72
def update_marking_state
  result = Result.find(params[:id])
  result.marking_state = params[:value]
  result.save
  render :update do |page|
     page.redirect_to :controller => 'results', :action => 'edit', :id =>
     result.id
  end
end