本文整理汇总了PHP中grade_grade::set_locked方法的典型用法代码示例。如果您正苦于以下问题:PHP grade_grade::set_locked方法的具体用法?PHP grade_grade::set_locked怎么用?PHP grade_grade::set_locked使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类grade_grade
的用法示例。
在下文中一共展示了grade_grade::set_locked方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1:
} else {
$grade_grade->set_hidden($hidden);
// checkbox data might be undefined
}
}
}
if (isset($data->locked) and !$grade_item->is_locked()) {
if (($old_grade_grade->locked or $old_grade_grade->locktime) and (!has_capability('moodle/grade:manage', $context) and !has_capability('moodle/grade:unlock', $context))) {
//ignore data
} else {
if (!$old_grade_grade->locked and !$old_grade_grade->locktime and (!has_capability('moodle/grade:manage', $context) and !has_capability('moodle/grade:lock', $context))) {
//ignore data
} else {
$grade_grade->set_locktime($data->locktime);
//set_lock may reset locktime
$grade_grade->set_locked($data->locked, false, true);
// reload grade in case it was regraded from activity
$grade_grade = new grade_grade(array('userid' => $data->userid, 'itemid' => $grade_item->id), true);
$grade_grade->grade_item =& $grade_item;
// no db fetching
}
}
}
if (isset($data->excluded) and has_capability('moodle/grade:manage', $context)) {
$grade_grade->set_excluded($data->excluded);
}
// detect cases when we need to do full regrading
if ($old_grade_grade->excluded != $grade_grade->excluded) {
$parent = $grade_item->get_parent_category();
$parent->force_regrading();
} else {
示例2: time
/**
* Locks or unlocks this grade_item and (optionally) all its associated final grades.
* @param int $locked 0, 1 or a timestamp int(10) after which date the item will be locked.
* @param boolean $cascade lock/unlock child objects too
* @param boolean $refresh refresh grades when unlocking
* @return boolean true if grade_item all grades updated, false if at least one update fails
*/
function set_locked($lockedstate, $cascade = false, $refresh = true)
{
if ($lockedstate) {
/// setting lock
if ($this->needsupdate) {
return false;
// can not lock grade without first having final grade
}
$this->locked = time();
$this->update();
if ($cascade) {
$grades = $this->get_final();
foreach ($grades as $g) {
$grade = new grade_grade($g, false);
$grade->grade_item =& $this;
$grade->set_locked(1, null, false);
}
}
return true;
} else {
/// removing lock
if (!empty($this->locked) and $this->locktime < time()) {
//we have to reset locktime or else it would lock up again
$this->locktime = 0;
}
$this->locked = 0;
$this->update();
if ($cascade) {
if ($grades = grade_grade::fetch_all(array('itemid' => $this->id))) {
foreach ($grades as $grade) {
$grade->grade_item =& $this;
$grade->set_locked(0, null, false);
}
}
}
if ($refresh) {
//refresh when unlocking
$this->refresh_grades();
}
return true;
}
}