Restrict a user to only one course

Restrict a user to only one course

by Chad Gross -
Number of replies: 4
We have a situation where we'd like a user to only be able to access one course in our system. They should not be able to get into any of the other courses. We've tried roles for this but I'm just not seeing any way of doing this without having touch every course on the system. Is there an obvious way of doing this that I'm missing? What is the best way to handle this situation?
Average of ratings: -
In reply to Chad Gross

Re: Restrict a user to only one course

by Teresa Gibbison -
Hi Chad
Restricting access to courses is completed via the course not the user. You should ensure courses have enrolment keys to prevent unauthorised access, alternatively you can remove the 'All courses' link and use hidden course categories to prevent users browsing through the site.
Probably not what you were hoping to hear but I hope this helps
Cheers
Teresa

In reply to Teresa Gibbison

Re: Restrict a user to only one course

by Ger Tielemans -

Why hide?? just use a different access-key for every course and give the user only that key.


(If you fear that studenst exchange keys: change the keys every week... every day... every smile) You can do this with a script:

  1. change the keys at random
  2. generate a list of the new keys
  3. send by email the enroll-key for this week.. this day..


We have the rule that every course should have a key, otherwise the admin puts a key on it. Now and then we run a check script

I put it in the /admin/report/newkey/index.php section, something like:

<?php

include('../../../config.php');

require_login();

require_capability('moodle/site:viewreports', get_context_instance(CONTEXT_SYSTEM, SITEID));

srand ((double) microtimeegg*1000000);
$random_number = randegg;

$result4 = mysql_query("UPDATE mdl_course SET password="$random_number." where id>1 and password='' ");

mtrace ("Ok new key... (".$result4.") ");

?>

// not complete for you: all courses in one run get the same key, for us ok 

// mcrotime and rand brackets look now like an Easter egg, done by this funny WYSIWYG editor???


We use a more complex version of this script for creating zones(categories) with (parent)guest-access and other closed zones..

In reply to Chad Gross

Re: Restrict a user to only one course

by Dirk Meyer -
Perfectly good question. I am trying to set up a user that can only get into one course for a professor who is evaluating a student teacher but who I do not want to navigate our site other than that one course.
In reply to Dirk Meyer

Re: Restrict a user to only one course

by ben reynolds -
I think the real issue is "What's your enrollment method?"

We upload our users in bulk. So, we set "Course enrollable" to No, and that prevents strangers from wandering into classrooms where they don't belong. It won't stop them from seeing links to classrooms, but, hey, all the doors but one are locked.

With courses unenrollable, you simply go into the student teacher's classroom and add the prof manually.