示例#1
0
 public function run()
 {
     $model = new Question();
     //条件
     $criteria = new CDbCriteria();
     $realname = trim(Yii::app()->request->getParam('realname'));
     $question = trim(Yii::app()->request->getParam('question'));
     $question && $criteria->addSearchCondition('question', $question);
     $realname && $criteria->addSearchCondition('realname', $realname);
     $criteria->order = 't.id ASC';
     $count = $model->count($criteria);
     //分页
     $pages = new CPagination($count);
     $pages->pageSize = 10;
     $pages->applyLimit($criteria);
     //查询
     $result = $model->findAll($criteria);
     $this->controller->render('index', array('model' => $model, 'datalist' => $result, 'pagebar' => $pages));
 }
示例#2
0
 /**
  * 首页
  */
 public function actionIndex()
 {
     $bagecmsQuestionModel = new Question();
     $bagecmsQuestionCriteria = new CDbCriteria();
     $bagecmsQuestionCriteria->condition = 'status_is=:status';
     $bagecmsQuestionCriteria->params = array('status' => 'Y');
     $bagecmsQuestionCriteria->order = 't.id DESC';
     $bagecmsQuestionCount = $bagecmsQuestionModel->count($bagecmsQuestionCriteria);
     $bagecmsQuestionPages = new CPagination($bagecmsQuestionCount);
     $bagecmsQuestionPages->pageSize = 10;
     $bagecmsQuestionPageParams = XUtils::buildCondition($_GET, array());
     $bagecmsQuestionPageParams['#'] = 'list';
     $bagecmsQuestionPages->params = is_array($bagecmsQuestionPageParams) ? $bagecmsQuestionPageParams : array();
     $bagecmsQuestionCriteria->limit = $bagecmsQuestionPages->pageSize;
     $bagecmsQuestionCriteria->offset = $bagecmsQuestionPages->currentPage * $bagecmsQuestionPages->pageSize;
     $bagecmsQuestionList = $bagecmsQuestionModel->findAll($bagecmsQuestionCriteria);
     $this->_seoTitle = '留言咨询 - ' . $this->_conf['site_name'];
     $this->render('index', array('bagecmsQuestionList' => $bagecmsQuestionList, 'pages' => $bagecmsQuestionPages));
 }
示例#3
0
 /**
  * 首页
  */
 public function actionIndex()
 {
     $model = new Question();
     $criteria = new CDbCriteria();
     $condition = '1';
     $realname = trim($this->_request->getParam('realname'));
     $question = trim($this->_request->getParam('question'));
     $question && ($condition .= ' AND question LIKE \'%' . $question . '%\'');
     $realname && ($condition .= ' AND realname LIKE \'%' . $realname . '%\'');
     $criteria->condition = $condition;
     $criteria->order = 't.id DESC';
     $count = $model->count($criteria);
     $pages = new CPagination($count);
     $pages->pageSize = 15;
     $pageParams = $this->buildCondition($_GET, array('site_name'));
     $pages->params = is_array($pageParams) ? $pageParams : array();
     $criteria->limit = $pages->pageSize;
     $criteria->offset = $pages->currentPage * $pages->pageSize;
     $result = $model->findAll($criteria);
     $this->render('index', array('datalist' => $result, 'pagebar' => $pages));
 }
 public function postGuardar()
 {
     $bandera = false;
     $id = Input::get('idQues');
     $ans = Input::get('res');
     $answers = Answer::all();
     $question = Question::find($id);
     $cantidad = Question::count();
     foreach ($answers as $a) {
         if ($a->id_question == $id) {
             $bandera = true;
             $answer = $a;
             break;
         }
     }
     if (!$bandera) {
         $answer = new Answer();
         $answer->id_question = $id;
         $ids = Auth::id();
         $student = Student::where('id_user', '=', $ids)->get()->first();
         $answer->id_student = $student->id;
         $answer->answer = $ans;
         $answer->result = QuestionsController::verifyAnswer($question, $ans);
         $answer->save();
     } else {
         $answer->result = QuestionsController::verifyAnswer($question, $ans);
         $answer->answer = $ans;
         $answer->save();
     }
     if ($cantidad == $id) {
         return Redirect::to('questions/exam?endTest=yes');
         //"holi ".$id." ".$ans;
     } else {
         if ($cantidad > $id) {
             return Redirect::to('questions/exam?numberQIn=' . ++$id);
         }
     }
 }
示例#5
0
文件: q2a.php 项目: Osin/Intranet
<?php

include '../../inc/init.inc';
if (isset($tag)) {
    $conditions = array('id in (?)', Questions_Tag::find('all', array('conditions' => array('tag_id' => Tag::find_by_name($tag)->id)))->asQuestion_ID());
}
isset($conditions) ? $args['conditions'] = $conditions : ($args['conditions'] = 'title NOT LIKE ""');
$res->total = isset($args) ? Question::count($args) : Question::count();
$res->currentPage = isset($currentPage) ? $currentPage : 1;
$res->limit = $args['limit'] = isset($limit) ? $limit : 7;
$args['offset'] = ($res->currentPage - 1) * $args['limit'];
$args['order'] = isset($order) ? $order : 'created_at desc';
$res->questions = Question::all($args);
$res->tags = Tag::find('all', array('order' => 'Rand()', 'limit' => 20));
if (!isset($infos)) {
    $infos = array();
}
$res->search_opts = array(0 => array('label' => 'Quelle question vous posez vous ?', 'field' => 'title', 'type' => 'text', 'class' => 'xxlarge'));
$res->useTemplate("Questions - Reponses", $infos);
示例#6
0
 /**
  * 删除Paper 表数据
  * 关联到Question,Question_ans表, 因此不能随意删除
  * 尤其是Question表, 其中的数据必须是在获取到paper_id 之后才能导入
  * @return boolean
  * true 删除成功
  * false 删除失败
  */
 public static function deletePaperData()
 {
     if (Question::count() != 0) {
         throw new Exception("The foreign key is used for table Question!");
     }
     $paper_data = Paper::find();
     try {
         $manager = new TxManager();
         $transaction = $manager->get();
         foreach ($paper_data as $record) {
             if ($record->delete() == false) {
                 $transaction->rollback("Cannot delete Paper data");
             }
         }
         $transaction->commit();
         return true;
     } catch (TxFailed $e) {
         throw new Exception("Failed, reason: " . $e->getMessage());
     }
 }
	  <div class="content">  
   

   <!--Start : Question Number (Example 2 de 5) -->	 
   
   <div class="row">
          <p class="instructions-title"><span style="background-color: #808285; padding: 3px 3px 3px 3px;">Exam Instructions </span></p>
    </div>
   <!--End : Question Number -->	

    <div class="frame">
                              
<p class="orange-p"> ITIL FOUNDATION (2011)</p>
 <?php 
$exam = Exam::find(1);
echo '<p class="instructions-p ">All ' . Question::count() . ' questions should be attempted</p>';
echo '<p class="instructions-p ">There are no trick questions</p>';
echo '<p class="instructions-p ">You have 75 minutes for this exam</p>';
echo '<p class="instructions-p ">You must get ' . $exam->score . ' points or more to pass</p>';
echo '<p class="instructions-p ">During this exam you are allowed to navigate freely and review items you have already answered</p>';
echo '<p class="instructions-p ">If you have time at the end of the exam you can review your answers or any questions that you flag for review during the exam</p>';
echo '<p class="instructions-p ">Please note that it is strictly forbidden to copy or reproduce the content of this exam without the approval of PEOPLECERT</p>                                  <br>';
?>
                               
		</div>
	    {{ Form::open(array('method' => 'GET', 'route' => array('exam.show', $exam->id))) }}
		      <input type="submit" class="btn-option" value="Next" >
      {{ Form::close() }}
	</div>
	</div>
	          </td>
?>
;
            decrement--;
            window.location.href="exam?numberQDc="+decrement;
          }
        
      }

      function prueba2()
      {
        var increment = <?php 
echo $increment;
?>
;
        var cant = <?php 
echo Question::count();
?>
;
        if(increment == cant)
        {
          alert("Somos iguales");
          increment = 1;
          window.location.href="exam?numberQIn="+increment;
        }else
          {
            alert("Somos diferentes");
            increment++;
            window.location.href="exam?numberQIn="+increment;
          }
      }
        </script>
示例#9
0
 function view($id, $idQuestion = null)
 {
     if ($idQuestion == null) {
         $adviceDetails = AdviceDetail::where('id_advice', $id)->get();
         $listHistory = Question::whereIn('id', array_diff($adviceDetails->lists('id_question'), Question::$_rootQuestionID))->get();
         if (array_unique($adviceDetails->lists('id_question')) == Question::count()) {
             return View::make('advice.view', ['select' => 'next', 'question' => null, 'listHistory' => $listHistory, 'id' => $id, 'tours' => []]);
         }
         if ($adviceDetails->count() == 0) {
             return Redirect::route('advice.view', ['id' => $id, 'idQuestion' => 'root']);
         } else {
             $adviceDetails = AdviceDetail::where('id_advice', $id)->get();
             //=============
             $questionAnswerLoc = AdviceDetail::where('id_advice', $id)->where('id_question', 1)->first();
             $location = Location::join(Answer::getTableName(), Answer::getTableName() . '.name', '=', Location::getTableName() . '.code')->where(Answer::getTableName() . '.id', $questionAnswerLoc->id_answer)->select(Location::getTableName() . '.*')->first();
             $tours = Tour::where('start_loc', $location->id)->get();
             $listAnsOfNotFactor = $adviceDetails->filter(function ($row) {
                 return !in_array($row->id_question, Question::$_rootQuestionID);
             });
             if ($listAnsOfNotFactor->count() > 0) {
                 $arrAnsPoint = $this->scoreAnswer($listAnsOfNotFactor->lists('id_answer'));
                 $arrAnsPoint = $this->interaction($arrAnsPoint);
                 $idAttrForNext = $this->getAttributeForNext($arrAnsPoint);
                 if ($idAttrForNext) {
                     $listIDQuestionHistory = $adviceDetails->lists('id_question');
                     $strAvoid = implode(',', $listIDQuestionHistory);
                     $questionForNext = DB::select("\n                            SELECT `questions`.*\n                            FROM `questions`\n                            INNER JOIN `question_answer`\n                            ON `questions`.`id` = `question_answer`.`id_question`\n                            INNER JOIN `answers`\n                            ON `question_answer`.`id_answer` = `answers`.`id`\n                            WHERE `answers`.`id_attribute` = {$idAttrForNext}\n                            AND `questions`.`id` NOT IN ({$strAvoid})\n                            GROUP BY `question_answer`.`id_question`\n                            ORDER BY COUNT(DISTINCT `question_answer`.`id_answer`) DESC\n                        ")[0];
                     $question = new Question((array) $questionForNext);
                 }
             } else {
                 $question = Question::find(5);
             }
             return View::make('advice.view', ['select' => 'next', 'question' => $question, 'listHistory' => $listHistory, 'id' => $id, 'tours' => $tours]);
         }
     } else {
         if ($idQuestion == 'root') {
             $questions = Question::whereIn('id', Question::$_rootQuestionID)->get();
             $listHistory = new Collection();
             return View::make('advice.view', ['select' => 'root', 'questions' => $questions, 'listHistory' => $listHistory, 'id' => $id]);
         } else {
             $question = Question::find($idQuestion);
             $adviceDetails = AdviceDetail::where('id_advice', $id)->get();
             $listHistory = Question::whereIn('id', array_diff($adviceDetails->lists('id_question'), array_merge(Question::$_rootQuestionID, [$idQuestion])))->get();
             return View::make('advice.view', ['select' => 'history', 'question' => $question, 'listHistory' => $listHistory, 'id' => $id]);
         }
     }
 }