本文整理汇总了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');
}
示例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 .= '☑ ';
} else {
$content .= '☐ ';
}
} else {
$content .= '☐ ';
}
$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');
}
示例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);
}
示例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);
}
示例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;
}