Replaced deprecated moodle api function

Changes made by @jordif
Replaced deprecated function get_context_instance()
original request was #8, but splitted up by me into separate commits.