当前位置: 首页>>代码示例>>PHP>>正文


PHP Answer::selectAnswerByAutoId方法代码示例

本文整理汇总了PHP中Answer::selectAnswerByAutoId方法的典型用法代码示例。如果您正苦于以下问题:PHP Answer::selectAnswerByAutoId方法的具体用法?PHP Answer::selectAnswerByAutoId怎么用?PHP Answer::selectAnswerByAutoId使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Answer的用法示例。


在下文中一共展示了Answer::selectAnswerByAutoId方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: showQuestion

    /**
     * Shows a question
     *
     * @param int    $questionId question id
     * @param bool   $only_questions if true only show the questions, no exercise title
     * @param bool   $origin  i.e = learnpath
     * @param string $current_item current item from the list of questions
     * @param bool   $show_title
     * @param bool   $freeze
     * @param array  $user_choice
     * @param bool   $show_comment
     * @param bool   $exercise_feedback
     * @param bool   $show_answers
     * */
    public static function showQuestion($questionId, $only_questions = false, $origin = false, $current_item = '', $show_title = true, $freeze = false, $user_choice = array(), $show_comment = false, $exercise_feedback = null, $show_answers = false)
    {
        $course_id = api_get_course_int_id();
        // Change false to true in the following line to enable answer hinting
        $debug_mark_answer = $show_answers;
        // Reads question information
        if (!($objQuestionTmp = Question::read($questionId))) {
            // Question not found
            return false;
        }
        if ($exercise_feedback != EXERCISE_FEEDBACK_TYPE_END) {
            $show_comment = false;
        }
        $answerType = $objQuestionTmp->selectType();
        $pictureName = $objQuestionTmp->selectPicture();
        $s = '';
        if ($answerType != HOT_SPOT && $answerType != HOT_SPOT_DELINEATION) {
            // Question is not a hotspot
            if (!$only_questions) {
                $questionDescription = $objQuestionTmp->selectDescription();
                if ($show_title) {
                    TestCategory::displayCategoryAndTitle($objQuestionTmp->id);
                    echo Display::div($current_item . '. ' . $objQuestionTmp->selectTitle(), array('class' => 'question_title'));
                }
                if (!empty($questionDescription)) {
                    echo Display::div($questionDescription, array('class' => 'question_description'));
                }
            }
            if (in_array($answerType, array(FREE_ANSWER, ORAL_EXPRESSION)) && $freeze) {
                return '';
            }
            echo '<div class="question_options row">';
            // construction of the Answer object (also gets all answers details)
            $objAnswerTmp = new Answer($questionId);
            $nbrAnswers = $objAnswerTmp->selectNbrAnswers();
            $quiz_question_options = Question::readQuestionOption($questionId, $course_id);
            // For "matching" type here, we need something a little bit special
            // because the match between the suggestions and the answers cannot be
            // done easily (suggestions and answers are in the same table), so we
            // have to go through answers first (elems with "correct" value to 0).
            $select_items = array();
            //This will contain the number of answers on the left side. We call them
            // suggestions here, for the sake of comprehensions, while the ones
            // on the right side are called answers
            $num_suggestions = 0;
            if (in_array($answerType, [MATCHING, DRAGGABLE, MATCHING_DRAGGABLE])) {
                if ($answerType == DRAGGABLE) {
                    $s .= '<div class="col-md-12 ui-widget ui-helper-clearfix">
                        <div class="clearfix">
                        <ul class="exercise-draggable-answer ui-helper-reset ui-helper-clearfix">';
                } else {
                    $s .= <<<HTML
                        <div id="drag{$questionId}_question" class="drag_question">
                            <table class="data_table">
HTML;
                }
                // Iterate through answers
                $x = 1;
                //mark letters for each answer
                $letter = 'A';
                $answer_matching = array();
                $cpt1 = array();
                for ($answerId = 1; $answerId <= $nbrAnswers; $answerId++) {
                    $answerCorrect = $objAnswerTmp->isCorrect($answerId);
                    $numAnswer = $objAnswerTmp->selectAutoId($answerId);
                    if ($answerCorrect == 0) {
                        // options (A, B, C, ...) that will be put into the list-box
                        // have the "correct" field set to 0 because they are answer
                        $cpt1[$x] = $letter;
                        $answer_matching[$x] = $objAnswerTmp->selectAnswerByAutoId($numAnswer);
                        $x++;
                        $letter++;
                    }
                }
                $i = 1;
                $select_items[0]['id'] = 0;
                $select_items[0]['letter'] = '--';
                $select_items[0]['answer'] = '';
                foreach ($answer_matching as $id => $value) {
                    $select_items[$i]['id'] = $value['id'];
                    $select_items[$i]['letter'] = $cpt1[$id];
                    $select_items[$i]['answer'] = $value['answer'];
                    $i++;
                }
                $user_choice_array_position = array();
                if (!empty($user_choice)) {
//.........这里部分代码省略.........
开发者ID:secuencia24,项目名称:chamilo-lms,代码行数:101,代码来源:exercise.lib.php

示例2: showQuestion

    /**
     * Shows a question
     *
     * @param int    $questionId question id
     * @param bool   $only_questions if true only show the questions, no exercise title
     * @param bool   $origin  i.e = learnpath
     * @param string $current_item current item from the list of questions
     * @param bool   $show_title
     * @param bool   $freeze
     * @param array  $user_choice
     * @param bool   $show_comment
     * @param bool   $exercise_feedback
     * @param bool   $show_answers
     * */
    public static function showQuestion($questionId, $only_questions = false, $origin = false, $current_item = '', $show_title = true, $freeze = false, $user_choice = array(), $show_comment = false, $exercise_feedback = null, $show_answers = false)
    {
        $course_id = api_get_course_int_id();
        // Change false to true in the following line to enable answer hinting
        $debug_mark_answer = $show_answers;
        // Reads question information
        if (!($objQuestionTmp = Question::read($questionId))) {
            // Question not found
            return false;
        }
        if ($exercise_feedback != EXERCISE_FEEDBACK_TYPE_END) {
            $show_comment = false;
        }
        $answerType = $objQuestionTmp->selectType();
        $pictureName = $objQuestionTmp->selectPicture();
        $s = '';
        if ($answerType != HOT_SPOT && $answerType != HOT_SPOT_DELINEATION) {
            // Question is not a hotspot
            if (!$only_questions) {
                $questionDescription = $objQuestionTmp->selectDescription();
                if ($show_title) {
                    TestCategory::displayCategoryAndTitle($objQuestionTmp->id);
                    echo Display::div($current_item . '. ' . $objQuestionTmp->selectTitle(), array('class' => 'question_title'));
                }
                if (!empty($questionDescription)) {
                    echo Display::div($questionDescription, array('class' => 'question_description'));
                }
            }
            if (in_array($answerType, array(FREE_ANSWER, ORAL_EXPRESSION)) && $freeze) {
                return '';
            }
            echo '<div class="question_options row">';
            // construction of the Answer object (also gets all answers details)
            $objAnswerTmp = new Answer($questionId);
            $nbrAnswers = $objAnswerTmp->selectNbrAnswers();
            $quiz_question_options = Question::readQuestionOption($questionId, $course_id);
            // For "matching" type here, we need something a little bit special
            // because the match between the suggestions and the answers cannot be
            // done easily (suggestions and answers are in the same table), so we
            // have to go through answers first (elems with "correct" value to 0).
            $select_items = array();
            //This will contain the number of answers on the left side. We call them
            // suggestions here, for the sake of comprehensions, while the ones
            // on the right side are called answers
            $num_suggestions = 0;
            if (in_array($answerType, [MATCHING, DRAGGABLE, MATCHING_DRAGGABLE])) {
                if ($answerType == DRAGGABLE) {
                    $s .= '<div class="col-md-12 ui-widget ui-helper-clearfix">
                        <div class="clearfix">
                        <ul class="exercise-draggable-answer ui-helper-reset ui-helper-clearfix">';
                } else {
                    $s .= '<div id="drag' . $questionId . '_question" class="drag_question">
                           <table class="data_table">';
                }
                // Iterate through answers
                $x = 1;
                //mark letters for each answer
                $letter = 'A';
                $answer_matching = array();
                $cpt1 = array();
                for ($answerId = 1; $answerId <= $nbrAnswers; $answerId++) {
                    $answerCorrect = $objAnswerTmp->isCorrect($answerId);
                    $numAnswer = $objAnswerTmp->selectAutoId($answerId);
                    if ($answerCorrect == 0) {
                        // options (A, B, C, ...) that will be put into the list-box
                        // have the "correct" field set to 0 because they are answer
                        $cpt1[$x] = $letter;
                        $answer_matching[$x] = $objAnswerTmp->selectAnswerByAutoId($numAnswer);
                        $x++;
                        $letter++;
                    }
                }
                $i = 1;
                $select_items[0]['id'] = 0;
                $select_items[0]['letter'] = '--';
                $select_items[0]['answer'] = '';
                foreach ($answer_matching as $id => $value) {
                    $select_items[$i]['id'] = $value['id_auto'];
                    $select_items[$i]['letter'] = $cpt1[$id];
                    $select_items[$i]['answer'] = $value['answer'];
                    $i++;
                }
                $user_choice_array_position = array();
                if (!empty($user_choice)) {
                    foreach ($user_choice as $item) {
                        $user_choice_array_position[$item['position']] = $item['answer'];
//.........这里部分代码省略.........
开发者ID:feroli1000,项目名称:chamilo-lms,代码行数:101,代码来源:exercise.lib.php

示例3: showQuestion

/**
 * Shows a question
 *
 * @param int    $questionId question id
 * @param bool   $only_questions if true only show the questions, no exercise title
 * @param bool   $origin  i.e = learnpath
 * @param string $current_item current item from the list of questions
 * @param bool   $show_title
 * @param bool   $freeze
 * @param array  $user_choice
 * @param bool   $show_comment
 * @param bool   $exercise_feedback
 * @param bool   $show_answers
 * */
function showQuestion($questionId, $only_questions = false, $origin = false, $current_item = '', $show_title = true, $freeze = false, $user_choice = array(), $show_comment = false, $exercise_feedback = null, $show_answers = false)
{
    // Text direction for the current language
    $is_ltr_text_direction = api_get_text_direction() != 'rtl';
    // Change false to true in the following line to enable answer hinting
    $debug_mark_answer = $show_answers;
    //api_is_allowed_to_edit() && false;
    // Reads question information
    if (!($objQuestionTmp = Question::read($questionId))) {
        // Question not found
        return false;
    }
    if ($exercise_feedback != EXERCISE_FEEDBACK_TYPE_END) {
        $show_comment = false;
    }
    $answerType = $objQuestionTmp->selectType();
    $pictureName = $objQuestionTmp->selectPicture();
    $s = '';
    if ($answerType != HOT_SPOT && $answerType != HOT_SPOT_DELINEATION) {
        // Question is not a hotspot
        if (!$only_questions) {
            $questionDescription = $objQuestionTmp->selectDescription();
            if ($show_title) {
                Testcategory::displayCategoryAndTitle($objQuestionTmp->id);
                echo Display::div($current_item . '. ' . $objQuestionTmp->selectTitle(), array('class' => 'question_title'));
            }
            if (!empty($questionDescription)) {
                echo Display::div($questionDescription, array('class' => 'question_description'));
            }
        }
        if (in_array($answerType, array(FREE_ANSWER, ORAL_EXPRESSION)) && $freeze) {
            return '';
        }
        echo '<div class="question_options">';
        // construction of the Answer object (also gets all answers details)
        $objAnswerTmp = new Answer($questionId);
        $nbrAnswers = $objAnswerTmp->selectNbrAnswers();
        $course_id = api_get_course_int_id();
        $quiz_question_options = Question::readQuestionOption($questionId, $course_id);
        // For "matching" type here, we need something a little bit special
        // because the match between the suggestions and the answers cannot be
        // done easily (suggestions and answers are in the same table), so we
        // have to go through answers first (elems with "correct" value to 0).
        $select_items = array();
        //This will contain the number of answers on the left side. We call them
        // suggestions here, for the sake of comprehensions, while the ones
        // on the right side are called answers
        $num_suggestions = 0;
        if ($answerType == MATCHING) {
            $s .= '<table class="data_table">';
            // Iterate through answers
            $x = 1;
            //mark letters for each answer
            $letter = 'A';
            $answer_matching = array();
            $cpt1 = array();
            for ($answerId = 1; $answerId <= $nbrAnswers; $answerId++) {
                $answerCorrect = $objAnswerTmp->isCorrect($answerId);
                $numAnswer = $objAnswerTmp->selectAutoId($answerId);
                $answer = $objAnswerTmp->selectAnswer($answerId);
                if ($answerCorrect == 0) {
                    // options (A, B, C, ...) that will be put into the list-box
                    // have the "correct" field set to 0 because they are answer
                    $cpt1[$x] = $letter;
                    $answer_matching[$x] = $objAnswerTmp->selectAnswerByAutoId($numAnswer);
                    $x++;
                    $letter++;
                }
            }
            $i = 1;
            $select_items[0]['id'] = 0;
            $select_items[0]['letter'] = '--';
            $select_items[0]['answer'] = '';
            foreach ($answer_matching as $id => $value) {
                $select_items[$i]['id'] = $value['id'];
                $select_items[$i]['letter'] = $cpt1[$id];
                $select_items[$i]['answer'] = $value['answer'];
                $i++;
            }
            $user_choice_array_position = array();
            if (!empty($user_choice)) {
                foreach ($user_choice as $item) {
                    $user_choice_array_position[$item['position']] = $item['answer'];
                }
            }
            $num_suggestions = $nbrAnswers - $x + 1;
//.........这里部分代码省略.........
开发者ID:annickvdp,项目名称:Chamilo1.9.10,代码行数:101,代码来源:exercise.lib.php


注:本文中的Answer::selectAnswerByAutoId方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。