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


PHP Question::getId方法代码示例

本文整理汇总了PHP中Question::getId方法的典型用法代码示例。如果您正苦于以下问题:PHP Question::getId方法的具体用法?PHP Question::getId怎么用?PHP Question::getId使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Question的用法示例。


在下文中一共展示了Question::getId方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: flush

 /**
  * 
  * @param Question $question
  * @return int id of the Question inserted in base. False if it didn't work.
  */
 public static function flush($question)
 {
     $questionId = $question->getId();
     $questionVar = $question->getQuestion();
     $theme = $question->getTheme()->getIdTheme();
     if ($questionId > 0) {
         $sql = 'UPDATE question SET ' . 'question = ?, ' . 'THEME_id_theme = ? ' . 'WHERE id_question = ?';
         $params = array('sii', &$questionVar, &$theme, &$questionId);
     } else {
         $sql = 'INSERT INTO question (question, THEME_id_theme) VALUES (?, ?)';
         $params = array('si', &$questionVar, &$theme);
     }
     $idInsert = BaseSingleton::insertOrEdit($sql, $params);
     if ($idInsert !== false && $questionId > 0) {
         $idInsert = $questionId;
     }
     return $idInsert;
 }
开发者ID:Eurymone,项目名称:Student-Exam-Report-System,代码行数:23,代码来源:QuestionDAL.php

示例2: updateQuestion

 /**
  * @return int
  * @param Question $q
  */
 public static function updateQuestion($q)
 {
     $db = DB::getConn();
     $stm = $db->prepare('update Question set title=:title, category=:cate, point=:point, explain=:explain where id=:id');
     $stm->bindParam(':title', $q->getTitle());
     $stm->bindParam(':cate', $q->getCategory());
     $stm->bindParam(':point', $q->getPoint());
     $stm->bindParam(':explain', $q->getExplain());
     $stm->bindParam(':id', $q->getId());
     $stm->execute();
     return QuestionCtrl::getLastID();
 }
开发者ID:rmit-s3443163-quan-do,项目名称:its,代码行数:16,代码来源:QuestionCtrl.php

示例3: array

$newQuestions = array();
$found = false;
// open questions file
$fileName = "questions.json";
$dataFile = fopen($fileName, "r+");
// if file existed before
if (filesize($fileName) > 0) {
    // read all file contents
    $fileContents = fread($dataFile, filesize($fileName));
    // create array of stdClass objects from contents
    $stdQuestions = json_decode($fileContents);
    // convert array elements into Question objects
    // also insert/overwrite with the submitted question
    foreach ($stdQuestions as $stdQuestion) {
        $question = Question::fromStdObj($stdQuestion);
        if ($question->getId() == $submittedQuestion->getId()) {
            array_push($newQuestions, $submittedQuestion);
            $found = true;
        } else {
            array_push($newQuestions, $question);
        }
    }
}
// insert submitted question if it has not been used to replace a previous question
if (!$found) {
    array_push($newQuestions, $submittedQuestion);
}
// close read-access file
fclose($dataFile);
// overwrite file with write access
// (ftruncate to clear the existing file lead to errors :-/)
开发者ID:timpauls,项目名称:cardboard-qr-questionform,代码行数:31,代码来源:process.php

示例4: foreach

    ?>
        <div class="accordion">
            <?php 
    foreach ($survey_questions as $question_id) {
        $question = new Question();
        $question->get_from_db($question_id);
        if ($question->getType() == 1) {
            ?>
                </div>
                <h3 class="no-float ac"><?php 
            print_r($question->getTitle());
            ?>
</h3>
                <div class="al">
                    <?php 
            $answers = get_survey_answers($question->getId());
            foreach ($answers as $answer_id) {
                $answer = new Answer();
                $answer->get_from_db($answer_id);
                ?>
                        <p>&emsp;&emsp;&emsp;<?php 
                print_r($answer->getValue());
                ?>
</p>
                        <?php 
            }
            ?>
                </div>
                <div class="accordion">
                    <?php 
        } elseif ($question->getType() == 0) {
开发者ID:tttodorov13,项目名称:suSurvey,代码行数:31,代码来源:survey.php

示例5: Question

 function test_getAnswers()
 {
     //Arrange
     $test_field = "What is their name?";
     $test_description = "What you want to call your character.";
     $test_question = new Question($test_field, $test_description);
     $test_question->save();
     $test_field = "Joe GetAll";
     $test_quest_id = $test_question->getId();
     $test_answer = new Answer($test_field, $test_quest_id);
     $test_answer->save();
     //Act
     $test_question->addAnswer($test_answer->getId());
     //Assert
     $result = $test_question->getAnswers($test_answer->getId());
     $this->assertEquals($test_answer, $result[0]);
 }
开发者ID:umamiMike,项目名称:promptr,代码行数:17,代码来源:QuestionTest.php

示例6: save_question

/**
 * Function to handle the "/questions" REST-POST call.
 *
 * It stores the transmitted question on the file system
 * and redirects to the previous page.
 */
function save_question()
{
    // create question from POST data
    $submittedQuestion = new Question($_POST["questionId"], $_POST["question"], array($_POST["answer1"], $_POST["answer2"], $_POST["answer3"], $_POST["answer4"]), $_POST["correct-answer"] - 1);
    $submittedQuestion->saveToFile();
    // create coin only after question has been saved to ensure the id has been initialized
    $coin = new Coin($submittedQuestion->getId());
    $coin->saveToFile();
    // redirect back to previous page
    header('Location: ' . $_SERVER['HTTP_REFERER']);
}
开发者ID:mervyn-mccreight,项目名称:cardboard-qr-questionform,代码行数:17,代码来源:api.php

示例7: foreach

        <div class="accordion">
            <?php 
    foreach ($survey_questions as $question_id) {
        $question = new Question();
        $question->get_from_db($question_id);
        if ($question->getType() == 1) {
            ?>
                </div>
                <div class="clearfix">
                    <h3 class="no-float ac"><?php 
            print_r($question->getTitle());
            ?>
</h3>

                    <?php 
            $answers = get_survey_answers($question->getId());
            foreach ($answers as $answer_id) {
                $answer = new Answer();
                $answer->get_from_db($answer_id);
                if ($answer->getType() == "textbox") {
                    ?>
                            <div  class="al">
                                &emsp;&emsp;&emsp;<?php 
                    print_r($answer->getValue());
                    ?>
                            </div>
                            <?php 
                }
            }
            ?>
                    <div class="al">
开发者ID:tttodorov13,项目名称:suSurvey,代码行数:31,代码来源:survey_edit.php

示例8: Exercise

 require_once './lib/question.class.php';
 $exercise = new Exercise();
 $exercise->load($exId);
 if ($exercise->getShuffle() && isset($_REQUEST['shuffle']) && $_REQUEST['shuffle'] == 1) {
     $questionList = $exercise->getRandomQuestionList();
 } else {
     $questionList = $exercise->getQuestionList();
 }
 foreach ($questionList as $_id => $question) {
     $questionObj = new Question();
     $questionObj->setExerciseId($exId);
     if ($questionObj->load($question['id'])) {
         $questionList[$_id]['description'] = $questionObj->getDescription();
         $questionList[$_id]['attachment'] = $questionObj->getAttachment();
         if (!empty($questionList[$_id]['attachment'])) {
             $questionList[$_id]['attachmentURL'] = get_conf('rootWeb') . 'courses/' . claro_get_current_course_id() . '/exercise/question_' . $questionObj->getId() . '/' . $questionObj->getAttachment();
         }
         switch ($questionObj->getType()) {
             case 'MCUA':
             case 'MCMA':
                 $questionList[$_id]['answers'] = $questionObj->answer->answerList;
                 break;
             case 'TF':
                 $questionList[$_id]['answers'][0]['answer'] = get_lang('True');
                 $questionList[$_id]['answers'][0]['feedback'] = $questionObj->answer->trueFeedback;
                 $questionList[$_id]['answers'][1]['answer'] = get_lang('False');
                 $questionList[$_id]['answers'][1]['feedback'] = $questionObj->answer->falseFeedback;
                 break;
             case 'FIB':
                 $questionList[$_id]['answerText'] = $questionObj->answer->answerDecode($questionObj->answer->answerText);
                 $questionList[$_id]['answerList'] = $questionObj->answer->answerList;
开发者ID:rhertzog,项目名称:lcs,代码行数:31,代码来源:exercise.php


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