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


PHP Test::createFromItem方法代碼示例

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


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

示例1: test

 function test()
 {
     $item_id = $_GET['id'];
     $test = new Test();
     $test->createFromItem($item_id);
     $test->questions = $test->getAllQuestions();
     $this->set('test', $test);
     $this->set('page_title', 'SlideWiki - List of questions for ' . $test->title);
     $this->set('page_keywords', 'SlideWiki, questions');
 }
開發者ID:TBoonX,項目名稱:SlideWiki,代碼行數:10,代碼來源:StaticController.php

示例2: test

 function test()
 {
     $item_id = $_GET['id'];
     if (isset($_GET['show_answers'])) {
         $show_answers = $_GET['show_answers'];
     } else {
         $show_answers = 2;
     }
     $test = new Test();
     $test->createFromItem($item_id);
     $test->questions = $test->getAllQuestions();
     $content = '';
     $content .= '<h2>List of questions for ' . $test->title . ' course</h2>';
     $questions = $test->questions;
     if (count($questions)) {
         $content .= '<ol>';
         for ($i = 0; $i < count($questions); $i++) {
             $content .= '<li>' . $questions[$i]->question . '<br/>';
             if ($show_answers) {
                 foreach ($questions[$i]->answers as $answer) {
                     if ($show_answers == '2') {
                         if ($answer['is_right'] == 'yes') {
                             $content .= '&#9745;&nbsp;&nbsp;&nbsp;';
                         } else {
                             $content .= '&#9744;&nbsp;&nbsp;&nbsp;';
                         }
                     } else {
                         $content .= '&#9744;&nbsp;&nbsp;&nbsp;';
                     }
                     $content .= $answer['answer'] . '<br/>';
                 }
             }
             $content .= '</li>';
         }
         $content .= '</ol>';
     }
     $content = '<page style="font-family: freeserif"><br />' . $content . '</page>';
     $html2pdf = new HTML2PDF('P', 'A4', 'fr');
     //$html2pdf->pdf->SetDisplayMode('real');
     $html2pdf->writeHTML($content);
     $html2pdf->Output('utf8.pdf');
 }
開發者ID:TBoonX,項目名稱:SlideWiki,代碼行數:42,代碼來源:PdfController.php

示例3: scores

 function scores()
 {
     //authorize user
     $id = $_GET['id'];
     if ($this->_user['is_authorized']) {
         if (!($this->_user['id'] == $id)) {
             $this->set('authorized', false);
             die('You are not allowed to view this page!');
         } else {
             $this->set('authorized', true);
         }
     } else {
         $this->set('authorized', false);
         die('You are not allowed to view this page!');
     }
     $testsArray = array();
     $testsTable = array();
     $listsArray = array();
     $listsTable = array();
     $timestampRow = array();
     $user = new User();
     $user->createFromID($id);
     foreach ($user->getTests() as $testRow) {
         $test = new Test();
         $test->createFromItem($testRow['item_id']);
         $type = $test->type;
         $timestampRow = $test->getLast($id, $type);
         $test->getMaxForUser($id, $type);
         $testsArray['title'] = $test->title;
         $testsArray['max_score'] = $test->max_for_user * 100;
         $testsArray['timestamp'] = $timestampRow['timestamp'];
         $testsArray['count'] = $test->getCountForUser($id, $type);
         $testsArray['item_id'] = $testRow['item_id'];
         $testsTable[] = $testsArray;
     }
     foreach ($user->getLists() as $listRow) {
         $list = new QList();
         $list->createFromID($listRow['item_id']);
         $type = $list->type;
         $timestampRow = $list->getLast($id, $type);
         $maxForUser = $list->getMaxForUser($id, $type);
         $listsArray['title'] = $listRow['title'];
         $listsArray['max_score'] = $maxForUser * 100;
         $listsArray['timestamp'] = $timestampRow['timestamp'];
         $listsArray['count'] = $list->getCountForUser($id, $type);
         $listsArray['item_id'] = $listRow['item_id'];
         $listsTable[] = $listsArray;
     }
     $this->set("testsTable", $testsTable);
     $this->set("listsTable", $listsTable);
     $this->set('user_obj', $user);
 }
開發者ID:TBoonX,項目名稱:SlideWiki,代碼行數:52,代碼來源:UserController.php

示例4: test

 function test()
 {
     if (isset($_GET['id'])) {
         $id = $_GET['id'];
     } else {
         $id = 0;
     }
     if (isset($_GET['type'])) {
         $type = $_GET['type'];
     } else {
         $type = 'auto';
     }
     if ($type == 'manual' || $type == 'user') {
         $type = 'list';
     }
     $this->set('test_id', $id);
     $this->set('type', $type);
     if (isset($_GET['limit'])) {
         $limit = $_GET['limit'];
     } else {
         $limit = 0;
     }
     $this->set('limit', $limit);
     if (isset($_GET['mode'])) {
         $mode = $_GET['mode'];
     } else {
         $mode = 1;
     }
     $this->set('mode', $mode);
     $questions = array();
     $user_id = $this->getCurrentUserID();
     if (isset($_GET['type']) && $type == 'list') {
         $test = new QList();
         $test->createFromID($id, $limit, $mode);
         $questions = $test->questions;
         $test->getMaxForUser($user_id);
         $attempt = $test->evaluation($limit, $mode, $user_id);
         $this->set('test_title', $test->title);
     } else {
         $test = new Test();
         $test->createFromItem($id, $limit, $mode);
         $this->set('test_title', $test->title);
         $slug_title = $test->sluggify($test->title);
         $this->set('slug_title', $slug_title);
         //$this->set('deck_slides', $deck->slides);
         $attempt = $test->evaluation($limit, $mode, $user_id);
         $test->getMaxForUser($user_id);
         $questions = $test->getAllQuestions($mode);
     }
     $this->set('test', json_encode($test));
     $this->set('questions', $questions);
     $count = count($questions);
     $this->set('count', $count);
     $this->set('attempt', $attempt);
 }
開發者ID:TBoonX,項目名稱:SlideWiki,代碼行數:55,代碼來源:MainController.php

示例5: buildWithQuestions

 public function buildWithQuestions($keywords, $order)
 {
     $all_decks = array();
     $all_decks = $this->searchMatchAll($keywords, $order);
     $result = array();
     foreach ($all_decks as $deck) {
         $deck_obj = new Deck();
         $deck_obj->id = $deck['id'];
         $deck_obj->deck_id = $deck['deck_id'];
         $id = $deck_obj->getLastRevisionID();
         $test = new Test();
         $test->createFromItem($id);
         if ($test->quest_count > 0) {
             $test->id = $id;
             $result[] = $test;
         }
     }
     return $result;
 }
開發者ID:TBoonX,項目名稱:SlideWiki,代碼行數:19,代碼來源:DeckList.php


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