Fixed up guest access PROPERLY - it's now more obvious and simple for teachers

to set it how they want.  Guest access now has THREE states (off, on, on with key).
This commit is contained in:
martin
2002-08-21 12:54:27 +00:00
parent babab0e100
commit 7363ff911f
6 changed files with 40 additions and 71 deletions
+1
View File
@@ -33,6 +33,7 @@
<td><?
$choices["0"] = get_string("guestsno");
$choices["1"] = get_string("guestsyes");
$choices["2"] = get_string("guestskey");
choose_from_menu ($choices, "guest", $form->guest, "");
helpbutton("guestaccess", get_string("opentoguests")); ?>
</td>
-28
View File
@@ -21,31 +21,3 @@
enrolled will not be affected, but the unwanted people won't be
able to get back in.
<P>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')
<P>This diagram explains how it works:
<table border="1" align="center" cellpadding="5">
<tr>
<th nowrap width="8">&nbsp;</th>
<th nowrap width="84">Enrolment key</th>
<th nowrap width="79">No enrolment key</th>
</tr>
<tr>
<th nowrap>Guest access</th>
<td nowrap><p>Students need key</p>
<p>Guests get in free</p></td>
<td nowrap><p>Students get in free</p>
<p>Guests get in free</p></td>
</tr>
<tr>
<th nowrap>No guest access</th>
<td nowrap><p>Students need key</p>
<p>Guests need key</p></td>
<td nowrap><p>Students get in free</p>
<p>No guests allowed</p></td>
</tr>
</table>
+9 -28
View File
@@ -1,40 +1,21 @@
<P ALIGN=CENTER><B>Guest Access</B></P>
<P>You have the choice of allowing "guests" into your course
<P>You have the choice of allowing "guests" into your course.
<P>People can log in as guests using the "Login as a guest" button
on the login screen.
<P>Guests have "read-only" access - meaning they can't leave
<P>Guests ALWAYS have "read-only" access - meaning they can't leave
any posts or otherwise mess up the course for real students.
<P>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.
<P>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.
<P>This diagram might help make the behaviour clear:
<table border="1" align="center" cellpadding="5">
<tr>
<th nowrap width="8">&nbsp;</th>
<th nowrap width="84">Enrolment key</th>
<th nowrap width="79">No enrolment key</th>
</tr>
<tr>
<th nowrap>Guest access</th>
<td nowrap><p>Students need key</p>
<p>Guests get in free</p></td>
<td nowrap><p>Students get in free</p>
<p>Guests get in free</p></td>
</tr>
<tr>
<th nowrap>No guest access</th>
<td nowrap><p>Students need key</p>
<p>Guests need key</p></td>
<td nowrap><p>Students get in free</p>
<p>No guests allowed</p></td>
</tr>
</table>
<P>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.
+5 -3
View File
@@ -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";
+17 -8
View File
@@ -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");
+8 -4
View File
@@ -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;