本文整理汇总了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);
}