Not get user response from input form

Not get user response from input form

by ensiferum ka -
Number of replies: 6
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?

Attachment 1.png
Attachment 2.png
Average of ratings: -
In reply to ensiferum ka

Re: Not get user response from input form

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 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.)

In reply to Tim Hunt

Re: Not get user response from input form

by ensiferum ka -

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

In reply to ensiferum ka

Re: Not get user response from input form

by Tim Hunt -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin 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.

In reply to Tim Hunt

Re: Not get user response from input form

by ensiferum ka -

Thank you for reply, I will try it.

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

In reply to ensiferum ka

Re: Not get user response from input form

by Tim Hunt -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin 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


In reply to Tim Hunt

Re: Not get user response from input form

by ensiferum ka -
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?