Опубликовано Itamar Tzadok

Moodle in English -> General developer forum -> phpunit test and $USER

от Itamar Tzadok -

The default user id for $USER in the phpunit test is 0. I need it to be a privileged user such as admin so as to test certain privileged actions. In the test I've set $USER->id = 2 which seems to work. Is there a better/recommended way for achieving the same effect? улыбаюсь 

I have a sort of experimental implementation but right now I don't have the time to finalize it. It works in the Dataform and may be populated to the course page in various ways including the Dataform autolink filter. An illustration of that (with the Dataform embedded resource) could be found at http://substantialmethods.com/subject/view.php?id=6&topic=1. The page should display an embedded random question from the list. I've added so far only a few of the available question methods. So many options and so little time to document them all. улыбаюсь

Another related setting is 'Auto-login guest' in  Site administration
    / ► Users
    / ► Permissions
    / ► User policies

It defaults to No (unticked). If you enable it visitors will be automatically logged in as guests.

You should be able to control what different roles see on the frontpage and hide from guests everything but a link to the designated course.

Alternately you could hack the frontpage to redirect guests to the designated url. You might even be able to do that in the theme so as not to hack the core code.

There is also the My Moodle page which could serve registered users and you can force it after login. You should be able to design it to look like an internal frontpage and free the "real" frontpage for guests use.

hth улыбаюсь