mirror of
https://github.com/moodle/moodle.git
synced 2025-08-04 00:16:46 +02:00
Merge branch 'MDL-78168-master-final' of https://github.com/andrewnicols/moodle
This commit is contained in:
commit
2cc54dda28
3 changed files with 77 additions and 48 deletions
|
@ -24,12 +24,16 @@
|
||||||
|
|
||||||
namespace mod_assign\output;
|
namespace mod_assign\output;
|
||||||
|
|
||||||
|
use assign_files;
|
||||||
|
use html_writer;
|
||||||
|
use mod_assign\output\grading_app;
|
||||||
|
use portfolio_add_button;
|
||||||
|
use stored_file;
|
||||||
|
|
||||||
defined('MOODLE_INTERNAL') || die();
|
defined('MOODLE_INTERNAL') || die();
|
||||||
|
|
||||||
require_once($CFG->dirroot . '/mod/assign/locallib.php');
|
require_once($CFG->dirroot . '/mod/assign/locallib.php');
|
||||||
|
|
||||||
use \mod_assign\output\grading_app;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A custom renderer class that extends the plugin_renderer_base and is used by the assign module.
|
* A custom renderer class that extends the plugin_renderer_base and is used by the assign module.
|
||||||
*
|
*
|
||||||
|
@ -1397,11 +1401,13 @@ class renderer extends \plugin_renderer_base {
|
||||||
$result .= '<li yuiConfig=\'' . json_encode($yuiconfig) . '\'>' .
|
$result .= '<li yuiConfig=\'' . json_encode($yuiconfig) . '\'>' .
|
||||||
'<div>' .
|
'<div>' .
|
||||||
'<div class="fileuploadsubmission">' . $image . ' ' .
|
'<div class="fileuploadsubmission">' . $image . ' ' .
|
||||||
$file->fileurl . ' ' .
|
html_writer::link($tree->get_file_url($file), $file->get_filename(), [
|
||||||
|
'target' => '_blank',
|
||||||
|
]) . ' ' .
|
||||||
$plagiarismlinks . ' ' .
|
$plagiarismlinks . ' ' .
|
||||||
$file->portfoliobutton . ' ' .
|
$this->get_portfolio_button($tree, $file) . ' ' .
|
||||||
'</div>' .
|
'</div>' .
|
||||||
'<div class="fileuploadsubmissiontime">' . $file->timemodified . '</div>' .
|
'<div class="fileuploadsubmissiontime">' . $tree->get_modified_time($file) . '</div>' .
|
||||||
'</div>' .
|
'</div>' .
|
||||||
'</li>';
|
'</li>';
|
||||||
}
|
}
|
||||||
|
@ -1411,6 +1417,35 @@ class renderer extends \plugin_renderer_base {
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the portfolio button content for the specified file.
|
||||||
|
*
|
||||||
|
* @param assign_files $tree
|
||||||
|
* @param stored_file $file
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
protected function get_portfolio_button(assign_files $tree, stored_file $file): string {
|
||||||
|
global $CFG;
|
||||||
|
if (empty($CFG->enableportfolios)) {
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!has_capability('mod/assign:exportownsubmission', $tree->context)) {
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
|
||||||
|
require_once($CFG->libdir . '/portfoliolib.php');
|
||||||
|
|
||||||
|
$button = new portfolio_add_button();
|
||||||
|
$portfolioparams = [
|
||||||
|
'cmid' => $tree->cm->id,
|
||||||
|
'fileid' => $file->get_id(),
|
||||||
|
];
|
||||||
|
$button->set_callback_options('assign_portfolio_caller', $portfolioparams, 'mod_assign');
|
||||||
|
$button->set_format_by_file($file);
|
||||||
|
return $button->to_html(PORTFOLIO_ADD_ICON_LINK);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Helper method dealing with the fact we can not just fetch the output of flexible_table
|
* Helper method dealing with the fact we can not just fetch the output of flexible_table
|
||||||
*
|
*
|
||||||
|
|
|
@ -734,10 +734,7 @@ class assign_files implements renderable {
|
||||||
$button->reset_formats();
|
$button->reset_formats();
|
||||||
$this->portfolioform = $button->to_html(PORTFOLIO_ADD_TEXT_LINK);
|
$this->portfolioform = $button->to_html(PORTFOLIO_ADD_TEXT_LINK);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->preprocess($this->dir, $filearea, $component);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -746,49 +743,40 @@ class assign_files implements renderable {
|
||||||
* @param array $dir
|
* @param array $dir
|
||||||
* @param string $filearea
|
* @param string $filearea
|
||||||
* @param string $component
|
* @param string $component
|
||||||
* @return void
|
* @deprecated since Moodle 4.3
|
||||||
*/
|
*/
|
||||||
public function preprocess($dir, $filearea, $component) {
|
public function preprocess($dir, $filearea, $component) {
|
||||||
global $CFG;
|
// Nothing to do here any more.
|
||||||
|
debugging('The preprocess method has been deprecated since Moodle 4.3.', DEBUG_DEVELOPER);
|
||||||
foreach ($dir['subdirs'] as $subdir) {
|
|
||||||
$this->preprocess($subdir, $filearea, $component);
|
|
||||||
}
|
}
|
||||||
foreach ($dir['files'] as $file) {
|
|
||||||
$file->portfoliobutton = '';
|
|
||||||
|
|
||||||
$file->timemodified = userdate(
|
/**
|
||||||
|
* Get the modified time of the specified file.
|
||||||
|
* @param stored_file $file
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function get_modified_time(stored_file $file): string {
|
||||||
|
return userdate(
|
||||||
$file->get_timemodified(),
|
$file->get_timemodified(),
|
||||||
get_string('strftimedatetime', 'langconfig')
|
get_string('strftimedatetime', 'langconfig'),
|
||||||
);
|
);
|
||||||
|
}
|
||||||
|
|
||||||
if (!empty($CFG->enableportfolios)) {
|
/**
|
||||||
require_once($CFG->libdir . '/portfoliolib.php');
|
* Get the URL used to view the file.
|
||||||
$button = new portfolio_add_button();
|
*
|
||||||
if (has_capability('mod/assign:exportownsubmission', $this->context)) {
|
* @param stored_file
|
||||||
$portfolioparams = array('cmid' => $this->cm->id, 'fileid' => $file->get_id());
|
* @return moodle_url
|
||||||
$button->set_callback_options('assign_portfolio_caller',
|
*/
|
||||||
$portfolioparams,
|
public function get_file_url(stored_file $file): moodle_url {
|
||||||
'mod_assign');
|
return \moodle_url::make_pluginfile_url(
|
||||||
$button->set_format_by_file($file);
|
$this->context->id,
|
||||||
$file->portfoliobutton = $button->to_html(PORTFOLIO_ADD_ICON_LINK);
|
$file->get_component(),
|
||||||
}
|
$file->get_filearea(),
|
||||||
}
|
$file->get_itemid(),
|
||||||
$path = '/' .
|
$file->get_filepath(),
|
||||||
$this->context->id .
|
$file->get_filename(),
|
||||||
'/' .
|
true,
|
||||||
$component .
|
);
|
||||||
'/' .
|
|
||||||
$filearea .
|
|
||||||
'/' .
|
|
||||||
$file->get_itemid() .
|
|
||||||
$file->get_filepath() .
|
|
||||||
$file->get_filename();
|
|
||||||
$url = file_encode_url("$CFG->wwwroot/pluginfile.php", $path, true);
|
|
||||||
$filename = $file->get_filename();
|
|
||||||
$file->fileurl = html_writer::link($url, $filename, [
|
|
||||||
'target' => '_blank',
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,6 +6,12 @@ This files describes API changes in the assign code.
|
||||||
- `assign::format_grade_for_log`
|
- `assign::format_grade_for_log`
|
||||||
- `assign::format_submission_for_log`
|
- `assign::format_submission_for_log`
|
||||||
- `assign_plugin::format_for_log`
|
- `assign_plugin::format_for_log`
|
||||||
|
* The assign_files renderable no longer abuses the dynamic nature of PHP and puts random properties onto stored_file
|
||||||
|
instances.
|
||||||
|
If you were previously using these properties, please update to use the new method on the tree:
|
||||||
|
* $file->portfoliobutton $renderer->get_portfolio_button($file)
|
||||||
|
* $file->timemodified $tree->get_modified_time($file)
|
||||||
|
* $file->fileurl $tree->get_file_url($file)
|
||||||
|
|
||||||
=== 4.2 ===
|
=== 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.
|
* 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.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue