MDL-71470 repository_googledocs: Use file name in the source attribute

Instead of using the file title when generating the source attribute,
we should be using only the name of the Google Drive file in order to
avoid having the original extension within the filename after the file
is imported and added into Moodle.
This commit is contained in:
Mihail Geshoski 2021-04-28 12:56:46 +08:00
parent a5f0b354e7
commit 0ce519591b

View File

@ -31,6 +31,9 @@ class file_node implements node {
/** @var string|null The title of the file node. */
private $title;
/** @var string The name of the file. */
private $name;
/** @var string|null The file's export format. */
private $exportformat;
@ -54,6 +57,7 @@ class file_node implements node {
public function __construct(\stdClass $gdfile) {
$this->id = $gdfile->id;
$this->title = $this->generate_file_title($gdfile);
$this->name = $gdfile->name;
$this->exportformat = $this->generate_file_export_format($gdfile);
$this->link = $this->generate_file_link($gdfile);
$this->modified = ($gdfile->modifiedTime) ? strtotime($gdfile->modifiedTime) : '';
@ -90,7 +94,7 @@ class file_node implements node {
'source' => json_encode(
[
'id' => $this->id,
'name' => $this->title,
'name' => $this->name,
'link' => $this->link,
'exportformat' => $this->exportformat,
]