Skip to content

Commit

Permalink
fixed the isstudent function
Browse files Browse the repository at this point in the history
  • Loading branch information
gustav_delius committed Aug 30, 2004
1 parent b2794b6 commit 129af65
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions lib/moodlelib.php
Expand Up @@ -582,7 +582,7 @@ function iscreator ($userid=0) {
function isstudent($courseid, $userid=0) {
/// Is the user a student in this course?
/// If course is site, is the user a confirmed user on the site?
global $USER;
global $USER, $CFG;

if (empty($USER->id) and !$userid) {
return false;
Expand All @@ -595,12 +595,15 @@ function isstudent($courseid, $userid=0) {
if (isguest($userid)) {
return false;
}
// a site teacher can never be a site student
if (isteacher($courseid, $userid)) {
return false;
}
if ($CFG->allusersaresitestudents) {
return record_exists('user', 'id', $userid);
} else {
return (record_exists('user_students', 'userid', $userid)
or (record_exists('user_teachers', 'userid', $userid)
and !record_exists('user_teachers', 'userid', $userid, 'course', SITEID)));
or record_exists('user_teachers', 'userid', $userid));
}
}

Expand Down

0 comments on commit 129af65

Please sign in to comment.