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


PHP Question::add方法代码示例

本文整理汇总了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;
开发者ID:Granbusk,项目名称:Quiz-api,代码行数:31,代码来源:index.php

示例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");
开发者ID:DarthDonald,项目名称:DarkMoon,代码行数:18,代码来源:addQuestionMovies.php

示例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;
         }
     }
 }
开发者ID:jedaika,项目名称:Trainings,代码行数:66,代码来源:admin_questions.php


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