Site Policy displayed on every login

Site Policy displayed on every login

von Sean Young -
Anzahl Antworten: 4
Hi everyone. 


I am not new to Moodle but very new to the development thereof. I have a very basic understanding of code and how it works, and would really appreciate some real advice.

I have about 1000 users on my Moodle, of which I create each account for them. What I need to do, is make each user agree to the site policy, every time they log in. I have no need for guest users and I have already set up my site policy (Which does appear on first log in). I have also enabled forced user log in. 

I have tried editing the /moodle/user/policy.php but I don't know enough to make any headway.

I would really appreciate any assistance!

Sean

Mittelwert:  -
Als Antwort auf Sean Young

Re: Site Policy displayed on every login

von Richard Oelmann -
Nutzerbild von Core developers Nutzerbild von Particularly helpful Moodlers Nutzerbild von Plugin developers Nutzerbild von Testers

If you want the users to see something every time they log in, make it part of the logging in page instructions on

(your site)admin/settings.php?section=manageauths

This could even be a link to a pdf stored somewhere accessible - that depends on your policy of how obvious and 'in your face' you want to make it.

Just add one line to the instructions after that - something along the lines of 'By logging in you are agreeing that you have read, understand and will comply with the terms of the Site Policy'


Als Antwort auf Richard Oelmann

Re: Site Policy displayed on every login

von Sean Young -

Thank you for the advice.

Although it isn't exactly what I was after, this will suffice for now.

Appreciate the help!

Als Antwort auf Sean Young

Re: Site Policy displayed on every login

von Mark Johnson -
Nutzerbild von Core developers Nutzerbild von Particularly helpful Moodlers Nutzerbild von Peer reviewers Nutzerbild von Plugin developers
One way of doing this would be to have a handler for the user_loggedin event which sets the policyagreed field in the user's database record to 0.

Edit: This might not work exactly how you want, since require_login() (which is used all over the place) checks if the policy has been agreed, which depending on when user_loggedin is fired could mean that the user logs in, then navigates to a page, then sees the policy (maybe twice the first time they ever log in).  You'd have to test how it works to see if it does what you want.
Als Antwort auf Sean Young

Re: Site Policy displayed on every login

von chaitanya varanasi -

Not sure if you are still searching for a better way. You can do this by editing /user/policy.php. 

Change line 59 to-

if ($agree and confirm_sesskey()) {    // User has agreed.

    if (!isguestuser()) {              // Don't remember guests.

   //     $DB->set_field('user', 'policyagreed', 1, array('id' => $USER->id));

    }

    $USER->policyagreed = 1;

    unset($SESSION->wantsurl);

    redirect($return);

}

This would stop setting the policyagreed field to 1 every time the policy is agreed. The flip side is that there may be audit issues. If you need to show that the user has agreed to the site policy, you can only prove that to access the site, they would have to go through the site policy page but cannot show a record to prove the agreement. 

Cheers.