The blog post example is completely wrong (see the comments box of the blog!).. With the recent QGIS version (3.4.) I can do it easily with the tool "Extract vertices", which gives you all line vertices an the cummulated distances from the start vertex.
Then you sample a DEM raster, using the vertices' point layer with the tool "Sample raster values", resulting in a new point layer with the raster (elevation) values joined to the single vertices/features.
As next step you need the segment distances and the elevation differences for calculating the grades.
With the field calculator you can calculate the single segment distances, with something along the lines
'vertices_layer', @row_number) , 'id') = attribute( get_feature_by_id('vertices_layer', @row_number-1) , 'id')
THEN attribute( get_feature_by_id('vertices_layer', @row_number) , 'distance') - attribute( get_feature_by_id('vertices_layer', @row_number-1) , 'distance')
The condition tests if segments between consecutive vertices belong to the same feature, as given by the id. Using the generic variable @row_number, we assume that the points/vertices are ordered as in the original lines.
The elevation difference you get, by putting something like the below to the field calculator:
attribute( get_feature_by_id('vertices_layer', @row_number+1) , 'rvalue_1') - attribute( get_feature_by_id('vertices_layer', @row_number) , 'rvalue_1')
Again, you'd need to make a CASE WHEN condition, as above, testing if the consecutive vertices belong to the same line feature!
With the vertex distance and the elevation difference you can calculate the segments' grade. This values you use in an aggregate calculation to get the average grades for the line features (aggregating over segments with mean function and grouping by id). Then you need to join these values back to the lines layer.
If you only want the elevation, you stop after sampling the DEM raster and aggregate the elevations, then join back by id.. But what's that good for? Average elevation of a line feature?
I dug a little deeper into this, and obviously everything is way easier - just use tool "explode lines", then "drape (set z-values from raster)" using your DEM as raster. The elevations you get from the segments with the field calculator by expression:
z( end_point( $geometry))
z( start_point( $geometry))
Then you could aggregate over the segments with the line ids as grouping variable, to yield an aggregate value for each original line.
If you want the grades (%) you could use the field calculator:
(z( end_point( $geometry))-z( start_point( $geometry)) ) / $length * 100