forked from autolab/Autolab
-
Notifications
You must be signed in to change notification settings - Fork 0
/
annotations_controller.rb
executable file
·52 lines (45 loc) · 1.65 KB
/
annotations_controller.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# All modifications to the annotations are meant to be asynchronous and
# thus this contorller only exposes javascript interfaces.
#
# Only people acting as instructors or CA's should be able to do anything
# but view the annotations and since all of these mutate them, they are
# all restricted to those types.
class AnnotationsController < ApplicationController
before_action :set_assessment
before_action :set_submission
before_action :set_annotation, except: [:create]
respond_to :json
# POST /:course/annotations.json
action_auth_level :create, :course_assistant
def create
annotation = @submission.annotations.new(annotation_params)
annotation.save
respond_with(@course, @assessment, @submission, annotation)
end
# PUT /:course/annotations/1.json
action_auth_level :update, :course_assistant
def update
@annotation.update(annotation_params)
respond_with(@course, @assessment, @submission, @annotation) do |format|
format.json { render json: @annotation }
end
end
# DELETE /:course/annotations/1.json
action_auth_level :destroy, :course_assistant
def destroy
@annotation.destroy
respond_with(@course, @assessment, @submission, @annotation)
end
private
def annotation_params
params[:annotation].delete(:id)
params[:annotation].delete(:submission_id)
params[:annotation].delete(:created_at)
params[:annotation].delete(:updated_at)
params.require(:annotation).permit(:filename, :position, :line, :text, :submitted_by,
:comment, :value, :problem_id)
end
def set_annotation
@annotation = @submission.annotations.find(params[:id])
end
end