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


PHP question_bank::get_finder方法代码示例

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


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

示例1: get_available_questions_from_category

    /**
     * Get all the usable questions from a particular question category.
     *
     * @param int $categoryid the id of a question category.
     * @param bool whether to include questions from subcategories.
     * @param string $questionsinuse comma-separated list of question ids to
     *      exclude from consideration.
     * @return array of question records.
     */
    public function get_available_questions_from_category($categoryid, $subcategories) {
        if (isset($this->availablequestionsbycategory[$categoryid][$subcategories])) {
            return $this->availablequestionsbycategory[$categoryid][$subcategories];
        }

        $this->init_qtype_lists();
        if ($subcategories) {
            $categoryids = question_categorylist($categoryid);
        } else {
            $categoryids = array($categoryid);
        }

        $questionids = question_bank::get_finder()->get_questions_from_categories(
                $categoryids, 'qtype NOT IN (' . $this->excludedqtypes . ')');
        $this->availablequestionsbycategory[$categoryid][$subcategories] = $questionids;
        return $questionids;
    }
开发者ID:nottmoo,项目名称:moodle,代码行数:26,代码来源:questiontype.php

示例2: get_available_saquestions_from_category

 /**
  * Get all the usable shortanswer questions from a particular question category.
  *
  * @param integer $categoryid the id of a question category.
  * @param bool $subcategories whether to include questions from subcategories.
  * @return array of question records.
  */
 public function get_available_saquestions_from_category($categoryid, $subcategories)
 {
     if (isset($this->availablesaquestionsbycategory[$categoryid][$subcategories])) {
         return $this->availablesaquestionsbycategory[$categoryid][$subcategories];
     }
     if ($subcategories) {
         $categoryids = question_categorylist($categoryid);
     } else {
         $categoryids = array($categoryid);
     }
     $questionids = question_bank::get_finder()->get_questions_from_categories($categoryids, "qtype = 'shortanswer'");
     $this->availablesaquestionsbycategory[$categoryid][$subcategories] = $questionids;
     return $questionids;
 }
开发者ID:evltuma,项目名称:moodle,代码行数:21,代码来源:questiontype.php

示例3: test_get_questions_from_categories_with_usage_counts

 public function test_get_questions_from_categories_with_usage_counts()
 {
     $this->resetAfterTest();
     $generator = $this->getDataGenerator()->get_plugin_generator('core_question');
     $cat = $generator->create_question_category();
     $questiondata1 = $generator->create_question('shortanswer', null, array('category' => $cat->id));
     $questiondata2 = $generator->create_question('shortanswer', null, array('category' => $cat->id));
     $questiondata3 = $generator->create_question('shortanswer', null, array('category' => $cat->id));
     $quba = question_engine::make_questions_usage_by_activity('test', context_system::instance());
     $quba->set_preferred_behaviour('deferredfeedback');
     $question1 = question_bank::load_question($questiondata1->id);
     $question3 = question_bank::load_question($questiondata3->id);
     $quba->add_question($question1);
     $quba->add_question($question1);
     $quba->add_question($question3);
     $quba->start_all_questions();
     question_engine::save_questions_usage_by_activity($quba);
     $this->assertEquals(array($questiondata2->id => 0, $questiondata3->id => 1, $questiondata1->id => 2), question_bank::get_finder()->get_questions_from_categories_with_usage_counts(array($cat->id), new qubaid_list(array($quba->get_id()))));
 }
开发者ID:alanaipe2015,项目名称:moodle,代码行数:19,代码来源:questionbank_test.php

示例4: ensure_questions_for_category_loaded

 /**
  * Populate {@link $availablequestionscache} for this combination of options.
  * @param int $categoryid the id of a category in the question bank.
  * @param bool $includesubcategories wether to pick a question from exactly
  *      that category, or that category and subcategories.
  */
 protected function ensure_questions_for_category_loaded($categoryid, $includesubcategories)
 {
     global $DB;
     $categorykey = $this->get_category_key($categoryid, $includesubcategories);
     if (isset($this->availablequestionscache[$categorykey])) {
         // Data is already in the cache, nothing to do.
         return;
     }
     // Load the available questions from the question bank.
     if ($includesubcategories) {
         $categoryids = question_categorylist($categoryid);
     } else {
         $categoryids = array($categoryid);
     }
     list($extraconditions, $extraparams) = $DB->get_in_or_equal($this->excludedqtypes, SQL_PARAMS_NAMED, 'excludedqtype', false);
     $questionidsandcounts = \question_bank::get_finder()->get_questions_from_categories_with_usage_counts($categoryids, $this->qubaids, 'q.qtype ' . $extraconditions, $extraparams);
     if (!$questionidsandcounts) {
         // No questions in this category.
         $this->availablequestionscache[$categorykey] = array();
         return;
     }
     // Put all the questions with each value of $prevusecount in separate arrays.
     $idsbyusecount = array();
     foreach ($questionidsandcounts as $questionid => $prevusecount) {
         if (isset($this->recentlyusedquestions[$questionid])) {
             // Recently used questions are never returned.
             continue;
         }
         $idsbyusecount[$prevusecount][] = $questionid;
     }
     // Now put that data into our cache. For each count, we need to shuffle
     // questionids, and make those the keys of an array.
     $this->availablequestionscache[$categorykey] = array();
     foreach ($idsbyusecount as $prevusecount => $questionids) {
         shuffle($questionids);
         $this->availablequestionscache[$categorykey][$prevusecount] = array_combine($questionids, array_fill(0, count($questionids), 1));
     }
     ksort($this->availablequestionscache[$categorykey]);
 }
开发者ID:evltuma,项目名称:moodle,代码行数:45,代码来源:random_question_loader.php


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