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


PHP Question::getAnswers方法代码示例

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


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

示例1: __construct

 public function __construct($url)
 {
     $user_data = User::getUserData(['username', 'first_name', 'last_name', 'user_id', 'email', 'profile_pic'])[0];
     $this->data['title'] = 'Question - NCube School';
     $this->data['first_name'] = ucwords($user_data['first_name']);
     $this->data['last_name'] = ucwords($user_data['last_name']);
     $this->data['token'] = Token::generate();
     $this->data['username'] = $user_data['username'];
     $this->data['side_active']['questions'] = ' active';
     $this->data['profile_pic'] = User::getProfilePic($user_data['profile_pic']);
     $this->data['question'] = Question::getPublicQuestion($url[0])[0];
     $this->data['q_user'] = User::getPublicUserData($this->data['question']['user_id'])[0];
     $this->data['q_user']['profile_pic'] = User::getProfilePic($this->data['q_user']['profile_pic']);
     $this->data['question']['up_count'] = Question::getVoteUpCount($this->data['question']['q_id']);
     $this->data['question']['down_count'] = Question::getVoteDownCount($this->data['question']['q_id']);
     $this->data['question']['level'] = Question::getDifficultyLevel($this->data['question']['q_id']);
     $this->data['question']['answers_count'] = Question::getAnswersCount($this->data['question']['q_id']);
     $answers = Question::getAnswers($this->data['question']['q_id']);
     foreach ($answers as $key => $value) {
         $answers[$key]['user'] = User::getPublicUserData($value['user_id'])[0];
         $answers[$key]['user']['profile_pic'] = User::getProfilePic($answers[$key]['user']['profile_pic']);
     }
     $this->data['answers'] = $answers;
     require_once 'include/header.php';
 }
开发者ID:ncube,项目名称:edu,代码行数:25,代码来源:QuestionsModel.php

示例2: translateQuestions

    public function translateQuestions($old_slide_id, $new_slide_id, $source_arr, $language)
    {
        $questions_array = array();
        $questions = array();
        $translator = new LanguageTranslator('AIzaSyBlwXdmxJZ__ZNScwe4zq5r3qh3ebXb26k');
        $questions_array = $this->dbQuery('SELECT *
			FROM questions INNER JOIN users on questions.user_id = users.id
			WHERE questions.based_on IS NULL AND questions.mark = "accepted" AND questions.item_id=' . $old_slide_id);
        if (count($questions_array)) {
            foreach ($questions_array as $row) {
                $question = new Question();
                $question->createFromID($row['0']);
                $lastId = $question->getLastRevision();
                $lastRevision = new Question();
                $lastRevision->createFromID($lastId);
                $questions[] = $lastRevision;
            }
        }
        if (count($questions)) {
            $source = $source_arr['id'];
            $target_arr = explode('-', $language);
            $target = $target_arr[0];
            foreach ($questions as $question) {
                $answers = array();
                $answers = $question->getAnswers();
                $q = $question->question;
                $question->question = $translator->translate($q, $target, $source);
                $question->item_id = $new_slide_id;
                $question->based_on = NULL;
                $question->user->id = $this->user->id;
                $question->id = $question->create();
                if (count($answers)) {
                    foreach ($answers as $answer) {
                        $q = $answer['answer'];
                        $answer['answer'] = $translator->translate($q, $target, $source);
                        $q = $answer['explanation'];
                        if ($q != '') {
                            $answer['explanation'] = $translator->translate($q, $target, $source);
                        }
                        $question->addAnswer($answer['answer'], $answer['explanation'], $answer['is_right']);
                    }
                }
            }
        }
    }
开发者ID:TBoonX,项目名称:SlideWiki,代码行数:45,代码来源:Slide.php

示例3: Question

 function test_getAnswers()
 {
     //Arrange
     $test_field = "What is their name?";
     $test_description = "What you want to call your character.";
     $test_question = new Question($test_field, $test_description);
     $test_question->save();
     $test_field = "Joe GetAll";
     $test_quest_id = $test_question->getId();
     $test_answer = new Answer($test_field, $test_quest_id);
     $test_answer->save();
     //Act
     $test_question->addAnswer($test_answer->getId());
     //Assert
     $result = $test_question->getAnswers($test_answer->getId());
     $this->assertEquals($test_answer, $result[0]);
 }
开发者ID:umamiMike,项目名称:promptr,代码行数:17,代码来源:QuestionTest.php


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