本文整理汇总了PHP中grade_grade::get_dategraded方法的典型用法代码示例。如果您正苦于以下问题:PHP grade_grade::get_dategraded方法的具体用法?PHP grade_grade::get_dategraded怎么用?PHP grade_grade::get_dategraded使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类grade_grade
的用法示例。
在下文中一共展示了grade_grade::get_dategraded方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: grade_get_course_grade
/**
* Returns the aggregated or calculated course grade for the given user(s).
* @public
* @param int $userid
* @param int $courseid optional id of course or array of ids, empty means all uses courses (returns array if not present)
* @return mixed grade info or grades array including item info, false if error
*/
function grade_get_course_grade($userid, $courseid_or_ids = null)
{
if (!is_array($courseid_or_ids)) {
if (empty($courseid_or_ids)) {
if (!($courses = enrol_get_users_courses($userid))) {
return false;
}
$courseids = array_keys($courses);
return grade_get_course_grade($userid, $courseids);
}
if (!is_numeric($courseid_or_ids)) {
return false;
}
if (!($grades = grade_get_course_grade($userid, array($courseid_or_ids)))) {
return false;
} else {
// only one grade - not array
$grade = reset($grades);
return $grade;
}
}
foreach ($courseid_or_ids as $courseid) {
$grade_item = grade_item::fetch_course_item($courseid);
$course_items[$grade_item->courseid] = $grade_item;
}
$grades = array();
foreach ($course_items as $grade_item) {
if ($grade_item->needsupdate) {
grade_regrade_final_grades($courseid);
}
$item = new stdClass();
$item->scaleid = $grade_item->scaleid;
$item->name = $grade_item->get_name();
$item->grademin = $grade_item->grademin;
$item->grademax = $grade_item->grademax;
$item->gradepass = $grade_item->gradepass;
$item->locked = $grade_item->is_locked();
$item->hidden = $grade_item->is_hidden();
switch ($grade_item->gradetype) {
case GRADE_TYPE_NONE:
continue;
case GRADE_TYPE_VALUE:
$item->scaleid = 0;
break;
case GRADE_TYPE_TEXT:
$item->scaleid = 0;
$item->grademin = 0;
$item->grademax = 0;
$item->gradepass = 0;
break;
}
$grade_grade = new grade_grade(array('userid' => $userid, 'itemid' => $grade_item->id));
$grade_grade->grade_item =& $grade_item;
$grade = new stdClass();
$grade->grade = $grade_grade->finalgrade;
$grade->locked = $grade_grade->is_locked();
$grade->hidden = $grade_grade->is_hidden();
$grade->overridden = $grade_grade->overridden;
$grade->feedback = $grade_grade->feedback;
$grade->feedbackformat = $grade_grade->feedbackformat;
$grade->usermodified = $grade_grade->usermodified;
$grade->dategraded = $grade_grade->get_dategraded();
$grade->item = $item;
// create text representation of grade
if ($grade_item->needsupdate) {
$grade->grade = false;
$grade->str_grade = get_string('error');
$grade->str_long_grade = $grade->str_grade;
} else {
if (is_null($grade->grade)) {
$grade->str_grade = '-';
$grade->str_long_grade = $grade->str_grade;
} else {
$grade->str_grade = grade_format_gradevalue($grade->grade, $grade_item);
if ($grade_item->gradetype == GRADE_TYPE_SCALE or $grade_item->get_displaytype() != GRADE_DISPLAY_TYPE_REAL) {
$grade->str_long_grade = $grade->str_grade;
} else {
$a = new stdClass();
$a->grade = $grade->str_grade;
$a->max = grade_format_gradevalue($grade_item->grademax, $grade_item);
$grade->str_long_grade = get_string('gradelong', 'grades', $a);
}
}
}
// create html representation of feedback
if (is_null($grade->feedback)) {
$grade->str_feedback = '';
} else {
$grade->str_feedback = format_text($grade->feedback, $grade->feedbackformat);
}
$grades[$grade_item->courseid] = $grade;
}
return $grades;
//.........这里部分代码省略.........
示例2: fill_table_recursive
//.........这里部分代码省略.........
$gradeitemdata['itemmodule'] = $grade_object->itemmodule;
$gradeitemdata['iteminstance'] = $grade_object->iteminstance;
$gradeitemdata['itemnumber'] = $grade_object->itemnumber;
$gradeitemdata['categoryid'] = $grade_object->categoryid;
$gradeitemdata['outcomeid'] = $grade_object->outcomeid;
$gradeitemdata['scaleid'] = $grade_object->outcomeid;
if ($this->showfeedback) {
// Copy $class before appending itemcenter as feedback should not be centered
$classfeedback = $class;
}
$class .= " itemcenter ";
if ($this->showweight) {
$data['weight']['class'] = $class;
$data['weight']['content'] = '-';
$data['weight']['headers'] = "{$header_cat} {$header_row} weight";
// has a weight assigned, might be extra credit
// This obliterates the weight because it provides a more informative description.
if (is_numeric($hint['weight'])) {
$data['weight']['content'] = format_float($hint['weight'] * 100.0, 2) . ' %';
$gradeitemdata['weightraw'] = $hint['weight'];
$gradeitemdata['weightformatted'] = $data['weight']['content'];
}
if ($hint['status'] != 'used' && $hint['status'] != 'unknown') {
$data['weight']['content'] .= '<br>' . get_string('aggregationhint' . $hint['status'], 'grades');
$gradeitemdata['status'] = $hint['status'];
}
}
if ($this->showgrade) {
$gradeitemdata['graderaw'] = null;
$gradeitemdata['gradehiddenbydate'] = false;
$gradeitemdata['gradeneedsupdate'] = $grade_grade->grade_item->needsupdate;
$gradeitemdata['gradeishidden'] = $grade_grade->is_hidden();
$gradeitemdata['gradedatesubmitted'] = $grade_grade->get_datesubmitted();
$gradeitemdata['gradedategraded'] = $grade_grade->get_dategraded();
if ($grade_grade->grade_item->needsupdate) {
$data['grade']['class'] = $class . ' gradingerror';
$data['grade']['content'] = get_string('error');
} else {
if (!empty($CFG->grade_hiddenasdate) and $grade_grade->get_datesubmitted() and !$this->canviewhidden and $grade_grade->is_hidden() and !$grade_grade->grade_item->is_category_item() and !$grade_grade->grade_item->is_course_item()) {
// the problem here is that we do not have the time when grade value was modified, 'timemodified' is general modification date for grade_grades records
$class .= ' datesubmitted';
$data['grade']['class'] = $class;
$data['grade']['content'] = get_string('submittedon', 'grades', userdate($grade_grade->get_datesubmitted(), get_string('strftimedatetimeshort')));
$gradeitemdata['gradehiddenbydate'] = true;
} else {
if ($grade_grade->is_hidden()) {
$data['grade']['class'] = $class . ' dimmed_text';
$data['grade']['content'] = '-';
if ($this->canviewhidden) {
$gradeitemdata['graderaw'] = $gradeval;
$data['grade']['content'] = grade_format_gradevalue($gradeval, $grade_grade->grade_item, true);
}
} else {
$data['grade']['class'] = $class;
$data['grade']['content'] = grade_format_gradevalue($gradeval, $grade_grade->grade_item, true);
$gradeitemdata['graderaw'] = $gradeval;
}
}
}
$data['grade']['headers'] = "{$header_cat} {$header_row} grade";
$gradeitemdata['gradeformatted'] = $data['grade']['content'];
}
// Range
if ($this->showrange) {
$data['range']['class'] = $class;
$data['range']['content'] = $grade_grade->grade_item->get_formatted_range(GRADE_DISPLAY_TYPE_REAL, $this->rangedecimals);
示例3: prepare_import_grade_data
//.........这里部分代码省略.........
while ($line = $csvimport->next()) {
if (count($line) <= 1) {
// There is no data on this line, move on.
continue;
}
// Array to hold all grades to be inserted.
$this->newgrades = array();
// Array to hold all feedback.
$this->newfeedbacks = array();
// Each line is a student record.
foreach ($line as $key => $value) {
$value = clean_param($value, PARAM_RAW);
$value = trim($value);
/*
* the options are
* 1) userid, useridnumber, usermail, username - used to identify user row
* 2) new - new grade item
* 3) id - id of the old grade item to map onto
* 3) feedback_id - feedback for grade item id
*/
// Explode the mapping for feedback into a label 'feedback' and the identifying number.
$mappingbase = explode("_", $map[$key]);
$mappingidentifier = $mappingbase[0];
// Set the feedback identifier if it exists.
if (isset($mappingbase[1])) {
$feedbackgradeid = (int) $mappingbase[1];
} else {
$feedbackgradeid = '';
}
$this->map_user_data_with_value($mappingidentifier, $value, $header, $map, $key, $courseid, $feedbackgradeid, $verbosescales);
if ($this->status === false) {
return $this->status;
}
}
// No user mapping supplied at all, or user mapping failed.
if (empty($this->studentid) || !is_numeric($this->studentid)) {
// User not found, abort whole import.
$this->cleanup_import(get_string('usermappingerrorusernotfound', 'grades'));
break;
}
if ($separatemode and !groups_is_member($currentgroup, $this->studentid)) {
// Not allowed to import into this group, abort.
$this->cleanup_import(get_string('usermappingerrorcurrentgroup', 'grades'));
break;
}
// Insert results of this students into buffer.
if ($this->status and !empty($this->newgrades)) {
foreach ($this->newgrades as $newgrade) {
// Check if grade_grade is locked and if so, abort.
if (!empty($newgrade->itemid) and $gradegrade = new grade_grade(array('itemid' => $newgrade->itemid, 'userid' => $this->studentid))) {
if ($gradegrade->is_locked()) {
// Individual grade locked.
$this->cleanup_import(get_string('gradelocked', 'grades'));
return $this->status;
}
// Check if the force import option is disabled and the last exported date column is present.
if (!$forceimport && !empty($timeexportkey)) {
$exportedtime = $line[$timeexportkey];
if (clean_param($exportedtime, PARAM_INT) != $exportedtime || $exportedtime > time() || $exportedtime < strtotime("-1 year", time())) {
// The date is invalid, or in the future, or more than a year old.
$this->cleanup_import(get_string('invalidgradeexporteddate', 'grades'));
return $this->status;
}
$timemodified = $gradegrade->get_dategraded();
if (!empty($timemodified) && $exportedtime < $timemodified) {
// The item was graded after we exported it, we return here not to override it.
$user = core_user::get_user($this->studentid);
$this->cleanup_import(get_string('gradealreadyupdated', 'grades', fullname($user)));
return $this->status;
}
}
}
$insertid = self::insert_grade_record($newgrade, $this->studentid);
// Check to see if the insert was successful.
if (empty($insertid)) {
return null;
}
}
}
// Updating/inserting all comments here.
if ($this->status and !empty($this->newfeedbacks)) {
foreach ($this->newfeedbacks as $newfeedback) {
$sql = "SELECT *\n FROM {grade_import_values}\n WHERE importcode=? AND userid=? AND itemid=? AND importer=?";
if ($feedback = $DB->get_record_sql($sql, array($this->importcode, $this->studentid, $newfeedback->itemid, $USER->id))) {
$newfeedback->id = $feedback->id;
$DB->update_record('grade_import_values', $newfeedback);
} else {
// The grade item for this is not updated.
$newfeedback->importonlyfeedback = true;
$insertid = self::insert_grade_record($newfeedback, $this->studentid);
// Check to see if the insert was successful.
if (empty($insertid)) {
return null;
}
}
}
}
}
return $this->status;
}