本文整理汇总了PHP中grade_grade::get_locktime方法的典型用法代码示例。如果您正苦于以下问题:PHP grade_grade::get_locktime方法的具体用法?PHP grade_grade::get_locktime怎么用?PHP grade_grade::get_locktime使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类grade_grade
的用法示例。
在下文中一共展示了grade_grade::get_locktime方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: object
/**
* Updates raw grade value for given user, this is a only way to update raw
* grades from external source (modules, etc.),
* because it logs the change in history table and deals with final grade recalculation.
*
* @param int $userid the graded user
* @param mixed $rawgrade float value of raw grade - false means do not change
* @param string $howmodified modification source
* @param string $note optional note
* @param mixed $feedback teachers feedback as string - false means do not change
* @param int $feedbackformat
* @return boolean success
*/
function update_raw_grade($userid, $rawgrade = false, $source = NULL, $note = NULL, $feedback = false, $feedbackformat = FORMAT_MOODLE, $usermodified = null)
{
global $USER;
if (empty($usermodified)) {
$usermodified = $USER->id;
}
$result = true;
// calculated grades can not be updated; course and category can not be updated because they are aggregated
if ($this->is_calculated() or $this->is_outcome_item() or !$this->is_normal_item() or $this->gradetype == GRADE_TYPE_NONE or $this->is_locked()) {
return false;
}
$grade = new grade_grade(array('itemid' => $this->id, 'userid' => $userid));
$grade->grade_item =& $this;
// prevent db fetching of this grade_item
$grade->usermodified = $usermodified;
if ($grade->is_locked()) {
// do not update locked grades at all
return false;
}
$locktime = $grade->get_locktime();
if ($locktime and $locktime < time()) {
// do not update grades that should be already locked and force regrade
$this->force_regrading();
return false;
}
$oldgrade = new object();
$oldgrade->finalgrade = $grade->finalgrade;
$oldgrade->rawgrade = $grade->rawgrade;
$oldgrade->rawgrademin = $grade->rawgrademin;
$oldgrade->rawgrademax = $grade->rawgrademax;
$oldgrade->rawscaleid = $grade->rawscaleid;
$oldgrade->feedback = $grade->feedback;
$oldgrade->feedbackformat = $grade->feedbackformat;
// fist copy current grademin/max and scale
$grade->rawgrademin = $this->grademin;
$grade->rawgrademax = $this->grademax;
$grade->rawscaleid = $this->scaleid;
// change raw grade?
if ($rawgrade !== false) {
$grade->rawgrade = $rawgrade;
}
// do we have comment from teacher?
if ($feedback !== false) {
$grade->feedback = $feedback;
$grade->feedbackformat = $feedbackformat;
}
if (empty($grade->id)) {
$result = (bool) $grade->insert($source);
} else {
if ($grade->finalgrade !== $oldgrade->finalgrade or $grade->rawgrade !== $oldgrade->rawgrade or $grade->rawgrademin !== $oldgrade->rawgrademin or $grade->rawgrademax !== $oldgrade->rawgrademax or $grade->rawscaleid !== $oldgrade->rawscaleid or $grade->feedback !== $oldgrade->feedback or $grade->feedbackformat !== $oldgrade->feedbackformat) {
$result = $grade->update($source);
}
}
if (!$result) {
// something went wrong - better force final grade recalculation
$this->force_regrading();
} else {
if (!$this->needsupdate) {
$course_item = grade_item::fetch_course_item($this->courseid);
if (!$course_item->needsupdate) {
if (!grade_regrade_final_grades($this->courseid, $userid, $this)) {
$this->force_regrading();
}
} else {
$this->force_regrading();
}
}
}
return $result;
}
示例2: object
/**
* Updates raw grade value for given user, this is a only way to update raw
* grades from external source (modules, etc.),
* because it logs the change in history table and deals with final grade recalculation.
*
* @param int $userid the graded user
* @param mixed $rawgrade float value of raw grade - false means do not change
* @param string $howmodified modification source
* @param string $note optional note
* @param mixed $feedback teachers feedback as string - false means do not change
* @param int $feedbackformat
* @param int $usermodified - user which did the grading
* @param int $dategraded
* @param int $datesubmitted
* @param object $grade object - usefull for bulk upgrades
* @return boolean success
*/
function update_raw_grade($userid, $rawgrade = false, $source = NULL, $feedback = false, $feedbackformat = FORMAT_MOODLE, $usermodified = null, $dategraded = null, $datesubmitted = null, $grade = null)
{
global $USER;
$result = true;
// calculated grades can not be updated; course and category can not be updated because they are aggregated
if (!$this->is_raw_used() or $this->gradetype == GRADE_TYPE_NONE or $this->is_locked()) {
return false;
}
if (is_null($grade)) {
//fetch from db
$grade = new grade_grade(array('itemid' => $this->id, 'userid' => $userid));
}
$grade->grade_item =& $this;
// prevent db fetching of this grade_item
if (empty($usermodified)) {
$grade->usermodified = $USER->id;
} else {
$grade->usermodified = $usermodified;
}
if ($grade->is_locked()) {
// do not update locked grades at all
return false;
}
$locktime = $grade->get_locktime();
if ($locktime and $locktime < time()) {
// do not update grades that should be already locked and force regrade
$this->force_regrading();
return false;
}
$oldgrade = new object();
$oldgrade->finalgrade = $grade->finalgrade;
$oldgrade->rawgrade = $grade->rawgrade;
$oldgrade->rawgrademin = $grade->rawgrademin;
$oldgrade->rawgrademax = $grade->rawgrademax;
$oldgrade->rawscaleid = $grade->rawscaleid;
$oldgrade->feedback = $grade->feedback;
$oldgrade->feedbackformat = $grade->feedbackformat;
// use new min and max
$grade->rawgrade = $grade->rawgrade;
$grade->rawgrademin = $this->grademin;
$grade->rawgrademax = $this->grademax;
$grade->rawscaleid = $this->scaleid;
// change raw grade?
if ($rawgrade !== false) {
$grade->rawgrade = $rawgrade;
}
// empty feedback means no feedback at all
if ($feedback === '') {
$feedback = null;
}
// do we have comment from teacher?
if ($feedback !== false and !$grade->is_overridden()) {
$grade->feedback = $feedback;
$grade->feedbackformat = $feedbackformat;
}
// update final grade if possible
if (!$grade->is_locked() and !$grade->is_overridden()) {
$grade->finalgrade = $this->adjust_raw_grade($grade->rawgrade, $grade->rawgrademin, $grade->rawgrademax);
}
// TODO: hack alert - create new fields for these in 2.0
$oldgrade->timecreated = $grade->timecreated;
$oldgrade->timemodified = $grade->timemodified;
$grade->timecreated = $datesubmitted;
if ($grade->is_overridden()) {
// keep original graded date - update_final_grade() sets this for overridden grades
} else {
if (is_null($grade->rawgrade) and is_null($grade->feedback)) {
// no grade and feedback means no grading yet
$grade->timemodified = null;
} else {
if (!empty($dategraded)) {
// fine - module sends info when graded (yay!)
$grade->timemodified = $dategraded;
} else {
if (grade_floats_different($grade->finalgrade, $oldgrade->finalgrade) or $grade->feedback !== $oldgrade->feedback) {
// guess - if either grade or feedback changed set new graded date
$grade->timemodified = time();
} else {
//keep original graded date
}
}
}
}
//.........这里部分代码省略.........
示例3: object
/**
* Updates final grade value for given user, this is a only way to update final
* grades from gradebook and import because it logs the change in history table
* and deals with overridden flag. This flag is set to prevent later overriding
* from raw grades submitted from modules.
*
* @param int $userid the graded user
* @param mixed $finalgrade float value of final grade - false means do not change
* @param string $howmodified modification source
* @param string $note optional note
* @param mixed $feedback teachers feedback as string - false means do not change
* @param int $feedbackformat
* @return boolean success
*/
function update_final_grade($userid, $finalgrade = false, $source = NULL, $feedback = false, $feedbackformat = FORMAT_MOODLE, $usermodified = null)
{
global $USER, $CFG;
$result = true;
// no grading used or locked
if ($this->gradetype == GRADE_TYPE_NONE or $this->is_locked()) {
return false;
}
$grade = new grade_grade(array('itemid' => $this->id, 'userid' => $userid));
$grade->grade_item =& $this;
// prevent db fetching of this grade_item
if (empty($usermodified)) {
$grade->usermodified = $USER->id;
} else {
$grade->usermodified = $usermodified;
}
if ($grade->is_locked()) {
// do not update locked grades at all
return false;
}
$locktime = $grade->get_locktime();
if ($locktime and $locktime < time()) {
// do not update grades that should be already locked, force regrade instead
$this->force_regrading();
return false;
}
$oldgrade = new object();
$oldgrade->finalgrade = $grade->finalgrade;
$oldgrade->overridden = $grade->overridden;
$oldgrade->feedback = $grade->feedback;
$oldgrade->feedbackformat = $grade->feedbackformat;
// changed grade?
if ($finalgrade !== false) {
if ($this->is_overridable_item()) {
$grade->overridden = time();
} else {
$grade->overridden = 0;
}
$grade->finalgrade = $this->bounded_grade($finalgrade);
}
// do we have comment from teacher?
if ($feedback !== false) {
if ($this->is_overridable_item_feedback()) {
// external items (modules, plugins) may have own feedback
$grade->overridden = time();
}
$grade->feedback = $feedback;
$grade->feedbackformat = $feedbackformat;
}
// HACK: Bob Puffer to allow accurate max score to be inserted into the grade_item record
$grade->rawgrademax = $this->grademax;
// END OF HACK
if (empty($grade->id)) {
$grade->timecreated = null;
// hack alert - date submitted - no submission yet
$grade->timemodified = time();
// hack alert - date graded
$result = (bool) $grade->insert($source);
} else {
if (grade_floats_different($grade->finalgrade, $oldgrade->finalgrade) or $grade->feedback !== $oldgrade->feedback or $grade->feedbackformat != $oldgrade->feedbackformat or $grade->overridden != $oldgrade->overridden) {
$grade->timemodified = time();
// hack alert - date graded
$result = $grade->update($source);
} else {
// no grade change
return $result;
}
}
if (!$result) {
// something went wrong - better force final grade recalculation
$this->force_regrading();
} else {
if ($this->is_course_item() and !$this->needsupdate) {
if (grade_regrade_final_grades($this->courseid, $userid, $this) !== true) {
$this->force_regrading();
}
} else {
if (!$this->needsupdate) {
$course_item = grade_item_local::fetch_course_item($this->courseid);
if (!$course_item->needsupdate) {
if (grade_regrade_final_grades_local($this->courseid, $userid, $this) !== true) {
$this->force_regrading();
}
} else {
$this->force_regrading();
}
//.........这里部分代码省略.........