當前位置: 首頁>>代碼示例>>PHP>>正文


PHP grade_category::apply_limit_rules方法代碼示例

本文整理匯總了PHP中grade_category::apply_limit_rules方法的典型用法代碼示例。如果您正苦於以下問題:PHP grade_category::apply_limit_rules方法的具體用法?PHP grade_category::apply_limit_rules怎麽用?PHP grade_category::apply_limit_rules使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在grade_category的用法示例。


在下文中一共展示了grade_category::apply_limit_rules方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: sub_test_grade_category_apply_limit_rules

 protected function sub_test_grade_category_apply_limit_rules()
 {
     $items[$this->grade_items[0]->id] = new grade_item($this->grade_items[0], false);
     $items[$this->grade_items[1]->id] = new grade_item($this->grade_items[1], false);
     $items[$this->grade_items[2]->id] = new grade_item($this->grade_items[2], false);
     $items[$this->grade_items[4]->id] = new grade_item($this->grade_items[4], false);
     $category = new grade_category();
     $category->droplow = 2;
     $grades = array($this->grade_items[0]->id => 5.374, $this->grade_items[1]->id => 9.474299999999999, $this->grade_items[2]->id => 2.5474, $this->grade_items[4]->id => 7.3754);
     $category->apply_limit_rules($grades, $items);
     $this->assertEquals(count($grades), 2);
     $this->assertEquals($grades[$this->grade_items[1]->id], 9.474299999999999);
     $this->assertEquals($grades[$this->grade_items[4]->id], 7.3754);
     $category = new grade_category();
     $category->keephigh = 1;
     $category->droplow = 0;
     $grades = array($this->grade_items[0]->id => 5.374, $this->grade_items[1]->id => 9.474299999999999, $this->grade_items[2]->id => 2.5474, $this->grade_items[4]->id => 7.3754);
     $category->apply_limit_rules($grades, $items);
     $this->assertEquals(count($grades), 1);
     $grade = reset($grades);
     $this->assertEquals(9.474299999999999, $grade);
     $category = new grade_category();
     $category->droplow = 2;
     $category->aggregation = GRADE_AGGREGATE_SUM;
     $items[$this->grade_items[2]->id]->aggregationcoef = 1;
     $grades = array($this->grade_items[0]->id => 5.374, $this->grade_items[1]->id => 9.474299999999999, $this->grade_items[2]->id => 2.5474, $this->grade_items[4]->id => 7.3754);
     $category->apply_limit_rules($grades, $items);
     $this->assertEquals(count($grades), 2);
     $this->assertEquals($grades[$this->grade_items[1]->id], 9.474299999999999);
     $this->assertEquals($grades[$this->grade_items[2]->id], 2.5474);
     $category = new grade_category();
     $category->keephigh = 1;
     $category->droplow = 0;
     $category->aggregation = GRADE_AGGREGATE_SUM;
     $items[$this->grade_items[2]->id]->aggregationcoef = 1;
     $grades = array($this->grade_items[0]->id => 5.374, $this->grade_items[1]->id => 9.474299999999999, $this->grade_items[2]->id => 2.5474, $this->grade_items[4]->id => 7.3754);
     $category->apply_limit_rules($grades, $items);
     $this->assertEquals(count($grades), 2);
     $this->assertEquals($grades[$this->grade_items[1]->id], 9.474299999999999);
     $this->assertEquals($grades[$this->grade_items[2]->id], 2.5474);
 }
開發者ID:numbas,項目名稱:moodle,代碼行數:41,代碼來源:grade_category_test.php

示例2: sub_test_grade_category_apply_limit_rules

 protected function sub_test_grade_category_apply_limit_rules()
 {
     $items[$this->grade_items[0]->id] = new grade_item($this->grade_items[0], false);
     $items[$this->grade_items[1]->id] = new grade_item($this->grade_items[1], false);
     $items[$this->grade_items[2]->id] = new grade_item($this->grade_items[2], false);
     $items[$this->grade_items[4]->id] = new grade_item($this->grade_items[4], false);
     // Test excluding the lowest 2 out of 4 grades from aggregation with no 0 grades
     $category = new grade_category();
     $category->droplow = 2;
     $grades = array($this->grade_items[0]->id => 5.374, $this->grade_items[1]->id => 9.474299999999999, $this->grade_items[2]->id => 2.5474, $this->grade_items[4]->id => 7.3754);
     $category->apply_limit_rules($grades, $items);
     $this->assertEquals(count($grades), 2);
     $this->assertEquals($grades[$this->grade_items[1]->id], 9.474299999999999);
     $this->assertEquals($grades[$this->grade_items[4]->id], 7.3754);
     // Test aggregating only the highest 1 out of 4 grades
     $category = new grade_category();
     $category->keephigh = 1;
     $category->droplow = 0;
     $grades = array($this->grade_items[0]->id => 5.374, $this->grade_items[1]->id => 9.474299999999999, $this->grade_items[2]->id => 2.5474, $this->grade_items[4]->id => 7.3754);
     $category->apply_limit_rules($grades, $items);
     $this->assertEquals(count($grades), 1);
     $grade = reset($grades);
     $this->assertEquals(9.474299999999999, $grade);
     // Test excluding the lowest 2 out of 4 grades from aggregation with no 0 grades
     // An extra credit grade item should be kept even if droplow means it would otherwise be excluded
     $category = new grade_category();
     $category->droplow = 2;
     $category->aggregation = GRADE_AGGREGATE_SUM;
     $items[$this->grade_items[2]->id]->aggregationcoef = 1;
     // Mark grade item 2 as "extra credit"
     $grades = array($this->grade_items[0]->id => 5.374, $this->grade_items[1]->id => 9.474299999999999, $this->grade_items[2]->id => 2.5474, $this->grade_items[4]->id => 7.3754);
     $category->apply_limit_rules($grades, $items);
     $this->assertEquals(count($grades), 2);
     $this->assertEquals($grades[$this->grade_items[1]->id], 9.474299999999999);
     $this->assertEquals($grades[$this->grade_items[2]->id], 2.5474);
     // Test only aggregating the highest 1 out of 4 grades
     // An extra credit grade item is retained in addition to the highest grade
     $category = new grade_category();
     $category->keephigh = 1;
     $category->droplow = 0;
     $category->aggregation = GRADE_AGGREGATE_SUM;
     $items[$this->grade_items[2]->id]->aggregationcoef = 1;
     // Mark grade item 2 as "extra credit"
     $grades = array($this->grade_items[0]->id => 5.374, $this->grade_items[1]->id => 9.474299999999999, $this->grade_items[2]->id => 2.5474, $this->grade_items[4]->id => 7.3754);
     $category->apply_limit_rules($grades, $items);
     $this->assertEquals(count($grades), 2);
     $this->assertEquals($grades[$this->grade_items[1]->id], 9.474299999999999);
     $this->assertEquals($grades[$this->grade_items[2]->id], 2.5474);
     // Test excluding the lowest 1 out of 4 grades from aggregation with two 0 grades
     $items[$this->grade_items[2]->id]->aggregationcoef = 0;
     // Undo marking grade item 2 as "extra credit"
     $category = new grade_category();
     $category->droplow = 1;
     $category->aggregation = GRADE_AGGREGATE_WEIGHTED_MEAN2;
     // simple weighted mean
     $grades = array($this->grade_items[0]->id => 0, $this->grade_items[1]->id => 5, $this->grade_items[2]->id => 2, $this->grade_items[4]->id => 0);
     // 0 out of 100
     $category->apply_limit_rules($grades, $items);
     $this->assertEquals(count($grades), 3);
     $this->assertEquals($grades[$this->grade_items[1]->id], 5);
     $this->assertEquals($grades[$this->grade_items[2]->id], 2);
     $this->assertEquals($grades[$this->grade_items[4]->id], 0);
     // Test excluding the lowest 2 out of 4 grades from aggregation with three 0 grades
     $category = new grade_category();
     $category->droplow = 2;
     $category->aggregation = GRADE_AGGREGATE_WEIGHTED_MEAN2;
     // simple weighted mean
     $grades = array($this->grade_items[0]->id => 0, $this->grade_items[1]->id => 5, $this->grade_items[2]->id => 0, $this->grade_items[4]->id => 0);
     // 0 out of 100. Should be excluded from aggregation.
     $category->apply_limit_rules($grades, $items);
     $this->assertEquals(count($grades), 2);
     $this->assertEquals($grades[$this->grade_items[1]->id], 5);
     $this->assertEquals($grades[$this->grade_items[2]->id], 0);
     // Test excluding the lowest 5 out of 4 grades from aggregation
     // Just to check we handle this sensibly
     $category = new grade_category();
     $category->droplow = 5;
     $category->aggregation = GRADE_AGGREGATE_WEIGHTED_MEAN2;
     // simple weighted mean
     $grades = array($this->grade_items[0]->id => 0, $this->grade_items[1]->id => 5, $this->grade_items[2]->id => 6, $this->grade_items[4]->id => 1);
     // 1 out of 100. Should be excluded from aggregation.
     $category->apply_limit_rules($grades, $items);
     $this->assertEquals(count($grades), 0);
     // Test excluding the lowest 4 out of 4 grades from aggregation with one marked as extra credit
     $category = new grade_category();
     $category->droplow = 4;
     $category->aggregation = GRADE_AGGREGATE_WEIGHTED_MEAN2;
     // simple weighted mean
     $items[$this->grade_items[2]->id]->aggregationcoef = 1;
     // Mark grade item 2 as "extra credit"
     $grades = array($this->grade_items[0]->id => 0, $this->grade_items[1]->id => 5, $this->grade_items[2]->id => 6, $this->grade_items[4]->id => 1);
     // 1 out of 100. Should be excluded from aggregation.
     $category->apply_limit_rules($grades, $items);
     $this->assertEquals(count($grades), 1);
     $this->assertEquals($grades[$this->grade_items[2]->id], 6);
     // MDL-35667 - There was an infinite loop if several items had the same grade and at least one was extra credit
     $category = new grade_category();
     $category->droplow = 1;
     $category->aggregation = GRADE_AGGREGATE_WEIGHTED_MEAN2;
     // simple weighted mean
//.........這裏部分代碼省略.........
開發者ID:Jtgadbois,項目名稱:Pedadida,代碼行數:101,代碼來源:grade_category_test.php


注:本文中的grade_category::apply_limit_rules方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。