From 57bc53c652b5b9e9f7b1b1bcf733aca65f08bddf Mon Sep 17 00:00:00 2001 From: gustav_delius Date: Sun, 25 Sep 2005 17:30:51 +0000 Subject: [PATCH] Made student view work also for admins. Also modified isstudent() function to take student view into account. --- lib/moodlelib.php | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/lib/moodlelib.php b/lib/moodlelib.php index 0b00c33db72..f6a1d701e18 100644 --- a/lib/moodlelib.php +++ b/lib/moodlelib.php @@ -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 @@ -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