Class: Course::Assessment::Submission::Answer::Programming::ProgrammingController

Inherits:
Controller
  • Object
show all
Defined in:
app/controllers/course/assessment/submission/answer/programming/programming_controller.rb

Instance Method Summary collapse

Instance Method Details

#create_programming_filesObject


11
12
13
14
15
16
17
18
19
# File 'app/controllers/course/assessment/submission/answer/programming/programming_controller.rb', line 11

def create_programming_files
  authorize! :create_programming_files, @programming_answer

  if update_answer_files_attributes(create_programming_files_params)
    render @programming_answer.answer
  else
    render json: { errors: @programming_answer.answer.errors }, status: :bad_request
  end
end

#destroy_programming_fileObject


21
22
23
24
25
26
27
28
29
30
# File 'app/controllers/course/assessment/submission/answer/programming/programming_controller.rb', line 21

def destroy_programming_file
  authorize! :destroy_programming_file, @programming_answer

  file_id = delete_programming_file_params[:file_id].to_i
  if delete_programming_file(file_id)
    render json: { answerId: @programming_answer.answer.id, fileId: file_id }
  else
    render json: { errors: @programming_answer.answer.errors }, status: :bad_request
  end
end