The short answer to the question
" Can I use, edit or redistribute it or even sell it? "
Is yes, but you cannot deprive the buyer of the rights to do those things.
I write Moodle plugins in my non employed time which I and I fervently hope that other people get use out of them both for education and as part of money making services. I don't expect any money from that.