mirror of
https://github.com/moodle/moodle.git
synced 2025-01-19 06:18:28 +01:00
When logging in as a user, take on their "current group" setting too,
then afterwards return teacher to their old setting
This commit is contained in:
parent
7692b869ef
commit
6e51e14435
@ -18,6 +18,12 @@
|
||||
$USER = get_user_info_from_db("id", $USER->realuser);
|
||||
$USER->loggedin = true;
|
||||
$USER->site = $CFG->wwwroot;
|
||||
|
||||
if (isset($SESSION->oldcurrentgroup)) { // Restore previous "current group"
|
||||
$SESSION->currentgroup[$course->id] = $SESSION->oldcurrentgroup;
|
||||
unset($SESSION->oldcurrentgroup);
|
||||
}
|
||||
|
||||
redirect($_SERVER["HTTP_REFERER"]);
|
||||
exit;
|
||||
}
|
||||
@ -41,11 +47,16 @@
|
||||
$teacher_name = fullname($USER, true);
|
||||
$teacher_id = "$USER->id";
|
||||
|
||||
$USER = get_user_info_from_db("id", $user);
|
||||
$USER = get_user_info_from_db("id", $user); // Create the new USER object with all details
|
||||
$USER->loggedin = true;
|
||||
$USER->site = $CFG->wwwroot;
|
||||
$USER->realuser = $teacher_id;
|
||||
|
||||
if (isset($SESSION->currentgroup[$course->id])) { // Remember current setting for later
|
||||
$SESSION->oldcurrentgroup = $SESSION->currentgroup[$course->id];
|
||||
unset($SESSION->currentgroup[$course->id]);
|
||||
}
|
||||
|
||||
set_moodle_cookie($USER->username);
|
||||
$student_name = fullname($USER, true);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user