Merge branch 'MDL-72097' of git://github.com/danmarsden/moodle

This commit is contained in:
Víctor Déniz 2021-08-18 17:19:18 +01:00 committed by Ilya Tregubov
commit 735bd7ffdb
3 changed files with 16 additions and 10 deletions

View file

@ -638,7 +638,7 @@ class assign_grading_table extends table_sql implements renderable {
public function col_workflowstatus(stdClass $row) {
$o = '';
$gradingdisabled = $this->assignment->grading_disabled($row->id);
$gradingdisabled = $this->assignment->grading_disabled($row->id, true, $this->gradinginfo);
// The function in the assignment keeps a static cache of this list of states.
$workflowstates = $this->assignment->get_marking_workflow_states_for_current_user();
$workflowstate = $row->workflowstate;
@ -946,7 +946,7 @@ class assign_grading_table extends table_sql implements renderable {
* @return string
*/
public function col_gradecanbechanged(stdClass $row) {
$gradingdisabled = $this->assignment->grading_disabled($row->id);
$gradingdisabled = $this->assignment->grading_disabled($row->id, true, $this->gradinginfo);
if ($gradingdisabled) {
return get_string('no');
} else {
@ -981,7 +981,7 @@ class assign_grading_table extends table_sql implements renderable {
$link = '';
$separator = $this->output->spacer(array(), true);
$grade = '';
$gradingdisabled = $this->assignment->grading_disabled($row->id);
$gradingdisabled = $this->assignment->grading_disabled($row->id, true, $this->gradinginfo);
if (!$this->is_downloading() && $this->hasgrade) {
$urlparams = array('id' => $this->assignment->get_course_module()->id,

View file

@ -7585,10 +7585,10 @@ class assign {
*
* @param int $userid - The student userid
* @param bool $checkworkflow - whether to include a check for the workflow state.
* @param stdClass $gradinginfo - optional, allow gradinginfo to be passed for performance.
* @return bool $gradingdisabled
*/
public function grading_disabled($userid, $checkworkflow=true) {
global $CFG;
public function grading_disabled($userid, $checkworkflow = true, $gradinginfo = null) {
if ($checkworkflow && $this->get_instance()->markingworkflow) {
$grade = $this->get_user_grade($userid, false);
$validstates = $this->get_marking_workflow_states_for_current_user();
@ -7596,11 +7596,15 @@ class assign {
return true;
}
}
$gradinginfo = grade_get_grades($this->get_course()->id,
'mod',
'assign',
$this->get_instance()->id,
array($userid));
if (is_null($gradinginfo)) {
$gradinginfo = grade_get_grades($this->get_course()->id,
'mod',
'assign',
$this->get_instance()->id,
array($userid));
}
if (!$gradinginfo) {
return false;
}

View file

@ -1,4 +1,6 @@
This files describes API changes in the assign code.
=== 4.0 ===
* The method \assign::grading_disabled() now has optional $gradinginfo parameter to improve performance
=== 3.9 ===