To open your course to students or to prevent students from accessing your course after it ends or before it begins, you must change the Course visibility setting under the course settings.
Select "Settings" from the top of your course page:
Set "Course visibility" on the "Edit Settings" page: