Where the data, which is sent by the "next" button is proccessed

Where the data, which is sent by the "next" button is proccessed

by Eran Levin -
Number of replies: 6

Hi there,

every time a user clicks the "next" button, it seems that the system floods the database with new info.

I'm interested in where in the code the mdl_question_attempt_step_data is being edited.

To be more specified, where the "answer" rows in that table are being determent.

I was able to add an uncheck button to a question, but I need to update the database, otherwise every-time user switches the question, his unset, won't have effect.


Thanks.

Average of ratings: -
In reply to Eran Levin

Re: Where the data, which is sent by the "next" button is proccessed

by Tim Hunt -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

If your really want to understand what is going on, you need to get to grips with https://docs.moodle.org/dev/Overview_of_the_Moodle_question_engine and https://docs.moodle.org/dev/Using_the_question_engine_from_module

How the quiz works is a carefully choreographed dance between the quiz, question engine, question behaviour and question type. Each of those parts has clear and separate areas of responsibility.

If you want to see an example of how this sort of thing can be implemented, look at how, for a Matching question, running under Interactive with multiple tries behaviour, implements the clearwrong feature. (Search the whole code for 'clearwrong' to find some places to start looking.)

In reply to Tim Hunt

Re: Where the data, which is sent by the "next" button is proccessed

by Eran Levin -

I'm looking for something, much more low level.

Because no option to uncheck an answer has ever made in moodle, there is no file that checks whether a user unchecked his form.

I would like to edit the file that does check whether he change his selection, to add the option that it will check whether the user unchecked, and if so to delete the row from the database, or nullify it.

In reply to Eran Levin

Re: Where the data, which is sent by the "next" button is proccessed

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 understood what you want to try to do, and my previous answer still applies: It is not one file. The behaviour is spilt between several different PHP classes, which each handle a different bit of the process. This is complex to understand at first, but once you do understand, it is much easier and safer to modify things.

In reply to Tim Hunt

Re: Where the data, which is sent by the "next" button is proccessed

by Eran Levin -

I understand it goes through processattemt.php to another file.

My question to where it goes if I press the "next" button.


The documents doesn't answer where process_all_action is defined.

In reply to Eran Levin

Re: Where the data, which is sent by the "next" button is proccessed

by Tim Hunt -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

A vital skill when working on the Moodle code is to be able to find where any given function is defined.  (If you always have to stop and ask, you won't get anything done.)

If you use and IDE like Eclipse or PHPStorm, then there is normally a short-cut for this. In Eclipse, it is CTRL + Click on the function name.

Programmers' text editors like VIM have similar functionality.

Alternatively, just search all the files in the Moodle code for the name.

Average of ratings: Useful (1)
In reply to Tim Hunt

Re: Where the data, which is sent by the "next" button is proccessed

by Eran Levin -

I am able to reach to:

$attemptobj->get_quiz()

and everything is fine.

but when I try:

$attemptobj->get_quiz()->get_context()

I get an error.

I need the context so this will work:

 question_engine_data_mapper::delete_steps($attemptobj->get_active_slots($thispage),$attemptobj->get_quiz()->get_context());


If you can help me, how do I reach the quiz context, I'll be very grateful.