how to automatically select entity reference field value from url when adding a node
I think the easiest way would be to use hook_form_alter() and set a default value for the field. You can use arg() to get the course ID