Skip to content

Commit

Permalink
Made student view work also for admins.
Browse files Browse the repository at this point in the history
Also modified isstudent() function to take student view into account.
  • Loading branch information
gustav_delius committed Sep 25, 2005
1 parent 73cff34 commit 57bc53c
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions lib/moodlelib.php
Original file line number Diff line number Diff line change
Expand Up @@ -2037,15 +2037,12 @@ function isteacher($courseid=0, $userid=0, $includeadmin=true) {
if (empty($USER) or empty($USER->id)) { // not logged in so can't be a teacher
return false;
}
if (!empty($USER->studentview)) {
return false;
}
if (!empty($USER->teacher) and $courseid) { // look in session cache
if (!empty($USER->teacher[$courseid])) { // Explicitly a teacher, good
// normally return 'true', but override if 'studentview' on
if (!empty($USER->studentview)) {
return false;
}
else {
return true;
}
return true;
}
}
$userid = $USER->id; // we need to make further checks
Expand Down Expand Up @@ -2192,7 +2189,7 @@ function isstudent($courseid, $userid=0) {
}

if (!$userid) {
return !empty($USER->student[$courseid]);
return (!empty($USER->student[$courseid]) and empty($USER->studentview));
}

// $timenow = time(); // todo: add time check below
Expand Down

0 comments on commit 57bc53c

Please sign in to comment.