Форма усов закончилась слишком рано в фактическом рендеринге - PullRequest
0 голосов
/ 26 сентября 2019

Форма усов слишком рано закончилась при фактическом рендеринге на сайте и вызывает проблемы с отправкой.

Я использую Moodle 3.5.2 и PHP 7.0 (с необходимыми расширениями) для запуска электронного обучениясайт, клиент хотел добавить личностный тест, поэтому я нашел плагин Анкеты, который может сделать это, а затем установить его.

Итак, я протестировал плагин, создав новую Анкету, которая может иметь обратную связь (ближайший к вамможно пройти тест на личность в Moodle).Однако, когда я нажал кнопку отправки, данные не передаются.Из-за проверки HTML очевидно, что форма закончилась слишком рано, и кнопки управления не считаются частью формы, и поэтому она не передает никаких данных (дух)

Вот усы, ответственные за все это

<div class="mod_questionnaire_completepage generalbox">
    {{#notifications}}{{{.}}}{{/notifications}}
    {{{respondentinfo}}}
    {{#title}}<h3 class="surveyTitle">{{.}}</h3>{{/title}}{{{printblank}}}
    {{#subtitle}}<h4 class="surveySubTitle">{{.}}</h4>{{/subtitle}}
    {{#addinfo}}<div class="addInfo">{{{.}}}</div>{{/addinfo}}
    {{#message}}<div class="message">{{{.}}}</div>{{/message}}
    <div class="generalbox">
        {{{formstart}}}
        {{#questions}}{{{.}}}{{/questions}}
        {{#pageinfo}}{{{.}}}{{/pageinfo}}
        <div class="notice" style="padding: 0.5em 0 0.5em 0.2em;">
            <div class="buttons">
                {{{controlbuttons}}}
            </div>
        </div>
        {{{formend}}}
    </div>
</div>

вот класс php для кнопок управления

$formdatareferer = !empty($formdata->referer) ? htmlspecialchars($formdata->referer) : '';
        $formdatarid = isset($formdata->rid) ? $formdata->rid : '0';
        $this->page->add_to_page('formstart', $this->renderer->complete_formstart($action, ['referer' => $formdatareferer,
            'a' => $this->id, 'sid' => $this->survey->id, 'rid' => $formdatarid, 'sec' => $formdata->sec, 'sesskey' => sesskey()]));
        if (isset($this->questions) && $numsections) { // Sanity check.
            $this->survey_render($formdata->sec, $msg, $formdata);
            $controlbuttons = [];
            if ($formdata->sec > 1) {
                $controlbuttons['prev'] = ['type' => 'submit', 'value' => '<< '.get_string('previouspage', 'questionnaire')];
            }
            if ($this->resume) {
                $controlbuttons['resume'] = ['type' => 'submit', 'value' => get_string('save', 'questionnaire')];
            }

            // Add a 'hidden' variable for the mod's 'view.php', and use a language variable for the submit button.

            if ($formdata->sec == $numsections) {
                $controlbuttons['submittype'] = ['type' => 'hidden', 'value' => 'Submit Survey'];
                $controlbuttons['submit'] = ['type' => 'submit', 'value' => get_string('submitsurvey', 'questionnaire')];
            } else {
                $controlbuttons['next'] = ['type' => 'submit', 'value' => get_string('nextpage', 'questionnaire').' >>'];
            }
            $this->page->add_to_page('controlbuttons', $this->renderer->complete_controlbuttons($controlbuttons));
        } else {
            $this->page->add_to_page('controlbuttons',
                $this->renderer->complete_controlbuttons(get_string('noneinuse', 'questionnaire')));
        }
        $this->page->add_to_page('formend', $this->renderer->complete_formend());

и вот фактический отрендеренный HTML

<div class="generalbox">
        <form id="phpesp_response" method="post" action="https://devgli.edplus.biz/mod/questionnaire/complete.php?id=200">
<input type="hidden" name="referer" value="">
<input type="hidden" name="a" value="2">
<input type="hidden" name="sid" value="2">
<input type="hidden" name="rid" value="">
<input type="hidden" name="sec" value="1">
<input type="hidden" name="sesskey" value="0pPB6dGUGQ">

        <!-- Begin fieldset generated from question_container template. -->
<fieldset id="qn-1" class="qn-container">

    <legend class="accesshide">Question #1</legend>
    <div class="qn-legend">
        <div class="qn-info">
            <h2 class="qn-number">1</h2>
        </div>
        <div class="accesshide">Response is required</div><img class="req" title="Response is required" alt="Response is required" src="https://devgli.edplus.biz/theme/image.php/remui/core/1569400984/req">
    </div>
    <div class="qn-content">
        <div class="qn-question ">

            <div class="no-overflow"><h4><strong>People tell me they’re at ease with me</strong>: they have a good sense of who I am, they feel they know me, they know what to expect when they see me, talk to me, deal with me.</h4><p><i><b>Orang merasa nyaman dengan saya:</b> mereka memiliki perasaan yang positif terhadap saya, mereka merasa mengetahui tentang saya, mereka mengetahui apa yang diharapkan dari saya, ketika berbicara dengan saya dan berurusan dengan saya</i><br></p></div>

        </div>
        <div class="qn-answer">
            <!-- Begin HTML generated from question_radio template. -->

<input id="auto-rb0001" value="1" name="q1" type="radio">
<label for="auto-rb0001">almost never</label>

<br>

<input id="auto-rb0002" value="2" name="q1" type="radio">
<label for="auto-rb0002">rarely</label>

<br>

<input id="auto-rb0003" value="3" name="q1" type="radio">
<label for="auto-rb0003">often</label>

<br>

<input id="auto-rb0004" value="4" name="q1" type="radio">
<label for="auto-rb0004">almost always</label>

<br>
<!-- End HTML generated from question_radio template. -->
        </div>
    </div>
</fieldset>

<!-- End fieldset generated from question_container template. --><!-- Begin fieldset generated from question_container template. -->
<fieldset id="qn-2" class="qn-container">

    <legend class="accesshide">Question #2</legend>
    <div class="qn-legend">
        <div class="qn-info">
            <h2 class="qn-number">2</h2>
        </div>
        <div class="accesshide">Response is required</div><img class="req" title="Response is required" alt="Response is required" src="https://devgli.edplus.biz/theme/image.php/remui/core/1569400984/req">
    </div>
    <div class="qn-content">
        <div class="qn-question ">

            <div class="no-overflow"><p></p><div><h4><span><b>Orang memandang saya sebagai komunikator yang logis dan jelas: </b>apa yang saya katakan masuk akal, dan orang lain memuji hal itu.</span></h4><p><i><strong>People see me as a logical and clear communicator</strong>: what I say makes sense, and people compliment me on it.</i></p></div><div></div><div><br>

</div><br><p></p></div>

        </div>
        <div class="qn-answer">
            <!-- Begin HTML generated from question_radio template. -->

<input id="auto-rb0005" value="6" name="q2" type="radio">
<label for="auto-rb0005">almost never</label>

<br>

<input id="auto-rb0006" value="7" name="q2" type="radio">
<label for="auto-rb0006">rarely</label>

<br>

<input id="auto-rb0007" value="8" name="q2" type="radio">
<label for="auto-rb0007">often</label>

<br>

<input id="auto-rb0008" value="9" name="q2" type="radio">
<label for="auto-rb0008">almost always</label>

<br>
<!-- End HTML generated from question_radio template. -->
        </div>
    </div>
</fieldset></form>

<!-- End fieldset generated from question_container template. --><!-- Begin fieldset generated from question_container template. -->
<fieldset id="qn-5" class="qn-container">

    <legend class="accesshide">Question #3</legend>
    <div class="qn-legend">
        <div class="qn-info">
            <h2 class="qn-number">3</h2>
        </div>
        <div class="accesshide">Response is required</div><img class="req" title="Response is required" alt="Response is required" src="https://devgli.edplus.biz/theme/image.php/remui/core/1569400984/req">
    </div>
    <div class="qn-content">
        <div class="qn-question ">

            <div class="no-overflow"><h4><b>I don’t focus on blaming others when things go wrong:</b> I focus on the learnings, and move on easily from disappointment, without attachment to the past.</h4><p><i><b>Saya tidak fokus menyalahkan orang lain ketika ada masalah: </b>Saya fokus pada pembelajaran, dan beralih dengan mudah dari kekecewaan, tanpa keterikatan pada masa lalu.</i><br></p></div>

        </div>
        <div class="qn-answer">
            <!-- Begin HTML generated from question_radio template. -->

<input id="auto-rb0009" value="15" name="q5" type="radio">
<label for="auto-rb0009">almost never</label>

<br>

<input id="auto-rb0010" value="16" name="q5" type="radio">
<label for="auto-rb0010">rarely</label>

<br>

<input id="auto-rb0011" value="17" name="q5" type="radio">
<label for="auto-rb0011">often</label>

<br>

<input id="auto-rb0012" value="18" name="q5" type="radio">
<label for="auto-rb0012">almost always</label>

<br>
<!-- End HTML generated from question_radio template. -->
        </div>
    </div>
</fieldset>

<!-- End fieldset generated from question_container template. --><!-- Begin fieldset generated from question_container template. -->
<fieldset id="qn-6" class="qn-container">

    <legend class="accesshide">Question #4</legend>
    <div class="qn-legend">
        <div class="qn-info">
            <h2 class="qn-number">4</h2>
        </div>
        <div class="accesshide">Response is required</div><img class="req" title="Response is required" alt="Response is required" src="https://devgli.edplus.biz/theme/image.php/remui/core/1569400984/req">
    </div>
    <div class="qn-content">
        <div class="qn-question ">

            <div class="no-overflow"><h4><b>People tell me I’m honest and open:</b> when I say something, people view it not just as true, but as the whole truth; they don’t think I’m holding back; they feel I’m giving them the whole picture.</h4><p><i><b>Orang-orang mengatakan kepada saya bahwa saya jujur ​​dan terbuka:</b> ketika saya mengatakan sesuatu, orang-orang melihatnya bukan hanya sebagai kebenaran, tetapi sebagai kebenaran yang absolut; mereka tidak berpikir saya menahan; mereka merasa saya memberi mereka penjelasan yang menyeluruh.</i><br></p></div>

        </div>
        <div class="qn-answer">
            <!-- Begin HTML generated from question_radio template. -->

<input id="auto-rb0013" value="19" name="q6" type="radio">
<label for="auto-rb0013">almost never</label>

<br>

<input id="auto-rb0014" value="20" name="q6" type="radio">
<label for="auto-rb0014">rarely</label>

<br>

<input id="auto-rb0015" value="21" name="q6" type="radio">
<label for="auto-rb0015">often</label>

<br>

<input id="auto-rb0016" value="22" name="q6" type="radio">
<label for="auto-rb0016">almost always</label>

<br>
<!-- End HTML generated from question_radio template. -->
        </div>
    </div>
</fieldset>

<!-- End fieldset generated from question_container template. --><!-- Begin fieldset generated from question_container template. -->
<fieldset id="qn-7" class="qn-container">

    <legend class="accesshide">Question #5</legend>
    <div class="qn-legend">
        <div class="qn-info">
            <h2 class="qn-number">5</h2>
        </div>
        <div class="accesshide">Response is required</div><img class="req" title="Response is required" alt="Response is required" src="https://devgli.edplus.biz/theme/image.php/remui/core/1569400984/req">
    </div>
    <div class="qn-content">
        <div class="qn-question ">

            <div class="no-overflow"><h4><b>I am not afraid to take emotional risks by being open about myself:</b> to acknowledge some failing about myself, or to engage in a conversation where I’m not an expert, and to admit my limitations.</h4><p><i><b>Saya tidak takut mengambil risiko emosional dengan bersikap terbuka tentang diri saya: </b>mengakui kegagalan dalam diri saya, atau terlibat dalam percakapan di mana saya bukan ahli, dan mengakui keterbatasan saya.</i><br></p></div>

        </div>
        <div class="qn-answer">
            <!-- Begin HTML generated from question_radio template. -->

<input id="auto-rb0017" value="23" name="q7" type="radio">
<label for="auto-rb0017">almost never</label>

<br>

<input id="auto-rb0018" value="24" name="q7" type="radio">
<label for="auto-rb0018">rarely</label>

<br>

<input id="auto-rb0019" value="25" name="q7" type="radio">
<label for="auto-rb0019">often</label>

<br>

<input id="auto-rb0020" value="26" name="q7" type="radio">
<label for="auto-rb0020">almost always</label>

<br>
<!-- End HTML generated from question_radio template. -->
        </div>
    </div>
</fieldset>

<!-- End fieldset generated from question_container template. --><!-- Begin fieldset generated from question_container template. -->
<fieldset id="qn-8" class="qn-container">

    <legend class="accesshide">Question #6</legend>
    <div class="qn-legend">
        <div class="qn-info">
            <h2 class="qn-number">6</h2>
        </div>
        <div class="accesshide">Response is required</div><img class="req" title="Response is required" alt="Response is required" src="https://devgli.edplus.biz/theme/image.php/remui/core/1569400984/req">
    </div>
    <div class="qn-content">
        <div class="qn-question ">

            <div class="no-overflow"><h4><b>I am consistent and predictable:</b> people know what to expect from me, and they get it. I am the same person at all times, and the same to all people.</h4><p><i><b>Saya konsisten dan dapat diprediksi:</b> orang tahu apa yang diharapkan dari saya, dan mereka mendapatkannya. Saya adalah orang yang sama setiap saat, dan sama untuk semua orang.</i><br></p></div>

        </div>
        <div class="qn-answer">
            <!-- Begin HTML generated from question_radio template. -->

<input id="auto-rb0021" value="27" name="q8" type="radio">
<label for="auto-rb0021">almost never</label>

<br>

<input id="auto-rb0022" value="28" name="q8" type="radio">
<label for="auto-rb0022">rarely</label>

<br>

<input id="auto-rb0023" value="29" name="q8" type="radio">
<label for="auto-rb0023">often</label>

<br>

<input id="auto-rb0024" value="30" name="q8" type="radio">
<label for="auto-rb0024">almost always</label>

<br>
<!-- End HTML generated from question_radio template. -->
        </div>
    </div>
</fieldset>

<!-- End fieldset generated from question_container template. -->

        <div class="notice" style="padding: 0.5em 0 0.5em 0.2em;">
            <div class="buttons">
                <input name="submittype" type="hidden" value="Submit Survey"><input name="submit" type="submit" value="Submit questionnaire">
            </div>
        </div>


    </div>

фактический результат должен быть внутри кнопокформа.Если вы ищете «/ form», он остановится прямо перед отображением div.qn-5.Как мне сделать так, чтобы он останавливался прямо в конце, даже с помощью кнопок внутри формы?

...