Moodle Plugins directory: DemoStudent block | Moodle.org

DemoStudent block
Students have a different view of your course than instructors do. This block provides a way to test the student experience beyond the existing Switch role to... link in the Settings block. Instructors in a course can use the DemoStudent block to create a personal "demostudent" account, and then switch between the demostudent user and their instructor role. The demostudent user can complete assignments and quizzes with persistent data to verify grading, and can be used to test restricted access using groups or groupings.
To test email features, the DemoStudent account clones the email address of the user who creates it. For this reason, if your site has TAs/Instructors who are also students in other courses, note that grade imports which match on email will break if any of the graded students have created DemoStudent accounts. The workaround is to match on another field during the grade import, or update the profile of the DemoStudent account to use a different email address.
We're having sporadic incidents of a teacher creating a DemoStudent, and at the same time as the creation/enrolment of the DemoStudent and them being given the role of demostudent, they are given a teacher role, and then ANOTHER DemoStudent (of the DemoStudent) is created/enrolled/given student role. This seems to also cause the teacher to be suspended from the course when the next sync with our registration database happens (likely due to the fact that the teacher DemoStudent and the teacher have the same email). Additionally, the DemoStudent teacher then shows up as being a database enrolled user and not a manual one. Therefore you can't alter the user in the course, the user needs to be completely removed from the site at the admin level. After doing this, the teacher gets reinstated from the database. Lots of strangeness. Any ideas?
kirk
Thank you for the DemoStudent plugin.
We now use Moodle 3.9
Can your plug-in be used there too?
I see that the last update is from October 2019.
Thank you in advance for your response.
Sincerely,
Kees Koopman
We have not tested the plugin with 3.9. We plan to upgrade to 3.10 this summer, so we will be looking at it again in the next 3-4 months. A preliminary test after upgrade to 3.10 seems to work fine. If you run into any problems with the plugin on 3.9, let us know.
Thanks,
Dom.
Needing to log in again when switching back to the instructor role is required, depending on the authentication settings of your site. The workaround we suggest to our instructors is to have two browsers open (or one browser using a regular as well as an incognito/private window), with one logged in as themselves, and one switched to the demostudent role. This also allows easier checking of effects as settings are changed.
Looks similar to what Kirk was experiencing last year (see comments above). Take a look in blocks/demostudent/locallib.php at the function create_demostudent_account(). That's where the email address for the newly created account is set, and you can modify it to something that will work for your system, or something meaningless. If you use something meaningless, like an @example.com address, you will unfortunately lose the ability to test email notifications. Having an email alias which maps to the same user (perhaps using capitalisation?) would be better. For existing demostudent accounts, you can find them in the database using the query "select id,username,email from mdl_user where firstname='DemoStudent';". How you want to replace these will depend on whether you can get aliases working. Hope that helps.