For the one-variable functions:
$$\frac{\text d y}{\text d z} = \frac{\text d y}{\text d x} \cdot \frac{\text d x}{\text d z} = \frac{f'(x)}{g'(x)}$$
For the two-variable functions:
$$\frac{\partial y}{\partial z} = \frac{\partial y}{\partial x_1} \frac{\partial x_1}{\partial z} + \frac{\partial y}{\partial x_2}\frac{\partial x_2}{\partial z}$$
Now, depending on whether $x_1$ or $x_2$ is a constant, one of the terms becomes zero.
EDIT: Let's see what $\frac{\partial x_1}{\partial z}$ is when $x_2=\text{const}$. The same reasoning applies to $\frac{\partial x_2}{\partial z}$ when $x_1=\text{const}$.
Since $x_2$ is constant, then $z=g(x_1,x_2)$ is just a function of $x_1$. Because of this, we can define a new function
$$h(x_1) = g(x_1,x_2=\text{const})$$
and we have that $z=h(x_1)$. In the case of a one-variable function, a partial derivative is the same as an ordinary derivative. Hence
$$\frac{\partial x_1}{\partial z}=\frac{\partial x_1}{\partial h(x_1)} = \underbrace{ \frac{\text d x_1}{\text d h(x_1)} = \frac{1}{h'(x_1)} }_\text{inverse function rule} = \frac{1}{\dfrac{\partial z}{\partial x_1}}$$