本文整理汇总了PHP中grade_grade::get_aggregation_hint方法的典型用法代码示例。如果您正苦于以下问题:PHP grade_grade::get_aggregation_hint方法的具体用法?PHP grade_grade::get_aggregation_hint怎么用?PHP grade_grade::get_aggregation_hint使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类grade_grade
的用法示例。
在下文中一共展示了grade_grade::get_aggregation_hint方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: fill_table_recursive
/**
* Fill the table with data.
*
* @param $element - An array containing the table data for the current row.
*/
private function fill_table_recursive(&$element)
{
global $DB, $CFG;
$type = $element['type'];
$depth = $element['depth'];
$grade_object = $element['object'];
$eid = $grade_object->id;
$element['userid'] = $this->user->id;
$fullname = $this->gtree->get_element_header($element, true, true, true, true, true);
$data = array();
$gradeitemdata = array();
$hidden = '';
$excluded = '';
$itemlevel = $type == 'categoryitem' || $type == 'category' || $type == 'courseitem' ? $depth : $depth + 1;
$class = 'level' . $itemlevel . ' level' . ($itemlevel % 2 ? 'odd' : 'even');
$classfeedback = '';
// If this is a hidden grade category, hide it completely from the user
if ($type == 'category' && $grade_object->is_hidden() && !$this->canviewhidden && ($this->showhiddenitems == GRADE_REPORT_USER_HIDE_HIDDEN || $this->showhiddenitems == GRADE_REPORT_USER_HIDE_UNTIL && !$grade_object->is_hiddenuntil())) {
return false;
}
if ($type == 'category') {
$this->evenodd[$depth] = ($this->evenodd[$depth] + 1) % 2;
}
$alter = $this->evenodd[$depth] == 0 ? 'even' : 'odd';
/// Process those items that have scores associated
if ($type == 'item' or $type == 'categoryitem' or $type == 'courseitem') {
$header_row = "row_{$eid}_{$this->user->id}";
$header_cat = "cat_{$grade_object->categoryid}_{$this->user->id}";
if (!($grade_grade = grade_grade::fetch(array('itemid' => $grade_object->id, 'userid' => $this->user->id)))) {
$grade_grade = new grade_grade();
$grade_grade->userid = $this->user->id;
$grade_grade->itemid = $grade_object->id;
}
$grade_grade->load_grade_item();
/// Hidden Items
if ($grade_grade->grade_item->is_hidden()) {
$hidden = ' dimmed_text';
}
$hide = false;
// If this is a hidden grade item, hide it completely from the user.
if ($grade_grade->is_hidden() && !$this->canviewhidden && ($this->showhiddenitems == GRADE_REPORT_USER_HIDE_HIDDEN || $this->showhiddenitems == GRADE_REPORT_USER_HIDE_UNTIL && !$grade_grade->is_hiddenuntil())) {
$hide = true;
} else {
if (!empty($grade_object->itemmodule) && !empty($grade_object->iteminstance)) {
// The grade object can be marked visible but still be hidden if
// the student cannot see the activity due to conditional access
// and it's set to be hidden entirely.
$instances = $this->modinfo->get_instances_of($grade_object->itemmodule);
if (!empty($instances[$grade_object->iteminstance])) {
$cm = $instances[$grade_object->iteminstance];
$gradeitemdata['cmid'] = $cm->id;
if (!$cm->uservisible) {
// If there is 'availableinfo' text then it is only greyed
// out and not entirely hidden.
if (!$cm->availableinfo) {
$hide = true;
}
}
}
}
}
// Actual Grade - We need to calculate this whether the row is hidden or not.
$gradeval = $grade_grade->finalgrade;
$hint = $grade_grade->get_aggregation_hint();
if (!$this->canviewhidden) {
/// Virtual Grade (may be calculated excluding hidden items etc).
$adjustedgrade = $this->blank_hidden_total_and_adjust_bounds($this->courseid, $grade_grade->grade_item, $gradeval);
$gradeval = $adjustedgrade['grade'];
// We temporarily adjust the view of this grade item - because the min and
// max are affected by the hidden values in the aggregation.
$grade_grade->grade_item->grademax = $adjustedgrade['grademax'];
$grade_grade->grade_item->grademin = $adjustedgrade['grademin'];
$hint['status'] = $adjustedgrade['aggregationstatus'];
$hint['weight'] = $adjustedgrade['aggregationweight'];
} else {
// The max and min for an aggregation may be different to the grade_item.
if (!is_null($gradeval)) {
$grade_grade->grade_item->grademax = $grade_grade->get_grade_max();
$grade_grade->grade_item->grademin = $grade_grade->get_grade_min();
}
}
if (!$hide) {
/// Excluded Item
/**
if ($grade_grade->is_excluded()) {
$fullname .= ' ['.get_string('excluded', 'grades').']';
$excluded = ' excluded';
}
**/
/// Other class information
$class .= $hidden . $excluded;
if ($this->switch) {
// alter style based on whether aggregation is first or last
$class .= ($type == 'categoryitem' or $type == 'courseitem') ? " " . $alter . "d{$depth} baggt b2b" : " item b1b";
} else {
//.........这里部分代码省略.........
示例2: blank_hidden_total_and_adjust_bounds
/**
* Optionally blank out course/category totals if they contain any hidden items
* @param string $courseid the course id
* @param string $course_item an instance of grade_item
* @param string $finalgrade the grade for the course_item
* @return array[] containing values for 'grade', 'grademax', 'grademin', 'aggregationstatus' and 'aggregationweight'
*/
protected function blank_hidden_total_and_adjust_bounds($courseid, $course_item, $finalgrade)
{
global $CFG, $DB;
static $hiding_affected = null;
//array of items in this course affected by hiding
// If we're dealing with multiple users we need to know when we've moved on to a new user.
static $previous_userid = null;
// If we're dealing with multiple courses we need to know when we've moved on to a new course.
static $previous_courseid = null;
$coursegradegrade = grade_grade::fetch(array('userid' => $this->user->id, 'itemid' => $course_item->id));
$grademin = $course_item->grademin;
$grademax = $course_item->grademax;
if ($coursegradegrade) {
$grademin = $coursegradegrade->rawgrademin;
$grademax = $coursegradegrade->rawgrademax;
} else {
$coursegradegrade = new grade_grade(array('userid' => $this->user->id, 'itemid' => $course_item->id), false);
}
$hint = $coursegradegrade->get_aggregation_hint();
$aggregationstatus = $hint['status'];
$aggregationweight = $hint['weight'];
if (!is_array($this->showtotalsifcontainhidden)) {
debugging('showtotalsifcontainhidden should be an array', DEBUG_DEVELOPER);
$this->showtotalsifcontainhidden = array($courseid => $this->showtotalsifcontainhidden);
}
if ($this->showtotalsifcontainhidden[$courseid] == GRADE_REPORT_SHOW_REAL_TOTAL_IF_CONTAINS_HIDDEN) {
return array('grade' => $finalgrade, 'grademin' => $grademin, 'grademax' => $grademax, 'aggregationstatus' => $aggregationstatus, 'aggregationweight' => $aggregationweight);
}
// If we've moved on to another course or user, reload the grades.
if ($previous_userid != $this->user->id || $previous_courseid != $courseid) {
$hiding_affected = null;
$previous_userid = $this->user->id;
$previous_courseid = $courseid;
}
if (!$hiding_affected) {
$items = grade_item::fetch_all(array('courseid' => $courseid));
$grades = array();
$sql = "SELECT g.*\n FROM {grade_grades} g\n JOIN {grade_items} gi ON gi.id = g.itemid\n WHERE g.userid = {$this->user->id} AND gi.courseid = {$courseid}";
if ($gradesrecords = $DB->get_records_sql($sql)) {
foreach ($gradesrecords as $grade) {
$grades[$grade->itemid] = new grade_grade($grade, false);
}
unset($gradesrecords);
}
foreach ($items as $itemid => $unused) {
if (!isset($grades[$itemid])) {
$grade_grade = new grade_grade();
$grade_grade->userid = $this->user->id;
$grade_grade->itemid = $items[$itemid]->id;
$grades[$itemid] = $grade_grade;
}
$grades[$itemid]->grade_item =& $items[$itemid];
}
$hiding_affected = grade_grade::get_hiding_affected($grades, $items);
}
//if the item definitely depends on a hidden item
if (array_key_exists($course_item->id, $hiding_affected['altered']) || array_key_exists($course_item->id, $hiding_affected['alteredgrademin']) || array_key_exists($course_item->id, $hiding_affected['alteredgrademax']) || array_key_exists($course_item->id, $hiding_affected['alteredaggregationstatus']) || array_key_exists($course_item->id, $hiding_affected['alteredaggregationweight'])) {
if (!$this->showtotalsifcontainhidden[$courseid] && array_key_exists($course_item->id, $hiding_affected['altered'])) {
// Hide the grade, but only when it has changed.
$finalgrade = null;
} else {
//use reprocessed marks that exclude hidden items
if (array_key_exists($course_item->id, $hiding_affected['altered'])) {
$finalgrade = $hiding_affected['altered'][$course_item->id];
}
if (array_key_exists($course_item->id, $hiding_affected['alteredgrademin'])) {
$grademin = $hiding_affected['alteredgrademin'][$course_item->id];
}
if (array_key_exists($course_item->id, $hiding_affected['alteredgrademax'])) {
$grademax = $hiding_affected['alteredgrademax'][$course_item->id];
}
if (array_key_exists($course_item->id, $hiding_affected['alteredaggregationstatus'])) {
$aggregationstatus = $hiding_affected['alteredaggregationstatus'][$course_item->id];
}
if (array_key_exists($course_item->id, $hiding_affected['alteredaggregationweight'])) {
$aggregationweight = $hiding_affected['alteredaggregationweight'][$course_item->id];
}
if (!$this->showtotalsifcontainhidden[$courseid]) {
// If the course total is hidden we must hide the weight otherwise
// it can be used to compute the course total.
$aggregationstatus = 'unknown';
$aggregationweight = null;
}
}
} else {
if (!empty($hiding_affected['unknown'][$course_item->id])) {
//not sure whether or not this item depends on a hidden item
if (!$this->showtotalsifcontainhidden[$courseid]) {
//hide the grade
$finalgrade = null;
} else {
//use reprocessed marks that exclude hidden items
$finalgrade = $hiding_affected['unknown'][$course_item->id];
//.........这里部分代码省略.........