Skip to content

Commit

Permalink
Merge branch 'MDL-78333' of https://github.com/paulholden/moodle
Browse files Browse the repository at this point in the history
  • Loading branch information
junpataleta committed Jun 15, 2023
2 parents af75727 + ca95bee commit 5088fba
Show file tree
Hide file tree
Showing 12 changed files with 53 additions and 158 deletions.
10 changes: 3 additions & 7 deletions mod/assign/assignmentplugin.php
Expand Up @@ -522,14 +522,10 @@ public function upgrade(context $oldcontext,
}

/**
* Formatting for log info
*
* @param stdClass $submissionorgrade assign_submission or assign_grade The new submission or grade
* @return string
* @deprecated since 2.7
*/
public function format_for_log(stdClass $submissionorgrade) {
// Format the info for each submission plugin add_to_log.
return '';
public function format_for_log() {
throw new coding_exception(__FUNCTION__ . ' has been deprecated, please do not use it any more');
}

/**
Expand Down
29 changes: 29 additions & 0 deletions mod/assign/deprecatedlib.php
Expand Up @@ -57,3 +57,32 @@ function assign_get_completion_state($course, $cm, $userid, $type) {
return $type;
}
}

/**
* @deprecated since Moodle 3.3, when the block_course_overview block was removed.
*/
function assign_print_overview() {
throw new coding_exception('assign_print_overview() can not be used any more and is obsolete.');
}

/**
* @deprecated since Moodle 3.3, when the block_course_overview block was removed.
*/
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.');
}

/**
* @deprecated since Moodle 3.3, when the block_course_overview block was removed.
*/
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.');
}

/**
* @deprecated since Moodle 3.8
*/
function assign_scale_used() {
throw new coding_exception('assign_scale_used() can not be used anymore. Plugins can implement ' .
'<modname>_scale_used_anywhere, all implementations of <modname>_scale_used are now ignored');
}
29 changes: 0 additions & 29 deletions mod/assign/lib.php
Expand Up @@ -618,27 +618,6 @@ function assign_page_type_list($pagetype, $parentcontext, $currentcontext) {
return $modulepagetype;
}

/**
* @deprecated since Moodle 3.3, when the block_course_overview block was removed.
*/
function assign_print_overview() {
throw new coding_exception('assign_print_overview() can not be used any more and is obsolete.');
}

/**
* @deprecated since Moodle 3.3, when the block_course_overview block was removed.
*/
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.');
}

/**
* @deprecated since Moodle 3.3, when the block_course_overview block was removed.
*/
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.');
}

/**
* Print recent activity from all assignments in a given course
*
Expand Down Expand Up @@ -961,14 +940,6 @@ function assign_print_recent_mod_activity($activity, $courseid, $detail, $modnam
echo '</td></tr></table>';
}

/**
* @deprecated since Moodle 3.8
*/
function assign_scale_used() {
throw new coding_exception('assign_scale_used() can not be used anymore. Plugins can implement ' .
'<modname>_scale_used_anywhere, all implementations of <modname>_scale_used are now ignored');
}

/**
* Checks if scale is being used by any instance of assignment
*
Expand Down
92 changes: 6 additions & 86 deletions mod/assign/locallib.php
Expand Up @@ -3700,42 +3700,10 @@ protected function download_submissions($userids = null) {
}

/**
* Util function to add a message to the log.
*
* @deprecated since 2.7 - Use new events system instead.
* (see http://docs.moodle.org/dev/Migrating_logging_calls_in_plugins).
*
* @param string $action The current action
* @param string $info A detailed description of the change. But no more than 255 characters.
* @param string $url The url to the assign module instance.
* @param bool $return If true, returns the arguments, else adds to log. The purpose of this is to
* retrieve the arguments to use them with the new event system (Event 2).
* @return void|array
*/
public function add_to_log($action = '', $info = '', $url='', $return = false) {
global $USER;

$fullurl = 'view.php?id=' . $this->get_course_module()->id;
if ($url != '') {
$fullurl .= '&' . $url;
}

$args = array(
$this->get_course()->id,
'assign',
$action,
$fullurl,
$info,
$this->get_course_module()->id
);

if ($return) {
// We only need to call debugging when returning a value. This is because the call to
// call_user_func_array('add_to_log', $args) will trigger a debugging message of it's own.
debugging('The mod_assign add_to_log() function is now deprecated.', DEBUG_DEVELOPER);
return $args;
}
call_user_func_array('add_to_log', $args);
public function add_to_log() {
throw new coding_exception(__FUNCTION__ . ' has been deprecated, please do not use it any more');
}

/**
Expand Down Expand Up @@ -7386,65 +7354,17 @@ protected function process_save_grading_options() {
}

/**
* Take a grade object and print a short summary for the log file.
* The size limit for the log file is 255 characters, so be careful not
* to include too much information.
*
* @deprecated since 2.7
*
* @param stdClass $grade
* @return string
*/
public function format_grade_for_log(stdClass $grade) {
global $DB;

$user = $DB->get_record('user', array('id' => $grade->userid), '*', MUST_EXIST);

$info = get_string('gradestudent', 'assign', array('id'=>$user->id, 'fullname'=>fullname($user)));
if ($grade->grade != '') {
$info .= get_string('gradenoun') . ': ' . $this->display_grade($grade->grade, false) . '. ';
} else {
$info .= get_string('nograde', 'assign');
}
return $info;
public function format_grade_for_log() {
throw new coding_exception(__FUNCTION__ . ' has been deprecated, please do not use it any more');
}

/**
* Take a submission object and print a short summary for the log file.
* The size limit for the log file is 255 characters, so be careful not
* to include too much information.
*
* @deprecated since 2.7
*
* @param stdClass $submission
* @return string
*/
public function format_submission_for_log(stdClass $submission) {
global $DB;

$info = '';
if ($submission->userid) {
$user = $DB->get_record('user', array('id' => $submission->userid), '*', MUST_EXIST);
$name = fullname($user);
} else {
$group = $this->get_submission_group($submission->userid);
if ($group) {
$name = $group->name;
} else {
$name = get_string('defaultteam', 'assign');
}
}
$status = get_string('submissionstatus_' . $submission->status, 'assign');
$params = array('id'=>$submission->userid, 'fullname'=>$name, 'status'=>$status);
$info .= get_string('submissionlog', 'assign', $params) . ' <br>';

foreach ($this->submissionplugins as $plugin) {
if ($plugin->is_enabled() && $plugin->is_visible()) {
$info .= '<br>' . $plugin->format_for_log($submission);
}
}

return $info;
public function format_submission_for_log() {
throw new coding_exception(__FUNCTION__ . ' has been deprecated, please do not use it any more');
}

/**
Expand Down
4 changes: 3 additions & 1 deletion mod/assign/submission/file/lang/en/assignsubmission_file.php
Expand Up @@ -41,8 +41,10 @@
$string['maxfilessubmission_help'] = 'If file submissions are enabled, each student will be able to upload up to this number of files for their submission.';
$string['maximumsubmissionsize'] = 'Maximum submission size';
$string['maximumsubmissionsize_help'] = 'Files uploaded by students may be up to this size.';
$string['numfilesforlog'] = 'The number of file(s) : {$a} file(s).';
$string['pluginname'] = 'File submissions';
$string['privacy:metadata:filepurpose'] = 'The files loaded for this assignment submission';
$string['siteuploadlimit'] = 'Site upload limit';
$string['submissionfilearea'] = 'Uploaded submission files';

// Deprecated since Moodle 4.3.
$string['numfilesforlog'] = 'The number of file(s) : {$a} file(s).';
1 change: 1 addition & 0 deletions mod/assign/submission/file/lang/en/deprecated.txt
@@ -0,0 +1 @@
numfilesforlog,assignsubmission_file
13 changes: 0 additions & 13 deletions mod/assign/submission/file/locallib.php
Expand Up @@ -509,19 +509,6 @@ public function delete_instance() {
return true;
}

/**
* Formatting for log info
*
* @param stdClass $submission The submission
* @return string
*/
public function format_for_log(stdClass $submission) {
// Format the info for each submission plugin (will be added to log).
$filecount = $this->count_files($submission->id, ASSIGNSUBMISSION_FILE_FILEAREA);

return get_string('numfilesforlog', 'assignsubmission_file', $filecount);
}

/**
* Return true if there are no submission files
* @param stdClass $submission
Expand Down
Expand Up @@ -33,7 +33,6 @@
$string['onlinetextfilename'] = 'onlinetext.html';
$string['onlinetextsubmission'] = 'Allow online text submission';
$string['numwords'] = '({$a} words)';
$string['numwordsforlog'] = 'Submission word count: {$a} words';
$string['pluginname'] = 'Online text submissions';
$string['privacy:metadata:assignmentid'] = 'Assignment ID';
$string['privacy:metadata:filepurpose'] = 'Files that are embedded in the text submission.';
Expand All @@ -46,3 +45,6 @@
'of words that each student will be allowed to submit.';
$string['wordlimitexceeded'] = 'The word limit for this assignment is {$a->limit} words and you ' .
'are attempting to submit {$a->count} words. Please review your submission and try again.';

// Deprecated since Moodle 4.3.
$string['numwordsforlog'] = 'Submission word count: {$a} words';
1 change: 1 addition & 0 deletions mod/assign/submission/onlinetext/lang/en/deprecated.txt
@@ -0,0 +1 @@
numwordsforlog,assignsubmission_onlinetext
17 changes: 0 additions & 17 deletions mod/assign/submission/onlinetext/locallib.php
Expand Up @@ -562,23 +562,6 @@ public function upgrade(context $oldcontext,
return true;
}

/**
* Formatting for log info
*
* @param stdClass $submission The new submission
* @return string
*/
public function format_for_log(stdClass $submission) {
// Format the info for each submission plugin (will be logged).
$onlinetextsubmission = $this->get_onlinetext_submission($submission->id);
$onlinetextloginfo = '';
$onlinetextloginfo .= get_string('numwordsforlog',
'assignsubmission_onlinetext',
count_words($onlinetextsubmission->onlinetext));

return $onlinetextloginfo;
}

/**
* The assignment has been deleted - cleanup
*
Expand Down
4 changes: 0 additions & 4 deletions mod/assign/tests/fixtures/testable_assign.php
Expand Up @@ -44,10 +44,6 @@ public function testable_apply_grade_to_user($formdata, $userid, $attemptnumber)
return parent::apply_grade_to_user($formdata, $userid, $attemptnumber);
}

public function testable_format_submission_for_log(stdClass $submission) {
return parent::format_submission_for_log($submission);
}

public function testable_get_grading_userid_list() {
return parent::get_grading_userid_list();
}
Expand Down
7 changes: 7 additions & 0 deletions mod/assign/upgrade.txt
@@ -1,5 +1,12 @@
This files describes API changes in the assign code.

=== 4.3 ===
* The following deprecated methods have been removed and should not be used any more:
- `assign::add_to_log`
- `assign::format_grade_for_log`
- `assign::format_submission_for_log`
- `assign_plugin::format_for_log`

=== 4.2 ===
* The upgradelib.php file has been removed from mod_assign as it was only being used by mod_assignment and mod_assignment has been removed from core.

Expand Down

0 comments on commit 5088fba

Please sign in to comment.