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


PHP Question::factory方法代码示例

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


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

示例1: test_check_answer

 public function test_check_answer()
 {
     $ques = ORM::factory('question', 10);
     $question = Question::factory($ques);
     $submitted = array(0 => array(0 => "s dasda s", 1 => "asd asd"), 1 => array(0 => "asd asdasdasd", 1 => "asda sasdasd"), 2 => array(0 => "dsf dsdfsdfsdf", 1 => "sa asasd assad"));
     $this->assertTrue($question->check_answer($submitted));
 }
开发者ID:hemsinfotech,项目名称:kodelearn,代码行数:7,代码来源:Question_MatchingTest.php

示例2: test_check_answer

 public function test_check_answer()
 {
     $ques = ORM::factory('question', 5);
     $question = Question::factory($ques);
     $submitted = 5;
     $this->assertTrue($question->check_answer($submitted));
 }
开发者ID:hemsinfotech,项目名称:kodelearn,代码行数:7,代码来源:Question_OpenTest.php

示例3: test_process_hints

 public function test_process_hints()
 {
     $formdata = array('hint' => array('hint1', 'hint2', ''), 'sort_order' => array('1', '2', '3'), 'deduction' => array('3.2', '3.4', '5.6'));
     $question = Question::factory('choice');
     $hints = $question->process_hints($formdata);
     $this->assertEquals($hints, array(0 => array('hint' => 'hint1', 'sort_order' => 1, 'deduction' => 3.2), 1 => array('hint' => 'hint2', 'sort_order' => 2, 'deduction' => 3.4)));
 }
开发者ID:hemsinfotech,项目名称:kodelearn,代码行数:7,代码来源:QuestionformTest.php

示例4: test_check_answer

 public function test_check_answer()
 {
     $ques = ORM::factory('question', 8);
     $question = Question::factory($ques);
     $submitted = array('twelve', 'sixteen', 'twenty five', 'thirty five');
     $this->assertTrue($question->check_answer($submitted));
     $ques = ORM::factory('question', 7);
     $question = Question::factory($ques);
     $submitted = array('Router', 'Controller', 'Model', 'View');
     $this->assertTrue($question->check_answer($submitted));
 }
开发者ID:hemsinfotech,项目名称:kodelearn,代码行数:11,代码来源:Question_OrderingTest.php

示例5: test_check_answer

 public function test_check_answer()
 {
     // try to load a question of type choice
     $ques = ORM::factory('question', 2);
     $question = Question::factory($ques);
     $submitted = array(4);
     $this->assertTrue($question->check_answer($submitted));
     $ques = ORM::factory('question', 1);
     $question = Question::factory($ques);
     $submitted = array('echo', 'print_r');
     $this->assertTrue($question->check_answer($submitted));
 }
开发者ID:hemsinfotech,项目名称:kodelearn,代码行数:12,代码来源:Question_ChoiceTest.php

示例6: __construct

 /**
  * @param the exercise progress information stored in the Session
  */
 public function __construct($attempt_session)
 {
     $this->_exercise = ORM::factory('exercise', $attempt_session['exercise_id']);
     $questions = $attempt_session['questions'];
     foreach ($questions as $question_id => $marks) {
         $q = Question::factory((int) $question_id);
         $q->marks($marks);
         $this->_total_marks += $marks;
         $this->_questions[] = $q;
     }
     $this->questions_attempted($attempt_session['ques_attempted']);
     $this->_hints_taken = Arr::get($attempt_session, 'hints_taken', array());
     $this->_score = $this->calculate_score();
     $this->_num_correct = count(array_filter($this->_questions_results));
     $this->_num_incorrect = count($this->_questions) - $this->_num_correct;
 }
开发者ID:hemsinfotech,项目名称:kodelearn,代码行数:19,代码来源:result.php

示例7: action_ajax_test_submit

 public function action_ajax_test_submit()
 {
     $attempt_session = Session::instance()->get('exercise_attempt');
     $responses = $this->request->post('responses');
     $arr = array();
     if ($responses) {
         foreach ($responses as $response) {
             $question = Question::factory((int) $response['question_id']);
             $result = $question->check_answer($response['answer']);
             $arr[$response['question_id']] = array('answer' => $response['answer'], 'result' => $result);
         }
     }
     $exercise = ORM::factory('exercise', $this->request->post('exercise_id'));
     $questions = $exercise->questions();
     $attempt_session['ques_attempted'] = $arr;
     // save in the session
     Session::instance()->set('exercise_attempt', $attempt_session);
     $this->content = json_encode(array('status' => 1));
 }
开发者ID:hemsinfotech,项目名称:kodelearn,代码行数:19,代码来源:exercise.php

示例8: action_preview_overlay

 public function action_preview_overlay()
 {
     // incase the request is not an ajax request, redirect to the not_found page
     if (!$this->request->is_ajax()) {
         Request::current()->redirect('error/not_found');
     }
     $question_id = $this->request->param('id');
     $ques_obj = Question::factory((int) $question_id);
     $question_partial = $ques_obj->render_question(true);
     $this->content = $question_partial;
 }
开发者ID:hemsinfotech,项目名称:kodelearn,代码行数:11,代码来源:question.php


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