diff --git a/mod/assign/lib.php b/mod/assign/lib.php
index 6f0d59b2994..e494d633c0c 100644
--- a/mod/assign/lib.php
+++ b/mod/assign/lib.php
@@ -560,315 +560,24 @@ function assign_page_type_list($pagetype, $parentcontext, $currentcontext) {
}
/**
- * Print an overview of all assignments
- * for the courses.
- *
- * @deprecated since 3.3
- * @todo The final deprecation of this function will take place in Moodle 3.7 - see MDL-57487.
- * @param mixed $courses The list of courses to print the overview for
- * @param array $htmlarray The array of html to return
- * @return true
+ * @deprecated since Moodle 3.3, when the block_course_overview block was removed.
*/
-function assign_print_overview($courses, &$htmlarray) {
- global $CFG, $DB;
-
- debugging('The function assign_print_overview() is now deprecated.', DEBUG_DEVELOPER);
-
- if (empty($courses) || !is_array($courses) || count($courses) == 0) {
- return true;
- }
-
- if (!$assignments = get_all_instances_in_courses('assign', $courses)) {
- return true;
- }
-
- $assignmentids = array();
-
- // Do assignment_base::isopen() here without loading the whole thing for speed.
- foreach ($assignments as $key => $assignment) {
- $time = time();
- $isopen = false;
- if ($assignment->duedate) {
- $duedate = false;
- if ($assignment->cutoffdate) {
- $duedate = $assignment->cutoffdate;
- }
- if ($duedate) {
- $isopen = ($assignment->allowsubmissionsfromdate <= $time && $time <= $duedate);
- } else {
- $isopen = ($assignment->allowsubmissionsfromdate <= $time);
- }
- }
- if ($isopen) {
- $assignmentids[] = $assignment->id;
- }
- }
-
- if (empty($assignmentids)) {
- // No assignments to look at - we're done.
- return true;
- }
-
- // Definitely something to print, now include the constants we need.
- require_once($CFG->dirroot . '/mod/assign/locallib.php');
-
- $strduedate = get_string('duedate', 'assign');
- $strcutoffdate = get_string('nosubmissionsacceptedafter', 'assign');
- $strnolatesubmissions = get_string('nolatesubmissions', 'assign');
- $strduedateno = get_string('duedateno', 'assign');
- $strassignment = get_string('modulename', 'assign');
-
- // We do all possible database work here *outside* of the loop to ensure this scales.
- list($sqlassignmentids, $assignmentidparams) = $DB->get_in_or_equal($assignmentids);
-
- $mysubmissions = null;
- $unmarkedsubmissions = null;
-
- foreach ($assignments as $assignment) {
-
- // Do not show assignments that are not open.
- if (!in_array($assignment->id, $assignmentids)) {
- continue;
- }
-
- $context = context_module::instance($assignment->coursemodule);
-
- // Does the submission status of the assignment require notification?
- if (has_capability('mod/assign:submit', $context, null, false)) {
- // Does the submission status of the assignment require notification?
- $submitdetails = assign_get_mysubmission_details_for_print_overview($mysubmissions, $sqlassignmentids,
- $assignmentidparams, $assignment);
- } else {
- $submitdetails = false;
- }
-
- if (has_capability('mod/assign:grade', $context, null, false)) {
- // Does the grading status of the assignment require notification ?
- $gradedetails = assign_get_grade_details_for_print_overview($unmarkedsubmissions, $sqlassignmentids,
- $assignmentidparams, $assignment, $context);
- } else {
- $gradedetails = false;
- }
-
- if (empty($submitdetails) && empty($gradedetails)) {
- // There is no need to display this assignment as there is nothing to notify.
- continue;
- }
-
- $dimmedclass = '';
- if (!$assignment->visible) {
- $dimmedclass = ' class="dimmed"';
- }
- $href = $CFG->wwwroot . '/mod/assign/view.php?id=' . $assignment->coursemodule;
- $basestr = '
' .
- '
';
- if ($assignment->duedate) {
- $userdate = userdate($assignment->duedate);
- $basestr .= '
' . $strduedate . ': ' . $userdate . '
';
- } else {
- $basestr .= '
' . $strduedateno . '
';
- }
- if ($assignment->cutoffdate) {
- if ($assignment->cutoffdate == $assignment->duedate) {
- $basestr .= '
' . $strnolatesubmissions . '
';
- } else {
- $userdate = userdate($assignment->cutoffdate);
- $basestr .= '
' . $strcutoffdate . ': ' . $userdate . '
';
- }
- }
-
- // Show only relevant information.
- if (!empty($submitdetails)) {
- $basestr .= $submitdetails;
- }
-
- if (!empty($gradedetails)) {
- $basestr .= $gradedetails;
- }
- $basestr .= '
';
-
- if (empty($htmlarray[$assignment->course]['assign'])) {
- $htmlarray[$assignment->course]['assign'] = $basestr;
- } else {
- $htmlarray[$assignment->course]['assign'] .= $basestr;
- }
- }
- return true;
+function assign_print_overview() {
+ throw new coding_exception('assign_print_overview() can not be used any more and is obsolete.');
}
/**
- * This api generates html to be displayed to students in print overview section, related to their submission status of the given
- * assignment.
- *
- * @deprecated since 3.3
- * @todo The final deprecation of this function will take place in Moodle 3.7 - see MDL-57487.
- * @param array $mysubmissions list of submissions of current user indexed by assignment id.
- * @param string $sqlassignmentids sql clause used to filter open assignments.
- * @param array $assignmentidparams sql params used to filter open assignments.
- * @param stdClass $assignment current assignment
- *
- * @return bool|string html to display , false if nothing needs to be displayed.
- * @throws coding_exception
+ * @deprecated since Moodle 3.3, when the block_course_overview block was removed.
*/
-function assign_get_mysubmission_details_for_print_overview(&$mysubmissions, $sqlassignmentids, $assignmentidparams,
- $assignment) {
- global $USER, $DB;
-
- debugging('The function assign_get_mysubmission_details_for_print_overview() is now deprecated.', DEBUG_DEVELOPER);
-
- if ($assignment->nosubmissions) {
- // Offline assignment. No need to display alerts for offline assignments.
- return false;
- }
-
- $strnotsubmittedyet = get_string('notsubmittedyet', 'assign');
-
- if (!isset($mysubmissions)) {
-
- // Get all user submissions, indexed by assignment id.
- $dbparams = array_merge(array($USER->id), $assignmentidparams, array($USER->id));
- $mysubmissions = $DB->get_records_sql('SELECT a.id AS assignment,
- a.nosubmissions AS nosubmissions,
- g.timemodified AS timemarked,
- g.grader AS grader,
- g.grade AS grade,
- s.status AS status
- FROM {assign} a, {assign_submission} s
- LEFT JOIN {assign_grades} g ON
- g.assignment = s.assignment AND
- g.userid = ? AND
- g.attemptnumber = s.attemptnumber
- WHERE a.id ' . $sqlassignmentids . ' AND
- s.latest = 1 AND
- s.assignment = a.id AND
- s.userid = ?', $dbparams);
- }
-
- $submitdetails = '';
- $submitdetails .= '';
- $submitdetails .= get_string('mysubmission', 'assign');
- $submission = false;
-
- if (isset($mysubmissions[$assignment->id])) {
- $submission = $mysubmissions[$assignment->id];
- }
-
- if ($submission && $submission->status == ASSIGN_SUBMISSION_STATUS_SUBMITTED) {
- // A valid submission already exists, no need to notify students about this.
- return false;
- }
-
- // We need to show details only if a valid submission doesn't exist.
- if (!$submission ||
- !$submission->status ||
- $submission->status == ASSIGN_SUBMISSION_STATUS_DRAFT ||
- $submission->status == ASSIGN_SUBMISSION_STATUS_NEW
- ) {
- $submitdetails .= $strnotsubmittedyet;
- } else {
- $submitdetails .= get_string('submissionstatus_' . $submission->status, '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 {
- $gradingstatus = ASSIGN_GRADING_STATUS_NOT_GRADED;
- }
- $submitdetails .= ', ' . get_string($gradingstatus, 'assign');
- $submitdetails .= '
';
- return $submitdetails;
+function assign_get_mysubmission_details_for_print_overview() {
+ throw new coding_exception('assign_get_mysubmission_details_for_print_overview() can not be used any more and is obsolete.');
}
/**
- * This api generates html to be displayed to teachers in print overview section, related to the grading status of the given
- * assignment's submissions.
- *
- * @deprecated since 3.3
- * @todo The final deprecation of this function will take place in Moodle 3.7 - see MDL-57487.
- * @param array $unmarkedsubmissions list of submissions of that are currently unmarked indexed by assignment id.
- * @param string $sqlassignmentids sql clause used to filter open assignments.
- * @param array $assignmentidparams sql params used to filter open assignments.
- * @param stdClass $assignment current assignment
- * @param context $context context of the assignment.
- *
- * @return bool|string html to display , false if nothing needs to be displayed.
- * @throws coding_exception
+ * @deprecated since Moodle 3.3, when the block_course_overview block was removed.
*/
-function assign_get_grade_details_for_print_overview(&$unmarkedsubmissions, $sqlassignmentids, $assignmentidparams,
- $assignment, $context) {
- global $DB;
-
- debugging('The function assign_get_grade_details_for_print_overview() is now deprecated.', DEBUG_DEVELOPER);
-
- if (!isset($unmarkedsubmissions)) {
- // Build up and array of unmarked submissions indexed by assignment id/ userid
- // for use where the user has grading rights on assignment.
- $dbparams = array_merge(array(ASSIGN_SUBMISSION_STATUS_SUBMITTED), $assignmentidparams);
- $rs = $DB->get_recordset_sql('SELECT s.assignment as assignment,
- s.userid as userid,
- s.id as id,
- s.status as status,
- g.timemodified as timegraded
- FROM {assign_submission} s
- LEFT JOIN {assign_grades} g ON
- s.userid = g.userid AND
- s.assignment = g.assignment AND
- g.attemptnumber = s.attemptnumber
- LEFT JOIN {assign} a ON
- a.id = s.assignment
- WHERE
- ( g.timemodified is NULL OR
- s.timemodified >= g.timemodified OR
- g.grade IS NULL OR
- (g.grade = -1 AND
- a.grade < 0)) AND
- s.timemodified IS NOT NULL AND
- s.status = ? AND
- s.latest = 1 AND
- s.assignment ' . $sqlassignmentids, $dbparams);
-
- $unmarkedsubmissions = array();
- foreach ($rs as $rd) {
- $unmarkedsubmissions[$rd->assignment][$rd->userid] = $rd->id;
- }
- $rs->close();
- }
-
- // Count how many people can submit.
- $submissions = 0;
- if ($students = get_enrolled_users($context, 'mod/assign:view', 0, 'u.id')) {
- foreach ($students as $student) {
- if (isset($unmarkedsubmissions[$assignment->id][$student->id])) {
- $submissions++;
- }
- }
- }
-
- if ($submissions) {
- $urlparams = array('id' => $assignment->coursemodule, 'action' => 'grading');
- $url = new moodle_url('/mod/assign/view.php', $urlparams);
- $gradedetails = '';
- return $gradedetails;
- } else {
- return false;
- }
-
+function assign_get_grade_details_for_print_overview() {
+ throw new coding_exception('assign_get_grade_details_for_print_overview() can not be used any more and is obsolete.');
}
/**
diff --git a/mod/assign/tests/generator.php b/mod/assign/tests/generator.php
index 0d341507651..f4cbcef10a6 100644
--- a/mod/assign/tests/generator.php
+++ b/mod/assign/tests/generator.php
@@ -128,8 +128,6 @@ trait mod_assign_test_generator {
]);
// Bump all timecreated and timemodified for this user back.
- // The old assign_print_overview function includes submissions which have been graded where the grade modified
- // date matches the submission modified date.
$DB->execute('UPDATE {assign_submission} SET timecreated = timecreated - 1, timemodified = timemodified - 1 WHERE userid = :userid',
['userid' => $student->id]);
diff --git a/mod/assign/tests/lib_test.php b/mod/assign/tests/lib_test.php
index 759f534818a..e002e4f3cd8 100644
--- a/mod/assign/tests/lib_test.php
+++ b/mod/assign/tests/lib_test.php
@@ -46,139 +46,6 @@ class mod_assign_lib_testcase extends advanced_testcase {
// Use the generator helper.
use mod_assign_test_generator;
- public function test_assign_print_overview() {
- global $DB;
-
- $this->resetAfterTest();
-
- $course = $this->getDataGenerator()->create_course();
- $teacher = $this->getDataGenerator()->create_and_enrol($course, 'teacher');
- $student = $this->getDataGenerator()->create_and_enrol($course, 'student');
-
- $this->setAdminUser();
-
- // Assignment with default values.
- $firstassign = $this->create_instance($course, ['name' => 'First Assignment']);
-
- // Assignment with submissions.
- $secondassign = $this->create_instance($course, [
- 'name' => 'Assignment with submissions',
- 'duedate' => time(),
- 'attemptreopenmethod' => ASSIGN_ATTEMPT_REOPEN_METHOD_MANUAL,
- 'maxattempts' => 3,
- 'submissiondrafts' => 1,
- 'assignsubmission_onlinetext_enabled' => 1,
- ]);
- $this->add_submission($student, $secondassign);
- $this->submit_for_grading($student, $secondassign);
- $this->mark_submission($teacher, $secondassign, $student, 50.0);
-
- // Past assignments should not show up.
- $pastassign = $this->create_instance($course, [
- 'name' => 'Past Assignment',
- 'duedate' => time() - DAYSECS - 1,
- 'cutoffdate' => time() - DAYSECS,
- 'nosubmissions' => 0,
- 'assignsubmission_onlinetext_enabled' => 1,
- ]);
-
- // Open assignments should show up only if relevant.
- $openassign = $this->create_instance($course, [
- 'name' => 'Open Assignment',
- 'duedate' => time(),
- 'cutoffdate' => time() + DAYSECS,
- 'nosubmissions' => 0,
- 'assignsubmission_onlinetext_enabled' => 1,
- ]);
- $pastsubmission = $pastassign->get_user_submission($student->id, true);
- $opensubmission = $openassign->get_user_submission($student->id, true);
-
- // Check the overview as the different users.
- // For students , open assignments should show only when there are no valid submissions.
- $this->setUser($student);
- $overview = array();
- $courses = $DB->get_records('course', array('id' => $course->id));
- assign_print_overview($courses, $overview);
- $this->assertDebuggingCalledCount(3);
- $this->assertEquals(1, count($overview));
- $this->assertRegExp('/.*Open Assignment.*/', $overview[$course->id]['assign']); // No valid submission.
- $this->assertNotRegExp('/.*First Assignment.*/', $overview[$course->id]['assign']); // Has valid submission.
-
- // And now submit the submission.
- $opensubmission->status = ASSIGN_SUBMISSION_STATUS_SUBMITTED;
- $openassign->testable_update_submission($opensubmission, $student->id, true, false);
-
- $overview = array();
- assign_print_overview($courses, $overview);
- $this->assertDebuggingCalledCount(3);
- $this->assertEquals(0, count($overview));
-
- $this->setUser($teacher);
- $overview = array();
- assign_print_overview($courses, $overview);
- $this->assertDebuggingCalledCount(3);
- $this->assertEquals(1, count($overview));
- // Submissions without a grade.
- $this->assertRegExp('/.*Open Assignment.*/', $overview[$course->id]['assign']);
- $this->assertNotRegExp('/.*Assignment with submissions.*/', $overview[$course->id]['assign']);
-
- $this->setUser($teacher);
- $overview = array();
- assign_print_overview($courses, $overview);
- $this->assertDebuggingCalledCount(3);
- $this->assertEquals(1, count($overview));
- // Submissions without a grade.
- $this->assertRegExp('/.*Open Assignment.*/', $overview[$course->id]['assign']);
- $this->assertNotRegExp('/.*Assignment with submissions.*/', $overview[$course->id]['assign']);
-
- // Let us grade a submission.
- $this->setUser($teacher);
- $data = new stdClass();
- $data->grade = '50.0';
- $openassign->testable_apply_grade_to_user($data, $student->id, 0);
-
- // The assign_print_overview expects the grade date to be after the submission date.
- $graderecord = $DB->get_record('assign_grades', array('assignment' => $openassign->get_instance()->id,
- 'userid' => $student->id, 'attemptnumber' => 0));
- $graderecord->timemodified += 1;
- $DB->update_record('assign_grades', $graderecord);
-
- $overview = array();
- assign_print_overview($courses, $overview);
- // Now assignment 4 should not show up.
- $this->assertDebuggingCalledCount(3);
- $this->assertEmpty($overview);
-
- $this->setUser($teacher);
- $overview = array();
- assign_print_overview($courses, $overview);
- $this->assertDebuggingCalledCount(3);
- // Now assignment 4 should not show up.
- $this->assertEmpty($overview);
- }
-
- /**
- * Test that assign_print_overview does not return any assignments which are Open Offline.
- */
- public function test_assign_print_overview_open_offline() {
- $this->resetAfterTest();
- $course = $this->getDataGenerator()->create_course();
- $student = $this->getDataGenerator()->create_and_enrol($course, 'student');
-
- $this->setAdminUser();
- $openassign = $this->create_instance($course, [
- 'duedate' => time() + DAYSECS,
- 'cutoffdate' => time() + (DAYSECS * 2),
- ]);
-
- $this->setUser($student);
- $overview = [];
- assign_print_overview([$course], $overview);
-
- $this->assertDebuggingCalledCount(1);
- $this->assertEquals(0, count($overview));
- }
-
/**
* Test that assign_print_recent_activity shows ungraded submitted assignments.
*/