 defmodule OntagCoreWeb.AnswerController do
   use OntagCoreWeb, :controller
   alias OntagCore.QAMS
+  alias OntagCore.Repo
 
   plug OntagCoreWeb.Authentication when action in [:create]
   action_fallback OntagCoreWeb.FallbackController

      |> json(%{message: "Tag successfully deleted"})
    end
  end
end

    with {:ok, answer} <- QAMS.create_answer(author, params) do
      conn
      |> put_status(:created)
      |> json(%{id: answer.id,
                question_id: answer.question_id})
    end
  end

  def index(conn, _) do
    answers =
      QAMS.list_answers()
      |> Repo.preload(:annotations)
      |> Enum.map(fn answer -> %{id: answer.id,
                                 question_id: answer.question_id,
                                 annotations: take(answer.annotations)} end)

    conn
    |> put_status(:ok)
