Investigation of charm and beauty production via semileptonic decays of heavy-flavour hadrons in pp at 7 TeV and Pb–Pb at 2.76 TeV with ALICE