General developer forum

Not get user response from input form

 
Picture of ensiferum ka
Not get user response from input form
 
Hello! I'm creating a new question type (modifying gapselect question). I have some input forms in my question renderer (see screenshot below). In get_expected_data() I have:
        $vars = array();
        foreach ($this->places as $place => $notused) {
$vars[$this->field($place)] = PARAM_TEXT;
        }
        return $vars;

But it takes only numbers. Screenshot 2 - letters was entered.

Please, tell me what's wrong?



 
Average of ratings: -
Tim at Lone Pine Koala Sanctuary
Re: Not get user response from input form
Core developersDocumentation writersParticularly helpful MoodlersPlugin developers

A good way to start debugging this to watch the output of a query like https://docs.moodle.org/dev/Overview_of_the_Moodle_question_engine#Detailed_data_about_an_attempt while interacting with the question. (That query is for questions in a quiz attempt, but it should be a small change to make it work for previews.)

 
Average of ratings: -
Picture of ensiferum ka
Re: Not get user response from input form
 

Tim, I'm sorry, but I don't understand how I can watch the output of any query

 
Average of ratings: -
Tim at Lone Pine Koala Sanctuary
Re: Not get user response from input form
Core developersDocumentation writersParticularly helpful MoodlersPlugin developers

Connect to the database on your development site, using whatever database tool you like best.

Keep running the query and look at the results.

 
Average of ratings: -
Picture of ensiferum ka
Re: Not get user response from input form
 

Thank you for reply, I will try it.

May there is the problem with 'id'/'name' attributes of html input?

 
Average of ratings: -
Tim at Lone Pine Koala Sanctuary
Re: Not get user response from input form
Core developersDocumentation writersParticularly helpful MoodlersPlugin developers

Well, obviously get_expected_response has to use names that match the names on your <input name="..."> (allowing for the unique prefix added by the question system). So the other useful bit of debugging is your web brower developer tools, to see exactly what is being submitted in each POST reqest.

Also, I have been assuming that you have already read https://docs.moodle.org/dev/Overview_of_the_Moodle_question_engine and https://docs.moodle.org/dev/Question_types. If not, you should smile


 
Average of ratings: -
Picture of ensiferum ka
Re: Not get user response from input form
 
SELECT
    quiza.userid,
    quiza.quiz,
    quiza.id AS quizattemptid,
    quiza.attempt,
    quiza.sumgrades,
    qu.preferredbehaviour,
    qa.slot,
    qa.behaviour,
    qa.questionid,
    qa.variant,
    qa.maxmark,
    qa.minfraction,
    qa.flagged,
    qas.sequencenumber,
    qas.state,
    qas.fraction,
    timestamptz 'epoch' + qas.timecreated * INTERVAL '1 second',  // OR FROM_UNIXTIME(qas.timecreated) IF you are ON MySQL.
    qas.userid,
    qasd.name,
    qasd.value,
    qa.questionsummary,
    qa.rightanswer,
    qa.responsesummary
FROM mdl_quiz_attempts quiza
JOIN mdl_question_usages qu ON qu.id = quiza.uniqueid
JOIN mdl_question_attempts qa ON qa.questionusageid = qu.id
JOIN mdl_question_attempt_steps qas ON qas.questionattemptid = qa.id
LEFT JOIN mdl_question_attempt_step_data qasd ON qasd.attemptstepid = qas.id
WHERE quiza.id = 675767
ORDER BY quiza.userid, quiza.attempt, qa.slot, qas.sequencenumber, qasd.name

Am I understanding right, 

WHERE quiza.id =

should be my own?

If yes, how to know which is?

 
Average of ratings: -