本文整理汇总了PHP中grade_scale::load_items方法的典型用法代码示例。如果您正苦于以下问题:PHP grade_scale::load_items方法的具体用法?PHP grade_scale::load_items怎么用?PHP grade_scale::load_items使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类grade_scale
的用法示例。
在下文中一共展示了grade_scale::load_items方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: get_moodle_grades
private function get_moodle_grades()
{
global $DB, $CFG;
$grades = $DB->get_records('grade_grades', array('itemid' => $this->course_grade_item->id), 'userid', 'userid, finalgrade');
if (!is_array($grades)) {
$grades = array();
}
$this->moodle_grades = array();
if ($this->course_grade_item->gradetype == GRADE_TYPE_SCALE) {
$pg_scale = new grade_scale(array('id' => $CFG->grade_report_newgradereport_scale));
$scale_items = $pg_scale->load_items();
foreach ($this->moodle_students as $st) {
if (isset($grades[$st->id])) {
$fg = (int) $grades[$st->id]->finalgrade;
if (isset($scale_items[$fg - 1])) {
$this->moodle_grades[$st->id] = $scale_items[$fg - 1];
} else {
$this->moodle_grades[$st->id] = null;
}
} else {
$this->moodle_grades[$st->id] = null;
}
}
} else {
foreach ($this->moodle_students as $st) {
if (isset($grades[$st->id])) {
$this->moodle_grades[$st->id] = grade_format_gradevalue($grades[$st->id]->finalgrade, $this->course_grade_item, true, $this->course_grade_item->get_displaytype(), null);
} else {
$this->moodle_grades[$st->id] = null;
}
}
}
}
示例2: load_scale
/**
* Instantiates a grade_scale object from the DB if this item's scaleid variable is set
*
* @return grade_scale Returns a grade_scale object or null if no scale used
*/
public function load_scale()
{
if ($this->gradetype != GRADE_TYPE_SCALE) {
$this->scaleid = null;
}
if (!empty($this->scaleid)) {
//do not load scale if already present
if (empty($this->scale->id) or $this->scale->id != $this->scaleid) {
$this->scale = grade_scale::fetch(array('id' => $this->scaleid));
if (!$this->scale) {
debugging('Incorrect scale id: ' . $this->scaleid);
$this->scale = null;
return null;
}
$this->scale->load_items();
}
// Until scales are uniformly set to min=0 max=count(scaleitems)-1 throughout Moodle, we
// stay with the current min=1 max=count(scaleitems)
$this->grademax = count($this->scale->scale_items);
$this->grademin = 1;
} else {
$this->scale = null;
}
return $this->scale;
}
示例3: sub_test_scale_one_item
protected function sub_test_scale_one_item()
{
$params = new stdClass();
$params->name = 'unittestscale1i';
$params->courseid = $this->course->id;
$params->userid = $this->userid;
$params->scale = 'Like';
$params->description = 'This scale is used to like something.';
$params->timemodified = time();
$scale = new grade_scale($params, false);
$scale->load_items();
$this->assertCount(1, $scale->scale_items);
$this->assertSame(array('Like'), $scale->scale_items);
$this->assertSame('Like', $scale->compact_items());
$scale->insert();
// Manual grade item with 1 item scale.
$grade_item = new stdClass();
$grade_item->courseid = $this->course->id;
$grade_item->categoryid = $this->grade_categories[0]->id;
$grade_item->itemname = 'manual grade_item scale_1';
$grade_item->itemtype = 'manual';
$grade_item->itemnumber = 0;
$grade_item->needsupdate = false;
$grade_item->gradetype = GRADE_TYPE_SCALE;
$grade_item->scaleid = $scale->id;
$grade_item->iteminfo = 'Manual grade item used for unit testing';
$grade_item->timecreated = time();
$grade_item->timemodified = time();
$grade_item = new grade_item($grade_item);
$grade_item->insert();
$this->assertNotEmpty($grade_item->id);
$this->assertEquals(1, $grade_item->grademin);
$this->assertEquals(1, $grade_item->grademax);
}