當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。