如何在phpfox中访问测验模块的所有答案?

时间:2016-09-03 07:44:25

标签: php phpfox

<div style="margin-top:10px;">
{foreach from=$aQuiz.results name=questions item=aQuestion} 
    <div class="clearfix quiz_result_item {if is_int($phpfox.iteration.questions/2)}row1{else}row2{/if}{if $phpfox.iteration.questions == 1} row_first{/if}{if $aQuestion.userAnswer == $aQuestion.correctAnswer} row_is_correct{else} row_is_incorrect{/if}">
        <div class="quiz_result_left">
            {$phpfox.iteration.questions}
        </div>
        <div class="quiz_result_right">
            <div class="txt-dark fs-lg-3 quiz_result_question">{$aQuestion.questionText}</div>

            <table><tr><th style="width:20%px;">Answer Choices</th><th>Correct</th> <th>Your Choice</th> <th>User Statistics</th></tr> </table>
            <div>
                <span class="txt-light">{phrase var='quiz.full_name_s_answer' full_name=$aQuestion.full_name}:</span>
                <span class="txt-dark fw-500">{$aQuestion.userAnswerText}</span>
            </div>
            <div>
                <span class="txt-light">{phrase var='quiz.correct_answer'}:</span>
                <span class="txt-dark fw-500">{$aQuestion.correctAnswerText}</span>
                <div class="table_left">{phrase var='quiz.answers'}:</div>


            </div>
        </div>
    </div>
{/foreach}  
</div>

此代码仅显示正确答案和userAnswer,但我想访问问题的所有答案我不知道如何访问所有答案。我们将不胜感激。

1 个答案:

答案 0 :(得分:0)

您在问题中引用的是测验模板。您需要找到$aQuiz的源代码,它通常位于块控制器中,或者位于常规控制器中。

在您的情况下,您很可能需要查看/PF.Base/module/quiz/include/component/controller/view.class.php

process()功能中,您需要从表phpfox_quiz_question中选择表示此选择中的quiz_id的问题。然后,您可以使用在->assign(...)的其他设置符链中调用的$this->template()来分配结果。