Skip to content

Commit

Permalink
MDL-66147 mod_assign: submissions overview page shows time interval
Browse files Browse the repository at this point in the history
Use get_time_interval_string() on the teacher only page, to show how
long after the course start the assignment is due for each user.
  • Loading branch information
snake committed Aug 13, 2019
1 parent 612b210 commit 9e719b8
Show file tree
Hide file tree
Showing 4 changed files with 69 additions and 32 deletions.
3 changes: 3 additions & 0 deletions mod/assign/lang/en/assign.php
Expand Up @@ -430,6 +430,9 @@
$string['quickgradingresult'] = 'Quick grading';
$string['quickgradingchangessaved'] = 'The grade changes were saved';
$string['quickgrading_help'] = 'Quick grading allows you to assign grades (and outcomes) directly in the submissions table. Quick grading is not compatible with advanced grading and is not recommended when there are multiple markers.';
$string['relativedatessubmissiontimeleft'] = 'Calculated for each student';
$string['relativedatessubmissionduedateafter'] = '{$a->datediffstr} after course start';
$string['relativedatessubmissionduedatebefore'] = '{$a->datediffstr} before course start';
$string['removeallgroupoverrides'] = 'Delete all group overrides';
$string['removealluseroverrides'] = 'Delete all user overrides';
$string['reopenuntilpassincompatiblewithblindmarking'] = 'Reopen until pass option is incompatible with blind marking, because the grades are not released to the gradebook until the student identities are revealed.';
Expand Down
63 changes: 36 additions & 27 deletions mod/assign/locallib.php
Expand Up @@ -5562,8 +5562,9 @@ public function get_all_submissions($userid) {
*/
public function get_assign_grading_summary_renderable($activitygroup = null) {

$instance = $this->get_instance();
$instance = $this->get_default_instance(); // Grading summary requires the raw dates, regardless of relativedates mode.
$cm = $this->get_course_module();
$course = $this->get_course();

$draft = ASSIGN_SUBMISSION_STATUS_DRAFT;
$submitted = ASSIGN_SUBMISSION_STATUS_SUBMITTED;
Expand All @@ -5584,35 +5585,43 @@ public function get_assign_grading_summary_renderable($activitygroup = null) {
}
}

$summary = new assign_grading_summary($this->count_teams($activitygroup),
$instance->submissiondrafts,
$this->count_submissions_with_status($draft, $activitygroup),
$this->is_any_submission_plugin_enabled(),
$this->count_submissions_with_status($submitted, $activitygroup),
$instance->cutoffdate,
$instance->duedate,
$this->get_course_module()->id,
$this->count_submissions_need_grading($activitygroup),
$instance->teamsubmission,
$warnofungroupedusers,
$this->can_grade(),
$isvisible);
$summary = new assign_grading_summary(
$this->count_teams($activitygroup),
$instance->submissiondrafts,
$this->count_submissions_with_status($draft, $activitygroup),
$this->is_any_submission_plugin_enabled(),
$this->count_submissions_with_status($submitted, $activitygroup),
$instance->cutoffdate,
$instance->duedate,
$this->get_course_module()->id,
$this->count_submissions_need_grading($activitygroup),
$instance->teamsubmission,
$warnofungroupedusers,
$course->relativedatesmode,
$course->startdate,
$this->can_grade(),
$isvisible
);
} else {
// The active group has already been updated in groups_print_activity_menu().
$countparticipants = $this->count_participants($activitygroup);
$summary = new assign_grading_summary($countparticipants,
$instance->submissiondrafts,
$this->count_submissions_with_status($draft, $activitygroup),
$this->is_any_submission_plugin_enabled(),
$this->count_submissions_with_status($submitted, $activitygroup),
$instance->cutoffdate,
$instance->duedate,
$this->get_course_module()->id,
$this->count_submissions_need_grading($activitygroup),
$instance->teamsubmission,
assign_grading_summary::WARN_GROUPS_NO,
$this->can_grade(),
$isvisible);
$summary = new assign_grading_summary(
$countparticipants,
$instance->submissiondrafts,
$this->count_submissions_with_status($draft, $activitygroup),
$this->is_any_submission_plugin_enabled(),
$this->count_submissions_with_status($submitted, $activitygroup),
$instance->cutoffdate,
$instance->duedate,
$this->get_course_module()->id,
$this->count_submissions_need_grading($activitygroup),
$instance->teamsubmission,
assign_grading_summary::WARN_GROUPS_NO,
$course->relativedatesmode,
$course->startdate,
$this->can_grade(),
$isvisible
);
}

return $summary;
Expand Down
10 changes: 10 additions & 0 deletions mod/assign/renderable.php
Expand Up @@ -748,6 +748,10 @@ class assign_grading_summary implements renderable {
public $teamsubmission = false;
/** @var boolean warnofungroupedusers - Do we need to warn people that there are users without groups */
public $warnofungroupedusers = false;
/** @var boolean relativedatesmode - Is the course a relative dates mode course or not */
public $courserelativedatesmode = false;
/** @var int coursestartdate - start date of the course as a unix timestamp*/
public $coursestartdate;
/** @var boolean cangrade - Can the current user grade students? */
public $cangrade = false;
/** @var boolean isvisible - Is the assignment's context module visible to students? */
Expand All @@ -774,6 +778,8 @@ class assign_grading_summary implements renderable {
* @param int $submissionsneedgradingcount
* @param bool $teamsubmission
* @param string $warnofungroupedusers
* @param bool $courserelativedatesmode true if the course is using relative dates, false otherwise.
* @param int $coursestartdate unix timestamp representation of the course start date.
* @param bool $cangrade
* @param bool $isvisible
*/
Expand All @@ -788,6 +794,8 @@ public function __construct($participantcount,
$submissionsneedgradingcount,
$teamsubmission,
$warnofungroupedusers,
$courserelativedatesmode,
$coursestartdate,
$cangrade = true,
$isvisible = true) {
$this->participantcount = $participantcount;
Expand All @@ -801,6 +809,8 @@ public function __construct($participantcount,
$this->submissionsneedgradingcount = $submissionsneedgradingcount;
$this->teamsubmission = $teamsubmission;
$this->warnofungroupedusers = $warnofungroupedusers;
$this->courserelativedatesmode = $courserelativedatesmode;
$this->coursestartdate = $coursestartdate;
$this->cangrade = $cangrade;
$this->isvisible = $isvisible;
}
Expand Down
25 changes: 20 additions & 5 deletions mod/assign/renderer.php
Expand Up @@ -312,15 +312,30 @@ public function render_assign_grading_summary(assign_grading_summary $summary) {
if ($summary->duedate) {
// Due date.
$duedate = $summary->duedate;
if ($summary->courserelativedatesmode) {
// Returns a formatted string, in the format '10d 10h 45m'.
$diffstr = get_time_interval_string($duedate, $summary->coursestartdate);
if ($duedate >= $summary->coursestartdate) {
$userduedate = get_string('relativedatessubmissionduedateafter', 'mod_assign', ['datediffstr' => $diffstr]);
} else {
$userduedate = get_string('relativedatessubmissionduedatebefore', 'mod_assign', ['datediffstr' => $diffstr]);
}
} else {
$userduedate = userdate($duedate);
}
$this->add_table_row_tuple($t, get_string('duedate', 'assign'),
userdate($duedate));
$userduedate);

// Time remaining.
$due = '';
if ($duedate - $time <= 0) {
$due = get_string('assignmentisdue', 'assign');
if ($summary->courserelativedatesmode) {
$due = get_string('relativedatessubmissiontimeleft', 'mod_assign');
} else {
$due = format_time($duedate - $time);
$due = '';
if ($duedate - $time <= 0) {
$due = get_string('assignmentisdue', 'assign');
} else {
$due = format_time($duedate - $time);
}
}
$this->add_table_row_tuple($t, get_string('timeremaining', 'assign'), $due);

Expand Down

0 comments on commit 9e719b8

Please sign in to comment.