Another approach uses rasterize method from Processing Tool Box and Raster Calculator. In my example, I used line vector layer and slope raster of next image:

For rasterizing, you first need these raster parameters (see in Metadata Properties) from original raster:
Layer Extent (layer original source projection)
Pixel Size
However, 'Layer Extent' is not in order required for rasterize tool. Must be ordered as: xmin, ymin, xmax, ymax.
In my case, these parameters were:
354971.3488602247089148, 479272.4038835020037368, 4414903.3223166307434440, 4473428.4023900907486677
73.9887
and they were copy/paste at rasterized tool as in next image (id in line vector layer must be 1):

After run, I got this rasterized line (pseudocolor with 2 classes and transparency for 0 values). This one is perfected aligned with original raster.

Finally, I used next formula in 'Raster calculator expression':
( "Rasterized@1" ) * "utah_demUTM2_slope@1"
to get a new rasterized line; but with slope values instead. Red rectangle at next image point out your required statistic parameters, average and maximum slope, for this vector line.

slope along the line
ordem slope at each point
.