Let $P_n$ the real vector space of all polynomial of degree $\le n$.
Let $B$ its canonical basis : $B=(e_0:t\mapsto 1,e_1:t\mapsto t,\cdots,e_n:t\mapsto t^n)$
Let $a,b$ two real numbers.
If the linear maps $\Phi:f\mapsto\sum_{i=1}^Nw_if(x_i)$ and $f\mapsto\int_a^bf(t)\,dt$ coincide of $B$, then they are equal.
Proof
For any $f\in P_n$, there exist unique $(a_0,\cdots,a_n)\in\mathbb{R}^{n+1}$ such that $f=\sum_{k=0}^na_ke_k$; hence by linearity :
$$\int_a^bf(t)\,dt=\sum_{k=0}^na_k\int_a^be_k(t)\,dt=\sum_{k=0}^na_k\Phi(e_k)=\Phi\left(\sum_{k=0}^na_ke_k\right)=\Phi(f)$$
What connection between $n$ and $N$ ?
There is no need to exist any connection between those integers if we only want to guaranty the previous point.
The Prop. 1 below asserts that taking $N=n+1$ is ok.
Of course, what we wish is an integration method that possibly works for a larger class of polynomials and which would also be a starting point for a general integration process for arbitrary functions (regular enough ones, though).
Prop. 1 Given $n\in\mathbb{N}$ and given pairwise distinct real numbers $t_0,\cdots,t_n$ (not necessary in $[a,b]$), there exist a unique $(\lambda_0,\cdots,\lambda_n)\in\mathbb{R}^{n+1}$ such that :
$$\forall f\in P_n,\int_a^bf(t)\,dt=\sum_{k=0}^n\lambda_kf(t_k)\tag{*}$$
Proof - The family of linear maps $\varphi_k:P_n\to\mathbb{R},f\mapsto f(t_k)$ is a basis of the dual space $P_n^\star$. Hence the linear map $P_n\to\mathbb{R},f\mapsto\int_a^bf(t)\,dt$ can be written, in a unique way, as a linear combination of $\varphi_0,\cdots,\varphi_n)$.
Prop. 2 Given $n\in\mathbb{N}$, there is exists a unique choice for the numbers $t_0,\cdots,t_n$ such that the formula (*) extends in fact to all $f\in P_{2n+1}$. Those numbers are the roots of the (monic) polynomial which spans the orthogonal in $P_{n+1}$ of $P_n$, with respect to the inner product defined by :
$$\left
=\int_a^bP(t)Q(t)\,dt$$
The next step is the so-called Gauss quadrature method.
Roughly speaking, the interval $[a,b]$ is divided into $q$ equal parts and an approximation of the integral of $f$ on each part is obtained with Prop. 2. Summing those approximations yields an approximate value of $\int_a^bf(t)\,dt$. To learn the details, you should start with this Wikipedia article.