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


PHP Question::getAnswersCount方法代码示例

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


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

 public function __construct()
 {
     $user_data = User::getUserData(['username', 'first_name', 'last_name', 'user_id', 'email', 'profile_pic'])[0];
     $this->data['title'] = 'Questions - 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']);
     require_once 'include/header.php';
     $questions = Question::getPublicQuestions();
     foreach ($questions as $key => $value) {
         $questions[$key]['up_count'] = Question::getVoteUpCount($value['q_id']);
         $questions[$key]['down_count'] = Question::getVoteDownCount($value['q_id']);
         $questions[$key]['level'] = Question::getDifficultyLevel($value['q_id']);
         $questions[$key]['user_data'] = User::getPublicUserData($value['user_id'], ['profile_pic', 'first_name', 'last_name'])[0];
         $questions[$key]['answers'] = Question::getAnswersCount($value['q_id']);
         $questions[$key]['pic'] = User::getProfilePic($questions[$key]['user_data']['profile_pic']);
         $vote = Question::getVote($value['q_id']);
         if ($vote == 1) {
             $questions[$key]['my_data']['vote_up_class'] = 'vote-up-active';
         } else {
             if ($vote == 0) {
                 $questions[$key]['my_data']['vote_down_class'] = 'vote-down-active';
             }
         }
     }
     $this->data['questions'] = $questions;
 }
开发者ID:ncube,项目名称:edu,代码行数:30,代码来源:QuestionsListModel.php

示例3: addQuestion

 public final function addQuestion(Question $question, $level)
 {
     if ($level < 0 || $level >= $this->levels_count) {
         throw new Exception('Invalid level number');
     }
     if (!$this->are_multiple_questions && count($this->questions[$level]) != 0) {
         throw new Exception('There is already a question for this level.');
     }
     if ($question->getAnswersCount() != $this->answers_by_level[$level]) {
         throw new Exception('The question contains a wrong number of answers');
     }
     if (!$question->isGoodAnswerSet()) {
         throw new Exception("The question doesn't have any good answer.");
     }
     $this->questions[$level][] = $question;
 }
开发者ID:etbh,项目名称:g2l2quizmanager,代码行数:16,代码来源:Quiz.php

示例4: _index

 public function _index()
 {
     new Protect();
     // Add Token Check
     $notif = Notif::getUnread();
     usort($notif, function ($b, $a) {
         return $a['time'] - $b['time'];
     });
     foreach ($notif as $key => $value) {
         $notif[$key]['profile_pic'] = User::getProfilePic($value['profile_pic']);
         $notif[$key]['time'] = date("d M h:i A", $value['time']);
         $notif[$key]['first_name'] = ucwords($value['first_name']);
         $notif[$key]['last_name'] = ucwords($value['last_name']);
         switch ($value['type']) {
             case 'F':
                 $msg = 'is following you';
                 $link = '/profile/' . $value['username'];
                 break;
             case 'RC':
                 $msg = 'wants to add you as Classmate';
                 $link = '/requests/';
                 break;
             case 'RT':
                 $msg = 'wants to add you as Teacher';
                 $link = '/requests/';
                 break;
             case 'RS':
                 $msg = 'wants to add you as Student';
                 $link = '/requests/';
                 break;
             case 'RF':
                 $msg = 'wants to add you as Friend';
                 $link = '/requests/';
                 break;
             case 'RP':
                 $msg = 'wants to add you as Parent or Guardian';
                 $link = '/requests/';
                 break;
             default:
                 $msg = '';
                 $link = '#';
                 break;
         }
         $notif[$key]['msg'] = $msg;
         $notif[$key]['link'] = $link;
     }
     $data['notif'] = $notif;
     $data['notif_count'] = Notif::getUnreadCount();
     // Messages
     $notifMsg = Notif::getUnreadMsg();
     foreach ($notifMsg as $key => $value) {
         $notifMsg[$key]['profile_pic'] = User::getProfilePic($value['profile_pic']);
         $notifMsg[$key]['first_name'] = ucwords($value['first_name']);
         $notifMsg[$key]['last_name'] = ucwords($value['last_name']);
         $notifMsg[$key]['time'] = date("d M h:i A", $value['time']);
     }
     usort($notifMsg, function ($b, $a) {
         return $a['time'] - $b['time'];
     });
     $data['notif_msg'] = $notifMsg;
     $data['notif_msg_count'] = Notif::getUnreadMsgCount();
     // User Data
     $data['user'] = User::getUserData(['first_name', 'last_name', 'profile_pic'])[0];
     $data['user']['profile_pic'] = User::getProfilePic($data['user']['profile_pic']);
     // Questions
     $questions = Question::getPublicQuestions();
     foreach ($questions as $key => $value) {
         $questions[$key]['up_count'] = Question::getVoteUpCount($value['q_id']);
         $questions[$key]['down_count'] = Question::getVoteDownCount($value['q_id']);
         $questions[$key]['level'] = Question::getDifficultyLevel($value['q_id']);
         $questions[$key]['user_data'] = User::getPublicUserData($value['user_id'], ['profile_pic', 'first_name', 'last_name'])[0];
         $questions[$key]['answers'] = Question::getAnswersCount($value['q_id']);
         $questions[$key]['pic'] = User::getProfilePic($questions[$key]['user_data']['profile_pic']);
         $vote = Question::getVote($value['q_id']);
         if ($vote == 1) {
             $questions[$key]['my_data']['vote_up_class'] = 'vote-up-active';
         } else {
             if ($vote == 0) {
                 $questions[$key]['my_data']['vote_down_class'] = 'vote-down-active';
             }
         }
     }
     $data['questions'] = $questions;
     return $data;
 }
开发者ID:ncube,项目名称:edu,代码行数:85,代码来源:data.php


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