| Línea 23... |
Línea 23... |
| 23 |
*/
|
23 |
*/
|
| Línea 24... |
Línea 24... |
| 24 |
|
24 |
|
| 25 |
require_once($CFG->dirroot . '/grade/report/lib.php');
|
25 |
require_once($CFG->dirroot . '/grade/report/lib.php');
|
| Línea -... |
Línea 26... |
| - |
|
26 |
require_once($CFG->libdir.'/tablelib.php');
|
| - |
|
27 |
|
| 26 |
require_once($CFG->libdir.'/tablelib.php');
|
28 |
use core_grades\penalty_manager;
|
| 27 |
|
29 |
|
| 28 |
/**
|
30 |
/**
|
| 29 |
* Class providing an API for the grader report building and displaying.
|
31 |
* Class providing an API for the grader report building and displaying.
|
| 30 |
* @uses grade_report
|
32 |
* @uses grade_report
|
| Línea 100... |
Línea 102... |
| 100 |
* Capability check caching
|
102 |
* Capability check caching
|
| 101 |
* @var boolean $canviewhidden
|
103 |
* @var boolean $canviewhidden
|
| 102 |
*/
|
104 |
*/
|
| 103 |
public $canviewhidden;
|
105 |
public $canviewhidden;
|
| Línea -... |
Línea 106... |
| - |
|
106 |
|
| 104 |
|
107 |
/**
|
| - |
|
108 |
* @var int Maximum number of students that can be shown on one page
|
| - |
|
109 |
* @deprecated Since Moodle 4.5 MDL-84245. Use grade_report_grader::get_max_students_per_page() instead.
|
| - |
|
110 |
*/
|
| 105 |
/** @var int Maximum number of students that can be shown on one page */
|
111 |
#[\core\attribute\deprecated('grade_report_grader::get_max_students_per_page()', since: '4.5', mdl: 'MDL-84245')]
|
| Línea -... |
Línea 112... |
| - |
|
112 |
public const MAX_STUDENTS_PER_PAGE = 5000;
|
| - |
|
113 |
|
| - |
|
114 |
/**
|
| - |
|
115 |
* @var int The maximum number of grades that can be shown on one page.
|
| - |
|
116 |
*
|
| - |
|
117 |
* More than this causes issues for the browser due to the size of the page.
|
| - |
|
118 |
*/
|
| 106 |
public const MAX_STUDENTS_PER_PAGE = 5000;
|
119 |
public const MAX_GRADES_PER_PAGE = 200000;
|
| 107 |
|
120 |
|
| Línea 108... |
Línea 121... |
| 108 |
/** @var int[] List of available options on the pagination dropdown */
|
121 |
/** @var int[] List of available options on the pagination dropdown */
|
| 109 |
public const PAGINATION_OPTIONS = [20, 100];
|
122 |
public const PAGINATION_OPTIONS = [20, 100];
|
| Línea 464... |
Línea 477... |
| 464 |
) rainner ON rainner.userid = u.id
|
477 |
) rainner ON rainner.userid = u.id
|
| 465 |
AND u.deleted = 0
|
478 |
AND u.deleted = 0
|
| 466 |
$this->userwheresql
|
479 |
$this->userwheresql
|
| 467 |
$this->groupwheresql
|
480 |
$this->groupwheresql
|
| 468 |
ORDER BY $sort";
|
481 |
ORDER BY $sort";
|
| 469 |
// We never work with unlimited result. Limit the number of records by MAX_STUDENTS_PER_PAGE if no other limit is specified.
|
482 |
// We never work with unlimited result. Limit the number of records by $this->get_max_students_per_page() if no other limit
|
| - |
|
483 |
// is specified.
|
| 470 |
$studentsperpage = ($this->get_students_per_page() && !$allusers) ?
|
484 |
$studentsperpage = ($this->get_students_per_page() && !$allusers) ?
|
| 471 |
$this->get_students_per_page() : static::MAX_STUDENTS_PER_PAGE;
|
485 |
$this->get_students_per_page() : $this->get_max_students_per_page();
|
| 472 |
$this->users = $DB->get_records_sql($sql, $params, $studentsperpage * $this->page, $studentsperpage);
|
486 |
$this->users = $DB->get_records_sql($sql, $params, $studentsperpage * $this->page, $studentsperpage);
|
| Línea 473... |
Línea 487... |
| 473 |
|
487 |
|
| 474 |
if (empty($this->users)) {
|
488 |
if (empty($this->users)) {
|
| 475 |
$this->userselect = '';
|
489 |
$this->userselect = '';
|
| Línea 525... |
Línea 539... |
| 525 |
|
539 |
|
| 526 |
return $this->allgradeitems;
|
540 |
return $this->allgradeitems;
|
| Línea 527... |
Línea 541... |
| 527 |
}
|
541 |
}
|
| - |
|
542 |
|
| - |
|
543 |
/**
|
| - |
|
544 |
* Return the maximum number of students we can display per page.
|
| - |
|
545 |
*
|
| - |
|
546 |
* This is based on the number of grade items on the course, to limit the overall number of grades displayed on a single page.
|
| - |
|
547 |
* Trying to display too many grades causes browser issues.
|
| - |
|
548 |
*
|
| - |
|
549 |
* @return int
|
| - |
|
550 |
*/
|
| - |
|
551 |
public function get_max_students_per_page(): int {
|
| - |
|
552 |
global $CFG;
|
| - |
|
553 |
|
| - |
|
554 |
$gradeitemcount = count($this->get_allgradeitems());
|
| - |
|
555 |
|
| - |
|
556 |
if (isset($CFG->maxgradesperpage) && clean_param($CFG->maxgradesperpage, PARAM_INT) > 0) {
|
| - |
|
557 |
$maxgradesperpage = $CFG->maxgradesperpage;
|
| - |
|
558 |
} else {
|
| - |
|
559 |
$maxgradesperpage = self::MAX_GRADES_PER_PAGE;
|
| - |
|
560 |
}
|
| - |
|
561 |
|
| - |
|
562 |
if ($gradeitemcount > 0) {
|
| - |
|
563 |
return round($maxgradesperpage / $gradeitemcount);
|
| - |
|
564 |
} else {
|
| - |
|
565 |
return $maxgradesperpage;
|
| - |
|
566 |
}
|
| - |
|
567 |
}
|
| 528 |
|
568 |
|
| 529 |
/**
|
569 |
/**
|
| 530 |
* we supply the userids in this query, and get all the grades
|
570 |
* we supply the userids in this query, and get all the grades
|
| 531 |
* pulls out all the grades, this does not need to worry about paging
|
571 |
* pulls out all the grades, this does not need to worry about paging
|
| 532 |
*/
|
572 |
*/
|
| Línea 592... |
Línea 632... |
| 592 |
}
|
632 |
}
|
| 593 |
}
|
633 |
}
|
| 594 |
}
|
634 |
}
|
| Línea 595... |
Línea 635... |
| 595 |
|
635 |
|
| 596 |
/**
|
- |
|
| 597 |
* Gets html toggle
|
- |
|
| 598 |
* @deprecated since Moodle 2.4 as it appears not to be used any more.
|
- |
|
| 599 |
*/
|
- |
|
| 600 |
public function get_toggles_html() {
|
- |
|
| 601 |
throw new coding_exception('get_toggles_html() can not be used any more');
|
- |
|
| 602 |
}
|
- |
|
| 603 |
|
- |
|
| 604 |
/**
|
- |
|
| 605 |
* Prints html toggle
|
- |
|
| 606 |
* @deprecated since 2.4 as it appears not to be used any more.
|
- |
|
| 607 |
* @param unknown $type
|
- |
|
| 608 |
*/
|
- |
|
| 609 |
public function print_toggle($type) {
|
- |
|
| 610 |
throw new coding_exception('print_toggle() can not be used any more');
|
- |
|
| 611 |
}
|
- |
|
| 612 |
|
- |
|
| 613 |
/**
|
636 |
/**
|
| 614 |
* Builds and returns the rows that will make up the left part of the grader report
|
637 |
* Builds and returns the rows that will make up the left part of the grader report
|
| 615 |
* This consists of student names and icons, links to user reports and id numbers, as well
|
638 |
* This consists of student names and icons, links to user reports and id numbers, as well
|
| 616 |
* as header cells for these columns. It also includes the fillers required for the
|
639 |
* as header cells for these columns. It also includes the fillers required for the
|
| 617 |
* categories displayed on the right side of the report.
|
640 |
* categories displayed on the right side of the report.
|
| Línea 643... |
Línea 666... |
| 643 |
$fillercell->attributes['class'] = 'cell topleft';
|
666 |
$fillercell->attributes['class'] = 'cell topleft';
|
| 644 |
$fillercell->text = html_writer::span(get_string('participants'), 'accesshide');
|
667 |
$fillercell->text = html_writer::span(get_string('participants'), 'accesshide');
|
| 645 |
$fillercell->colspan = $colspan;
|
668 |
$fillercell->colspan = $colspan;
|
| 646 |
$fillercell->rowspan = $levels;
|
669 |
$fillercell->rowspan = $levels;
|
| 647 |
$row = new html_table_row(array($fillercell));
|
670 |
$row = new html_table_row(array($fillercell));
|
| - |
|
671 |
if ($levels >= 1) { // Do not display the filler cell if there are no levels as there will be nothing else in the row.
|
| 648 |
$rows[] = $row;
|
672 |
$rows[] = $row;
|
| - |
|
673 |
}
|
| Línea 649... |
Línea 674... |
| 649 |
|
674 |
|
| 650 |
for ($i = 1; $i < $levels; $i++) {
|
675 |
for ($i = 1; $i < $levels; $i++) {
|
| 651 |
$row = new html_table_row();
|
676 |
$row = new html_table_row();
|
| 652 |
$rows[] = $row;
|
677 |
$rows[] = $row;
|
| Línea 657... |
Línea 682... |
| 657 |
|
682 |
|
| 658 |
$studentheader = new html_table_cell();
|
683 |
$studentheader = new html_table_cell();
|
| 659 |
// The browser's scrollbar may partly cover (in certain operative systems) the content in the student header
|
684 |
// The browser's scrollbar may partly cover (in certain operative systems) the content in the student header
|
| 660 |
// when horizontally scrolling through the table contents (most noticeable when in RTL mode).
|
685 |
// when horizontally scrolling through the table contents (most noticeable when in RTL mode).
|
| 661 |
// Therefore, add slight padding on the left or right when using RTL mode.
|
686 |
// Therefore, add slight padding on the left or right when using RTL mode.
|
| 662 |
$studentheader->attributes['class'] = "header pl-3";
|
687 |
$studentheader->attributes['class'] = "header ps-3";
|
| 663 |
$studentheader->scope = 'col';
|
688 |
$studentheader->scope = 'col';
|
| 664 |
$studentheader->header = true;
|
689 |
$studentheader->header = true;
|
| 665 |
$studentheader->id = 'studentheader';
|
690 |
$studentheader->id = 'studentheader';
|
| 666 |
$element = ['type' => 'userfield', 'name' => 'fullname'];
|
691 |
$element = ['type' => 'userfield', 'name' => 'fullname'];
|
| 667 |
$studentheader->text = $arrows['studentname'] .
|
692 |
$studentheader->text = $arrows['studentname'] .
|
| 668 |
$this->gtree->get_cell_action_menu($element, 'gradeitem', $this->gpr, $this->baseurl);
|
- |
|
| 669 |
|
693 |
$this->gtree->get_cell_action_menu($element, 'gradeitem', $this->gpr, $this->baseurl);
|
| Línea 670... |
Línea 694... |
| 670 |
$headerrow->cells[] = $studentheader;
|
694 |
$headerrow->cells[] = $studentheader;
|
| 671 |
|
695 |
|
| 672 |
foreach ($extrafields as $field) {
|
696 |
foreach ($extrafields as $field) {
|
| Línea 732... |
Línea 756... |
| 732 |
$usercell->text .= html_writer::tag('span', $icon, array('class'=>'usersuspendedicon'));
|
756 |
$usercell->text .= html_writer::tag('span', $icon, array('class'=>'usersuspendedicon'));
|
| 733 |
}
|
757 |
}
|
| 734 |
// The browser's scrollbar may partly cover (in certain operative systems) the content in the user cells
|
758 |
// The browser's scrollbar may partly cover (in certain operative systems) the content in the user cells
|
| 735 |
// when horizontally scrolling through the table contents (most noticeable when in RTL mode).
|
759 |
// when horizontally scrolling through the table contents (most noticeable when in RTL mode).
|
| 736 |
// Therefore, add slight padding on the left or right when using RTL mode.
|
760 |
// Therefore, add slight padding on the left or right when using RTL mode.
|
| 737 |
$usercell->attributes['class'] .= ' pl-3';
|
761 |
$usercell->attributes['class'] .= ' ps-3';
|
| 738 |
$usercell->text .= $this->gtree->get_cell_action_menu(['userid' => $userid], 'user', $this->gpr);
|
762 |
$usercell->text .= $this->gtree->get_cell_action_menu(['userid' => $userid], 'user', $this->gpr);
|
| Línea 739... |
Línea 763... |
| 739 |
|
763 |
|
| Línea 740... |
Línea 764... |
| 740 |
$userrow->cells[] = $usercell;
|
764 |
$userrow->cells[] = $usercell;
|
| Línea 1166... |
Línea 1190... |
| 1166 |
}
|
1190 |
}
|
| Línea 1167... |
Línea 1191... |
| 1167 |
|
1191 |
|
| 1168 |
$context->extraclasses = 'gradevalue ' . $hidden . $gradepass;
|
1192 |
$context->extraclasses = 'gradevalue ' . $hidden . $gradepass;
|
| 1169 |
$context->text = grade_format_gradevalue($gradeval, $item, true,
|
1193 |
$context->text = grade_format_gradevalue($gradeval, $item, true,
|
| - |
|
1194 |
$gradedisplaytype, null);
|
| 1170 |
$gradedisplaytype, null);
|
1195 |
$context->text .= penalty_manager::show_penalty_indicator($grade);
|
| 1171 |
}
|
1196 |
}
|
| Línea 1172... |
Línea 1197... |
| 1172 |
}
|
1197 |
}
|
| 1173 |
|
1198 |
|
| Línea 1279... |
Línea 1304... |
| 1279 |
// We don't want the table to be enclosed within in a .table-responsive div as it is heavily customised.
|
1304 |
// We don't want the table to be enclosed within in a .table-responsive div as it is heavily customised.
|
| 1280 |
$fulltable->responsive = false;
|
1305 |
$fulltable->responsive = false;
|
| Línea 1281... |
Línea 1306... |
| 1281 |
|
1306 |
|
| 1282 |
// Extract rows from each side (left and right) and collate them into one row each
|
1307 |
// Extract rows from each side (left and right) and collate them into one row each
|
| - |
|
1308 |
foreach ($leftrows as $key => $row) {
|
| 1283 |
foreach ($leftrows as $key => $row) {
|
1309 |
if (isset($rightrows[$key])) {
|
| - |
|
1310 |
$row->cells = array_merge($row->cells, $rightrows[$key]->cells);
|
| - |
|
1311 |
$fulltable->data[] = $row;
|
| - |
|
1312 |
unset($leftrows[$key]);
|
| - |
|
1313 |
unset($rightrows[$key]);
|
| 1284 |
$row->cells = array_merge($row->cells, $rightrows[$key]->cells);
|
1314 |
} else { // Right row is not set - this is the case of the left side.
|
| - |
|
1315 |
$fulltable->data[] = $row;
|
| - |
|
1316 |
unset($leftrows[$key]);
|
| 1285 |
$fulltable->data[] = $row;
|
1317 |
}
|
| 1286 |
}
|
1318 |
}
|
| 1287 |
$html .= html_writer::table($fulltable);
|
1319 |
$html .= html_writer::table($fulltable);
|
| 1288 |
return $OUTPUT->container($html, 'gradeparent');
|
1320 |
return $OUTPUT->container($html, 'gradeparent');
|
| Línea 1462... |
Línea 1494... |
| 1462 |
return $rows;
|
1494 |
return $rows;
|
| 1463 |
}
|
1495 |
}
|
| Línea 1464... |
Línea 1496... |
| 1464 |
|
1496 |
|
| 1465 |
/**
|
1497 |
/**
|
| 1466 |
* @deprecated since Moodle 4.4 - Call calculate_average instead.
|
- |
|
| 1467 |
* Builds and return the row of averages for the right part of the grader report.
|
- |
|
| 1468 |
* @param array $rows Whether to return only group averages or all averages.
|
- |
|
| 1469 |
* @param bool $grouponly Whether to return only group averages or all averages.
|
- |
|
| 1470 |
* @return array Array of rows for the right part of the report
|
1498 |
* @deprecated since Moodle 4.4 - Call calculate_average instead.
|
| 1471 |
*/
|
- |
|
| 1472 |
public function get_right_avg_row($rows=array(), $grouponly=false) {
|
- |
|
| 1473 |
global $USER, $DB, $OUTPUT, $CFG;
|
- |
|
| 1474 |
|
- |
|
| 1475 |
debugging('grader_report_grader::get_right_avg_row() is deprecated.
|
1499 |
*/
|
| 1476 |
Call grade_report::calculate_average() instead.', DEBUG_DEVELOPER);
|
- |
|
| 1477 |
|
- |
|
| 1478 |
if (!$this->canviewhidden) {
|
- |
|
| 1479 |
// Totals might be affected by hiding, if user can not see hidden grades the aggregations might be altered
|
- |
|
| 1480 |
// better not show them at all if user can not see all hidden grades.
|
- |
|
| 1481 |
return $rows;
|
- |
|
| 1482 |
}
|
- |
|
| 1483 |
|
- |
|
| 1484 |
$averagesdisplaytype = $this->get_pref('averagesdisplaytype');
|
- |
|
| 1485 |
$averagesdecimalpoints = $this->get_pref('averagesdecimalpoints');
|
- |
|
| 1486 |
$meanselection = $this->get_pref('meanselection');
|
- |
|
| 1487 |
$shownumberofgrades = $this->get_pref('shownumberofgrades');
|
- |
|
| 1488 |
|
- |
|
| 1489 |
if ($grouponly) {
|
- |
|
| 1490 |
$showaverages = $this->currentgroup && $this->get_pref('showaverages');
|
- |
|
| 1491 |
$groupsql = $this->groupsql;
|
- |
|
| 1492 |
$groupwheresql = $this->groupwheresql;
|
- |
|
| 1493 |
$groupwheresqlparams = $this->groupwheresql_params;
|
- |
|
| 1494 |
} else {
|
- |
|
| 1495 |
$showaverages = $this->get_pref('showaverages');
|
- |
|
| 1496 |
$groupsql = "";
|
- |
|
| 1497 |
$groupwheresql = "";
|
- |
|
| 1498 |
$groupwheresqlparams = array();
|
- |
|
| 1499 |
}
|
- |
|
| 1500 |
|
- |
|
| 1501 |
if ($showaverages) {
|
- |
|
| 1502 |
$totalcount = $this->get_numusers($grouponly);
|
- |
|
| 1503 |
|
- |
|
| 1504 |
// Limit to users with a gradeable role.
|
- |
|
| 1505 |
list($gradebookrolessql, $gradebookrolesparams) = $DB->get_in_or_equal(explode(',', $this->gradebookroles), SQL_PARAMS_NAMED, 'grbr0');
|
- |
|
| 1506 |
|
- |
|
| 1507 |
// Limit to users with an active enrollment.
|
- |
|
| 1508 |
$coursecontext = $this->context->get_course_context(true);
|
- |
|
| 1509 |
$defaultgradeshowactiveenrol = !empty($CFG->grade_report_showonlyactiveenrol);
|
- |
|
| 1510 |
$showonlyactiveenrol = get_user_preferences('grade_report_showonlyactiveenrol', $defaultgradeshowactiveenrol);
|
- |
|
| 1511 |
$showonlyactiveenrol = $showonlyactiveenrol || !has_capability('moodle/course:viewsuspendedusers', $coursecontext);
|
- |
|
| 1512 |
list($enrolledsql, $enrolledparams) = get_enrolled_sql($this->context, '', 0, $showonlyactiveenrol);
|
- |
|
| 1513 |
|
- |
|
| 1514 |
// We want to query both the current context and parent contexts.
|
- |
|
| 1515 |
list($relatedctxsql, $relatedctxparams) = $DB->get_in_or_equal($this->context->get_parent_context_ids(true), SQL_PARAMS_NAMED, 'relatedctx');
|
- |
|
| 1516 |
|
- |
|
| 1517 |
$params = array_merge(array('courseid' => $this->courseid), $gradebookrolesparams, $enrolledparams, $groupwheresqlparams, $relatedctxparams);
|
- |
|
| 1518 |
|
- |
|
| 1519 |
// Find sums of all grade items in course.
|
- |
|
| 1520 |
$sql = "SELECT g.itemid, SUM(g.finalgrade) AS sum
|
- |
|
| 1521 |
FROM {grade_items} gi
|
- |
|
| 1522 |
JOIN {grade_grades} g ON g.itemid = gi.id
|
- |
|
| 1523 |
JOIN {user} u ON u.id = g.userid
|
- |
|
| 1524 |
JOIN ($enrolledsql) je ON je.id = u.id
|
- |
|
| 1525 |
JOIN (
|
- |
|
| 1526 |
SELECT DISTINCT ra.userid
|
- |
|
| 1527 |
FROM {role_assignments} ra
|
- |
|
| 1528 |
WHERE ra.roleid $gradebookrolessql
|
- |
|
| 1529 |
AND ra.contextid $relatedctxsql
|
- |
|
| 1530 |
) rainner ON rainner.userid = u.id
|
- |
|
| 1531 |
$groupsql
|
- |
|
| 1532 |
WHERE gi.courseid = :courseid
|
- |
|
| 1533 |
AND u.deleted = 0
|
- |
|
| 1534 |
AND g.finalgrade IS NOT NULL
|
- |
|
| 1535 |
$groupwheresql
|
- |
|
| 1536 |
GROUP BY g.itemid";
|
- |
|
| 1537 |
$sumarray = array();
|
- |
|
| 1538 |
if ($sums = $DB->get_records_sql($sql, $params)) {
|
- |
|
| 1539 |
foreach ($sums as $itemid => $csum) {
|
- |
|
| 1540 |
$sumarray[$itemid] = $csum->sum;
|
- |
|
| 1541 |
}
|
- |
|
| 1542 |
}
|
- |
|
| 1543 |
|
- |
|
| 1544 |
// MDL-10875 Empty grades must be evaluated as grademin, NOT always 0
|
- |
|
| 1545 |
// This query returns a count of ungraded grades (NULL finalgrade OR no matching record in grade_grades table)
|
- |
|
| 1546 |
$sql = "SELECT gi.id, COUNT(DISTINCT u.id) AS count
|
- |
|
| 1547 |
FROM {grade_items} gi
|
- |
|
| 1548 |
CROSS JOIN ($enrolledsql) u
|
- |
|
| 1549 |
JOIN {role_assignments} ra
|
- |
|
| 1550 |
ON ra.userid = u.id
|
- |
|
| 1551 |
LEFT OUTER JOIN {grade_grades} g
|
- |
|
| 1552 |
ON (g.itemid = gi.id AND g.userid = u.id AND g.finalgrade IS NOT NULL)
|
- |
|
| 1553 |
$groupsql
|
- |
|
| 1554 |
WHERE gi.courseid = :courseid
|
- |
|
| 1555 |
AND ra.roleid $gradebookrolessql
|
- |
|
| 1556 |
AND ra.contextid $relatedctxsql
|
- |
|
| 1557 |
AND g.id IS NULL
|
- |
|
| 1558 |
$groupwheresql
|
- |
|
| 1559 |
GROUP BY gi.id";
|
- |
|
| 1560 |
|
- |
|
| 1561 |
$ungradedcounts = $DB->get_records_sql($sql, $params);
|
- |
|
| 1562 |
|
1500 |
#[\core\attribute\deprecated('grade_report::calculate_average()', since: '4.4', final: true)]
|
| 1563 |
$avgrow = new html_table_row();
|
- |
|
| 1564 |
$avgrow->attributes['class'] = 'avg';
|
- |
|
| 1565 |
|
- |
|
| 1566 |
foreach ($this->gtree->items as $itemid => $unused) {
|
- |
|
| 1567 |
$item =& $this->gtree->items[$itemid];
|
- |
|
| 1568 |
|
- |
|
| 1569 |
if ($item->needsupdate) {
|
- |
|
| 1570 |
$avgcell = new html_table_cell();
|
- |
|
| 1571 |
$avgcell->attributes['class'] = 'i'. $itemid;
|
- |
|
| 1572 |
$avgcell->text = $OUTPUT->container(get_string('error'), 'gradingerror');
|
- |
|
| 1573 |
$avgrow->cells[] = $avgcell;
|
- |
|
| 1574 |
continue;
|
- |
|
| 1575 |
}
|
- |
|
| 1576 |
|
- |
|
| 1577 |
if (!isset($sumarray[$item->id])) {
|
- |
|
| 1578 |
$sumarray[$item->id] = 0;
|
- |
|
| 1579 |
}
|
- |
|
| 1580 |
|
- |
|
| 1581 |
if (empty($ungradedcounts[$itemid])) {
|
- |
|
| 1582 |
$ungradedcount = 0;
|
- |
|
| 1583 |
} else {
|
- |
|
| 1584 |
$ungradedcount = $ungradedcounts[$itemid]->count;
|
- |
|
| 1585 |
}
|
- |
|
| 1586 |
|
- |
|
| 1587 |
if ($meanselection == GRADE_REPORT_MEAN_GRADED) {
|
- |
|
| 1588 |
$meancount = $totalcount - $ungradedcount;
|
- |
|
| 1589 |
} else { // Bump up the sum by the number of ungraded items * grademin
|
- |
|
| 1590 |
$sumarray[$item->id] += $ungradedcount * $item->grademin;
|
- |
|
| 1591 |
$meancount = $totalcount;
|
- |
|
| 1592 |
}
|
- |
|
| 1593 |
|
- |
|
| 1594 |
// Determine which display type to use for this average
|
- |
|
| 1595 |
if (!empty($USER->editing)) {
|
- |
|
| 1596 |
$displaytype = GRADE_DISPLAY_TYPE_REAL;
|
- |
|
| 1597 |
|
- |
|
| 1598 |
} else if ($averagesdisplaytype == GRADE_REPORT_PREFERENCE_INHERIT) { // no ==0 here, please resave the report and user preferences
|
- |
|
| 1599 |
$displaytype = $item->get_displaytype();
|
- |
|
| 1600 |
|
- |
|
| 1601 |
} else {
|
- |
|
| 1602 |
$displaytype = $averagesdisplaytype;
|
- |
|
| 1603 |
}
|
- |
|
| 1604 |
|
- |
|
| 1605 |
// Override grade_item setting if a display preference (not inherit) was set for the averages
|
- |
|
| 1606 |
if ($averagesdecimalpoints == GRADE_REPORT_PREFERENCE_INHERIT) {
|
- |
|
| 1607 |
$decimalpoints = $item->get_decimals();
|
- |
|
| 1608 |
|
- |
|
| 1609 |
} else {
|
- |
|
| 1610 |
$decimalpoints = $averagesdecimalpoints;
|
- |
|
| 1611 |
}
|
- |
|
| 1612 |
|
1501 |
public function get_right_avg_row() {
|
| 1613 |
$gradetypeclass = $this->get_cell_display_class($item);
|
- |
|
| 1614 |
|
- |
|
| 1615 |
if (!isset($sumarray[$item->id]) || $meancount == 0) {
|
- |
|
| 1616 |
$avgcell = new html_table_cell();
|
- |
|
| 1617 |
$avgcell->attributes['class'] = $gradetypeclass . ' i'. $itemid;
|
- |
|
| 1618 |
$avgcell->attributes['data-itemid'] = $itemid;
|
- |
|
| 1619 |
$avgcell->text = html_writer::div('-', '', ['data-collapse' => 'avgrowcell']);
|
- |
|
| 1620 |
$avgrow->cells[] = $avgcell;
|
- |
|
| 1621 |
} else {
|
- |
|
| 1622 |
$sum = $sumarray[$item->id];
|
- |
|
| 1623 |
$avgradeval = $sum/$meancount;
|
- |
|
| 1624 |
$gradehtml = grade_format_gradevalue($avgradeval, $item, true, $displaytype, $decimalpoints);
|
- |
|
| 1625 |
|
- |
|
| 1626 |
$numberofgrades = '';
|
- |
|
| 1627 |
if ($shownumberofgrades) {
|
- |
|
| 1628 |
$numberofgrades = " ($meancount)";
|
- |
|
| 1629 |
}
|
- |
|
| 1630 |
|
- |
|
| 1631 |
$avgcell = new html_table_cell();
|
- |
|
| 1632 |
$avgcell->attributes['class'] = $gradetypeclass . ' i'. $itemid;
|
- |
|
| 1633 |
$avgcell->attributes['data-itemid'] = $itemid;
|
- |
|
| 1634 |
$avgcell->text = html_writer::div($gradehtml.$numberofgrades, '', ['data-collapse' => 'avgrowcell']);
|
- |
|
| 1635 |
$avgrow->cells[] = $avgcell;
|
- |
|
| 1636 |
}
|
- |
|
| 1637 |
}
|
- |
|
| 1638 |
$rows[] = $avgrow;
|
- |
|
| 1639 |
}
|
- |
|
| 1640 |
return $rows;
|
1502 |
\core\deprecation::emit_deprecation([self::class, __FUNCTION__]);
|
| Línea 1641... |
Línea 1503... |
| 1641 |
}
|
1503 |
}
|
| 1642 |
|
1504 |
|
| 1643 |
/**
|
1505 |
/**
|
| Línea 1662... |
Línea 1524... |
| 1662 |
$courseheader = html_writer::tag('span', $name, [
|
1524 |
$courseheader = html_writer::tag('span', $name, [
|
| 1663 |
'title' => $nameunescaped,
|
1525 |
'title' => $nameunescaped,
|
| 1664 |
'class' => 'gradeitemheader',
|
1526 |
'class' => 'gradeitemheader',
|
| 1665 |
'aria-describedby' => $describedbyid
|
1527 |
'aria-describedby' => $describedbyid
|
| 1666 |
]);
|
1528 |
]);
|
| 1667 |
$courseheader .= html_writer::div($showing, 'sr-only', [
|
1529 |
$courseheader .= html_writer::div($showing, 'visually-hidden', [
|
| 1668 |
'id' => $describedbyid
|
1530 |
'id' => $describedbyid
|
| 1669 |
]);
|
1531 |
]);
|
| Línea 1670... |
Línea 1532... |
| 1670 |
|
1532 |
|
| 1671 |
return $courseheader;
|
1533 |
return $courseheader;
|
| Línea 1725... |
Línea 1587... |
| 1725 |
|
1587 |
|
| 1726 |
return $OUTPUT->container($editicon.$editcalculationicon.$showhideicon.$lockunlockicon.$gradeanalysisicon, 'grade_icons');
|
1588 |
return $OUTPUT->container($editicon.$editcalculationicon.$showhideicon.$lockunlockicon.$gradeanalysisicon, 'grade_icons');
|
| Línea 1727... |
Línea 1589... |
| 1727 |
}
|
1589 |
}
|
| 1728 |
|
- |
|
| 1729 |
/**
|
- |
|
| 1730 |
* Given a category element returns collapsing +/- icon if available
|
- |
|
| 1731 |
*
|
- |
|
| 1732 |
* @deprecated since Moodle 2.9 MDL-46662 - please do not use this function any more.
|
- |
|
| 1733 |
*/
|
- |
|
| 1734 |
protected function get_collapsing_icon($element) {
|
- |
|
| 1735 |
throw new coding_exception('get_collapsing_icon() can not be used any more, please use get_course_header() instead.');
|
- |
|
| 1736 |
}
|
- |
|
| 1737 |
|
1590 |
|
| 1738 |
/**
|
1591 |
/**
|
| 1739 |
* Processes a single action against a category, grade_item or grade.
|
1592 |
* Processes a single action against a category, grade_item or grade.
|
| 1740 |
* @param string $target eid ({type}{id}, e.g. c4 for category4)
|
1593 |
* @param string $target eid ({type}{id}, e.g. c4 for category4)
|
| 1741 |
* @param string $action Which action to take (edit, delete etc...)
|
1594 |
* @param string $action Which action to take (edit, delete etc...)
|