Simple question about new question type

Simple question about new question type

by Izac Gaeng -
Number of replies: 1

I'm a beginner, and I want create my own question type. I read some documentation about question engine, but I have a question.

I want to create my button in question. In renderer.php I wrote: $result .= html_writer::empty_tag('input', array('name'=>'btn', 'type' => 'submit', 'value' => 'Click me'));

Now I want bind this button and php script, where I can analyze the data entered by student (before pressing button), then remember the result and after reloading page, depending on calculated result to build a new body of  question.

Any ideas?

 

 

Average of ratings: -
In reply to Izac Gaeng

Re: Simple question about new question type

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

You should not think about using your own script for this. Questions need to be properly integrated into the question engine. When the student submits a page of a quiz (or another activity using questions) then all questions on the page need to be processed. The question engine handles this, first be calling the appropriate qbehaviour class to work out what kind of sumbission this was. the qbahviour then calls the qtype to do the appropriate type of processing (for example save the responses, validate the responses, grade the responses, etc.)

I suggest you look at some existing question types to get a feel for how this all works.