本文整理汇总了PHP中Question::add方法的典型用法代码示例。如果您正苦于以下问题:PHP Question::add方法的具体用法?PHP Question::add怎么用?PHP Question::add使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Question
的用法示例。
在下文中一共展示了Question::add方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: switch
case 'setmod':
$response = Group::setModerator($_POST['gid'], $_POST['uid'], $_POST['mod']);
break;
}
break;
case 'question':
switch ($action) {
case 'add':
$_POST['question'] = array_key_exists('question', $_POST) ? $_POST['question'] : '';
$_POST['correct'] = array_key_exists('correct', $_POST) ? $_POST['correct'] : null;
$_POST['answer-explanation'] = array_key_exists('answer-explanation', $_POST) ? $_POST['answer-explanation'] : '';
$alternatives = array();
for ($i = 0; $i < 4; $i++) {
$alternatives[] = $_POST['alt-' . $i];
}
$response = Question::add($_POST['question'], $alternatives, $_POST['correct'], $_POST['answer-explanation'], $_POST['gid']);
break;
case 'get':
$response = Question::get($params[0], $params[1]);
break;
case 'my':
$params[0] = count($params) >= 1 ? $params[0] : null;
$response = Question::getMine($params[0]);
break;
case 'answer':
$_POST['qid'] = array_key_exists('qid', $_POST) ? $_POST['qid'] : '';
$_POST['aid'] = array_key_exists('aid', $_POST) ? $_POST['aid'] : '';
$response = Question::answer($_POST['qid'], $_POST['aid']);
break;
}
break;
示例2: Question
<?php
require_once "Question.php";
require_once "db.php";
@Database::connect();
if (!Database::$link) {
Database::error();
}
if (!isset($_POST["text"]) || !isset($_POST["trueAnswer"]) || !isset($_POST["falseAnswer1"]) || !isset($_POST["falseAnswer2"])) {
die;
}
$text = $_POST["text"];
$trueAnswer = $_POST["trueAnswer"];
$falseAnswer1 = $_POST["falseAnswer1"];
$falseAnswer2 = $_POST["falseAnswer2"];
$question = new Question($text, $trueAnswer, $falseAnswer1, $falseAnswer2);
$question->add();
header("Location: ../front-end/moviesChallenge.html");
示例3: init
function init()
{
$question = new Question();
$func = array_shift($this->param);
if (is_numeric($func)) {
$this->id = $func;
} else {
if ($func != '') {
$_SERVER['REQUEST_METHOD'] = 'POST';
$course_id = array_shift($this->param);
Security::checkEditor($course_id);
switch ($func) {
case 'save':
$data['course_id'] = $course_id;
$data['type_id'] = $_POST['type_id'];
$data['data'] = $_POST['data'];
$data['count'] = $_POST['count'];
$data['answer'] = $_POST['answer'];
$id = $_POST['id'];
try {
$question->update($id, $data);
} catch (Exception $e) {
}
header('Location: /admin_questions/' . $data['course_id']);
exit;
break;
case 'delete':
try {
$question_id = array_shift($this->param);
$question->delete($question_id);
echo "ok";
} catch (Exception $e) {
echo $e;
}
header('Location: /admin_questions/' . $course_id);
exit;
break;
case 'find':
try {
$data = array('course_id' => $course_id, 'type_id' => 0, 'data' => '', 'answer' => '');
$q_id = $question->add($data);
$data['id'] = $q_id;
echo json_encode($data);
} catch (Exception $e) {
echo $e;
}
exit;
break;
case 'load':
try {
$question_id = array_shift($this->param);
$data = $question->get(array('course_id' => $course_id, 'id' => $question_id));
echo json_encode($data);
} catch (Exception $e) {
echo $e;
}
exit;
break;
default:
}
} else {
header('Location: /404');
exit;
}
}
}