本文整理汇总了PHP中grade_item::delete_all_grades方法的典型用法代码示例。如果您正苦于以下问题:PHP grade_item::delete_all_grades方法的具体用法?PHP grade_item::delete_all_grades怎么用?PHP grade_item::delete_all_grades使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类grade_item
的用法示例。
在下文中一共展示了grade_item::delete_all_grades方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: grade_update
//.........这里部分代码省略.........
$grade_item->insert();
} else {
if ($grade_item->is_locked()) {
// no notice() here, test returned value instead!
return GRADE_UPDATE_ITEM_LOCKED;
}
if ($itemdetails) {
$itemdetails = (array) $itemdetails;
$update = false;
foreach ($itemdetails as $k => $v) {
if (!in_array($k, $allowed)) {
// ignore it
continue;
}
if (in_array($k, $floats)) {
if (grade_floats_different($grade_item->{$k}, $v)) {
$grade_item->{$k} = $v;
$update = true;
}
} else {
if ($grade_item->{$k} != $v) {
$grade_item->{$k} = $v;
$update = true;
}
}
}
if ($update) {
$grade_item->update();
}
}
}
/// reset grades if requested
if (!empty($itemdetails['reset'])) {
$grade_item->delete_all_grades('reset');
return GRADE_UPDATE_OK;
}
/// Some extra checks
// do we use grading?
if ($grade_item->gradetype == GRADE_TYPE_NONE) {
return GRADE_UPDATE_OK;
}
// no grade submitted
if (empty($grades)) {
return GRADE_UPDATE_OK;
}
/// Finally start processing of grades
if (is_object($grades)) {
$grades = array($grades->userid => $grades);
} else {
if (array_key_exists('userid', $grades)) {
$grades = array($grades['userid'] => $grades);
}
}
/// normalize and verify grade array
foreach ($grades as $k => $g) {
if (!is_array($g)) {
$g = (array) $g;
$grades[$k] = $g;
}
if (empty($g['userid']) or $k != $g['userid']) {
debugging('Incorrect grade array index, must be user id! Grade ignored.');
unset($grades[$k]);
}
}
if (empty($grades)) {
return GRADE_UPDATE_FAILED;