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


PHP grade_item::rescale_grades_keep_percentage方法代码示例

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


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

示例1: sub_test_grade_item_rescale_grades_keep_percentage

 protected function sub_test_grade_item_rescale_grades_keep_percentage()
 {
     global $DB;
     $gradeitem = new grade_item($this->grade_items[10], false);
     // 10 is the manual grade item.
     // Create some grades to go with the grade item.
     $gradeids = array();
     $grade = new stdClass();
     $grade->itemid = $gradeitem->id;
     $grade->userid = $this->user[2]->id;
     $grade->finalgrade = 10;
     $grade->rawgrademax = $gradeitem->grademax;
     $grade->rawgrademin = $gradeitem->grademin;
     $grade->timecreated = time();
     $grade->timemodified = time();
     $gradeids[] = $DB->insert_record('grade_grades', $grade);
     $grade->userid = $this->user[3]->id;
     $grade->finalgrade = 50;
     $grade->rawgrademax = $gradeitem->grademax;
     $grade->rawgrademin = $gradeitem->grademin;
     $gradeids[] = $DB->insert_record('grade_grades', $grade);
     // Run the function.
     $gradeitem->grademax = 33;
     $gradeitem->grademin = 3;
     $gradeitem->update();
     $gradeitem->rescale_grades_keep_percentage(0, 100, 3, 33, 'test');
     // Check that the grades were updated to match the grade item.
     $grade = $DB->get_record('grade_grades', array('id' => $gradeids[0]));
     $this->assertEquals($gradeitem->grademax, $grade->rawgrademax, 'Max grade mismatch', 0.0001);
     $this->assertEquals($gradeitem->grademin, $grade->rawgrademin, 'Min grade mismatch', 0.0001);
     $this->assertEquals(6, $grade->finalgrade, 'Min grade mismatch', 0.0001);
     $grade = $DB->get_record('grade_grades', array('id' => $gradeids[1]));
     $this->assertEquals($gradeitem->grademax, $grade->rawgrademax, 'Max grade mismatch', 0.0001);
     $this->assertEquals($gradeitem->grademin, $grade->rawgrademin, 'Min grade mismatch', 0.0001);
     $this->assertEquals(18, $grade->finalgrade, 'Min grade mismatch', 0.0001);
 }
开发者ID:evltuma,项目名称:moodle,代码行数:36,代码来源:grade_item_test.php


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