MDL-83888 mod_assign: add course overview integration

This commit is contained in:
ferran
2025-03-04 15:05:18 +01:00
parent d6a8068cd1
commit 4c08c5fb9a
6 changed files with 692 additions and 4 deletions
+3 -3
View File
@@ -79,13 +79,13 @@ Feature: Users can access the course activities overview page
And I am on the "Course 1" "course > activities" page logged in as "teacher1"
And I should see "Assignments" in the "assign_overview_collapsible" "region"
And I should see "Forums" in the "forum_overview_collapsible" "region"
And I should not see "Go to Assignments overview" in the "assign_overview_collapsible" "region"
And I should not see "Test assignment name" in the "assign_overview_collapsible" "region"
And I should not see "Go to Forums overview" in the "forum_overview_collapsible" "region"
When I click on "Expand" "link" in the "assign_overview_collapsible" "region"
Then I should see "Go to Assignments overview" in the "assign_overview_collapsible" "region"
Then I should see "Test assignment name" in the "assign_overview_collapsible" "region"
And I should not see "Go to Forums overview" in the "forum_overview_collapsible" "region"
And I click on "Collapse" "link" in the "assign_overview_collapsible" "region"
And I should not see "Go to Assignments overview" in the "assign_overview_collapsible" "region"
And I should not see "Test assignment name" in the "assign_overview_collapsible" "region"
And I should not see "Go to Forums overview" in the "forum_overview_collapsible" "region"
Scenario: Course overview shows the course present activity types
@@ -0,0 +1,186 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
namespace mod_assign\courseformat;
use assign;
use cm_info;
use core_courseformat\local\overview\overviewitem;
use core\output\action_link;
use core\output\local\properties\text_align;
use core\output\local\properties\button;
use core\url;
use mod_assign\dates;
/**
* Assignment overview integration.
*
* @package mod_assign
* @copyright 2025 Ferran Recio <[email protected]>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class overview extends \core_courseformat\activityoverviewbase {
/** @var assign $assign the assign instance. */
private assign $assign;
/**
* Constructor.
*
* @param cm_info $cm the course module instance.
* @param \core\output\renderer_helper $rendererhelper the renderer helper.
*/
public function __construct(
cm_info $cm,
/** @var \core\output\renderer_helper $rendererhelper the renderer helper */
protected readonly \core\output\renderer_helper $rendererhelper,
) {
global $CFG;
require_once($CFG->dirroot . '/mod/assign/locallib.php');
parent::__construct($cm);
$this->assign = new assign($this->context, $this->cm, $this->cm->get_course());
}
#[\Override]
public function get_due_date_overview(): ?overviewitem {
global $USER;
$dates = new dates($this->cm, $USER->id);
$duedate = $dates->get_due_date();
if (empty($duedate)) {
return new overviewitem(
name: get_string('duedate', 'assign'),
value: null,
content: '-',
);
}
$content = userdate($duedate);
return new overviewitem(
name: get_string('duedate', 'assign'),
value: $duedate,
content: $content,
);
}
#[\Override]
public function get_actions_overview(): ?overviewitem {
if (!has_capability('mod/assign:grade', $this->context)) {
return null;
}
$needgrading = $this->assign->count_submissions_need_grading();
$renderer = $this->rendererhelper->get_core_renderer();
$badge = '';
if ($needgrading > 0) {
$badge = $renderer->notice_badge(
contents: $needgrading,
title: get_string('numberofsubmissionsneedgrading', 'assign'),
);
}
$content = new action_link(
url: new url('/mod/assign/view.php', ['id' => $this->cm->id, 'action' => 'grading']),
text: get_string('gradeverb') . $badge,
attributes: ['class' => button::SECONDARY_OUTLINE->classes()],
);
return new overviewitem(
name: get_string('actions'),
value: $needgrading,
content: $content,
textalign: text_align::CENTER,
);
}
#[\Override]
public function get_extra_overview_items(): array {
return [
'submissions' => $this->get_extra_submissions_overview(),
'submissionstatus' => $this->get_extra_submission_status_overview(),
];
}
/**
* Retrieves an overview of submissions for the assignment.
*
* @return overviewitem|null An overview item c, or null if the user lacks the required capability.
*/
private function get_extra_submissions_overview(): ?overviewitem {
global $USER;
if (!has_capability('mod/assign:grade', $this->cm->context)) {
return null;
}
$activitygroup = groups_get_activity_group($this->cm);
$submissions = $this->assign->count_submissions_with_status(ASSIGN_SUBMISSION_STATUS_SUBMITTED);
$total = $this->assign->count_participants($activitygroup);
$content = new action_link(
url: new url('/mod/assign/view.php', ['id' => $this->cm->id, 'action' => 'grading']),
text: get_string(
'count_of_total',
'core',
['count' => $submissions, 'total' => $total]
),
attributes: ['class' => button::SECONDARY_OUTLINE->classes()],
);
return new overviewitem(
name: get_string('submissions', 'assign'),
value: $submissions,
content: $content,
textalign: text_align::CENTER,
);
}
/**
* Retrieves the submission status overview for the current user.
*
* @return overviewitem|null The overview item, or null if the user does not have the required capabilities.
*/
private function get_extra_submission_status_overview(): ?overviewitem {
global $USER;
if (
!has_capability('mod/assign:submit', $this->context)
|| has_capability('moodle/site:config', $this->context)
) {
return null;
}
if ($this->assign->get_instance()->teamsubmission) {
$usersubmission = $this->assign->get_group_submission($USER->id, 0, false);
} else {
$usersubmission = $this->assign->get_user_submission($USER->id, false);
}
if (!empty($usersubmission->status)) {
$submittedstatus = get_string('submissionstatus_' . $usersubmission->status, 'assign');
} else {
$submittedstatus = get_string('submissionstatus_', 'assign');
}
return new overviewitem(
name: get_string('submissionstatus', 'assign'),
value: $submittedstatus,
content: $submittedstatus,
);
}
}
+18 -1
View File
@@ -36,6 +36,9 @@ use core\activity_dates;
*/
class dates extends activity_dates {
/** @var int|null $timedue the activity due date */
private ?int $timedue;
/**
* Returns a list of important dates in mod_assign
*
@@ -46,6 +49,8 @@ class dates extends activity_dates {
require_once($CFG->dirroot . '/mod/assign/locallib.php');
$this->timedue = null;
$course = get_course($this->cm->course);
$context = \context_module::instance($this->cm->id);
$assign = new \assign($context, $this->cm, $course);
@@ -83,10 +88,11 @@ class dates extends activity_dates {
}
if ($timedue) {
$this->timedue = (int) $timedue;
$date = [
'dataid' => 'duedate',
'label' => get_string('activitydate:submissionsdue', 'mod_assign'),
'timestamp' => (int) $timedue,
'timestamp' => $this->timedue,
];
if ($course->relativedatesmode && $assign->can_view_grades()) {
$date['relativeto'] = $course->startdate;
@@ -96,4 +102,15 @@ class dates extends activity_dates {
return $dates;
}
/**
* Returns the dues date data, if any.
* @return int|null the due date timestamp or null if not set.
*/
public function get_due_date(): ?int {
if (!isset($this->timedue)) {
$this->get_dates();
}
return $this->timedue;
}
}
+1
View File
@@ -611,6 +611,7 @@ You can see the status of your assignment submission:
$string['submissionreceipthtml'] = '<p>You have submitted an assignment submission for \'<i>{$a->assignment}</i>\'.</p>
<p>You can see the status of your <a href="{$a->url}">assignment submission</a>.</p>';
$string['submissionreceiptsmall'] = 'You have submitted your assignment submission for {$a->assignment}';
$string['submissions'] = 'Submissions';
$string['submissionslocked'] = 'This assignment is not accepting submissions';
$string['submissionslockedshort'] = 'Submission changes not allowed';
$string['submissionsclosed'] = 'Submissions closed';
@@ -0,0 +1,104 @@
@mod @mod_assign
Feature: Testing overview integration in mod_assign
In order to summarize the assignments
As a user
I need to be able to see the assignment overview
Background:
Given the following "users" exist:
| username | firstname | lastname |
| student1 | Username | 1 |
| student2 | Username | 2 |
| student3 | Username | 3 |
| student4 | Username | 4 |
| student5 | Username | 5 |
| student6 | Username | 6 |
| student7 | Username | 7 |
| student8 | Username | 8 |
| teacher1 | Teacher | T |
And the following "courses" exist:
| fullname | shortname | groupmode |
| Course 1 | C1 | 1 |
And the following "course enrolments" exist:
| user | course | role |
| student1 | C1 | student |
| student2 | C1 | student |
| student3 | C1 | student |
| student4 | C1 | student |
| student5 | C1 | student |
| student6 | C1 | student |
| student7 | C1 | student |
| student8 | C1 | student |
| teacher1 | C1 | editingteacher |
And the following "activities" exist:
| activity | name | course | idnumber | duedate | assignsubmission_onlinetext_enabled | assignsubmission_file_enabled | submissiondrafts |
| assign | Date assign | C1 | assign1 | ##1 Jan 2040 08:00## | 1 | 0 | 0 |
| assign | No submissions | C1 | assign2 | ##1 Jan 2040 08:00## | 1 | 0 | 0 |
| assign | Pending grades | C1 | assign3 | | 1 | 0 | 0 |
And the following "mod_assign > submissions" exist:
| assign | user | onlinetext |
| Date assign | student1 | This is a submission for assignment |
| Pending grades | student1 | This is a submission for assignment |
| Pending grades | student2 | This is a submission for assignment |
And the following "grade grades" exist:
| gradeitem | user | grade |
| Pending grades | student1 | 50 |
Scenario: The assign overview report should generate log events
Given I am on the "Course 1" "course > activities > assign" page logged in as "teacher1"
When I am on the "Course 1" "course" page logged in as "teacher1"
And I navigate to "Reports" in current page administration
And I click on "Logs" "link"
And I click on "Get these logs" "button"
Then I should see "Course activities overview page viewed"
And I should see "viewed the instance list for the module 'assign'"
Scenario: Teachers can see relevant columns in the assign overview
When I am on the "Course 1" "course > activities > assign" page logged in as "teacher1"
# Check columns.
Then I should see "Name" in the "assign_overview_collapsible" "region"
And I should see "Due date" in the "assign_overview_collapsible" "region"
And I should see "Submissions" in the "assign_overview_collapsible" "region"
And I should see "Actions" in the "assign_overview_collapsible" "region"
# Check Due dates.
And I should see "1 January 2040" in the "Date assign" "table_row"
And I should see "1 January 2040" in the "No submissions" "table_row"
And I should see "-" in the "Pending grades" "table_row"
# Check Submissions.
And I should see "1 of 8" in the "Date assign" "table_row"
And I should see "0 of 8" in the "No submissions" "table_row"
And I should see "2 of 8" in the "Pending grades" "table_row"
# Check main actions.
And I should see "Grade" in the "Date assign" "table_row"
And I should see "Grade" in the "No submissions" "table_row"
And I should see "Grade" in the "Pending grades" "table_row"
And I should see "(2)" in the "Pending grades" "table_row"
# Check submission link.
And I click on "2 of 8" "link" in the "Pending grades" "table_row"
And I should see "50.00" in the "Username 1" "table_row"
And I should see "-" in the "Username 2" "table_row"
# Check grade link.
And I am on the "Course 1" "course > activities > assign" page logged in as "teacher1"
And I click on "Grade" "link" in the "Date assign" "table_row"
And I should see "Submitted for grading" in the "Username 1" "table_row"
And I should see "No submission" in the "Username 2" "table_row"
Scenario: Students can see relevant columns in the assign overview
When I am on the "Course 1" "course > activities > assign" page logged in as "student1"
# Check columns.
Then I should see "Name" in the "assign_overview_collapsible" "region"
And I should see "Due date" in the "assign_overview_collapsible" "region"
And I should see "Submission status" in the "assign_overview_collapsible" "region"
And I should see "Grade" in the "assign_overview_collapsible" "region"
# Check Due dates.
And I should see "1 January 2040" in the "Date assign" "table_row"
And I should see "1 January 2040" in the "No submissions" "table_row"
And I should see "-" in the "Pending grades" "table_row"
# Check Submission status.
And I should see "Submitted for grading" in the "Date assign" "table_row"
And I should see "No submission" in the "No submissions" "table_row"
And I should see "-" in the "Submitted for grading" "table_row"
# Check Grade.
And I should see "-" in the "Date assign" "table_row"
And I should see "-" in the "No submissions" "table_row"
And I should see "50.00" in the "Pending grades" "table_row"
@@ -0,0 +1,380 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
namespace mod_assign\courseformat;
use core_courseformat\local\overview\overviewfactory;
/**
* Tests for Assignment overview integration.
*
* @covers \mod_assign\course\overview
* @package mod_assign
* @category test
* @copyright 2025 Ferran Recio <[email protected]>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
final class overview_test extends \advanced_testcase {
#[\Override]
public static function setUpBeforeClass(): void {
global $CFG;
require_once($CFG->dirroot . '/mod/assign/locallib.php');
require_once($CFG->dirroot . '/mod/assign/tests/fixtures/testable_assign.php');
parent::setUpBeforeClass();
}
/**
* Test get_actions_overview method.
*
* @covers ::get_actions_overview
*/
public function test_get_actions_overview(): void {
$this->resetAfterTest();
$course = $this->getDataGenerator()->create_course();
$teacher = $this->getDataGenerator()->create_and_enrol($course, 'teacher');
$student = $this->getDataGenerator()->create_and_enrol($course, 'student');
// Setup the assignment.
$activity = $this->getDataGenerator()->create_module(
'assign',
['course' => $course->id],
);
$cm = get_fast_modinfo($course)->get_cm($activity->cmid);
$assign = new \mod_assign_testable_assign($cm->context, $cm, $course);
// Check for 0 submissions.
$this->setUser($teacher);
$item = overviewfactory::create($cm)->get_actions_overview();
$this->assertEquals(get_string('actions'), $item->get_name());
$this->assertEquals(0, $item->get_value());
// Simulate an assignment submission.
$this->setUser($student);
$submission = $assign->get_user_submission($student->id, true);
$submission->status = ASSIGN_SUBMISSION_STATUS_SUBMITTED;
$assign->testable_update_submission($submission, $student->id, true, false);
$data = new \stdClass();
$data->onlinetext_editor = [
'itemid' => file_get_unused_draft_itemid(),
'text' => 'Submission text',
'format' => FORMAT_MOODLE,
];
$plugin = $assign->get_submission_plugin_by_type('onlinetext');
$plugin->save($submission, $data);
// Check for 1 ungraded submission.
$this->setUser($teacher);
$item = overviewfactory::create($cm)->get_actions_overview();
$this->assertEquals(get_string('actions'), $item->get_name());
$this->assertEquals(1, $item->get_value());
// Check students cannot access submissions.
$this->setUser($student);
$item = overviewfactory::create($cm)->get_actions_overview();
$this->assertNull($item);
}
/**
* Test get_due_date_overview method.
*
* @covers ::get_due_date_overview
* @dataProvider get_due_date_overview_provider
* @param int|null $timeincrement null if no due date, or due date increment.
*/
public function test_get_due_date_overview(
int|null $timeincrement,
): void {
$this->resetAfterTest();
$course = $this->getDataGenerator()->create_course();
$teacher = $this->getDataGenerator()->create_and_enrol($course, 'teacher');
if ($timeincrement === null) {
$expectedtime = null;
} else {
$expectedtime = $this->mock_clock_with_frozen()->time() + $timeincrement;
}
$activity = $this->getDataGenerator()->create_module(
'assign',
[
'course' => $course->id,
'assignsubmission_onlinetext_enabled' => 1,
'duedate' => !empty($expectedtime) ? $expectedtime : 0,
],
);
$this->setUser($teacher);
$cm = get_fast_modinfo($course)->get_cm($activity->cmid);
$item = overviewfactory::create($cm)->get_due_date_overview();
$this->assertEquals(get_string('duedate', 'assign'), $item->get_name());
$this->assertEquals($expectedtime, $item->get_value());
}
/**
* Provider for get_due_date_overview.
*
* @return array
*/
public static function get_due_date_overview_provider(): array {
return [
'no_due' => [
'timeincrement' => null,
],
'past_due' => [
'timeincrement' => -1 * (4 * DAYSECS),
],
'future_due' => [
'timeincrement' => (4 * DAYSECS),
],
];
}
/**
* Test get_extra_submissions_overview method.
*
* @covers ::get_extra_submissions_overview
*/
public function test_get_extra_submissions_overview(): void {
$this->resetAfterTest();
$course = $this->getDataGenerator()->create_course();
$teacher = $this->getDataGenerator()->create_and_enrol($course, 'teacher');
$student = $this->getDataGenerator()->create_and_enrol($course, 'student');
$student = $this->getDataGenerator()->create_and_enrol($course, 'student2');
// Setup the assignment.
$activity = $this->getDataGenerator()->create_module(
'assign',
[
'course' => $course->id,
'assignsubmission_onlinetext_enabled' => 1,
],
);
$cm = get_fast_modinfo($course)->get_cm($activity->cmid);
$assign = new \mod_assign_testable_assign($cm->context, $cm, $course);
// Check teacher has 0 submissions.
$this->setUser($teacher);
$cm = get_fast_modinfo($course)->get_cm($activity->cmid);
$overview = overviewfactory::create($cm);
$reflection = new \ReflectionClass($overview);
$method = $reflection->getMethod('get_extra_submissions_overview');
$method->setAccessible(true);
$item = $method->invoke($overview);
$this->assertEquals(get_string('submissions', 'assign'), $item->get_name());
$this->assertEquals(0, $item->get_value());
// Simulate an assignment submission.
$this->setUser($student);
$submission = $assign->get_user_submission($student->id, true);
$submission->status = ASSIGN_SUBMISSION_STATUS_SUBMITTED;
$assign->testable_update_submission($submission, $student->id, true, false);
$data = new \stdClass();
$data->onlinetext_editor = [
'itemid' => file_get_unused_draft_itemid(),
'text' => 'Submission text',
'format' => FORMAT_MOODLE,
];
$plugin = $assign->get_submission_plugin_by_type('onlinetext');
$plugin->save($submission, $data);
// Check students cannot access submissions.
$this->setUser($student);
$cm = get_fast_modinfo($course)->get_cm($activity->cmid);
$overview = overviewfactory::create($cm);
$reflection = new \ReflectionClass($overview);
$method = $reflection->getMethod('get_extra_submissions_overview');
$method->setAccessible(true);
$item = $method->invoke($overview);
$this->assertNull($item);
// Check teacher has 1 submissions.
$this->setUser($teacher);
$cm = get_fast_modinfo($course)->get_cm($activity->cmid);
$overview = overviewfactory::create($cm);
$reflection = new \ReflectionClass($overview);
$method = $reflection->getMethod('get_extra_submissions_overview');
$method->setAccessible(true);
$item = $method->invoke($overview);
$this->assertEquals(get_string('submissions', 'assign'), $item->get_name());
$this->assertEquals(1, $item->get_value());
}
/**
* Test get_extra_submission_status_overview method.
*
* @covers ::get_extra_submission_status_overview
*/
public function test_get_extra_submission_status_overview(): void {
$this->resetAfterTest();
$course = $this->getDataGenerator()->create_course();
$teacher = $this->getDataGenerator()->create_and_enrol($course, 'teacher');
$student = $this->getDataGenerator()->create_and_enrol($course, 'student');
// Setup the assignment.
$activity = $this->getDataGenerator()->create_module(
'assign',
[
'course' => $course->id,
'assignsubmission_onlinetext_enabled' => 1,
],
);
$cm = get_fast_modinfo($course)->get_cm($activity->cmid);
$assign = new \mod_assign_testable_assign($cm->context, $cm, $course);
// Check teacher does not has submission status.
$this->setUser($teacher);
$cm = get_fast_modinfo($course)->get_cm($activity->cmid);
$overview = overviewfactory::create($cm);
$reflection = new \ReflectionClass($overview);
$method = $reflection->getMethod('get_extra_submission_status_overview');
$method->setAccessible(true);
$item = $method->invoke($overview);
$this->assertNull($item);
// Admin does not have submission status.
$this->setAdminUser();
$cm = get_fast_modinfo($course)->get_cm($activity->cmid);
$overview = overviewfactory::create($cm);
$reflection = new \ReflectionClass($overview);
$method = $reflection->getMethod('get_extra_submission_status_overview');
$method->setAccessible(true);
$item = $method->invoke($overview);
$this->assertNull($item);
// Check student see the new status.
$this->setUser($student);
$cm = get_fast_modinfo($course)->get_cm($activity->cmid);
$overview = overviewfactory::create($cm);
$reflection = new \ReflectionClass($overview);
$method = $reflection->getMethod('get_extra_submission_status_overview');
$method->setAccessible(true);
$item = $method->invoke($overview);
$this->assertEquals(get_string('submissionstatus', 'assign'), $item->get_name());
$this->assertEquals(get_string('submissionstatus_new', 'assign'), $item->get_value());
// Simulate an assignment submission.
$this->setUser($student);
$submission = $assign->get_user_submission($student->id, true);
$submission->status = ASSIGN_SUBMISSION_STATUS_SUBMITTED;
$assign->testable_update_submission($submission, $student->id, true, false);
$data = new \stdClass();
$data->onlinetext_editor = [
'itemid' => file_get_unused_draft_itemid(),
'text' => 'Submission text',
'format' => FORMAT_MOODLE,
];
$plugin = $assign->get_submission_plugin_by_type('onlinetext');
$plugin->save($submission, $data);
// Check student see the new status.
$this->setUser($student);
$cm = get_fast_modinfo($course)->get_cm($activity->cmid);
$overview = overviewfactory::create($cm);
$reflection = new \ReflectionClass($overview);
$method = $reflection->getMethod('get_extra_submission_status_overview');
$method->setAccessible(true);
$item = $method->invoke($overview);
$this->assertEquals(get_string('submissionstatus', 'assign'), $item->get_name());
$this->assertEquals(get_string('submissionstatus_submitted', 'assign'), $item->get_value());
}
/**
* Test get_extra_submission_status_overview method in group submissions.
*
* @covers ::get_extra_submission_status_overview
*/
public function test_get_extra_submission_status_overview_groups(): void {
$this->resetAfterTest();
$course = $this->getDataGenerator()->create_course();
$teacher = $this->getDataGenerator()->create_and_enrol($course, 'teacher');
$student = $this->getDataGenerator()->create_and_enrol($course, 'student');
$student2 = $this->getDataGenerator()->create_and_enrol($course, 'student');
$group = $this->getDataGenerator()->create_group(['courseid' => $course->id]);
groups_add_member($group, $student);
groups_add_member($group, $student2);
// Setup the assignment.
$activity = $this->getDataGenerator()->create_module(
'assign',
[
'course' => $course->id,
'assignsubmission_onlinetext_enabled' => 1,
'teamsubmission' => 1,
],
);
$cm = get_fast_modinfo($course)->get_cm($activity->cmid);
$assign = new \mod_assign_testable_assign($cm->context, $cm, $course);
// Check teacher does not has submission status.
$this->setUser($teacher);
$cm = get_fast_modinfo($course)->get_cm($activity->cmid);
$overview = overviewfactory::create($cm);
$reflection = new \ReflectionClass($overview);
$method = $reflection->getMethod('get_extra_submission_status_overview');
$method->setAccessible(true);
$item = $method->invoke($overview);
$this->assertNull($item);
// Admin does not have submission status.
$this->setAdminUser();
$cm = get_fast_modinfo($course)->get_cm($activity->cmid);
$overview = overviewfactory::create($cm);
$reflection = new \ReflectionClass($overview);
$method = $reflection->getMethod('get_extra_submission_status_overview');
$method->setAccessible(true);
$item = $method->invoke($overview);
$this->assertNull($item);
// Check student see the new status.
$this->setUser($student);
$cm = get_fast_modinfo($course)->get_cm($activity->cmid);
$overview = overviewfactory::create($cm);
$reflection = new \ReflectionClass($overview);
$method = $reflection->getMethod('get_extra_submission_status_overview');
$method->setAccessible(true);
$item = $method->invoke($overview);
$this->assertEquals(get_string('submissionstatus', 'assign'), $item->get_name());
$this->assertEquals(get_string('submissionstatus_new', 'assign'), $item->get_value());
// Simulate an assignment submission.
$this->setUser($student2);
$submission = $assign->get_group_submission($student2->id, $group->id, true);
$submission->status = ASSIGN_SUBMISSION_STATUS_SUBMITTED;
$assign->testable_update_submission($submission, $student2->id, true, false);
$data = new \stdClass();
$data->onlinetext_editor = [
'itemid' => file_get_unused_draft_itemid(),
'text' => 'Submission text',
'format' => FORMAT_MOODLE,
];
$plugin = $assign->get_submission_plugin_by_type('onlinetext');
$plugin->save($submission, $data);
// Check student see the new status.
$this->setUser($student);
$cm = get_fast_modinfo($course)->get_cm($activity->cmid);
$overview = overviewfactory::create($cm);
$reflection = new \ReflectionClass($overview);
$method = $reflection->getMethod('get_extra_submission_status_overview');
$method->setAccessible(true);
$item = $method->invoke($overview);
$this->assertEquals(get_string('submissionstatus', 'assign'), $item->get_name());
$this->assertEquals(get_string('submissionstatus_submitted', 'assign'), $item->get_value());
}
}