本文整理汇总了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';
}
示例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']);
}
}
}
}
}
示例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]);
}