diff --git a/course/edit.html b/course/edit.html index 49a0f0b4eb6..f830feacb07 100644 --- a/course/edit.html +++ b/course/edit.html @@ -33,6 +33,7 @@
Note that if you have an enrolment key set, then the guest account - can also get in to the course using the key - but it will be asked - for the key EVERY TIME a guest logs in the course. (This occurs - EVEN if you have specified 'No guests are allowed') - -
This diagram explains how it works: - -
| - | Enrolment key | -No enrolment key | -
|---|---|---|
| Guest access | -Students need key -Guests get in free |
- Students get in free -Guests get in free |
-
| No guest access | -Students need key -Guests need key |
- Students get in free -No guests allowed |
-
Guest Access
-You have the choice of allowing "guests" into your course +
You have the choice of allowing "guests" into your course.
People can log in as guests using the "Login as a guest" button on the login screen. -
Guests have "read-only" access - meaning they can't leave +
Guests ALWAYS have "read-only" access - meaning they can't leave any posts or otherwise mess up the course for real students.
This can be handy when you want to let a colleague in to look around at your work, or to let students see a course before they have decided to enrol. -
If you have Guest access turned off, but have an enrolment key - defined, then guests can still get in provided they can provide - the right enrolment key. - -
This diagram might help make the behaviour clear: -
| - | Enrolment key | -No enrolment key | -
|---|---|---|
| Guest access | -Students need key -Guests get in free |
- Students get in free -Guests get in free |
-
| No guest access | -Students need key -Guests need key |
- Students get in free -No guests allowed |
-
Note that you have a choice between two types of guest access: + with the enrolment key or without. If you choose to allow + guests who have the key, then the guest will need to provide + the current enrolment key EVERY TIME they log in (unlike + students who only need to do it once). This lets you restrict + your guests. If you choose to allow guests without a key, then + anyone can get straight into your course. diff --git a/lang/en/moodle.php b/lang/en/moodle.php index 5c117e325fc..4ffce5e9ff8 100644 --- a/lang/en/moodle.php +++ b/lang/en/moodle.php @@ -140,8 +140,10 @@ GNU General Public License for more details: http://www.gnu.org/copyleft/gpl.html"; $string[grade] = "Grade"; -$string[guestsno] = "No, do not allow guests in"; -$string[guestsyes] = "Yes, allow 'guest' student in"; +$string[guestsno] = "Do not allow guests in"; +$string[guestsnotallowed] = "Sorry, '\$a' does not allow guests to enter."; +$string[guestsyes] = "Allow guests without the key"; +$string[guestskey] = "Allow guests who have the key"; $string[help] = "Help"; $string[helppicture] = "How to upload a picture"; $string[helptext] = "How to write text"; @@ -268,7 +270,7 @@ $string[numyears] = "\$a years"; $string[numwords] = "\$a words"; $string[numviews] = "\$a views"; $string[ok] = "OK"; -$string[opentoguests] = "Open to guests?"; +$string[opentoguests] = "Guest access"; $string[optional] = "optional"; $string[outline] = "Outline"; $string[participants] = "Participants"; diff --git a/lib/moodlelib.php b/lib/moodlelib.php index 54799b962b7..2d5323ae151 100644 --- a/lib/moodlelib.php +++ b/lib/moodlelib.php @@ -940,9 +940,10 @@ function require_login($courseid=0) { global $CFG, $SESSION, $USER, $FULLME, $HTTP_REFERER, $PHPSESSID; // First check that the user is logged in to the site. - if (! (isset( $USER->loggedin ) && $USER->confirmed) ) { + + if (! (isset($USER->loggedin) and $USER->confirmed) ) { // They're not $SESSION->wantsurl = $FULLME; - $SESSION->fromurl = $HTTP_REFERER; + $SESSION->fromurl = $HTTP_REFERER; save_session("SESSION"); if ($PHPSESSID) { // Cookies not enabled. redirect("$CFG->wwwroot/login/?PHPSESSID=$PHPSESSID"); @@ -955,7 +956,7 @@ function require_login($courseid=0) { // Next, check if the user can be in a particular course if ($courseid) { if ($USER->student[$courseid] || $USER->teacher[$courseid] || $USER->admin) { - if (!isset($USER->realuser)) { // Don't log if this isn't a realuser + if (!isset($USER->realuser)) { // Don't update if this isn't a realuser update_user_in_db(); } return; // user is a member of this course. @@ -963,13 +964,21 @@ function require_login($courseid=0) { if (! $course = get_record("course", "id", $courseid)) { error("That course doesn't exist"); } - if ($course->guest && ($USER->username == "guest")) { - update_user_in_db(); - return; // user is a guest and this course allows guests + if ($USER->username == "guest") { + switch ($course->guest) { + case 0: // Guests not allowed + print_header(); + notice(get_string("guestsnotallowed", "", $course->fullname)); + break; + case 1: // Guests allowed + update_user_in_db(); + return; + case 2: // Guests allowed with key (drop through) + break; + } } - // Not allowed in the course, so see if they want to enrol - + // Currently not enrolled in the course, so see if they want to enrol $SESSION->wantsurl = $FULLME; save_session("SESSION"); redirect("$CFG->wwwroot/course/enrol.php?id=$courseid"); diff --git a/version.php b/version.php index 68b4a7e6653..9c75019172b 100644 --- a/version.php +++ b/version.php @@ -17,7 +17,7 @@ // If there's something it cannot do itself, it // will tell you what you need to do. -$version = 2002082000; +$version = 2002082100; function upgrade_moodle($oldversion=0) { @@ -34,7 +34,7 @@ function upgrade_moodle($oldversion=0) { } if ($oldversion < 2002073100) { - execute_sql("DELETE FROM `modules` WHERE `name` = 'chat' "); + execute_sql(" DELETE FROM `modules` WHERE `name` = 'chat' "); } if ($oldversion < 2002080200) { @@ -43,8 +43,12 @@ function upgrade_moodle($oldversion=0) { } if ($oldversion < 2002080300) { - execute_sql(" ALTER TABLE `log_display` CHANGE `table` `mtable` VARCHAR( 20 ) NOT NULL "); - execute_sql(" ALTER TABLE `user_teachers` CHANGE `authority` `authority` TINYINT( 3 ) DEFAULT '3' NOT NULL "); + execute_sql(" ALTER TABLE `log_display` CHANGE `table` `mtable` VARCHAR( 20 ) NOT NULL "); + execute_sql(" ALTER TABLE `user_teachers` CHANGE `authority` `authority` TINYINT( 3 ) DEFAULT '3' NOT NULL "); + } + + if ($oldversion < 2002082100) { + execute_sql(" ALTER TABLE `course` CHANGE `guest` `guest` TINYINT(2) UNSIGNED DEFAULT '0' NOT NULL "); } return true;