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


PHP question_engine::load_used_variants方法代码示例

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


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

示例1: __construct

 /**
  * Constructor.
  * @param question_usage_by_activity $quba the question usage we will be picking variants for.
  * @param qubaid_condition $qubaids ids of the usages to consider when counting previous uses of each variant.
  */
 public function __construct(\question_usage_by_activity $quba, \qubaid_condition $qubaids)
 {
     $questionidtoseed = array();
     foreach ($quba->get_attempt_iterator() as $qa) {
         $question = $qa->get_question();
         if ($question->get_num_variants() > 1) {
             $questionidtoseed[$question->id] = $question->get_variants_selection_seed();
         }
     }
     if (empty($questionidtoseed)) {
         return;
     }
     $this->variantsusecounts = array_fill_keys($questionidtoseed, array());
     $variantsused = \question_engine::load_used_variants(array_keys($questionidtoseed), $qubaids);
     foreach ($variantsused as $questionid => $usagecounts) {
         $seed = $questionidtoseed[$questionid];
         foreach ($usagecounts as $variant => $count) {
             if (isset($this->variantsusecounts[$seed][$variant])) {
                 $this->variantsusecounts[$seed][$variant] += $count;
             } else {
                 $this->variantsusecounts[$seed][$variant] = $count;
             }
         }
     }
 }
开发者ID:evltuma,项目名称:moodle,代码行数:30,代码来源:least_used_strategy.php

示例2: test_load_used_variants

 public function test_load_used_variants()
 {
     $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($questiondata1->id => array(1 => 2), $questiondata2->id => array(), $questiondata3->id => array(1 => 1)), question_engine::load_used_variants(array($questiondata1->id, $questiondata2->id, $questiondata3->id), new qubaid_list(array($quba->get_id()))));
 }
开发者ID:alanaipe2015,项目名称:moodle,代码行数:19,代码来源:datalib_test.php


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