本文整理汇总了PHP中grade_item::set_properties方法的典型用法代码示例。如果您正苦于以下问题:PHP grade_item::set_properties方法的具体用法?PHP grade_item::set_properties怎么用?PHP grade_item::set_properties使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类grade_item
的用法示例。
在下文中一共展示了grade_item::set_properties方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: unset
unset($itemdata->locktime);
$convert = array('grademax', 'grademin', 'gradepass', 'multfactor', 'plusfactor', 'aggregationcoef', 'aggregationcoef2');
foreach ($convert as $param) {
if (property_exists($itemdata, $param)) {
$itemdata->{$param} = unformat_float($itemdata->{$param});
}
}
if (isset($itemdata->aggregationcoef2)) {
$itemdata->aggregationcoef2 = $itemdata->aggregationcoef2 / 100.0;
}
// When creating a new category, a number of grade item fields are filled out automatically, and are required.
// If the user leaves these fields empty during creation of a category, we let the default values take effect
// Otherwise, we let the user-entered grade item values take effect
$grade_item = $grade_category->load_grade_item();
$grade_item_copy = fullclone($grade_item);
grade_item::set_properties($grade_item, $itemdata);
if (empty($grade_item->id)) {
$grade_item->id = $grade_item_copy->id;
}
if (empty($grade_item->grademax) && $grade_item->grademax != '0') {
$grade_item->grademax = $grade_item_copy->grademax;
}
if (empty($grade_item->grademin) && $grade_item->grademin != '0') {
$grade_item->grademin = $grade_item_copy->grademin;
}
if (empty($grade_item->gradepass) && $grade_item->gradepass != '0') {
$grade_item->gradepass = $grade_item_copy->gradepass;
}
if (empty($grade_item->aggregationcoef) && $grade_item->aggregationcoef != '0') {
$grade_item->aggregationcoef = $grade_item_copy->aggregationcoef;
}
示例2: test_upgrade_course_letter_boundary
/**
* Test that the upgrade script correctly flags courses to be frozen due to letter boundary problems.
*/
public function test_upgrade_course_letter_boundary()
{
global $CFG, $DB;
$this->resetAfterTest(true);
require_once $CFG->libdir . '/db/upgradelib.php';
// Create a user.
$user = $this->getDataGenerator()->create_user();
// Create some courses.
$courses = array();
$contexts = array();
for ($i = 0; $i < 45; $i++) {
$course = $this->getDataGenerator()->create_course();
$context = context_course::instance($course->id);
if (in_array($i, array(2, 5, 10, 13, 14, 19, 23, 25, 30, 34, 36))) {
// Assign good letter boundaries.
$this->assign_good_letter_boundary($context->id);
}
if (in_array($i, array(3, 6, 11, 15, 20, 24, 26, 31, 35))) {
// Assign bad letter boundaries.
$this->assign_bad_letter_boundary($context->id);
}
if (in_array($i, array(3, 9, 10, 11, 18, 19, 20, 29, 30, 31, 40))) {
grade_set_setting($course->id, 'displaytype', '3');
} else {
if (in_array($i, array(8, 17, 28))) {
grade_set_setting($course->id, 'displaytype', '2');
}
}
if (in_array($i, array(37, 43))) {
// Show.
grade_set_setting($course->id, 'report_user_showlettergrade', '1');
} else {
if (in_array($i, array(38, 42))) {
// Hide.
grade_set_setting($course->id, 'report_user_showlettergrade', '0');
}
}
$assignrow = $this->getDataGenerator()->create_module('assign', array('course' => $course->id, 'name' => 'Test!'));
$gi = grade_item::fetch(array('itemtype' => 'mod', 'itemmodule' => 'assign', 'iteminstance' => $assignrow->id, 'courseid' => $course->id));
if (in_array($i, array(6, 13, 14, 15, 23, 24, 34, 35, 36, 41))) {
grade_item::set_properties($gi, array('display' => 3));
$gi->update();
} else {
if (in_array($i, array(12, 21, 32))) {
grade_item::set_properties($gi, array('display' => 2));
$gi->update();
}
}
$gradegrade = new grade_grade();
$gradegrade->itemid = $gi->id;
$gradegrade->userid = $user->id;
$gradegrade->rawgrade = 55.5563;
$gradegrade->finalgrade = 55.5563;
$gradegrade->rawgrademax = 100;
$gradegrade->rawgrademin = 0;
$gradegrade->timecreated = time();
$gradegrade->timemodified = time();
$gradegrade->insert();
$contexts[] = $context;
$courses[] = $course;
}
upgrade_course_letter_boundary();
// No system setting for grade letter boundaries.
// [0] A course with no letter boundaries.
$this->assertTrue(empty($CFG->{'gradebook_calculations_freeze_' . $courses[0]->id}));
// [1] A course with letter boundaries which are default.
$this->assertTrue(empty($CFG->{'gradebook_calculations_freeze_' . $courses[1]->id}));
// [2] A course with letter boundaries which are custom but not affected.
$this->assertTrue(empty($CFG->{'gradebook_calculations_freeze_' . $courses[2]->id}));
// [3] A course with letter boundaries which are custom and will be affected.
$this->assertEquals(20160518, $CFG->{'gradebook_calculations_freeze_' . $courses[3]->id});
// [4] A course with no letter boundaries, but with a grade item with letter boundaries which are default.
$this->assertTrue(empty($CFG->{'gradebook_calculations_freeze_' . $courses[4]->id}));
// [5] A course with no letter boundaries, but with a grade item with letter boundaries which are not default, but not affected.
$this->assertTrue(empty($CFG->{'gradebook_calculations_freeze_' . $courses[5]->id}));
// [6] A course with no letter boundaries, but with a grade item with letter boundaries which are not default which will be affected.
$this->assertEquals(20160518, $CFG->{'gradebook_calculations_freeze_' . $courses[6]->id});
// System setting for grade letter boundaries (default).
set_config('grade_displaytype', '3');
for ($i = 0; $i < 45; $i++) {
unset_config('gradebook_calculations_freeze_' . $courses[$i]->id);
}
upgrade_course_letter_boundary();
// [7] A course with no grade display settings for the course or grade items.
$this->assertTrue(empty($CFG->{'gradebook_calculations_freeze_' . $courses[7]->id}));
// [8] A course with grade display settings, but for something that isn't letters.
$this->assertTrue(empty($CFG->{'gradebook_calculations_freeze_' . $courses[8]->id}));
// [9] A course with grade display settings of letters which are default.
$this->assertTrue(empty($CFG->{'gradebook_calculations_freeze_' . $courses[9]->id}));
// [10] A course with grade display settings of letters which are not default, but not affected.
$this->assertTrue(empty($CFG->{'gradebook_calculations_freeze_' . $courses[10]->id}));
// [11] A course with grade display settings of letters which are not default, which will be affected.
$this->assertEquals(20160518, $CFG->{'gradebook_calculations_freeze_' . $courses[11]->id});
// [12] A grade item with display settings that are not letters.
$this->assertTrue(empty($CFG->{'gradebook_calculations_freeze_' . $courses[12]->id}));
// [13] A grade item with display settings of letters which are default.
$this->assertTrue(empty($CFG->{'gradebook_calculations_freeze_' . $courses[13]->id}));
//.........这里部分代码省略.........