   def show(%{assigns: %{current_user: %{id: id, role: "Teacher"}}} = conn,
            %{"id" => offered_course_id}) do
     case Attendances.get_teacher_course_attendances(offered_course_id, id) do
-      nil ->
-        conn
-        |> put_status(404)
-        |> render(CoursePlannerWeb.ErrorView, "404.html")
+      nil -> {:error, :not_found}
       offered_course ->
         render(conn, "show_teacher.html", offered_course: offered_course)
     end


  import Canary.Plugs
  plug :authorize_controller

  def index(%{assigns: %{current_user: %{id: _id, role: "Coordinator"}}} = conn, _params) do
    offered_courses = Attendances.get_all_offered_courses()

  def show(%{assigns: %{current_user: %{id: _id, role: "Coordinator"}}} = conn,
           %{"id" => offered_course_id}) do
    case Attendances.get_course_attendances(offered_course_id) do
      nil -> {:error, :not_found}
      offered_course ->
        render(conn, "show_coordinator.html", offered_course: offered_course)
    end
