本文整理汇总了PHP中grade_tree::can_output_item方法的典型用法代码示例。如果您正苦于以下问题:PHP grade_tree::can_output_item方法的具体用法?PHP grade_tree::can_output_item怎么用?PHP grade_tree::can_output_item使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类grade_tree
的用法示例。
在下文中一共展示了grade_tree::can_output_item方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: get_right_rows
/**
* Builds and returns the rows that will make up the right part of the grader report
* @param boolean $displayaverages whether to display average rows in the table
* @return array Array of html_table_row objects
*/
public function get_right_rows($displayaverages)
{
global $CFG, $USER, $OUTPUT, $DB, $PAGE;
$rows = array();
$this->rowcount = 0;
$numrows = count($this->gtree->get_levels());
$numusers = count($this->users);
$gradetabindex = 1;
$columnstounset = array();
$strgrade = $this->get_lang_string('grade');
$strfeedback = $this->get_lang_string("feedback");
$arrows = $this->get_sort_arrows();
$jsarguments = array('cfg' => array('ajaxenabled' => false), 'items' => array(), 'users' => array(), 'feedback' => array(), 'grades' => array());
$jsscales = array();
// Get preferences once.
$showactivityicons = $this->get_pref('showactivityicons');
$quickgrading = $this->get_pref('quickgrading');
$showquickfeedback = $this->get_pref('showquickfeedback');
$enableajax = $this->get_pref('enableajax');
$showanalysisicon = $this->get_pref('showanalysisicon');
// Get strings which are re-used inside the loop.
$strftimedatetimeshort = get_string('strftimedatetimeshort');
$strexcludedgrades = get_string('excluded', 'grades');
$strerror = get_string('error');
foreach ($this->gtree->get_levels() as $key => $row) {
$headingrow = new html_table_row();
$headingrow->attributes['class'] = 'heading_name_row';
foreach ($row as $columnkey => $element) {
$sortlink = clone $this->baseurl;
if (isset($element['object']->id)) {
$sortlink->param('sortitemid', $element['object']->id);
}
$eid = $element['eid'];
$object = $element['object'];
$type = $element['type'];
$categorystate = @$element['categorystate'];
if (!empty($element['colspan'])) {
$colspan = $element['colspan'];
} else {
$colspan = 1;
}
if (!empty($element['depth'])) {
$catlevel = 'catlevel' . $element['depth'];
} else {
$catlevel = '';
}
// Element is a filler
if ($type == 'filler' or $type == 'fillerfirst' or $type == 'fillerlast') {
$fillercell = new html_table_cell();
$fillercell->attributes['class'] = $type . ' ' . $catlevel;
$fillercell->colspan = $colspan;
$fillercell->text = ' ';
// This is a filler cell; don't use a <th>, it'll confuse screen readers.
$fillercell->header = false;
$headingrow->cells[] = $fillercell;
} else {
if ($type == 'category') {
// Make sure the grade category has a grade total or at least has child grade items.
if (grade_tree::can_output_item($element)) {
// Element is a category.
$categorycell = new html_table_cell();
$categorycell->attributes['class'] = 'category ' . $catlevel;
$categorycell->colspan = $colspan;
$categorycell->text = $this->get_course_header($element);
$categorycell->header = true;
$categorycell->scope = 'col';
// Print icons.
if ($USER->gradeediting[$this->courseid]) {
$categorycell->text .= $this->get_icons($element);
}
$headingrow->cells[] = $categorycell;
}
} else {
// Element is a grade_item
if ($element['object']->id == $this->sortitemid) {
if ($this->sortorder == 'ASC') {
$arrow = $this->get_sort_arrow('up', $sortlink);
} else {
$arrow = $this->get_sort_arrow('down', $sortlink);
}
} else {
$arrow = $this->get_sort_arrow('move', $sortlink);
}
$headerlink = $this->gtree->get_element_header($element, true, $showactivityicons, false, false, true);
$itemcell = new html_table_cell();
$itemcell->attributes['class'] = $type . ' ' . $catlevel . ' highlightable' . ' i' . $element['object']->id;
$itemcell->attributes['data-itemid'] = $element['object']->id;
if ($element['object']->is_hidden()) {
$itemcell->attributes['class'] .= ' dimmed_text';
}
$singleview = '';
// FIXME: MDL-52678 This is extremely hacky we should have an API for inserting grade column links.
if (get_capability_info('gradereport/singleview:view')) {
if (has_all_capabilities(array('gradereport/singleview:view', 'moodle/grade:viewall', 'moodle/grade:edit'), $this->context)) {
$url = new moodle_url('/grade/report/singleview/index.php', array('id' => $this->course->id, 'item' => 'grade', 'itemid' => $element['object']->id));
//.........这里部分代码省略.........
示例2: test_can_output_item
/**
* Test can_output_item.
*/
public function test_can_output_item()
{
$this->resetAfterTest();
$generator = $this->getDataGenerator();
// Course level grade category.
$course = $generator->create_course();
// Grade tree looks something like:
// - Test course (Rendered).
$gradetree = grade_category::fetch_course_tree($course->id);
$this->assertTrue(grade_tree::can_output_item($gradetree));
// Add a grade category with default settings.
$generator->create_grade_category(array('courseid' => $course->id));
// Grade tree now looks something like:
// - Test course n (Rendered).
// -- Grade category n (Rendered).
$gradetree = grade_category::fetch_course_tree($course->id);
$this->assertNotEmpty($gradetree['children']);
foreach ($gradetree['children'] as $child) {
$this->assertTrue(grade_tree::can_output_item($child));
}
// Add a grade category with grade type = None.
$nototalcategory = 'No total category';
$nototalparams = ['courseid' => $course->id, 'fullname' => $nototalcategory, 'aggregation' => GRADE_AGGREGATE_WEIGHTED_MEAN];
$nototal = $generator->create_grade_category($nototalparams);
$catnototal = grade_category::fetch(array('id' => $nototal->id));
// Set the grade type of the grade item associated to the grade category.
$catitemnototal = $catnototal->load_grade_item();
$catitemnototal->gradetype = GRADE_TYPE_NONE;
$catitemnototal->update();
// Grade tree looks something like:
// - Test course n (Rendered).
// -- Grade category n (Rendered).
// -- No total category (Not rendered).
$gradetree = grade_category::fetch_course_tree($course->id);
foreach ($gradetree['children'] as $child) {
if ($child['object']->fullname == $nototalcategory) {
$this->assertFalse(grade_tree::can_output_item($child));
} else {
$this->assertTrue(grade_tree::can_output_item($child));
}
}
// Add another grade category with default settings under 'No total category'.
$normalinnototalparams = ['courseid' => $course->id, 'fullname' => 'Normal category in no total category', 'parent' => $nototal->id];
$generator->create_grade_category($normalinnototalparams);
// Grade tree looks something like:
// - Test course n (Rendered).
// -- Grade category n (Rendered).
// -- No total category (Rendered).
// --- Normal category in no total category (Rendered).
$gradetree = grade_category::fetch_course_tree($course->id);
foreach ($gradetree['children'] as $child) {
// All children are now visible.
$this->assertTrue(grade_tree::can_output_item($child));
if (!empty($child['children'])) {
foreach ($child['children'] as $grandchild) {
$this->assertTrue(grade_tree::can_output_item($grandchild));
}
}
}
// Add a grade category with grade type = None.
$nototalcategory2 = 'No total category 2';
$nototal2params = ['courseid' => $course->id, 'fullname' => $nototalcategory2, 'aggregation' => GRADE_AGGREGATE_WEIGHTED_MEAN];
$nototal2 = $generator->create_grade_category($nototal2params);
$catnototal2 = grade_category::fetch(array('id' => $nototal2->id));
// Set the grade type of the grade item associated to the grade category.
$catitemnototal2 = $catnototal2->load_grade_item();
$catitemnototal2->gradetype = GRADE_TYPE_NONE;
$catitemnototal2->update();
// Add a category with no total under 'No total category'.
$nototalinnototalcategory = 'Category with no total in no total category';
$nototalinnototalparams = ['courseid' => $course->id, 'fullname' => $nototalinnototalcategory, 'aggregation' => GRADE_AGGREGATE_WEIGHTED_MEAN, 'parent' => $nototal2->id];
$nototalinnototal = $generator->create_grade_category($nototalinnototalparams);
$catnototalinnototal = grade_category::fetch(array('id' => $nototalinnototal->id));
// Set the grade type of the grade item associated to the grade category.
$catitemnototalinnototal = $catnototalinnototal->load_grade_item();
$catitemnototalinnototal->gradetype = GRADE_TYPE_NONE;
$catitemnototalinnototal->update();
// Grade tree looks something like:
// - Test course n (Rendered).
// -- Grade category n (Rendered).
// -- No total category (Rendered).
// --- Normal category in no total category (Rendered).
// -- No total category 2 (Not rendered).
// --- Category with no total in no total category (Not rendered).
$gradetree = grade_category::fetch_course_tree($course->id);
foreach ($gradetree['children'] as $child) {
if ($child['object']->fullname == $nototalcategory2) {
$this->assertFalse(grade_tree::can_output_item($child));
} else {
$this->assertTrue(grade_tree::can_output_item($child));
}
if (!empty($child['children'])) {
foreach ($child['children'] as $grandchild) {
if ($grandchild['object']->fullname == $nototalinnototalcategory) {
$this->assertFalse(grade_tree::can_output_item($grandchild));
} else {
$this->assertTrue(grade_tree::can_output_item($grandchild));
//.........这里部分代码省略.........