force user to logout

force user to logout

by Helaine Ferreira -
Number of replies: 3

Hi guys.

How can I force a user to logout when he makes a test and his grade is not >=7 ?

The idea is: when the user got a bad grade, the user is forced to logout and loses the access to the system. He will only be able to access again after making a payment.


Is it possible?

Average of ratings: -
In reply to Helaine Ferreira

Re: force user to logout

by Davo Smith -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

This would be possible, but you'd need someone to write a custom authentication plugin to do that  (or possibly some other sort of plugin, but authentication would be the best match).


Average of ratings: Useful (1)
In reply to Davo Smith

Re: force user to logout

by Helaine Ferreira -

Hey, Davo.
Thank you for your support. 


Do you have any idea of any plugin that allows me to do that? I have programmers, the develop in php. Is it easy to do that?

In reply to Helaine Ferreira

Re: force user to logout

by Davo Smith -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

I am not aware of any such plugin existing, it sounds pretty specific, but there might be something in the plugins database.

If I was tackling this, I'd probably look to create an authentication plugin, based on whatever form of authentication you use already, but adding in the check for a user having failed the test and then denying them access until they paid (whether that was on automatic online transaction, or a manual re-enabling process).

I would also include an event handler, that would catch the 'quiz submitted' event, check to see if it the quiz matched (one of) the configured quiz(es), then call user_logout if they did not succeed (might need a bit of care, so as to not break any other event handlers, if the user suddenly stopped being logged in).

If you've got PHP developers on hand, they should be able to put something like that together for you.