Note. You know that $\displaystyle\frac{d[w(x)]}{dx}=w'(x)\implies d[w(x)]=w'(x)dx$
$\displaystyle\int_{-L/2}^{L/2}w'(x)dx=\int_{-L/2}^{L/2}d[w(x)]=w(L/2)-w(-L/2)$
Method $1$
$\hat x=\frac xL\implies x=L\hat x$
Since $x$ ranges from $-L/2\to L/2, \hat x=\frac xL$ ranges from $-1/2\to1/2$.
Substitute $x$ by $L\hat x$ wherever you find $x$ in the integrand.
$\displaystyle\int_{-L/2}^{L/2}w'(x)dx=\int_{-1/2}^{1/2}w'(L\hat x)d(L\hat x)=L\int_{-1/2}^{1/2}w'(L\hat x)d\hat x\because d(L\hat x)=Ld(\hat x)$
Method $2$
$\displaystyle w'(x)=\frac d{dx}[w(x)]=\frac d{dx}[w(y)]$, where $y=L\hat x=x$
$\displaystyle w'(x)=\frac d{dx}[w(y)]=\frac d{dy}[w(y)]\times \frac{dy}{dx}=w'(y)\times\frac{dy}{dx}=w'(y)\times\frac{dx}{dx}=w'(y)=w'(L\hat x)$
The error in your approach lies when you claim that $\displaystyle\frac{d[w(x)]}{d\hat x}=w'(\hat x)$. Since $\displaystyle x=L\hat x,\frac{d[w(x)]}{d\hat x}=\frac{d[w(L\hat x)]}{d\hat x}$
By the chain rule, for finding this expression, you have to differentiate it with respect to the inner function and multiply with the derivative of the inner function with respect to $\hat x$.
$\displaystyle\frac{d[w(L\hat x)]}{d\hat x}=\frac{d[w(L\hat x)]}{d(L\hat x)}\times\frac{d(L\hat x)}{d\hat x}=Lw'(L\hat x)\because w'(L\hat x)=\frac d{d(L\hat x)}[w(L\hat x)]$
w'(x)and notw^{'}(x)that has quite bad output. – egreg Dec 14 '18 at 18:20