MDL-83888 mod_assign: redirect index.php to course overview
This commit is contained in:
@@ -0,0 +1,7 @@
|
||||
issueNumber: MDL-83888
|
||||
notes:
|
||||
mod_assign:
|
||||
- message: >-
|
||||
The assign_course_index_summary is now deprecated. The assign index is
|
||||
now generated using the mod_assign\course\overview integration class.
|
||||
type: deprecated
|
||||
@@ -1220,10 +1220,19 @@ class renderer extends \plugin_renderer_base {
|
||||
/**
|
||||
* Render a course index summary
|
||||
*
|
||||
* @deprecated since Moodle 5.0 (MDL-83888).
|
||||
* @todo MDL-84429 Final deprecation in Moodle 6.0.
|
||||
* @param \assign_course_index_summary $indexsummary
|
||||
* @return string
|
||||
*/
|
||||
#[\core\attribute\deprecated(
|
||||
since: '5.0',
|
||||
mdl: 'MDL-83888',
|
||||
reason: 'The assign_course_index_summary class is not used anymore.',
|
||||
)]
|
||||
public function render_assign_course_index_summary(\assign_course_index_summary $indexsummary) {
|
||||
\core\deprecation::emit_deprecation_if_present([$this, __FUNCTION__]);
|
||||
|
||||
$o = '';
|
||||
|
||||
$strplural = get_string('modulenameplural', 'assign');
|
||||
|
||||
+2
-24
@@ -25,28 +25,6 @@
|
||||
require_once("../../config.php");
|
||||
require_once($CFG->dirroot.'/mod/assign/locallib.php');
|
||||
// For this type of page this is the course id.
|
||||
$id = required_param('id', PARAM_INT);
|
||||
$courseid = required_param('id', PARAM_INT);
|
||||
|
||||
$course = $DB->get_record('course', array('id' => $id), '*', MUST_EXIST);
|
||||
require_login($course);
|
||||
$PAGE->set_url('/mod/assign/index.php', array('id' => $id));
|
||||
$PAGE->set_pagelayout('incourse');
|
||||
|
||||
\mod_assign\event\course_module_instance_list_viewed::create_from_course($course)->trigger();
|
||||
|
||||
// Print the header.
|
||||
$strplural = get_string("modulenameplural", "assign");
|
||||
$PAGE->navbar->add($strplural);
|
||||
$PAGE->set_title($strplural);
|
||||
$PAGE->set_heading($course->fullname);
|
||||
echo $OUTPUT->header();
|
||||
echo $OUTPUT->heading(format_string($strplural));
|
||||
|
||||
$context = context_course::instance($course->id);
|
||||
|
||||
require_capability('mod/assign:view', $context);
|
||||
|
||||
$assign = new assign($context, null, $course);
|
||||
|
||||
// Get the assign to render the page.
|
||||
echo $assign->view('viewcourseindex');
|
||||
\core_courseformat\activityoverviewbase::redirect_to_overview_page($courseid, 'assign');
|
||||
|
||||
@@ -699,8 +699,6 @@ class assign {
|
||||
$o .= $this->view_plugin_grading_batch_operation();
|
||||
} else if ($action == 'viewpluginpage') {
|
||||
$o .= $this->view_plugin_page();
|
||||
} else if ($action == 'viewcourseindex') {
|
||||
$o .= $this->view_course_index();
|
||||
} else if ($action == 'viewbatchsetmarkingworkflowstate') {
|
||||
$o .= $this->view_batch_set_workflow_state();
|
||||
} else if ($action == 'viewbatchmarkingallocation') {
|
||||
@@ -3255,97 +3253,6 @@ class assign {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* View a summary listing of all assignments in the current course.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
private function view_course_index() {
|
||||
global $USER;
|
||||
|
||||
$o = '';
|
||||
|
||||
$course = $this->get_course();
|
||||
$strplural = get_string('modulenameplural', 'assign');
|
||||
|
||||
if (!$cms = get_coursemodules_in_course('assign', $course->id, 'm.duedate')) {
|
||||
$o .= $this->get_renderer()->notification(get_string('thereareno', 'moodle', $strplural));
|
||||
$o .= $this->get_renderer()->continue_button(new moodle_url('/course/view.php', array('id' => $course->id)));
|
||||
return $o;
|
||||
}
|
||||
|
||||
$strsectionname = '';
|
||||
$usesections = course_format_uses_sections($course->format);
|
||||
$modinfo = get_fast_modinfo($course);
|
||||
|
||||
if ($usesections) {
|
||||
$strsectionname = course_get_format($course)->get_generic_section_name();
|
||||
$sections = $modinfo->get_section_info_all();
|
||||
}
|
||||
$courseindexsummary = new assign_course_index_summary($usesections, $strsectionname);
|
||||
|
||||
$timenow = time();
|
||||
|
||||
$currentsection = '';
|
||||
foreach ($modinfo->instances['assign'] as $cm) {
|
||||
if (!$cm->uservisible) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$timedue = $cms[$cm->id]->duedate;
|
||||
|
||||
$sectionname = '';
|
||||
if ($usesections && $cm->sectionnum) {
|
||||
$sectionname = get_section_name($course, $sections[$cm->sectionnum]);
|
||||
}
|
||||
|
||||
$submitted = '';
|
||||
$context = context_module::instance($cm->id);
|
||||
|
||||
$assignment = new assign($context, $cm, $course);
|
||||
|
||||
// Apply overrides.
|
||||
$assignment->update_effective_access($USER->id);
|
||||
$timedue = $assignment->get_instance()->duedate;
|
||||
|
||||
if (has_capability('mod/assign:submit', $context) &&
|
||||
!has_capability('moodle/site:config', $context)) {
|
||||
$cangrade = false;
|
||||
if ($assignment->get_instance()->teamsubmission) {
|
||||
$usersubmission = $assignment->get_group_submission($USER->id, 0, false);
|
||||
} else {
|
||||
$usersubmission = $assignment->get_user_submission($USER->id, false);
|
||||
}
|
||||
|
||||
if (!empty($usersubmission->status)) {
|
||||
$submitted = get_string('submissionstatus_' . $usersubmission->status, 'assign');
|
||||
} else {
|
||||
$submitted = get_string('submissionstatus_', 'assign');
|
||||
}
|
||||
|
||||
$gradinginfo = grade_get_grades($course->id, 'mod', 'assign', $cm->instance, $USER->id);
|
||||
if (isset($gradinginfo->items[0]->grades[$USER->id]) &&
|
||||
!$gradinginfo->items[0]->grades[$USER->id]->hidden ) {
|
||||
$grade = $gradinginfo->items[0]->grades[$USER->id]->str_grade;
|
||||
} else {
|
||||
$grade = '-';
|
||||
}
|
||||
} else if (has_capability('mod/assign:grade', $context)) {
|
||||
$submitted = $assignment->count_submissions_with_status(ASSIGN_SUBMISSION_STATUS_SUBMITTED);
|
||||
$grade = $assignment->count_submissions_need_grading();
|
||||
$cangrade = true;
|
||||
}
|
||||
|
||||
$courseindexsummary->add_assign_info($cm->id, $cm->get_formatted_name(),
|
||||
$sectionname, $timedue, $submitted, $grade, $cangrade);
|
||||
}
|
||||
|
||||
$o .= $this->get_renderer()->render($courseindexsummary);
|
||||
$o .= $this->view_footer();
|
||||
|
||||
return $o;
|
||||
}
|
||||
|
||||
/**
|
||||
* View a page rendered by a plugin.
|
||||
*
|
||||
|
||||
@@ -622,6 +622,10 @@ class assign_grading_summary implements renderable {
|
||||
|
||||
/**
|
||||
* Renderable course index summary
|
||||
*
|
||||
* @deprecated since Moodle 5.0 (MDL-83888).
|
||||
* @todo MDL-84429 Final deprecation in Moodle 6.0.
|
||||
*
|
||||
* @package mod_assign
|
||||
* @copyright 2012 NetSpot {@link http://www.netspot.com.au}
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
@@ -637,10 +641,18 @@ class assign_course_index_summary implements renderable {
|
||||
/**
|
||||
* constructor
|
||||
*
|
||||
* @deprecated since Moodle 5.0 (MDL-83888).
|
||||
* @todo MDL-84429 Final deprecation in Moodle 6.0.
|
||||
* @param boolean $usesections - True if this course format uses sections
|
||||
* @param string $courseformatname - The id of this course format
|
||||
*/
|
||||
#[\core\attribute\deprecated(
|
||||
since: '5.0',
|
||||
mdl: 'MDL-83888',
|
||||
reason: 'The assign_course_index_summary class is not used anymore.',
|
||||
)]
|
||||
public function __construct($usesections, $courseformatname) {
|
||||
\core\deprecation::emit_deprecation_if_present([$this, __FUNCTION__]);
|
||||
$this->usesections = $usesections;
|
||||
$this->courseformatname = $courseformatname;
|
||||
}
|
||||
@@ -648,6 +660,8 @@ class assign_course_index_summary implements renderable {
|
||||
/**
|
||||
* Add a row of data to display on the course index page
|
||||
*
|
||||
* @deprecated since Moodle 5.0 (MDL-83888).
|
||||
* @todo MDL-84429 Final deprecation in Moodle 6.0.
|
||||
* @param int $cmid - The course module id for generating a link
|
||||
* @param string $cmname - The course module name for generating a link
|
||||
* @param string $sectionname - The name of the course section (only if $usesections is true)
|
||||
@@ -657,7 +671,13 @@ class assign_course_index_summary implements renderable {
|
||||
* @param string $gradeinfo - The current users grade if they have been graded and it is not hidden.
|
||||
* @param bool cangrade - Does this user have grade capability?
|
||||
*/
|
||||
#[\core\attribute\deprecated(
|
||||
since: '5.0',
|
||||
mdl: 'MDL-83888',
|
||||
reason: 'The assign_course_index_summary class is not used anymore.',
|
||||
)]
|
||||
public function add_assign_info($cmid, $cmname, $sectionname, $timedue, $submissioninfo, $gradeinfo, $cangrade = false) {
|
||||
\core\deprecation::emit_deprecation_if_present([$this, __FUNCTION__]);
|
||||
$this->assignments[] = ['cmid' => $cmid,
|
||||
'cmname' => $cmname,
|
||||
'sectionname' => $sectionname,
|
||||
|
||||
@@ -102,3 +102,14 @@ Feature: Testing overview integration in mod_assign
|
||||
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"
|
||||
|
||||
Scenario: The assign index redirect to the activities overview
|
||||
When I log in as "admin"
|
||||
And I am on "Course 1" course homepage with editing mode on
|
||||
And I add the "Activities" block
|
||||
And I click on "Assignments" "link" in the "Activities" "block"
|
||||
Then I should see "View all the activities in this course"
|
||||
And 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"
|
||||
|
||||
@@ -4469,59 +4469,6 @@ Anchor link 2:<a title=\"bananas\" href=\"../logo-240x60.gif\">Link text</a>
|
||||
$this->assertSame('This one should be re-created', $event2->description);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test submissions that need grading output after one ungraded submission
|
||||
*/
|
||||
public function test_submissions_need_grading(): void {
|
||||
global $PAGE;
|
||||
|
||||
$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.
|
||||
$this->setUser($teacher);
|
||||
$time = time();
|
||||
$assign = $this->create_instance($course, [
|
||||
'assignsubmission_onlinetext_enabled' => 1,
|
||||
]);
|
||||
$PAGE->set_url(new \moodle_url('/mod/assign/view.php', [
|
||||
'id' => $assign->get_course_module()->id,
|
||||
'action' => 'grading',
|
||||
]));
|
||||
|
||||
// Check for 0 submissions.
|
||||
$summary = $assign->view('viewcourseindex');
|
||||
|
||||
$this->assertStringContainsString('/mod/assign/view.php?id=' .
|
||||
$assign->get_course_module()->id . '&action=grading">' .
|
||||
get_string('numberofsubmissionsneedgradinglabel', 'assign', 0) . '</a>', $summary);
|
||||
|
||||
// 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);
|
||||
|
||||
$summary = $assign->view('viewcourseindex');
|
||||
|
||||
$this->assertStringContainsString('/mod/assign/view.php?id=' .
|
||||
$assign->get_course_module()->id . '&action=grading">' .
|
||||
get_string('numberofsubmissionsneedgradinglabel', 'assign', 1) . '</a>', $summary);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test that attachments should not be provided if \assign->show_intro returns false.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user