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