Databases: Quiz module password?

Databases: Quiz module password?

by Zoran Igic -
Number of replies: 6
Where to find this password?
I need it becouse I wish to implement SMS payment to my quizes: The general idea is to generate and write password in quiz module field, then to send it back via SMS to the user.

Thanks!
Average of ratings: -
In reply to Zoran Igic

Re: Databases: Quiz module password?

by Tim Hunt -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
It is in the 'password' column of the 'mdl_quiz' table. I'm sorry we chose to hide it in such an obscure location wink

You will note it is the same password for all students, which may get in the way of your plans. You could hack the code so that instead it stores a per-user password using set_user_preference(), and the checks against that in the quiz code.

However, if you are doing that sort of thing, an alternative would be.

1. Change the student role so students do not pave permission to attempt a quiz.

2. Create a new role called something like 'Paid for quiz' which allows people to attempt quizzes.

3. Make the payment code assign the 'Paid for quiz' role in the context of the quiz before SMSing the student.

Then, after the student has received their SMS, they can just go straight into the quiz.
Average of ratings: Useful (1)
In reply to Tim Hunt

Re: Databases: Quiz module password?

by Zoran Igic -
Nice idea, evil

But then, student must send me some sort of ID (user name) with SMS request + "name of quiz" in order to be able to find him in database table and change role for him. Is it possible to change role only for specific quiz?
And another thing, in which point I should change the role back to "student", is it when student click on "try to solve quiz", and where is that place in code?

Thanks!


In reply to Zoran Igic

Re: Databases: Quiz module password?

by Tim Hunt -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
I fear you may need to read and understand How_permissions_are_calculated wink

A user can have more than one role at a time, and each role assignment has a particular scope. For example, anyone who is logged in will have the role 'Authenticated user' everywhere throughout the site.

If that user is goes into a course where they are enrolled as a student, then then they will have both 'Authenticated user' from the system context, and 'Student' from the course context. The list of things they are then allowed to do is a combination of those two roles.

I am suggestion that you assign them a third role 'Paid for quiz' just in the context of a specific quiz. When they are looking at the quiz they will then have three roles, and their capabilities will be a combination of those three roles. Since Student does not let you do a quiz (once you have edited it) but 'Paid for quiz' does, the result is that the student can only attempt the quiz if they have paid.


Yes, for this to work, the SMS will need to identify the student and the quiz in some way. Can you see the number the SMS is sent from? If so then you could get the student to add their mobile number to their profile (perhaps using a custom user profile field). To identify the quiz, I suggest adding a short, unique identifier to the quiz name or info, and getting the student to include that in their SMS. You could also store that identifier in the idnumber field of the quiz in the database, so it is easy to look up the quiz given the identifier.
Average of ratings: Useful (1)
In reply to Tim Hunt

Re: Databases: Quiz module password?

by Zoran Igic -
I´m not sure that we understand each other smile

My php script will add role to student named PaydForQuiz when it receive confirmation SMS with student user name, that is OK.

But, i want to be able to remove role PaydForQuiz AFTER quiz attempt from student.
Any suggestion on that?
Thanks in advance!
In reply to Zoran Igic

Re: Databases: Quiz module password?

by Tim Hunt -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
Why not just set the quiz to only allow one attempt, and enforce it that way. Don't you want students to be able to go in and review what they did later?
In reply to Tim Hunt

Re: Databases: Quiz module password?

by Zoran Igic -
The whole idea is that students try to solve the quiz multiple times, because they will always pay for each attempt smile.
Of course, the quiz questions will not be the same in every attempt.
If I allow only one attempt will significantly reduce my income smile
The best thing would be that role is worth a certain time, such as 1-2 hours.