class CollaborationsController

Public Instance Methods

create() click to toggle source
# File lib/etherpad_canvas/collaborations_controller.rb, line 32
def create
  # This code was taken fro the original canvas controller in an effort to get around
  # the limitations of Rails' version 5.0 to escape a redirect. The only changes that have
  # been made from the original code are on lines 46 where a .delete was removed from between the
  # params[:collaboration][:collaboration_type] and line 56
  content_item = params["contentItems"] ? JSON.parse(params["contentItems"]).first : nil
  if content_item
    @collaboration = collaboration_from_content_item(content_item)
    users, group_ids = content_item_visibility(content_item)
  else
    users = User.where(id: Array(params[:user])).to_a
    group_ids = Array(params[:group])
    collaboration_params = params.require(:collaboration).permit(:title, :description, :url)
    collaboration_params[:user] = @current_user
    @collaboration = Collaboration.typed_collaboration_instance(params[:collaboration][:collaboration_type])
    collaboration_params.delete(:url) unless @collaboration.is_a?(ExternalToolCollaboration)
    @collaboration.attributes = collaboration_params
  end
  @collaboration.context = @context
  if @collaboration.collaboration_type == "EtherPad"
    respond_to do |format|
      if @collaboration.save
        Lti::ContentItemUtil.new(content_item).success_callback if content_item
        @collaboration.update_members(users, group_ids)
        format.html { redirect_to EtherpadCollaboration.sign_url(@current_user, @collaboration) }
        format.json {
          render json: @collaboration.as_json(
            methods: [:collaborator_ids], permissions: {
              user: @current_user,
              session: session,
            }
          )
        }
      else
        Lti::ContentItemUtil.new(content_item).failure_callback if content_item
        flash[:error] = t "errors.create_failed", "Collaboration creation failed"
        format.html { redirect_to named_context_url(@context, :context_collaborations_url) }
        format.json { render json: @collaboration.errors, status: :bad_request }
      end
    end
  else
    create_without_etherpad
  end
end
Also aliased as: create_without_etherpad
create_without_etherpad()
Alias for: create
show() click to toggle source
# File lib/etherpad_canvas/collaborations_controller.rb, line 23
def show
  @collaboration = @context.collaborations.find(params[:id])
  if @collaboration.collaboration_type == "EtherPad"
    return redirect_to EtherpadCollaboration.sign_url(@current_user, @collaboration)
  else
    show_without_etherpad
  end
end
Also aliased as: show_without_etherpad
show_without_etherpad()
Alias for: show