本文整理汇总了PHP中grade_item::load_scale方法的典型用法代码示例。如果您正苦于以下问题:PHP grade_item::load_scale方法的具体用法?PHP grade_item::load_scale怎么用?PHP grade_item::load_scale使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类grade_item
的用法示例。
在下文中一共展示了grade_item::load_scale方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: stdClass
}
// check if grade item is locked if so, abort
if ($gradeitem->is_locked()) {
$status = false;
import_cleanup($importcode);
echo $OUTPUT->notification(get_string('gradeitemlocked', 'grades'));
break 3;
}
$newgrade = new stdClass();
$newgrade->itemid = $gradeitem->id;
if ($gradeitem->gradetype == GRADE_TYPE_SCALE and $verbosescales) {
if ($value === '' or $value == '-') {
$value = null;
// no grade
} else {
$scale = $gradeitem->load_scale();
$scales = explode(',', $scale->scale);
$scales = array_map('trim', $scales);
//hack - trim whitespace around scale options
array_unshift($scales, '-');
// scales start at key 1
$key = array_search($value, $scales);
if ($key === false) {
echo "<br/>t0 is {$t0}";
echo "<br/>grade is {$value}";
$status = false;
import_cleanup($importcode);
echo $OUTPUT->notification(get_string('badgrade', 'grades'));
break 3;
}
$value = $key;
示例2: update_grade_item
/**
* This updates existing grade items.
*
* @param int $courseid The course ID.
* @param array $map Mapping information provided by the user.
* @param int $key The line that we are currently working on.
* @param bool $verbosescales Form setting for grading with scales.
* @param string $value The grade value.
* @return array grades to be updated.
*/
protected function update_grade_item($courseid, $map, $key, $verbosescales, $value)
{
// Case of an id, only maps id of a grade_item.
// This was idnumber.
if (!($gradeitem = new grade_item(array('id' => $map[$key], 'courseid' => $courseid)))) {
// Supplied bad mapping, should not be possible since user
// had to pick mapping.
$this->cleanup_import(get_string('importfailed', 'grades'));
return null;
}
// Check if grade item is locked if so, abort.
if ($gradeitem->is_locked()) {
$this->cleanup_import(get_string('gradeitemlocked', 'grades'));
return null;
}
$newgrade = new stdClass();
$newgrade->itemid = $gradeitem->id;
if ($gradeitem->gradetype == GRADE_TYPE_SCALE and $verbosescales) {
if ($value === '' or $value == '-') {
$value = null;
// No grade.
} else {
$scale = $gradeitem->load_scale();
$scales = explode(',', $scale->scale);
$scales = array_map('trim', $scales);
// Hack - trim whitespace around scale options.
array_unshift($scales, '-');
// Scales start at key 1.
$key = array_search($value, $scales);
if ($key === false) {
$this->cleanup_import(get_string('badgrade', 'grades'));
return null;
}
$value = $key;
}
$newgrade->finalgrade = $value;
} else {
if ($value === '' or $value == '-') {
$value = null;
// No grade.
} else {
// If the value has a local decimal or can correctly be unformatted, do it.
$validvalue = unformat_float($value, true);
if ($validvalue !== false) {
$value = $validvalue;
} else {
// Non numeric grade value supplied, possibly mapped wrong column.
$this->cleanup_import(get_string('badgrade', 'grades'));
return null;
}
}
$newgrade->finalgrade = $value;
}
$this->newgrades[] = $newgrade;
return $this->newgrades;
}