The first part where you drop the lowest grade you can completely get rid of. Moodle has a built-in drop the lowest feature. To use go into Categories and items and then select Full View link underneath the tabs. There will be a column for drop the lowest. Entering a 1 drops the lowest, entering 2 drops two lowest and so on.
You will first want to arrange these grades into a category though. The final exam should not be in this category.
Your formula would then be similar to what is below. For my formula I am using CT to represent the category total of all those assignments.
=sum((CT+(FinalExam*2))/8)
Happy oodling!