   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 ->
-        conn
-        |> put_status(404)
-        |> render(CoursePlannerWeb.ErrorView, "404.html")
+      nil -> {:error, :not_found}
       offered_course ->
         render(conn, "show_coordinator.html", offered_course: offered_course)
     end

  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")
      offered_course ->
        render(conn, "show_teacher.html", offered_course: offered_course)
    end

    |> Repo.preload([:term, :course, :teachers])

    case Attendances.get_student_attendances(offered_course_id, id) do
     [] -> {:error, :not_found}
     attendances ->
       render(conn, "show_student.html", attendances: attendances, offered_course: offered_course)
    end
