Class: Course::Assessment::SubmissionQuestion::CommentsController

Inherits:
Controller show all
Includes:
Discussion::PostsConcern
Defined in:
app/controllers/course/assessment/submission_question/comments_controller.rb

Instance Method Summary collapse

Methods included from Discussion::PostsConcern

#skip_update_topic_status, #update_topic_pending_status

Methods included from ApplicationSignInCallbacksConcern

#sign_in

Methods included from ApplicationPaginationConcern

#page_param

Methods included from ApplicationAnnouncementsConcern

#global_announcements, #unread_global_announcements

Methods included from ApplicationInstanceUserConcern

#current_instance_user

Methods included from ApplicationUserTimeZoneConcern

#set_time_zone

Methods included from ApplicationUserConcern

#handle_access_denied, #publicly_accessible?

Methods included from ApplicationComponentsConcern

#handle_component_not_found

Instance Method Details

#createObject


6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'app/controllers/course/assessment/submission_question/comments_controller.rb', line 6

def create
  result = @submission_question.class.transaction do
    @post.title = @assessment.title
    # Set parent as the topologically last pre-existing post, if it exists.
    @post.parent = last_post_from(@submission_question) if @submission_question.posts.length > 1

    raise ActiveRecord::Rollback unless @post.save && create_topic_subscription && update_topic_pending_status
    raise ActiveRecord::Rollback unless @submission_question.save

    true
  end

  if result
    send_created_notification(@post)
    render_create_response
  else
    head :bad_request
  end
end