mirror of
https://github.com/moodle/moodle.git
synced 2025-04-22 08:55:15 +02:00
MDL-46498 mod_assign: display correct grading status
This commit is contained in:
parent
981f06fad5
commit
bd3ee80716
@ -476,11 +476,21 @@ function assign_print_overview($courses, &$htmlarray) {
|
||||
} else {
|
||||
$str .= get_string('submissionstatus_' . $submission->status, 'assign');
|
||||
}
|
||||
if (!$submission || !$submission->grade || $submission->grade < 0) {
|
||||
$str .= ', ' . get_string('notgraded', 'assign');
|
||||
|
||||
if ($assignment->markingworkflow) {
|
||||
$workflowstate = $DB->get_field('assign_user_flags', 'workflowstate', array('assignment' =>
|
||||
$assignment->id, 'userid' => $USER->id));
|
||||
if ($workflowstate) {
|
||||
$gradingstatus = 'markingworkflowstate' . $workflowstate;
|
||||
} else {
|
||||
$gradingstatus = 'markingworkflowstate' . ASSIGN_MARKING_WORKFLOW_STATE_NOTMARKED;
|
||||
}
|
||||
} else if (!empty($submission->grade) && $submission->grade !== null && $submission->grade >= 0) {
|
||||
$gradingstatus = ASSIGN_GRADING_STATUS_GRADED;
|
||||
} else {
|
||||
$str .= ', ' . get_string('graded', 'assign');
|
||||
$gradingstatus = ASSIGN_GRADING_STATUS_NOT_GRADED;
|
||||
}
|
||||
$str .= ', ' . get_string($gradingstatus, 'assign');
|
||||
$str .= '</div>';
|
||||
}
|
||||
$str .= '</div>';
|
||||
|
@ -49,6 +49,10 @@ define('ASSIGN_ATTEMPT_REOPEN_METHOD_UNTILPASS', 'untilpass');
|
||||
// Special value means allow unlimited attempts.
|
||||
define('ASSIGN_UNLIMITED_ATTEMPTS', -1);
|
||||
|
||||
// Grading states.
|
||||
define('ASSIGN_GRADING_STATUS_GRADED', 'graded');
|
||||
define('ASSIGN_GRADING_STATUS_NOT_GRADED', 'notgraded');
|
||||
|
||||
// Marking workflow states.
|
||||
define('ASSIGN_MARKING_WORKFLOW_STATE_NOTMARKED', 'notmarked');
|
||||
define('ASSIGN_MARKING_WORKFLOW_STATE_INMARKING', 'inmarking');
|
||||
@ -1958,7 +1962,9 @@ class assign {
|
||||
return true;
|
||||
}
|
||||
|
||||
$this->gradebook_item_update(null, $grade);
|
||||
if ($this->gradebook_item_update(null, $grade)) {
|
||||
\mod_assign\event\submission_graded::create_from_grade($this, $grade)->trigger();
|
||||
}
|
||||
|
||||
// If the conditions are met, allow another attempt.
|
||||
if ($submission) {
|
||||
@ -1966,7 +1972,7 @@ class assign {
|
||||
$submission,
|
||||
$reopenattempt);
|
||||
}
|
||||
\mod_assign\event\submission_graded::create_from_grade($this, $grade)->trigger();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -3046,7 +3052,8 @@ class assign {
|
||||
$this->is_blind_marking(),
|
||||
'',
|
||||
$instance->attemptreopenmethod,
|
||||
$instance->maxattempts);
|
||||
$instance->maxattempts,
|
||||
$this->get_grading_status($userid));
|
||||
$o .= $this->get_renderer()->render($submissionstatus);
|
||||
}
|
||||
|
||||
@ -3360,7 +3367,6 @@ class assign {
|
||||
require_once($CFG->dirroot . '/mod/assign/gradeform.php');
|
||||
|
||||
// Only load this if it is.
|
||||
|
||||
$o .= $this->view_grading_table();
|
||||
|
||||
$o .= $this->view_footer();
|
||||
@ -3906,6 +3912,7 @@ class assign {
|
||||
}
|
||||
$viewfullnames = has_capability('moodle/site:viewfullnames', $this->get_course_context());
|
||||
|
||||
$gradingstatus = $this->get_grading_status($user->id);
|
||||
$submissionstatus = new assign_submission_status($instance->allowsubmissionsfromdate,
|
||||
$instance->alwaysshowdescription,
|
||||
$submission,
|
||||
@ -3932,7 +3939,8 @@ class assign {
|
||||
$this->is_blind_marking(),
|
||||
$gradingcontrollerpreview,
|
||||
$instance->attemptreopenmethod,
|
||||
$instance->maxattempts);
|
||||
$instance->maxattempts,
|
||||
$gradingstatus);
|
||||
if (has_capability('mod/assign:submit', $this->get_context(), $user)) {
|
||||
$o .= $this->get_renderer()->render($submissionstatus);
|
||||
}
|
||||
@ -3965,10 +3973,7 @@ class assign {
|
||||
}
|
||||
}
|
||||
|
||||
$gradereleased = true;
|
||||
if ($this->get_instance()->markingworkflow &&
|
||||
(empty($grade) || $flags->workflowstate != ASSIGN_MARKING_WORKFLOW_STATE_RELEASED)) {
|
||||
$gradereleased = false;
|
||||
if ($this->get_instance()->markingworkflow && $gradingstatus != ASSIGN_MARKING_WORKFLOW_STATE_RELEASED) {
|
||||
$emptyplugins = true; // Don't show feedback plugins until released either.
|
||||
}
|
||||
|
||||
@ -4314,12 +4319,12 @@ class assign {
|
||||
if ($this->is_blind_marking()) {
|
||||
return false;
|
||||
}
|
||||
// If marking workflow is enabled and grade is not released then don't send to gradebook yet.
|
||||
if ($this->get_instance()->markingworkflow && !empty($grade)) {
|
||||
$flags = $this->get_user_flags($grade->userid, false);
|
||||
if (empty($flags->workflowstate) || $flags->workflowstate != ASSIGN_MARKING_WORKFLOW_STATE_RELEASED) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// If marking workflow is enabled and grade is not released then remove any grade that may exist in the gradebook.
|
||||
if ($this->get_instance()->markingworkflow && !empty($grade) &&
|
||||
$this->get_grading_status($grade->userid) != ASSIGN_MARKING_WORKFLOW_STATE_RELEASED) {
|
||||
// Remove the grade (if it exists) from the gradebook as it is not 'final'.
|
||||
$grade->grade = -1;
|
||||
}
|
||||
|
||||
if ($submission != null) {
|
||||
@ -4349,7 +4354,7 @@ class assign {
|
||||
$assign->cmidnumber = $this->get_course_module()->idnumber;
|
||||
// Set assign gradebook feedback plugin status (enabled and visible).
|
||||
$assign->gradefeedbackenabled = $this->is_gradebook_feedback_enabled();
|
||||
return assign_grade_item_update($assign, $gradebookgrade);
|
||||
return assign_grade_item_update($assign, $gradebookgrade) == GRADE_UPDATE_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -7268,6 +7273,31 @@ class assign {
|
||||
// Gradebook feedback plugin is either not visible/enabled.
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the grading status.
|
||||
*
|
||||
* @param int $userid the user id
|
||||
* @return string returns the grading status
|
||||
*/
|
||||
public function get_grading_status($userid) {
|
||||
if ($this->get_instance()->markingworkflow) {
|
||||
$flags = $this->get_user_flags($userid, false);
|
||||
if (!empty($flags->workflowstate)) {
|
||||
return $flags->workflowstate;
|
||||
}
|
||||
return ASSIGN_MARKING_WORKFLOW_STATE_NOTMARKED;
|
||||
} else {
|
||||
$attemptnumber = optional_param('attemptnumber', -1, PARAM_INT);
|
||||
$grade = $this->get_user_grade($userid, false, $attemptnumber);
|
||||
|
||||
if (!empty($grade) && $grade->grade !== null && $grade->grade >= 0) {
|
||||
return ASSIGN_GRADING_STATUS_GRADED;
|
||||
} else {
|
||||
return ASSIGN_GRADING_STATUS_NOT_GRADED;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -384,6 +384,9 @@ class assign_submission_status implements renderable {
|
||||
public $attemptreopenmethod = 'none';
|
||||
/** @var int maxattempts */
|
||||
public $maxattempts = -1;
|
||||
/** @var string gradingstatus */
|
||||
public $gradingstatus = '';
|
||||
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
@ -415,6 +418,7 @@ class assign_submission_status implements renderable {
|
||||
* @param string $gradingcontrollerpreview
|
||||
* @param string $attemptreopenmethod - The method of reopening student attempts.
|
||||
* @param int $maxattempts - How many attempts can a student make?
|
||||
* @param string $gradingstatus - The submission status (ie. Graded, Not Released etc).
|
||||
*/
|
||||
public function __construct($allowsubmissionsfromdate,
|
||||
$alwaysshowdescription,
|
||||
@ -442,7 +446,8 @@ class assign_submission_status implements renderable {
|
||||
$blindmarking,
|
||||
$gradingcontrollerpreview,
|
||||
$attemptreopenmethod,
|
||||
$maxattempts) {
|
||||
$maxattempts,
|
||||
$gradingstatus) {
|
||||
$this->allowsubmissionsfromdate = $allowsubmissionsfromdate;
|
||||
$this->alwaysshowdescription = $alwaysshowdescription;
|
||||
$this->submission = $submission;
|
||||
@ -470,6 +475,7 @@ class assign_submission_status implements renderable {
|
||||
$this->gradingcontrollerpreview = $gradingcontrollerpreview;
|
||||
$this->attemptreopenmethod = $attemptreopenmethod;
|
||||
$this->maxattempts = $maxattempts;
|
||||
$this->gradingstatus = $gradingstatus;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -553,12 +553,18 @@ class mod_assign_renderer extends plugin_renderer_base {
|
||||
$row = new html_table_row();
|
||||
$cell1 = new html_table_cell(get_string('gradingstatus', 'assign'));
|
||||
|
||||
if ($status->graded) {
|
||||
$cell2 = new html_table_cell(get_string('graded', 'assign'));
|
||||
$cell2->attributes = array('class'=>'submissiongraded');
|
||||
if ($status->gradingstatus == ASSIGN_GRADING_STATUS_GRADED ||
|
||||
$status->gradingstatus == ASSIGN_GRADING_STATUS_NOT_GRADED) {
|
||||
$cell2 = new html_table_cell(get_string($status->gradingstatus, 'assign'));
|
||||
} else {
|
||||
$cell2 = new html_table_cell(get_string('notgraded', 'assign'));
|
||||
$cell2->attributes = array('class'=>'submissionnotgraded');
|
||||
$gradingstatus = 'markingworkflowstate' . $status->gradingstatus;
|
||||
$cell2 = new html_table_cell(get_string($gradingstatus, 'assign'));
|
||||
}
|
||||
if ($status->gradingstatus == ASSIGN_GRADING_STATUS_GRADED ||
|
||||
$status->gradingstatus == ASSIGN_MARKING_WORKFLOW_STATE_RELEASED) {
|
||||
$cell2->attributes = array('class' => 'submissiongraded');
|
||||
} else {
|
||||
$cell2->attributes = array('class' => 'submissionnotgraded');
|
||||
}
|
||||
$row->cells = array($cell1, $cell2);
|
||||
$t->data[] = $row;
|
||||
|
Loading…
x
Reference in New Issue
Block a user