當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Test::findFirst方法代碼示例

本文整理匯總了PHP中Test::findFirst方法的典型用法代碼示例。如果您正苦於以下問題:PHP Test::findFirst方法的具體用法?PHP Test::findFirst怎麽用?PHP Test::findFirst使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Test的用法示例。


在下文中一共展示了Test::findFirst方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: viewAction

 public function viewAction($index)
 {
     $this->response->setHeader("Content-Type", "text/html; charset=utf-8");
     $test = Test::findFirst(array("t_id=:t_id:", "bind" => array("t_id" => $index)));
     $students = $test->getStudent();
     $done = 0;
     foreach ($students as $student) {
         $done += $student->status;
     }
     $sum = count($students);
     $this->view->setVar("notdone", $sum - $done);
     $this->view->setVar("sum", $sum);
     $this->view->setVar("test_id", $index);
     $this->view->setRenderLevel(\Phalcon\Mvc\View::LEVEL_ACTION_VIEW);
 }
開發者ID:sify21,項目名稱:Question,代碼行數:15,代碼來源:IndexController.php

示例2: surveyAction

 public function surveyAction()
 {
     $this->assets->collection("header")->addJs("lib/stickUp.min.js");
     // $this->view->setRenderLevel(\Phalcon\Mvc\View::LEVEL_AFTER_TEMPLATE);
     if ($this->request->isGet()) {
         $isfirst = $this->request->get("isfirst");
         if ($isfirst == 1) {
             $this->session->set("p_start", strtotime(date("Y-m-d H:i:s")));
             $test_id = $this->session->get("test_id");
             $test = Test::findFirst(array("t_id=:t_id:", "bind" => array("t_id" => $test_id)));
             $parts = array();
             foreach ($test->Part as $index => $part) {
                 $parts[$index] = $part->p_id;
             }
             $part_num = $this->session->get("exam_num");
             $this->session->set("parts", $parts);
             $answer_num = $this->session->get("answer_num");
             if ($answer_num != 0 && $answer_num < $part_num) {
                 $result = $this->nextpart(-1, $this->session->get("answer_num"));
             } else {
                 if ($answer_num == 0) {
                     $result = new SurveyResult();
                     $tnext = $part_num == 1 ? -1 : 1;
                     $cacheKey = $test->Part[0]->p_id . ".txt";
                     $result->description = $test->Part[0]->description;
                     $result->nextpart = $this->getquestion($test->Part[0], $cacheKey);
                     $result->resultinfo = 1;
                     $result->cur = 0;
                     $this->session->set("cur", 0);
                     $this->session->set("next", $tnext);
                     $result->next = $tnext;
                 } else {
                     $this->response->redirect("student/index");
                 }
             }
         } else {
             if ($isfirst == 2) {
                 $result = $this->nextpart($this->session->get("cur"), $this->session->get("next"));
             } else {
                 $this->response->redirect("student/index");
             }
         }
         $this->view->setVar("testinfo", $result);
     } else {
         $this->response->redirect("student/index");
     }
 }
開發者ID:sify21,項目名稱:Question,代碼行數:47,代碼來源:StudentController.php


注:本文中的Test::findFirst方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。